From 7228b2e1a2d0a8399facce3493d71a3569d250d5 Mon Sep 17 00:00:00 2001 From: mattkae Date: Fri, 23 Dec 2022 12:47:10 -0500 Subject: Improved the makefile considerably --- themes/src/MainLoop.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 themes/src/MainLoop.h (limited to 'themes/src/MainLoop.h') diff --git a/themes/src/MainLoop.h b/themes/src/MainLoop.h new file mode 100644 index 0000000..2573bb8 --- /dev/null +++ b/themes/src/MainLoop.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include +#include +#include + +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 -- cgit v1.2.1