Jump to content
  • Advertisement
Sign in to follow this  
xegoth

Best way to impliment a loading screen?

This topic is 4851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a DirectX app that takes a bit of time to load. What I want to do, is display a fullscreen bitmap (think like loading counter strike), while the game loads. I know I have to display my image after DirectX is initialized, but what about rendering it? I won't be in a render loop because I'll be loading my level. Does anyone know of a really good way to impliment a bitmap being displayed at load time? I can think of a few ways to do it but none of them stand out as really clean and effective to me. As far as I'm concerned, I want a simple implimentation that is displayed quickly.

Share this post


Link to post
Share on other sites
Advertisement
If you have an organized loading system, you could do it by calling a fairly simple drawing function every n percent. Kind like this:

LoadResources()
{
for( int i = 0; i < numResourcesToLoad; i++ )
{
// Load the resource
LoadResource( i );

float percentDone = i / numResourcesToLoad;

// Only update every 5 percent
if( (percentDone * 100) % 5 == 0 )
DrawLoadingScreen( percentDone );
}
}

Share this post


Link to post
Share on other sites
Or throw the resource loading into it's own thread. Then you'll still have your render loop, etc. Have the resource loading thread update the 'percentage done', and then you'll be able to use that during each render loop to render your progress bar, or however else you want your loading screen to work.

Best of luck.

Share this post


Link to post
Share on other sites
Those are the two ways that you can implement the loading screen. Circlesoft's implementation is undoubtably easier and will look decent for most things. However, if you want a continuously updated progress bar or a cool animation, then you will have to implement a seperate thread.

Share this post


Link to post
Share on other sites
What about just a fixed image without a loading bar. Do I need to continually redraw it or is once sufficient?

Share this post


Link to post
Share on other sites
Quote:
Original post by xegoth
What about just a fixed image without a loading bar. Do I need to continually redraw it or is once sufficient?


The back buffer can get trashed, I'm pretty sure.

Share this post


Link to post
Share on other sites
Quote:
Original post by xegoth
What about just a fixed image without a loading bar. Do I need to continually redraw it or is once sufficient?


It depends how you do it, I guess. I would think that stuff could happen to the window and it may get kinda messed up while loading. If it is a pretty short load time, you may be ok though.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sr_Guapo
Quote:
Original post by xegoth
What about just a fixed image without a loading bar. Do I need to continually redraw it or is once sufficient?

It depends how you do it, I guess. I would think that stuff could happen to the window and it may get kinda messed up while loading. If it is a pretty short load time, you may be ok though.

If you decide to not use a loading bar, and are having problems with the window getting trashed, just redraw the same screen after loading x percent of the resources. Just like I mentioned above, but without the loading bar stuff.

Share this post


Link to post
Share on other sites
Strange things can also happen if you don't run the message pump for an extended period of time, so you'll want to keep that in mind as well.

I would lean towards a separate thread for the load. It just seems more elegant and scalable.

Share this post


Link to post
Share on other sites
Quote:
Original post by RDragon1
Or throw the resource loading into it's own thread. Then you'll still have your render loop, etc. Have the resource loading thread update the 'percentage done', and then you'll be able to use that during each render loop to render your progress bar, or however else you want your loading screen to work.

Best of luck.


If you do this then how does the other thread get the loaded data?

ace

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!