Skip to content

Commit

Permalink
Fix emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 19, 2023
1 parent b582261 commit 8763b53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/hello_imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ endfunction()
function(him_sanity_checks)
_him_try_select_glfw_if_no_backend_selected()

# use SDL for emscripten
if (EMSCRIPTEN AND NOT HELLOIMGUI_USE_SDL_OPENGL3 AND NOT HELLOIMGUI_USE_GLFW_OPENGL3)
set(HELLOIMGUI_USE_SDL_OPENGL3 ON CACHE BOOL "" FORCE)
set(HELLOIMGUI_USE_GLFW_OPENGL3 OFF CACHE BOOL "" FORCE)
endif()

if (HELLOIMGUI_WITH_GLFW)
set(HELLOIMGUI_USE_GLFW_OPENGL3 ON CACHE BOOL "" FORCE)
endif()
Expand Down Expand Up @@ -273,19 +279,10 @@ endfunction()
# Emscripten related options: API = him_add_emscripten_options
###################################################################################################
function(him_add_emscripten_options)
#------------------------------------------------------------------------------
# use SDL for emscripten
#------------------------------------------------------------------------------
if (EMSCRIPTEN AND NOT HELLOIMGUI_USE_SDL_OPENGL3 AND NOT HELLOIMGUI_USE_GLFW_OPENGL3)
set(HELLOIMGUI_USE_SDL_OPENGL3 ON CACHE BOOL "" FORCE)
set(HELLOIMGUI_USE_GLFW_OPENGL3 OFF CACHE BOOL "" FORCE)
endif()

if (EMSCRIPTEN)
target_compile_definitions(${helloimgui_target} PUBLIC HELLOIMGUI_USE_GLES3)
target_compile_definitions(${helloimgui_target} PUBLIC HELLOIMGUI_CANNOTQUIT)
endif()

endfunction()


Expand Down
6 changes: 3 additions & 3 deletions src/hello_imgui/internal/backend_impls/runner_emscripten.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once
#ifdef __EMSCRIPTEN__

#include "hello_imgui/internal/backend_impls/runner_sdl_opengl3.h"
#include "hello_imgui/internal/backend_impls/runner_sdl2.h"

namespace HelloImGui
{
class RunnerEmscripten : public RunnerSdlOpenGl3
class RunnerEmscripten : public RunnerSdl2
{
public:
RunnerEmscripten(RunnerParams & runnerParams) : RunnerSdlOpenGl3(runnerParams) {}
RunnerEmscripten(RunnerParams & runnerParams) : RunnerSdl2(runnerParams) {}
virtual ~RunnerEmscripten() = default;
void Run() override;

Expand Down

0 comments on commit 8763b53

Please sign in to comment.