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:
parent
7dc66d2d3f
commit
4c15515ba6
1 changed files with 32 additions and 10 deletions
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue