Update rcore_web.c

This commit is contained in:
Ray 2025-01-20 14:01:57 +01:00
parent 77c509db6e
commit d48b8afbb5

View file

@ -155,14 +155,20 @@ static const char *GetCanvasId(void);
// Check if application should close // Check if application should close
// This will always return false on a web-build as web builds have no control over this functionality // This will always return false on a web-build as web builds have no control over this functionality
// Sleep is handled in EndDrawing for sync code // Sleep is handled in EndDrawing() for synchronous code
bool WindowShouldClose(void) bool WindowShouldClose(void)
{ {
// Emterpreter-Async required to run sync code // Emscripten Asyncify is required to run synchronous code in asynchronous JS
// https://github.com/emscripten-core/emscripten/wiki/Emterpreter#emterpreter-async-run-synchronous-code // REF: https://emscripten.org/docs/porting/asyncify.html
// This function should not called on a web-ready raylib build because you instead want to encapsulate
// frame code in an UpdateDrawFrame() function, to allow the browser to manage execution asynchronously // WindowShouldClose() is not called on a web-ready raylib application if using emscripten_set_main_loop()
// using emscripten_set_main_loop // and encapsulating one frame execution on a UpdateDrawFrame() function,
// allowing the browser to manage execution asynchronously
// Optionally we can manage the time we give-control-back-to-browser if required,
// but it seems below line could generate stuttering on some browsers
//emscripten_sleep(16);
return false; return false;
} }