I recently came across an odd issue when using multiple viewports, which I traced to OgreRenderTarget::setOgreViewportDimensions(). It concerns the creation of the viewports for rendertargets and initial rendering of the gui via a CEGUIRQListener approach.
The issue was that the first rendering of my gui, with dual viewports, was causing the left viewport to pickup the wrong dimensions and thus render a stretched splashscreen in that viewport, the right viewport was fine. This only happens on the very first rendering and it corrects itself from then on.
I traced it to the setOgreViewportDimensions() call inside which there is a check for a valid d_viewport variable.
Code: Select all
//----------------------------------------------------------------------------//
void OgreRenderTarget::setOgreViewportDimensions(const Rect& area)
{
if (d_viewport)
{
Ogre::RenderTarget* rt = d_viewport->getTarget();
if (rt)
{
d_viewport->setDimensions(
area.d_left / rt->getWidth(),
area.d_top / rt->getHeight(),
area.getWidth() / rt->getWidth(),
area.getHeight() / rt->getHeight());
}
d_viewportValid = false;
}
}
It seems initially this hasn't been created even though I do all my gui loading/creation prior to calling renderOneFrame(). I've had to add a call to updateViewport() inside that function, if d_viewport is NULL, to correct this issue.
Code: Select all
//----------------------------------------------------------------------------//
void OgreRenderTarget::setOgreViewportDimensions(const Rect& area)
{
if (!d_viewport) updateViewport();
Ogre::RenderTarget* rt = d_viewport->getTarget();
if (rt)
{
d_viewport->setDimensions(
area.d_left / rt->getWidth(),
area.d_top / rt->getHeight(),
area.getWidth() / rt->getWidth(),
area.getHeight() / rt->getHeight());
}
d_viewportValid = false;
}
I gather this is related to an 'AutoRenderingSurface' property I use on my root window, however I don't understand why updateViewport isn't called prior to rendering
Am I missing an initialisation step which corrects this, this is my initialisation code:
Code: Select all
// Set up GUI system
mGUIRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*mWindow->getViewport(0)->getTarget());
mGUISystem = CEGUI::System::getSingletonPtr();
mGUIRenderer->setFrameControlExecutionEnabled(false);
mRQListener = OGRE_NEW_T(CEGUIRQListener, Ogre::MEMCATEGORY_GENERAL)(mGUIRenderer, Ogre::RENDER_QUEUE_9, true);
mSceneMgr->addRenderQueueListener(mRQListener);
// Load default scheme
loadScheme("TaharezLook");
// Create a root window
mMenus["ROOT"] = CEGUI::WindowManager::getSingleton().createWindow((utf8*)"DefaultWindow", (utf8*)"MenuSheet");
mMenus["ROOT"]->setMousePassThroughEnabled(true);
mGUISystem->setGUISheet(mMenus["ROOT"]);
#if defined(_STEREO_)
mMenus["ROOT"]->setProperty("AutoRenderingSurface", "true");
#endif
Any ideas what might be going on?
This is using SVN branch v0-7.
Thanks.