Freezed rendering and cursor while setting up scene

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Freezed rendering and cursor while setting up scene

Post by kubatp »

Hi,
I would like to ask a pretty simple question. When I set up the scene (for example when user wants to load the game), the rendering freezes (due to creating meshes, etc). What is the best practice to avoid this? And more narrowed question - How to avoid freezing cursor during this?

I read about future option of loading this in background thread, but I am not sure if this already available in MOGRE (which I use).

Thank you for your help
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Freezed rendering and cursor while setting up scene

Post by kubatp »

Noone has had similar problem?
NotCamelCase
Greenskin
Posts: 140
Joined: Sun Feb 03, 2013 6:32 pm
x 8

Re: Freezed rendering and cursor while setting up scene

Post by NotCamelCase »

Are you using Ogre 1.9 or older? If so, you can simply compile with background thread support but when I tried it, it didn't bring so much improvement. I chose simply hiding the cursor and manually updating the engine as resources and scene initialization progressed.
Check out my projects: https://github.com/NotCamelCase
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Freezed rendering and cursor while setting up scene

Post by kubatp »

Hello,
thank you for reply.
NotCamelCase wrote:Are you using Ogre 1.9 or older?
Well, I am using MOGRE, which is compiled with 1.7.1
NotCamelCase wrote: I chose simply hiding the cursor and manually updating the engine as resources and scene initialization progressed.
I was thinking about this solution, but you would need to add these UI updates directly to the code where you add resources to scene, right? I was initially thinking about creating a timer, which would regularly update UI, but this update needs to be done on the UI thread anyway (which is busy), so this won't get executed till the UI thread is available again.
NotCamelCase
Greenskin
Posts: 140
Joined: Sun Feb 03, 2013 6:32 pm
x 8

Re: Freezed rendering and cursor while setting up scene

Post by NotCamelCase »

Hmm I'm not familiar with MOGRE but you'd register resource listeners to be triggered when the specific resources are parsed/loaded etc. and update UI accordingly. How long roughly does your resource loading take anyway?
Check out my projects: https://github.com/NotCamelCase
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Freezed rendering and cursor while setting up scene

Post by kubatp »

NotCamelCase wrote:How long roughly does your resource loading take anyway?
It depends on the map size, usually cca 30 seconds, but can be also one minute.
NotCamelCase wrote:Hmm I'm not familiar with MOGRE but you'd register resource listeners to be triggered when the specific resources are parsed/loaded etc. and update UI accordingly
But this can be done only when you load resources in background thread, correct? Or it works on the main thread as well? Can you just point me in right direction here? Code snippet or something?
NotCamelCase
Greenskin
Posts: 140
Joined: Sun Feb 03, 2013 6:32 pm
x 8

Re: Freezed rendering and cursor while setting up scene

Post by NotCamelCase »

If you don't turn on background threading and just load all resources at once, your UI will freeze no matter what. To avoid that without background threading, as I said, you can just hack it by hiding the cursor and manually updating your UI as the resources are loaded (progress bar and text describing the data, etc.) Just create a class implementing resource listener and act according to the event triggers that are detailed here: http://www.ogre3d.org/docs/api/1.9/clas ... ml#details

On the other hand, to improve it even better, you can enable background threading alongside the waiting UI to make it faster. Also, another point could be to pre-parse the resources during a simpler scene (Main Menu or Options) which also takes a significant amount of time, without loading so when you load them, it'll be faster.

Edit: The docs mention that resource listeners are thread-safe when using threading so you'll be OK.
Check out my projects: https://github.com/NotCamelCase
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Freezed rendering and cursor while setting up scene

Post by kubatp »

Hello,
thank you very much. I will definitely try that out.
Post Reply