I have an ImGui widget with code similar to this:
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::Begin("Window 1");
ImGui::Button("Hello 1");
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
This runs fine.
If I add another frame, something like this:
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::Begin("Window 1");
ImGui::Button("Hello 1");
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
ImGui::Begin("Window 2");
ImGui::Button("Hello 2");
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
It renders fine but any mouse click cause an infinite recursion when glfwPollEvents()
is called (the recursion is in ImGui_ImplGlfw_MouseButtonCallback(...)
).
Note: I know I can perform several Begin(...) ... End(...) sequences without creating a new frame between them but I want the widgets to be independent of each other.
This is the call stack btw:
.
.
.
ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *, int, int, int) imgui_impl_glfw.cpp:94
ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *, int, int, int) imgui_impl_glfw.cpp:94
ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *, int, int, int) imgui_impl_glfw.cpp:94
ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *, int, int, int) imgui_impl_glfw.cpp:94
ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *, int, int, int) imgui_impl_glfw.cpp:94
ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *, int, int, int) imgui_impl_glfw.cpp:94
_glfwInputMouseClick(_GLFWwindow *, int, int, int) input.c:350
windowProc(HWND__ *, unsigned int, unsigned long long, long long) win32_window.c:804
<unknown> 0x00007ffce6e4e858
<unknown> 0x00007ffce6e4e4ee
<unknown> 0x00007ffcb74702a0
<unknown> 0x00007ffce6e4e858
<unknown> 0x00007ffce6e4e299
_glfwPlatformPollEvents() win32_window.c:1977
glfwPollEvents() window.c:1092
Widget::NewFrame() Widget.cpp:20
Widget::Draw(const Eigen::Matrix<…> &, const Eigen::Matrix<…> &, const Eigen::Matrix<…> &, int, unsigned int) Widget.cpp:28
Movable::Draw(const Eigen::Matrix<…> &, const Eigen::Matrix<…> &, const Eigen::Matrix<…> &, int, unsigned int) Movable.cpp:160
Scene::Draw(int, const std::shared_ptr<…> &, unsigned int) Scene.cpp:30