How to add a "loading screen"?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Corak55
Gnoblar
Posts: 12
Joined: Tue Apr 29, 2014 11:28 am

How to add a "loading screen"?

Post by Corak55 » Sat Oct 25, 2014 9:35 am

Dear Ogreans,

when I start my ogre application it takes 10+ secounds until the engine displays the full scene. It's not assembled piece-by-piece, so I assume the program renderes everything first and if it's ready it starts to display.

Thats why I'd like to add a kind of "loading screen" (plain .jpg/.png will do) to my application. This image should be loaded and displayed at once, rendering the scene in the background. As soon as the scene is ready, the loading screen can fade out or simply turn off.

How would you perform this?

Kind regards,
Corak
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: How to add a "loading screen"?

Post by c6burns » Sat Oct 25, 2014 10:51 am

If you are using the tutorial framework, it loads every single resource group before doing any rendering. This causes a considerable delay if you are using the default resources.cfg in the SDK because you are loading every resource for the sample browser.

The sample browser does have an example of doing a loading screen that displays a progress bar while it loads all of the resource groups. I don't use the resources.cfg in my own projects. What I personally do, is load a minimal resource group with just a font definition, or a splash image, and then render a frame of "Now loading". Then I go ahead and load additional resource groups for the main menu screen.

My framework defines scene objects, to which I pass the SceneManager. These scenes handle their own load/unload of resource groups, and they can request a new scene to be loaded (at which point they are unloaded). That's how I handle stringing together a game with multiple screens and levels. It's simple, but it works for me.
0 x

Corak55
Gnoblar
Posts: 12
Joined: Tue Apr 29, 2014 11:28 am

Re: How to add a "loading screen"?

Post by Corak55 » Sat Oct 25, 2014 11:44 am

Hello c6burns,

thank you for you reply!

You're right, I'm using the resources.cfg from the SDK. I can't find and "loading screen" example in my sample browser (do you have a source for me?), so I tried to get the "minimal solution".

So I create a Ogre::Root, set a Render System, initialize, add a Window, SceneManager, camera and viewpoint - and then -> startRendering(). All works fine and a first scene is displayed within 3 seconds. :D
Unfortunately, that's it. When the program should load the other objects (and the OIS listener), nothing happens. Maybe it's on the wrong render-window, but I'm a bit lost to tell (and to be honest, I'm not that clear with all those frames, listerners and windows right now). :(
Do you have a sample structure code for me, how to start with one frame first and than switch to another one?

Kind regards,
Corak
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: How to add a "loading screen"?

Post by c6burns » Mon Oct 27, 2014 10:08 pm

At any time, you can create/load/unload/destroy resource groups. The resources.cfg and BaseApplication::setupResources in the tutorial framework are just one way to do it, which works well for the tutorials. I assume most applications need to switch scenes as the project matures from "does-this-work?" to "this-is-a-game!". So somehow your application will determine when it is time to switch scenes (eg. going from a simple loading screen, to the main menu) and you will have to load the resources necessary and attach all your renderables/lights/cameras to SceneNodes. When you need to clear the entire scene, there is a SceneManager::clearScene method which removes everything but the camera. At which point you can unload the resource groups and/or load new resource groups and set up a new scene.

I think the advanced framework in the wiki uses a game state class to manage these scenarios ... might be work checking out.
0 x

Corak55
Gnoblar
Posts: 12
Joined: Tue Apr 29, 2014 11:28 am

Re: How to add a "loading screen"?

Post by Corak55 » Fri Oct 31, 2014 2:11 pm

Dear c6burns,

thank you very much for your detailed and encouraging answer! :D With your advice I've learned a lot more about ogre by now. :)
The "loading screen" works fine now - and furthermore I'm able to do more structured scenes (like loading => menu => main => menu and so on).

Kind regards,
Corak
0 x

Post Reply