From 4e102fc31e770fd127d66a3671bc56bd7ead81ac Mon Sep 17 00:00:00 2001 From: ericek111 Date: Thu, 26 Mar 2026 15:01:36 +0100 Subject: [PATCH] wasm: disable ImGUI debug tools --- CMakeLists.txt | 10 +++++++--- src/ui/Application.cpp | 4 ++++ src/ui/Application.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d0b5fe..a5ce1e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,15 +20,18 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(imgui) -add_library(imgui STATIC +set(IMGUI_SOURCES ${imgui_SOURCE_DIR}/imgui.cpp - ${imgui_SOURCE_DIR}/imgui_demo.cpp ${imgui_SOURCE_DIR}/imgui_draw.cpp ${imgui_SOURCE_DIR}/imgui_tables.cpp ${imgui_SOURCE_DIR}/imgui_widgets.cpp ${imgui_SOURCE_DIR}/backends/imgui_impl_sdl2.cpp ${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp ) +if(NOT EMSCRIPTEN) + list(APPEND IMGUI_SOURCES ${imgui_SOURCE_DIR}/imgui_demo.cpp) +endif() +add_library(imgui STATIC ${IMGUI_SOURCES}) target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR} ${imgui_SOURCE_DIR}/backends @@ -141,9 +144,10 @@ if(EMSCRIPTEN) target_compile_definitions(fftw3f_wasm PRIVATE FFTW_SINGLE=1) target_compile_options(fftw3f_wasm PRIVATE -w) # suppress warnings from FFTW - # ImGui: link with Emscripten SDL2 port + # ImGui: link with Emscripten SDL2 port, disable demo/debug tools target_compile_options(imgui PUBLIC -sUSE_SDL=2) target_link_options(imgui PUBLIC -sUSE_SDL=2) + target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_DEMO_WINDOWS=1 IMGUI_DISABLE_DEBUG_TOOLS=1) add_executable(baudmine ${SOURCES}) target_include_directories(baudmine PRIVATE src) diff --git a/src/ui/Application.cpp b/src/ui/Application.cpp index 38ffed6..7be3f27 100644 --- a/src/ui/Application.cpp +++ b/src/ui/Application.cpp @@ -447,6 +447,7 @@ void Application::render() { ImGui::EndMenu(); } +#ifndef IMGUI_DISABLE_DEBUG_TOOLS if (ImGui::BeginMenu("Debug")) { ImGui::MenuItem("Metrics/Debugger", nullptr, &showMetricsWindow_); ImGui::MenuItem("Debug Log", nullptr, &showDebugLog_); @@ -457,6 +458,7 @@ void Application::render() { 1000.0f / ImGui::GetIO().Framerate); ImGui::EndMenu(); } +#endif #ifdef __EMSCRIPTEN__ if (ImGui::SmallButton(js_isFullscreen() ? "Exit Fullscreen" : "Fullscreen")) { @@ -584,11 +586,13 @@ void Application::render() { ImGui::End(); +#ifndef IMGUI_DISABLE_DEBUG_TOOLS // ImGui debug windows if (showDemoWindow_) ImGui::ShowDemoWindow(&showDemoWindow_); if (showMetricsWindow_) ImGui::ShowMetricsWindow(&showMetricsWindow_); if (showDebugLog_) ImGui::ShowDebugLogWindow(&showDebugLog_); if (showStackTool_) ImGui::ShowIDStackToolWindow(&showStackTool_); +#endif // Render ImGui::Render(); diff --git a/src/ui/Application.h b/src/ui/Application.h index 40d0b9a..4072c33 100644 --- a/src/ui/Application.h +++ b/src/ui/Application.h @@ -205,11 +205,13 @@ private: // UI visibility bool showSidebar_ = true; +#ifndef IMGUI_DISABLE_DEBUG_TOOLS // ImGui debug windows bool showDemoWindow_ = false; bool showMetricsWindow_ = false; bool showDebugLog_ = false; bool showStackTool_ = false; +#endif // Pre-allocated scratch buffers (avoid per-frame heap allocations) std::vector> wfSpectraScratch_;