Setup main emscripten loop.

This commit is contained in:
Bartosz Taudul 2022-09-30 00:57:07 +02:00
parent 863b36d04b
commit 78169326b3
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -2,6 +2,7 @@
#include "imgui/imgui_impl_opengl3.h"
#ifdef __EMSCRIPTEN__
# include <GLES2/gl2.h>
# include <emscripten/html5.h>
#else
# include "imgui/imgui_impl_opengl3_loader.h"
#endif
@ -120,6 +121,13 @@ void Backend::Show()
void Backend::Run()
{
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop( []() {
glfwPollEvents();
s_redraw();
s_mainThreadTasks->Run();
}, 0, 1 );
#else
while( !glfwWindowShouldClose( s_window ) )
{
if( s_iconified )
@ -137,6 +145,7 @@ void Backend::Run()
s_mainThreadTasks->Run();
}
}
#endif
}
void Backend::NewFrame( int& w, int& h )