diff --git a/source/main/gui/imgui/OgreImGui.cpp b/source/main/gui/imgui/OgreImGui.cpp index 3403ea9dac..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" @@ -137,19 +138,19 @@ void OgreImGui::renderQueueStarted(Ogre::uint8 queueGroupId, Ogre::Viewport* vp = Ogre::Root::getSingletonPtr()->getRenderSystem()->_getViewport(); if(vp != NULL) { - if (vp->getOverlaysEnabled()) + Ogre::SceneManager* sceneMgr = vp->getCamera()->getSceneManager(); + if (vp->getOverlaysEnabled() && sceneMgr->_getCurrentRenderStage() != Ogre::SceneManager::IRS_RENDER_TO_TEXTURE) { - Ogre::SceneManager* sceneMgr = vp->getCamera()->getSceneManager(); - if (sceneMgr->_getCurrentRenderStage() != Ogre::SceneManager::IRS_RENDER_TO_TEXTURE) + // 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) { - //ORIG//Ogre::OverlayManager::getSingleton()._queueOverlaysForRendering(vp->getCamera(), sceneMgr->getRenderQueue(), vp); m_imgui_overlay->_findVisibleObjects(vp->getCamera(), sceneMgr->getRenderQueue(), vp); } } - else - { - ImGui::EndFrame(); // Rendering won't happen - end frame manually. - } } } }