Page 1 of 1

Explicitly render CEGUI

Posted: Wed Jul 14, 2010 23:50
by -EleMenT-
Hello all,

I am currently trying to integrate CEGUI into an existing Ogre application and have done so with moderate success. However, I am running into an issue.

This application does not render its render targets via the renderOneFrame or startRendering methods that Ogre provides. This application needs to be able to explicitly update and render particular render targets without rendering all of them. I have been dealing with this issue for hours now, and fear the solution may be right under my nose. I have been playing around with the following methods:

Code: Select all

while(true) {
        Ogre::WindowEventUtilities::messagePump();
        root->_fireFrameStarted();
       
        renderWindow->update(false);
        rt->update(false);
       
        renderWindow->swapBuffers(true);
        rt->swapBuffers(true);
       
        root->_fireFrameRenderingQueued();
        //root->getRenderSystem()->_swapAllRenderTargetBuffers(true);
        root->_fireFrameEnded();
       
        //
        //root->renderOneFrame();
    }


This code does nothing. No CEGUI window is loaded.

For context, root is the OgreRoot, renderWindow is the render target created by my test application that is passed into the System::bootstrapSystem(renderWindow) function, and rt is the CEGUI render target I managed to hack-grab from the RenderSystem. I know it is a valid instance and is the correct one through testing. I won't be able to show more code, I am sorry. Here lies the problem:

If I simply call root->renderOneFrame(); without the other stuff, CEGUI loads along with the background image of the renderWindow. Fine, but not what I want, as that renders ALL render targets.

If I do:

Code: Select all

while(true) {
        Ogre::WindowEventUtilities::messagePump();
        root->_fireFrameStarted();
       
        //renderWindow->update(false);
        //rt->update(false);
       
        //renderWindow->swapBuffers(true);
        //rt->swapBuffers(true);
       
        root->_fireFrameRenderingQueued();
        root->getRenderSystem()->_swapAllRenderTargetBuffers(true);
        root->_fireFrameEnded();
       
        //
        //root->renderOneFrame();
    }


CEGUI loads a window, but the background is black.

If I do:

Code: Select all

while(true) {
        Ogre::WindowEventUtilities::messagePump();
        root->_fireFrameStarted();
       
        renderWindow->update(false);
        //rt->update(false);
       
        //renderWindow->swapBuffers(true);
        //rt->swapBuffers(true);
       
        root->_fireFrameRenderingQueued();
        root->getRenderSystem()->_swapAllRenderTargetBuffers(true);
        root->_fireFrameEnded();
       
        //
        //root->renderOneFrame();
    }


There is very fast flickering between the CEGUI window and the background image, as the buffers swap. I know that you probably have to render renderWindow in this case as CEGUI is using it, but that isn't the point. What I am trying to accomplish is to be able to explicitly render CEGUI and its render target from code not using methods like renderOneFrame(); or startRendering(); I have searched a lot for this, and maybe I missed something, so any help is appreciated.

Thanks!

Re: Explicitly render CEGUI

Posted: Wed Jul 14, 2010 23:59
by -EleMenT-
Its actually really funny that I JUST figured it out less than 10 minutes after posting. Thanks for your help everyone!!!! :mrgreen: You are that good, you didn't even have to reply :lol:

So I always hate it when people solve their own issue and neglect to post their solution, so here it was:

Code: Select all

while(true) {
        Ogre::WindowEventUtilities::messagePump();
        root->_fireFrameStarted();
       
        renderWindow->update(false);
       
        root->_fireFrameRenderingQueued();
        renderWindow->swapBuffers(true);
        root->_fireFrameEnded();
}


It seems I was trying to do too much explicitly. As you can see, this is quite similar to the implementation that I said "flickered". The issue was the ordering.

Re: Explicitly render CEGUI

Posted: Fri Jul 16, 2010 08:49
by CrazyEddie
Thanks for posting your solution; I also find it annoying when people do not post their own solutions :)

CE.

Re: Explicitly render CEGUI

Posted: Wed Nov 24, 2010 17:53
by Toadcop
same problem here ^_^

now i am trying to find also a solution. so stay tuned ! :P

*ADD*
ok the major issue was what i didn't keeped buffer swap in sync with CEGUI updates it has cause the major flickers.

now i have have very small flickers (but objects doesnt disapper now) in widgets especialy good to see on widgets with transparency. i will try find the issue for this also and post it here =)