diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-13 10:06:33 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-13 10:06:33 -0700 |
commit | 45ba35aa01f1650ed28479976262236bbf204ef1 (patch) | |
tree | a45ef1240a00776b9fd0b0b9b1a89b877848b474 /system | |
parent | 3a156a34e83fa301b8abbac6effdb5bd21d9be11 (diff) |
add parameter to emscripten_set_main_loop to optionally simulate an infinite loop by throwing an exception (like glutMainLoop)
Diffstat (limited to 'system')
-rw-r--r-- | system/include/emscripten/emscripten.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index 1b1310c4..078f87d2 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -46,14 +46,30 @@ extern void emscripten_async_run_script(const char *script, int millis); * code assumes that), so you can break the code up into * asynchronous callbacks, but you must pause the main * loop until they complete. + * + * @simulate_infinite_loop If true, this function will throw an + * exception in order to stop execution of the caller. This + * will lead to the main loop being entered instead of code + * after the call to emscripten_set_main_loop being run, which + * is the closest we can get to simulating an infinite loop + * (we do something similar in glutMainLoop in GLUT). If this + * parameter is false, then the behavior is the same as it + * was before this parameter was added to the API, which is + * that execution continues normally. Note that in both cases + * we do not run global destructors, atexit, etc., since we + * know the main loop will still be running, but if we do + * not simulate an infinite loop then the stack will be unwinded. + * That means that if simulate_infinite_loop is false, and + * you created an object on the stack, it will be cleaned up + * before the main loop will be called the first time. */ #if EMSCRIPTEN -extern void emscripten_set_main_loop(void (*func)(), int fps); +extern void emscripten_set_main_loop(void (*func)(), int fps, int simulate_infinite_loop); extern void emscripten_pause_main_loop(); extern void emscripten_resume_main_loop(); extern void emscripten_cancel_main_loop(); #else -#define emscripten_set_main_loop(func, fps) \ +#define emscripten_set_main_loop(func, fps, simulateInfiniteLoop) \ while (1) func(); #endif |