diff options
Diffstat (limited to 'system/include/emscripten.h')
-rw-r--r-- | system/include/emscripten.h | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/system/include/emscripten.h b/system/include/emscripten.h index 7bb2ae8e..d0e6cc46 100644 --- a/system/include/emscripten.h +++ b/system/include/emscripten.h @@ -17,14 +17,25 @@ extern "C" { */ extern void emscripten_run_script(const char *script); extern int emscripten_run_script_int(const char *script); +extern void emscripten_async_run_script(const char *script, int millis); /* * 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. + * second. Setting 0 or a negative value as the fps will use + * the browser's requestAnimationFrame mechanism. + * + * Pausing and resuming the main loop is useful if your app + * needs to perform some synchronous operation, for example + * to load a file from the network. It might be wrong to + * run the main loop before that finishes (the original + * code assumes that), so you can break the code up into + * asynchronous callbacks, but you must pause the main + * loop until they complete. */ extern void emscripten_set_main_loop(void (*func)(), int fps); +extern void emscripten_pause_main_loop(); +extern void emscripten_resume_main_loop(); extern void emscripten_cancel_main_loop(); /* @@ -32,6 +43,9 @@ extern void emscripten_cancel_main_loop(); * 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 millis is negative, the browser's requestAnimationFrame + * mechanism is used. */ #if EMSCRIPTEN extern void emscripten_async_call(void (*func)(), int millis); @@ -43,6 +57,23 @@ void emscripten_async_call(void (*func)(), int millis) { #endif /* + * Hide the OS mouse cursor over the canvas. Note that SDL's + * SDL_ShowCursor command shows and hides the SDL cursor, not + * the OS one. This command is useful to hide the OS cursor + * if your app draws its own cursor. + */ +void emscripten_hide_mouse(); + +/* + * Returns the highest-precision representation of the + * current time that the browser provides. This uses either + * Date.now or performance.now. The result is *not* an + * absolute time, and is only meaningful in comparison to + * other calls to this function. The unit is ms. + */ +float emscripten_get_now(); + +/* * 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 |