From 4baff267f6b4b8b0241c21e4927be25458bc6575 Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Sat, 12 Oct 2024 13:55:02 +0200 Subject: [PATCH] Add build option to show the Dear Imgui demo window in the headset for debugging --- CMakeLists.txt | 2 ++ build.gradle | 4 +++- client/render/imgui_impl.cpp | 6 ++++++ client/render/imgui_impl.h | 5 +++++ common/wivrn_config.h.in | 2 ++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 714813ad..53996ad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,8 @@ option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" OFF) option(WIVRN_CHECK_CAPSYSNICE "Check if CAP_SYS_NICE is available at startup" ON) +option(WIVRN_SHOW_IMGUI_DEMO_WINDOW "Show the Dear ImGui demo window in the client" OFF) + option(WIVRN_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH OFF) option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON) diff --git a/build.gradle b/build.gradle index fda47a10..275f2ce2 100644 --- a/build.gradle +++ b/build.gradle @@ -74,6 +74,7 @@ android { versionName = project.hasProperty('wivrn_version') ? wivrn_version : "1.0" versionCode = project.hasProperty('wivrn_versionCode') ? wivrn_versionCode.toInteger() : 1 + def showImguiDemo = project.hasProperty('wivrn_show_imgui_demo') ? wivrn_show_imgui_demo : 'OFF' externalNativeBuild { cmake { @@ -86,7 +87,8 @@ android { '-DWIVRN_BUILD_CLIENT=ON', '-DWIVRN_BUILD_SERVER=OFF', '-DWIVRN_BUILD_DASHBOARD=OFF', - '-DWIVRN_WERROR=ON' + '-DWIVRN_WERROR=ON', + '-DWIVRN_SHOW_IMGUI_DEMO_WINDOW=' + showImguiDemo resValue "string", "app_name", "WiVRn" } } diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index 900f71b2..1ebbfde3 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -740,6 +740,12 @@ void imgui_context::new_frame(XrTime display_time) draw_list->AddCircle(position_distance->first, radius * 1.2, ImGui::GetColorU32(ImVec4(0, 0, 0, alpha)), 0, radius * 0.4); } + +#if WIVRN_SHOW_IMGUI_DEMO_WINDOW + if (show_demo_window) + ImGui::ShowDemoWindow(&show_demo_window); +#endif + image_index = swapchain.acquire(); swapchain.wait(); } diff --git a/client/render/imgui_impl.h b/client/render/imgui_impl.h index 64f55dbf..e1bf9af0 100644 --- a/client/render/imgui_impl.h +++ b/client/render/imgui_impl.h @@ -20,6 +20,7 @@ #include "xr/hand_tracker.h" #include "xr/swapchain.h" +#include "wivrn_config.h" #include #include #include @@ -135,6 +136,10 @@ private: ImVector glyph_ranges; bool glyph_range_dirty = true; +#if WIVRN_SHOW_IMGUI_DEMO_WINDOW + bool show_demo_window = true; +#endif + void initialize_fonts(); public: diff --git a/common/wivrn_config.h.in b/common/wivrn_config.h.in index bf81af2f..9355dc04 100644 --- a/common/wivrn_config.h.in +++ b/common/wivrn_config.h.in @@ -32,4 +32,6 @@ #cmakedefine01 WIVRN_FEATURE_STEAMVR_LIGHTHOUSE #cmakedefine01 WIVRN_FEATURE_SOLARXR +#cmakedefine01 WIVRN_SHOW_IMGUI_DEMO_WINDOW + #define WIVRN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"