Page 1 of 1

[Solved] Loading bar

Posted: Mon May 30, 2011 22:11
by Progger
Hi,
I'm using Ogre 1.7.2 (Cthugha) and CEGUI 0.7.5 trying to implement a loading bar. Without a big success so far :(

Description: I created a progress bar showing the progress of the loading but the problem is that this progress bar is not visible until the loading is over. Using Ogre::ResourceGroupListener i add the progress to the progress bar and call 'CEGUI::System::getSingleton().renderGUI(); + Ogre::Window::update' just after it in hope the progress bar will be shown. But t seems i miss somewhat here. Unfortunately the searching function didn't help me a lot this time. I hope you can help me to solve this problem ;)

cu

Re: Loading bar

Posted: Tue May 31, 2011 17:52
by CrazyEddie
Not sure. Seems more like an Ogre related issue to me.

CE.

Re: Loading bar

Posted: Tue May 31, 2011 19:18
by Jamarr
You say that the progress bar is not shown until after loading is complete, so then what is shown during loading?

The first obvious thing to check is that you have initialized Ogre and CEGUI prior to loading your applications resources. You cannot include this initialization as part of the loading-progress since these systems have to be setup prior to so that they can render the progress bar.

The second obvious thing to check is that your loading-process is broken up over several frames. If you try to initialize, load, and render everything in a single frame of execution you are not going to see any progress since the renderer is never given time to update the screen. For the progress bar to work you have to allow rendering frames to occur during the loading process.

And of course there are other possibilities depending on what your exact setup and logic are. However, since you did not provide provide any relevant information beyond "this does not work, help" it will be difficult for anyone to assist you. Please provide as much contextual information as possible; the more relevant information you provide the easier it will be for someone else to help you.

Re: Loading bar

Posted: Wed Jun 01, 2011 21:40
by Progger
Jamarr wrote:You say that the progress bar is not shown until after loading is complete, so then what is shown during loading?

the colour of the viewport, in my case its black.

Jamarr wrote:The first obvious thing to check is that you have initialized Ogre and CEGUI prior to loading your applications resources. You cannot include this initialization as part of the loading-progress since these systems have to be setup prior to so that they can render the progress bar.

Yes, of course the systems are initilised before i call inititresources method. Since the program would rather crash than showing nothing.
here the sequnce:
ogre setup (root, window, scenemgr, camera)
cegui setup (bootstrap, scheme)
loading (create progressbar load ressources)

Jamarr wrote:The second obvious thing to check is that your loading-process is broken up over several frames. If you try to initialize, load, and render everything in a single frame of execution you are not going to see any progress since the renderer is never given time to update the screen. For the progress bar to work you have to allow rendering frames to occur during the loading process.

That's why I call "CEGUI::System::getSingleton().renderGUI();" Since I'm not using threads its the only option to update the scene and in fact when i try to render something in OGRE, e.g. simple model or an overlay so its really rendered during loading. "Ogre::Window::update" must be called in this case.

Jamarr wrote:And of course there are other possibilities depending on what your exact setup and logic are. However, since you did not provide provide any relevant information beyond "this does not work, help" it will be difficult for anyone to assist you. Please provide as much contextual information as possible; the more relevant information you provide the easier it will be for someone else to help you.

Ok, sorry when the call for help sounded so poor. This wasnt my intention, since I thought this description should be very informative for those who wanted to update CEGUI manually.

I try to put it this way:
The loading bar is one part of my game and this game is separed in different game states. in fact there are two different game states (intro, main menu) called and rendered corectly before I actually switch to one game state that uses this loading bar. So for this time only resources that are needed in this new game state are loaded so it shouldnt be a problem for CEGUI since all resources for CEGUI were used in a prior game state. But in order to create a new scene I call "CEGUI::WindowManager::getSingleton().destroyAllWindows();" and go on with this sequence:
create scene manager
setup camera (+ viewport)
create progress bar
call "Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup" (now everything updated by resource listener. i.e. renderGUI/window::update)
destroy progress bar and setup the actual game scene - in this case I commented out the destruction of the progress bar to see the effect if it's rendered at all and yes its really rendered, so it should'n be a setup issue.

As already mentioned rendering an OGRE overlay like in the sample browser is not a problem but there is a problem to render CEGUI widgets manually calling "renderGUI". So my question was just simple if I forgot to do something additional to this call to get things be rendered.

Re: Loading bar

Posted: Thu Jun 02, 2011 06:45
by CrazyEddie
...there is a problem to render CEGUI widgets manually calling "renderGUI". So my question was just simple if I forgot to do something additional to this call to get things be rendered.

The problem should not be the renderGUI call, after all, this is how CEGUI output is always drawn, including using Ogre. I think you'll find that the issue here is one of timing. I suspect that the CEGUI content is getting drawn (when you call renderGUI) and then overwritten by the other Ogre rendered content (when Ogre later reacts to the 'update' request).

One thing I can't explain is if you're relying on the Ogre loop to perform rendering, then the FrameListener we use on the initial Ogre::RenderTarget (in this case the window) should still trigger the automatic call of renderGUI, thus ensuring that things are still drawn the correct way around. Seems to me to be some weird inconsistent behaviour in Ogre that works normally, but not in these circumstances - if I were you, I would investigate in that area; test if the frame listeners still get triggered under these conditions...

CE

[Solved] Loading bar

Posted: Fri Jun 03, 2011 13:58
by Progger
Ok, after some hours debugging the code I could solve this problem ;)

CrazyEddie wrote:
...there is a problem to render CEGUI widgets manually calling "renderGUI". So my question was just simple if I forgot to do something additional to this call to get things be rendered.

The problem should not be the renderGUI call, after all, this is how CEGUI output is always drawn, including using Ogre. I think you'll find that the issue here is one of timing. I suspect that the CEGUI content is getting drawn (when you call renderGUI) and then overwritten by the other Ogre rendered content (when Ogre later reacts to the 'update' request).

Thats the point!
Chaning the code from

Code: Select all

mWindow->update();
CEGUI::System::getSingleton().renderGUI();
// or
CEGUI::System::getSingleton().renderGUI();
mWindow->update();

to

Code: Select all

mWindow->update(false);
CEGUI::System::getSingleton().renderGUI();
mWindow->swapBuffers(false);

made my day.

CrazyEddie wrote:One thing I can't explain is if you're relying on the Ogre loop to perform rendering, then the FrameListener we use on the initial Ogre::RenderTarget (in this case the window) should still trigger the automatic call of renderGUI, thus ensuring that things are still drawn the correct way around. Seems to me to be some weird inconsistent behaviour in Ogre that works normally, but not in these circumstances - if I were you, I would investigate in that area; test if the frame listeners still get triggered under these conditions...

Well, since I change the game states during the update of the frame listeners, it would be strange when one frame listener is being updated by another.
Here the sequence how it looks like or at least how I think it looks like:
Sequence per frame listener:

Code: Select all

frameStarted
frameRenderingQueued - Update CEGUI (automatically)
frameEnded - Change of the game state, i.e. load ressources AND update CEGUI (manually) after every load part just in this one method. As I said I dont use threads.


cu

Re: [Solved] Loading bar

Posted: Sun Jun 05, 2011 10:23
by Mikademus
Thanks for the solution! This to me sounds like an useful Wiki mini-article!