Skip to content

Commit

Permalink
[render] fix imgui_drawer build error if glfw or qt are not found
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Jan 22, 2025
1 parent faf5686 commit 3facc45
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions vclib/render/include/vclib/imgui/imgui_drawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ class ImGuiDrawer : public BlockerEventDrawer<DerivedRenderApp>
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();
}

Expand All @@ -91,6 +95,7 @@ class ImGuiDrawer : public BlockerEventDrawer<DerivedRenderApp>
// setup ImGui style
ImGui::StyleColorsDark();

#ifdef VCLIB_WITH_GLFW
if constexpr (DRA::WINDOW_MANAGER_ID == WindowManagerId::GLFW_WINDOW) {
GLFWwindow* mWindow =
reinterpret_cast<GLFWwindow*>(DRA::DRW::windowPtr(derived()));
Expand All @@ -101,9 +106,11 @@ class ImGuiDrawer : public BlockerEventDrawer<DerivedRenderApp>
#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<QWidget*>(DRA::DRW::windowPtr(derived()));
Expand All @@ -113,8 +120,9 @@ class ImGuiDrawer : public BlockerEventDrawer<DerivedRenderApp>
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)
Expand All @@ -124,14 +132,18 @@ class ImGuiDrawer : public BlockerEventDrawer<DerivedRenderApp>
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();
}

Expand All @@ -143,7 +155,7 @@ class ImGuiDrawer : public BlockerEventDrawer<DerivedRenderApp>
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
#elif defined(VCLIB_RENDER_BACKEND_BGFX)
ImGui_ImplBgfx_RenderDrawData(ImGui::GetDrawData());
#endif
#endif // VCLIB_RENDER_BACKEND_*
derived()->update();
}

Expand Down

0 comments on commit 3facc45

Please sign in to comment.