mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-15 07:48:15 +00:00
Support examples with Emterpreter
Examples can be compiled for web with no code change at all! Usually examples need to be refactored for web... using emscripten code interpreter (emterpreter), it can manage synchronous while() loops internally... as a downside, execution is very slow...
This commit is contained in:
15
src/core.c
15
src/core.c
@@ -141,6 +141,9 @@
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
#if defined(PLATFORM_WEB)
|
||||
#define GLFW_INCLUDE_ES2
|
||||
#endif
|
||||
//#define GLFW_INCLUDE_NONE // Disable the standard OpenGL header inclusion on GLFW3
|
||||
#include <GLFW/glfw3.h> // GLFW3 library: Windows, OpenGL context and Input management
|
||||
// NOTE: GLFW3 already includes gl.h (OpenGL) headers
|
||||
@@ -634,7 +637,17 @@ bool IsWindowReady(void)
|
||||
// Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
bool WindowShouldClose(void)
|
||||
{
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
#if defined(PLATFORM_WEB)
|
||||
// Emterpreter-Async required to run sync code
|
||||
// https://github.com/kripken/emscripten/wiki/Emterpreter#emterpreter-async-run-synchronous-code
|
||||
// By default, this function is never called on a web-ready raylib example because we encapsulate
|
||||
// frame code in a UpdateDrawFrame() function, to allow browser manage execution asynchronously
|
||||
// but now emscripten allows sync code to be executed in an interpreted way, using emterpreter!
|
||||
emscripten_sleep(16);
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
if (windowReady)
|
||||
{
|
||||
// While window minimized, stop loop execution
|
||||
|
Reference in New Issue
Block a user