Multiple windows with Ogre3D and CEGUI

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

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Multiple windows with Ogre3D and CEGUI

Postby Ident » Mon Aug 11, 2014 17:50

Well according to your description we can be 100% sure now that the states are not set when the second guicontext is being rendered.
How do you render the GuiContexts? Show me the lines for rendering please.
CrazyEddie: "I don't like GUIs"

User avatar
pawn
Just popping in
Just popping in
Posts: 10
Joined: Tue Aug 05, 2014 08:59

Re: Multiple windows with Ogre3D and CEGUI

Postby pawn » Tue Aug 12, 2014 17:36

Sorry but due to a connection error (I think) my post never arrived -.-'
So...
I never (explicitly) render guicontexts, I only call root->renderOneFrame(); where root is the Ogre::Root singleton, the call stack that I previously posted is (I think) the responsable for the rendering of the contexts whithin these functions:

Code: Select all

void System::renderAllGUIContexts()
{
    d_renderer->beginRendering();

    for (GUIContextCollection::iterator i = d_guiContexts.begin();
         i != d_guiContexts.end();
         ++i)
    {
        (*i)->draw();
    }

    d_renderer->endRendering();

    // do final destruction on dead-pool windows
    WindowManager::getSingleton().cleanDeadPool();
}

and

Code: Select all

void OgreRenderer::beginRendering()
{
    if ( !d_pimpl->d_previousVP )
    {
        d_pimpl->d_previousVP = d_pimpl->d_renderSystem->_getViewport();
        if ( d_pimpl->d_previousVP && d_pimpl->d_previousVP->getCamera() )
            d_pimpl->d_previousProjMatrix =
                d_pimpl->d_previousVP->getCamera()->getProjectionMatrixRS();
    }

    //FIXME: ???
    System::getSingleton().getDefaultGUIContext().getRenderTarget().activate();
    initialiseRenderStateSettings();

    if (d_pimpl->d_makeFrameControlCalls)
        d_pimpl->d_renderSystem->_beginFrame();
}

//----------------------------------------------------------------------------//
void OgreRenderer::endRendering()
{
    if (d_pimpl->d_makeFrameControlCalls)
        d_pimpl->d_renderSystem->_endFrame();

    //FIXME: ???
    System::getSingleton().getDefaultGUIContext().getRenderTarget().deactivate();

    if ( d_pimpl->d_previousVP )
    {
        d_pimpl->d_renderSystem->_setViewport(d_pimpl->d_previousVP);
   
        if ( d_pimpl->d_previousVP->getCamera() )
        {
            d_pimpl->d_renderSystem->_setProjectionMatrix(
                d_pimpl->d_previousProjMatrix);
            d_pimpl->d_renderSystem->_setViewMatrix(
                d_pimpl->d_previousVP->getCamera()->getViewMatrix());
        }
        d_pimpl->d_previousVP = 0;
        d_pimpl->d_previousProjMatrix = Ogre::Matrix4::IDENTITY;
    }
}

which seems to take care only of one GuiContext... (the draw instead is called for each guiContext)
Do you think that the problem could be here?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Multiple windows with Ogre3D and CEGUI

Postby Ident » Wed Aug 13, 2014 09:51

Each time you call Ogre's render function on your RenderWindow you should:
Explicitly call CEGUIOGreRenderer::beginRendering()
and then draw() on the GUIContext that is associated with that RenderWindow



Does this solve your issue?
CrazyEddie: "I don't like GUIs"

User avatar
pawn
Just popping in
Just popping in
Posts: 10
Joined: Tue Aug 05, 2014 08:59

Re: Multiple windows with Ogre3D and CEGUI

Postby pawn » Tue Aug 19, 2014 21:32

Sorry for the delay, the time runs too quickly hehe XD

So the problem is that the ogre's render function is called one time at all (not once per window) so I can't call the functions at each render.
What I have done is this:

Code: Select all

    root->renderOneFrame();
    guiRenderer->initialiseRenderStateSettings();
    secondGuiContext->draw();


That seems to work (I am not sure because I can't test everything now) so my guess is that is happening something like that

  • Ogre renders first window
    • CEGUI renders first window
    • CEGUI renders second window
  • Ogre renders second window

so by calling the two functions at the end it works by coincidence but it won't work if for example I have 3 windows.
I am not sure about what I said because I am far from being an expert of these things does it make sense?
If I find some time I'll try to examine the code more deeply...
Thanks

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Multiple windows with Ogre3D and CEGUI

Postby Ident » Wed Aug 20, 2014 06:12

pawn wrote:That seems to work (I am not sure because I can't test everything now) so my guess is that is happening something like that

  • Ogre renders first window
    • CEGUI renders first window
    • CEGUI renders second window
  • Ogre renders second window


Yes, this is what I pointed out (or at least tried to point out) earlier.
You clearly visualised it better than I did.

And yes, this is the issue to solve, and you can solve it by taking control of when you render the Ogre Window and when you render the CEGUI's GUI context. The latter you already do!
I am not sure how you can separate the rendering of Ogre windows, this is somewhat of an ogre issue. My guess would be that there would at least be some kind of handler for pre-window rendering that you can register for each window and put the CEGUI draw call into.

This is an Ogre issue however, so I cannot help you with specifics there. If you find out how to do this please post it here.
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests