diff --git a/examples/.gitignore b/examples/.gitignore index 54c0a118..d56b94f0 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -25,6 +25,7 @@ project.xcworkspace xcuserdata ## Emscripten output +*.o.tmp *.out.js *.out.wasm example_emscripten/example_emscripten.* diff --git a/examples/example_emscripten/Makefile b/examples/example_emscripten/Makefile index 6c9865ff..9edfafd0 100644 --- a/examples/example_emscripten/Makefile +++ b/examples/example_emscripten/Makefile @@ -24,10 +24,12 @@ UNAME_S := $(shell uname -s) EMS = -s USE_SDL=2 -s WASM=1 EMS += -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_TRAP_MODE=clamp EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0 -EMS += -s ASSERTIONS=1 -s SAFE_HEAP=1 +EMS += -s ASSERTIONS=1 -s NO_FILESYSTEM=1 +#EMS += -s SAFE_HEAP=1 ## Adds overhead CPPFLAGS = -I../ -I../../ -CPPFLAGS += -g -Wall -Wformat -O3 +#CPPFLAGS += -g +CPPFLAGS += -Wall -Wformat -Os CPPFLAGS += $(EMS) LIBS = $(EMS) LDFLAGS = --shell-file shell_minimal.html diff --git a/examples/example_emscripten/main.cpp b/examples/example_emscripten/main.cpp index 847b505a..fc7017d5 100644 --- a/examples/example_emscripten/main.cpp +++ b/examples/example_emscripten/main.cpp @@ -14,7 +14,7 @@ #include #include -// Emscripten requires to have full control over the main loop. We're going to store our SDL book-keeping variables globally. +// Emscripten requires to have full control over the main loop. We're going to store our SDL book-keeping variables globally. // Having a single function that acts as a loop prevents us to store state in the stack of said function. So we need some location for this. SDL_Window* g_Window = NULL; SDL_GLContext g_GLContext = NULL; @@ -63,6 +63,10 @@ int main(int, char**) ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file. + // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage. + io.IniFilename = NULL; + // Setup Dear ImGui style ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); @@ -90,7 +94,7 @@ int main(int, char**) emscripten_set_main_loop_arg(main_loop, NULL, 0, true); } -void main_loop(void* arg) +void main_loop(void* arg) { ImGuiIO& io = ImGui::GetIO(); IM_UNUSED(arg); // We can pass this argument as the second parameter of emscripten_set_main_loop_arg(), but we don't use that.