diff options
| author | Matt Kosarek <matt.kosarek@canonical.com> | 2025-12-29 09:34:00 -0500 |
|---|---|---|
| committer | Matt Kosarek <matt.kosarek@canonical.com> | 2025-12-29 09:34:00 -0500 |
| commit | bf4b3a5c35152c1292757134123b3363d0f81bf6 (patch) | |
| tree | 7796e03d309c43115596f78d553a74f911f82218 /themes/src/main_loop.h | |
| parent | 25c93a0ab9c855f75ee48df635fb5422c8eaba95 (diff) | |
Renamed PascalCase files to snake_case
Diffstat (limited to 'themes/src/main_loop.h')
| -rw-r--r-- | themes/src/main_loop.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/themes/src/main_loop.h b/themes/src/main_loop.h new file mode 100644 index 0000000..07520a2 --- /dev/null +++ b/themes/src/main_loop.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; + } +}; |
