diff options
Diffstat (limited to 'system/include/emscripten.h')
-rw-r--r-- | system/include/emscripten.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/system/include/emscripten.h b/system/include/emscripten.h index 7b135c5a..7bb2ae8e 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten.h @@ -19,6 +19,30 @@ extern void emscripten_run_script(const char *script); extern int emscripten_run_script_int(const char *script); /* + * Set a C function as the main event loop. The JS environment + * will call that function at a specified number of frames per + * second. Setting 0 as the fps will use the default browser + * frame rate. + */ +extern void emscripten_set_main_loop(void (*func)(), int fps); +extern void emscripten_cancel_main_loop(); + +/* + * Call a C function asynchronously, that is, after returning + * control to the JS event loop. This is done by a setTimeout. + * When building natively this becomes a simple direct call, + * after SDL_Delay (you must include SDL.h for that). + */ +#if EMSCRIPTEN +extern void emscripten_async_call(void (*func)(), int millis); +#else +void emscripten_async_call(void (*func)(), int millis) { + SDL_Delay(millis); + func(); +} +#endif + +/* * This macro-looking function will cause Emscripten to * generate a comment in the generated code. * XXX This is deprecated for now, because it requires us to |