Sign in to follow this  

how to control the file loading process?

This topic is 4869 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

well... as I have now the engine hangs when it loads a file, and when it is done it continue to work with the stuff it should do.. how does a game controll the loading of several files and know when to load it, and how make sure the app doesn't hang itself while loading, I want some kind of progress indicator that shows me how much is done. I have tried to display a logo that says it is loading before I load all huge files/textures etc. but it wont be displayed until after it is done and just for a second or less I can't figure out why. I would like to controll it something like this FileManager->Queue(...); FileManager->Queue(...); FileManager->Queue(...); ... FileManager->BeginLoad(); I have tried but it hangs my app untill it has loaded all items so then I can't display any loading logo or progress indicator at all, if the files are huge text-files the process takes a while.

Share this post


Link to post
Share on other sites
Do some multi-threading. Seperate thread for file loading, another for graphical display of progress. Unless you have some really intensive process that needs to be run to process the files being loaded, there shouldn't be any hanging going with this method. With a decent threading library, there shouldn't be even WITH lots of intensive processing on the file loading.

Share this post


Link to post
Share on other sites
so if I create a separate thread to load the files in, how do I know that the filemanager is in progress of the files and how to create a wait loop which draws the progress bar?!

can I make it like this?

FileManager->Queue(...);
...

FileManager->BeginLoad();

// Do som other stuff here

// Wait until it is done
while( FileManager->IsLoading() )
{
// Draw/update the progress bar
...
};

Share this post


Link to post
Share on other sites
It depends on what your program is.

If its a win32 app. Create a modless dialog box with your progress bar and pass the hwnd to it for file maneger to update the nessery fields. The Dialogbox will function as long as your main thread is able to process messages.

If its opengl/directx/anything frame based (i.e re-draw screen every frame)

Have a 'CurProgress' member of your filemanager class which it can update.

It could also have a ProcessComplete flag or something so the rest of your program knows when loading is done.

then

int frame()
{
//Do your normal drawing, even continue to run the game(if poss)
//Draw the prograss bar based on the Filemanager->CurProgress
}

Share this post


Link to post
Share on other sites

This topic is 4869 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.

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