From ad9fb0600fc385cdf6f291d29feb650dd324b62b Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Mon, 21 Feb 2022 04:56:49 +0100 Subject: [PATCH] :bug: Fixed DearIMGUI NewFrame()/EndFrame() mismatch. --- source/main/gui/imgui/OgreImGui.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/main/gui/imgui/OgreImGui.cpp b/source/main/gui/imgui/OgreImGui.cpp index 66d8f18b17..e71542dfa7 100644 --- a/source/main/gui/imgui/OgreImGui.cpp +++ b/source/main/gui/imgui/OgreImGui.cpp @@ -25,6 +25,7 @@ #include "OgreImGui.h" +#include "AppContext.h" #include "ContentManager.h" #include "OgreImGuiOverlay.h" @@ -140,8 +141,15 @@ void OgreImGui::renderQueueStarted(Ogre::uint8 queueGroupId, Ogre::SceneManager* sceneMgr = vp->getCamera()->getSceneManager(); if (vp->getOverlaysEnabled() && sceneMgr->_getCurrentRenderStage() != Ogre::SceneManager::IRS_RENDER_TO_TEXTURE) { - //ORIG//Ogre::OverlayManager::getSingleton()._queueOverlaysForRendering(vp->getCamera(), sceneMgr->getRenderQueue(), vp); - m_imgui_overlay->_findVisibleObjects(vp->getCamera(), sceneMgr->getRenderQueue(), vp); + // Checking `sceneMgr->_getCurrentRenderStage() == Ogre::SceneManager::IRS_RENDER_TO_TEXTURE`) + // doesn't do the trick if the RTT is updated by calling `Ogre::RenderTarget::update()` by hand, + // which we do frequently. + // To compensate, we also check if the active viewport matches our screen viewport. + Ogre::Viewport* vp_target = App::GetAppContext()->GetViewport(); + if (vp == vp_target) + { + m_imgui_overlay->_findVisibleObjects(vp->getCamera(), sceneMgr->getRenderQueue(), vp); + } } } }