From 2577e9286002841d4f166455af3cb5615b83ad25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Mon, 4 Sep 2017 23:17:35 +0200 Subject: [PATCH] Adapt Context to Emscripten --- src/openrct2/Context.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 2001a76eed..d16d39a8e7 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -17,6 +17,9 @@ #include #include #include +#ifdef __EMSCRIPTEN__ + #include +#endif // __EMSCRIPTEN__ #include "audio/AudioContext.h" #include "Context.h" #include "ui/UiContext.h" @@ -104,6 +107,9 @@ namespace OpenRCT2 // Remove this when GetContext() is no longer called so that // multiple instances can be created in parallel static Context * Instance; + static void RunFixedFrameFunc() { + Instance->RunFixedFrame(); + } public: Context(IPlatformEnvironment * env, IAudioContext * audioContext, IUiContext * uiContext) @@ -551,6 +557,7 @@ namespace OpenRCT2 log_verbose("begin openrct2 loop"); _finished = false; +#ifndef __EMSCRIPTEN__ bool variableFrame = ShouldRunVariableFrame(); bool useVariableFrame; @@ -573,6 +580,9 @@ namespace OpenRCT2 RunFixedFrame(); } } while (!_finished); +#else + emscripten_set_main_loop(RunFixedFrameFunc, 0, 1); +#endif // __EMSCRIPTEN__ log_verbose("finish openrct2 loop"); }