Sign in to follow this  
chillypacman

loading screens?

Recommended Posts

What would be a good way to do loading screens in directx? I think it should be fairly simple, just calling a specific function which renders the loading screen from the function that does the loading itself but that feels a bit tacky. Is there another way or is my idea acceptable?

Share this post


Link to post
Share on other sites
It depends on how fancy you want the screen. It's not DirectX, but I've used a modeless dialog and update a progress bar or just display percents.

If you want it to be DX, you can also setup a 2D scene with a full-view textured quad and draw over that with textured quads or a nice font.

Set up a Render() function for the loading screen separate from your app's normal render routine. Let it display loading parameters (percents, etc.) and put it on a timer.

I'm not sure if Sleep() is the right way to do it, but you might try adding a few Sleep() calls to your loading function to allow the screen to render. Or call the loading function from the load screen routine itself and load portions at a time.

When the loading's done, set a flag to start calling the normal render routine rather than the startup screen each frame or just go into another (normal) rendering loop.

Share this post


Link to post
Share on other sites
One good way to tackle this is to think of your startup / boot routines as being divided into 2 or more stages, then just divide them up in a logical order like stage 1 could be loading engine critical stuff like initialising the graphics api and creating the system font, stage 2 could be loading the splash data files for display, stage 3 could loading everything else.

If you want animation then you need to put your splash into a separate thread with its own render loop. Be prepared for the fact that you will only have access to stage 1 & 2 data, and also not to let it overlap with your rendering loop which will run on your main thread once booting is finished.

Hope that helps, and good luck!

Share this post


Link to post
Share on other sites
I like to use a separate thread to handle the loading screen. It's definitely the most work out of all the methods proposed (since you have to get into Win32 thread functions, and you have to use synchronization methods to ensure both your threads aren't messing with the device a the same time), but is also the most robust. Personally I'm of the opinion that an app should never stop pumping messages and processing user input, and I apply this to games as well.

Share this post


Link to post
Share on other sites
i agree with the seperate thread, you could have the loading thread periodicly change a variable to let the loading image know how much has been loaded, allowing you to accuratly display the amount

Share this post


Link to post
Share on other sites
It depends on how complicated you want to get. Threads are the best solution, but they are a pain to use. I would actually recommend against using threads unless you really know what you're doing.

Share this post


Link to post
Share on other sites
Well I don't really want to over complicate the matter, especially with threads since I don't have much experience using threads (actually I have none).

I've decided I'm just going to create a simple function that takes a string and then displays it with a menu background. Since I only have five functionw which load things I can simply call it from there (for instance loadingScreen.display("Loading: " + object.name)). Since the directx device is already initialized immediate and doesn't atke long to do so I can use it. The loading screen actually uses sprites rather than tex quads so hopefully it won't effect the performance too much.

Like I said, I don't want to make it too complex for my own good, I'm not that good a programmer to begin with.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this