summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2018-07-21 17:13:59 +0200
committerraysan5 <[email protected]>2018-07-21 17:13:59 +0200
commit4c15515ba687931ee3353e32b25c2ba0427d67b1 (patch)
tree62a5394c201b012f9ef42dc8930629a9d0cbde09 /src/core.c
parent7dc66d2d3f0668edd46ed3380656692d67ae6da0 (diff)
downloadraylib-4c15515ba687931ee3353e32b25c2ba0427d67b1.tar.gz
raylib-4c15515ba687931ee3353e32b25c2ba0427d67b1.zip
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...
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c
index c578a807..6939b844 100644
--- a/src/core.c
+++ b/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