SFML community forums

Help => Graphics => Topic started by: rojan_neo on August 16, 2011, 01:36:05 pm

Title: Help with implementing a loading screen
Post by: rojan_neo on August 16, 2011, 01:36:05 pm
I noticed that when I run my game ( if can call it one right now) there is a delay of 4-5 seconds where only blank white screen is displayed.. I figured that my resources are being loaded (my level is quite large)... I would like to show a loading screen during this time (or show anything on screen except the blank screen) but I have no idea how I would implement one....

Can any one can help me get an idea how a loading screen is implemented??
Title: Help with implementing a loading screen
Post by: Nexus on August 16, 2011, 01:48:51 pm
A loading screen must be continuously updated with the loading progress. Everytime a resource is loaded, your resource loader calls a function with the new progress as argument, this function draws the updated screen.

An alternative would be multithreading, but I think here it brings more complexity without real advantages. You cannot update the loading progress while a SFML resource loading function is being executed anyway (except if you estimate the progress).
Title: Help with implementing a loading screen
Post by: rojan_neo on August 16, 2011, 02:48:16 pm
ok... then how can i draw a static image ( no loading bar) saying that the game is loading.. instead of the white screen that is shown
Title: Help with implementing a loading screen
Post by: Nexus on August 16, 2011, 03:03:50 pm
Create a window, draw the image, and begin to load your other resources afterwards.

Your window does not respond during the loading, but you could update it by calling Display() from the resource-loading routine, or even use a separate thread, if user interaction is important.
Title: Help with implementing a loading screen
Post by: rojan_neo on August 16, 2011, 03:06:47 pm
Thank you, that will do for now