Multi-viewport rendertarget bug

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

ianstangoe
Quite a regular
Quite a regular
Posts: 79
Joined: Wed Jan 09, 2008 11:06

Multi-viewport rendertarget bug

Postby ianstangoe » Tue Sep 21, 2010 14:40

Hi CE,

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.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Multi-viewport rendertarget bug

Postby CrazyEddie » Wed Sep 22, 2010 09:10

Thanks for raising this issue.

I don't think there's anything wrong with your init code, though in your render queue listener are you (re)setting the view ports as detailed here: viewtopic.php?p=22052#p22052

Aside from this, and off the top of my head, I have no ideas about what might be going on here ;) I do actually have a whole raft of Ogre renderer related issues to look into, and at the moment I'm thinking that I might spend the coming weekend working on those. If you can confirm (or not) whether you're already resetting the view port in the render queue listener, I'll add this to the list of thing that I will check :)

CE

ianstangoe
Quite a regular
Quite a regular
Posts: 79
Joined: Wed Jan 09, 2008 11:06

Re: Multi-viewport rendertarget bug

Postby ianstangoe » Wed Sep 22, 2010 16:17

Hi CE,

yes, I am using that exact code and my startup process is basically:

* Init OGRE
* Create a rectangle2D
* call renderOneFrame() to display splash screen
* Init CEGUI
* load some layouts and set "AutoRenderingSurface" on my root window
* enter idle loop: calling renderOneFrame()..

Regards, Ian.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Multi-viewport rendertarget bug

Postby CrazyEddie » Mon Sep 27, 2010 13:15

I did not test this specifically yet (it will be either this evening or tomorrow morning, sorry for the delay). However, I did tweak something else in this area that may affect things, so if you could update and let me know i) if the issue still exists, and ii) if the multi-viewport rendering still works at all ( :lol: don't ask!).

CE.

ianstangoe
Quite a regular
Quite a regular
Posts: 79
Joined: Wed Jan 09, 2008 11:06

Re: Multi-viewport rendertarget bug

Postby ianstangoe » Mon Sep 27, 2010 15:16

Just tried the latest v0-7 SVN branch and there was no change to the multi-viewport rendering, however the viewprt size issue still remains. :(

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Multi-viewport rendertarget bug

Postby CrazyEddie » Tue Sep 28, 2010 10:25

Ok, I tried to reproduce this but failed, however via analysis of the code I did decide that the situation was not correct (i.e dimensions set on the viewport could be lost depending on the internal state), and I've committed a change that should fix this issue.

Let me know how it goes :)

CE.

ianstangoe
Quite a regular
Quite a regular
Posts: 79
Joined: Wed Jan 09, 2008 11:06

Re: Multi-viewport rendertarget bug

Postby ianstangoe » Wed Oct 06, 2010 15:03

Hi CE,

FYI, the latest code seems to fix this issue now, thanks! :D

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Multi-viewport rendertarget bug

Postby CrazyEddie » Fri Oct 08, 2010 09:16

Cool, thanks for letting me know :)

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests