Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixing DearIMGUI NewFrame()/EndFrame() cycle. #2834

Merged
merged 2 commits into from
Feb 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions source/main/gui/imgui/OgreImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "OgreImGui.h"

#include "AppContext.h"
#include "ContentManager.h"
#include "OgreImGuiOverlay.h"

Expand Down Expand Up @@ -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.
}
}
}
}