diff options
author | mattkae <mattkae@protonmail.com> | 2021-09-19 16:32:15 -0400 |
---|---|---|
committer | mattkae <mattkae@protonmail.com> | 2021-09-19 16:32:15 -0400 |
commit | de850676e79da39aec6f1ce0400cfa94cecbd744 (patch) | |
tree | 48927e3cd3a518ddee1874df40d188cbc5112393 /themes/MainLoop.h |
First commit
Diffstat (limited to 'themes/MainLoop.h')
-rw-r--r-- | themes/MainLoop.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/themes/MainLoop.h b/themes/MainLoop.h new file mode 100644 index 0000000..2573bb8 --- /dev/null +++ b/themes/MainLoop.h @@ -0,0 +1,29 @@ +#pragma once + +#include <emscripten.h> +#include <emscripten/html5.h> +#include <GLES2/gl2.h> +#include <EGL/egl.h> + +EM_BOOL loop(double time, void* loop); + +struct MainLoop { + bool isRunning = false; + double lastTime = 0, elapsedTime = 0; + int numFrames = 0; + void (*updateFunc)(float dtSeconds, void *userData); + + void run(void (*cb)(float dtSeconds, void *userData)) { + isRunning = true; + lastTime = 0; + elapsedTime = 0; + numFrames = 0; + updateFunc = cb; + + emscripten_request_animation_frame_loop(loop, this); + } + + void stop() { + isRunning = false; + } +};
\ No newline at end of file |