Add Emscripten support for SDL2 and SDL3 surface examples
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
#include "imgui_impl_sdlsurface2.h"
|
||||
#include <SDL.h>
|
||||
#include <stdio.h>
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
@@ -55,6 +58,9 @@ int main(int, char**)
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
#ifdef __EMSCRIPTEN__
|
||||
io.IniFilename = nullptr;
|
||||
#endif
|
||||
|
||||
// Setup Dear ImGui style
|
||||
ImGui::StyleColorsDark();
|
||||
@@ -76,7 +82,11 @@ int main(int, char**)
|
||||
|
||||
// Main loop
|
||||
bool done = false;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EMSCRIPTEN_MAINLOOP_BEGIN
|
||||
#else
|
||||
while (!done)
|
||||
#endif
|
||||
{
|
||||
// Poll and handle events (inputs, window resize, etc.)
|
||||
SDL_Event event;
|
||||
@@ -174,6 +184,9 @@ int main(int, char**)
|
||||
SDL_BlitSurface(framebuffer, nullptr, window_surface, nullptr);
|
||||
SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EMSCRIPTEN_MAINLOOP_END;
|
||||
#endif
|
||||
|
||||
ImGui_ImplSDLSurface2_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
|
||||
Reference in New Issue
Block a user