diff --git a/big2/include/big2/imgui/imgui_app_extension.h b/big2/include/big2/imgui/imgui_app_extension.h index 60f5d27..7a4b677 100644 --- a/big2/include/big2/imgui/imgui_app_extension.h +++ b/big2/include/big2/imgui/imgui_app_extension.h @@ -24,7 +24,7 @@ class ImGuiAppExtension final : public AppExtensionBase { protected: void OnWindowCreated(Window& window) override; void OnWindowDestroyed(Window& window) override; - void OnRender(Window& window) override; + void OnUpdate(std::float_t dt) override; private: std::vector contexts_; diff --git a/big2/src/imgui/imgui_app_extension.cpp b/big2/src/imgui/imgui_app_extension.cpp index 878a30c..728f92c 100644 --- a/big2/src/imgui/imgui_app_extension.cpp +++ b/big2/src/imgui/imgui_app_extension.cpp @@ -57,20 +57,22 @@ void ImGuiAppExtension::OnWindowDestroyed(Window& window) { }); } -void ImGuiAppExtension::OnRender(Window& window) { - AppExtensionBase::OnRender(window); +void ImGuiAppExtension::OnUpdate(std::float_t dt) { + AppExtensionBase::OnUpdate(dt); - std::optional maybe_context = big2::FirstIf(contexts_.begin(), contexts_.end(), [&window](ImGuiContextWrapper& context) { - return context.GetWindow() == window.GetWindowHandle(); - }); + for(Window& window : app_->GetWindows()) { + std::optional maybe_context = big2::FirstIf(contexts_.begin(), contexts_.end(), [&window](ImGuiContextWrapper& context) { + return context.GetWindow() == window.GetWindowHandle(); + }); - if(!maybe_context.has_value()) - { - return; - } + if(!maybe_context.has_value()) + { + return; + } - ImGui::SetCurrentContext(maybe_context.value().GetContext()); - big2::GlfwEventQueue::UpdateImGuiEvents(window.GetWindowHandle()); + ImGui::SetCurrentContext(maybe_context.value().GetContext()); + big2::GlfwEventQueue::UpdateImGuiEvents(window.GetWindowHandle()); + } } }