aboutsummaryrefslogtreecommitdiff
path: root/system/include/emscripten.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-18 19:22:09 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-18 19:22:09 -0700
commit1c11fdd98530b6d35e51c0eba14fb1f375d05229 (patch)
treebd471ce02003d0e1d16dfe773d1ed4d0acdcb499 /system/include/emscripten.h
parentd6cff2177ec065aa14f228ab547abc29ef37b248 (diff)
parent327b6f859e95be71e5613f24cc1c9d4f4b97c15f (diff)
merge
Diffstat (limited to 'system/include/emscripten.h')
-rw-r--r--system/include/emscripten.h24
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