From 8c4f41d1dfbbf2ee73c2eee003cf826249ef577d Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Wed, 15 Dec 2021 23:48:14 +0100 Subject: [PATCH 1/2] Revert "Fixed DearIMGUI debug assert - missing EndFrame()" This reverts commit 627d85b90bf833ff24de65f79903637951fc7a16. --- source/main/gui/imgui/OgreImGui.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source/main/gui/imgui/OgreImGui.cpp b/source/main/gui/imgui/OgreImGui.cpp index 3403ea9dac..66d8f18b17 100644 --- a/source/main/gui/imgui/OgreImGui.cpp +++ b/source/main/gui/imgui/OgreImGui.cpp @@ -137,18 +137,11 @@ 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) - { - //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. + //ORIG//Ogre::OverlayManager::getSingleton()._queueOverlaysForRendering(vp->getCamera(), sceneMgr->getRenderQueue(), vp); + m_imgui_overlay->_findVisibleObjects(vp->getCamera(), sceneMgr->getRenderQueue(), vp); } } } From e28216b41e29d6cac4fa0d970831b07967825c7b Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Mon, 21 Feb 2022 04:56:49 +0100 Subject: [PATCH 2/2] :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); + } } } }