From 3facc4569f34a4a82245483b6791d12d4cecfdd5 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 22 Jan 2025 18:41:07 +0100 Subject: [PATCH] [render] fix imgui_drawer build error if glfw or qt are not found --- .../render/include/vclib/imgui/imgui_drawer.h | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/vclib/render/include/vclib/imgui/imgui_drawer.h b/vclib/render/include/vclib/imgui/imgui_drawer.h index eb52647af..89ae4534e 100644 --- a/vclib/render/include/vclib/imgui/imgui_drawer.h +++ b/vclib/render/include/vclib/imgui/imgui_drawer.h @@ -67,14 +67,18 @@ class ImGuiDrawer : public BlockerEventDrawer ImGui_ImplOpenGL2_Shutdown(); #elif defined(VCLIB_RENDER_BACKEND_BGFX) ImGui_ImplBgfx_Shutdown(); -#endif +#endif // VCLIB_RENDER_BACKEND_* +#ifdef VCLIB_WITH_GLFW if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) { ImGui_ImplGlfw_Shutdown(); } - else if constexpr ( +#endif // VCLIB_WITH_GLFW +#ifdef VCLIB_WITH_QT + if constexpr ( DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) { ImGui_ImplQt_Shutdown(); } +#endif // VCLIB_WITH ImGui::DestroyContext(); } @@ -91,6 +95,7 @@ class ImGuiDrawer : public BlockerEventDrawer // setup ImGui style ImGui::StyleColorsDark(); +#ifdef VCLIB_WITH_GLFW if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) { GLFWwindow* mWindow = reinterpret_cast(DRA::DRW::windowPtr(derived())); @@ -101,9 +106,11 @@ class ImGuiDrawer : public BlockerEventDrawer #elif defined(VCLIB_RENDER_BACKEND_BGFX) ImGui_ImplGlfw_InitForOther(mWindow, true); ImGui_ImplBgfx_Init(); -#endif +#endif // VCLIB_RENDER_BACKEND_* } - else if constexpr ( +# endif // VCLIB_WITH_GLFW +#ifdef VCLIB_WITH_QT + if constexpr ( DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) { QWidget* mWindow = reinterpret_cast(DRA::DRW::windowPtr(derived())); @@ -113,8 +120,9 @@ class ImGuiDrawer : public BlockerEventDrawer ImGui_ImplOpenGL2_Init(); #elif defined(VCLIB_RENDER_BACKEND_BGFX) ImGui_ImplBgfx_Init(); -#endif +#endif // VCLIB_RENDER_BACKEND_* } +#endif // VCLIB_WITH_QT } virtual void onDraw(uint) @@ -124,14 +132,18 @@ class ImGuiDrawer : public BlockerEventDrawer ImGui_ImplOpenGL2_NewFrame(); #elif defined(VCLIB_RENDER_BACKEND_BGFX) ImGui_ImplBgfx_NewFrame(); -#endif +#endif // VCLIB_RENDER_BACKEND_* +#ifdef VCLIB_WITH_GLFW if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) { ImGui_ImplGlfw_NewFrame(); } - else if constexpr ( +#endif // VCLIB_WITH_GLFW +#ifdef VCLIB_WITH_QT + if constexpr ( DRA::WINDOW_MANAGER_ID == WindowManagerId::QT_WIDGET) { ImGui_ImplQt_NewFrame(); } +#endif // VCLIB_WITH_QT ImGui::NewFrame(); } @@ -143,7 +155,7 @@ class ImGuiDrawer : public BlockerEventDrawer ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); #elif defined(VCLIB_RENDER_BACKEND_BGFX) ImGui_ImplBgfx_RenderDrawData(ImGui::GetDrawData()); -#endif +#endif // VCLIB_RENDER_BACKEND_* derived()->update(); }