c++ - SDL2 Loading screen/thread -
Hi fellow programmer,
Try to get the loading screen in SDL2 to spend time at the end After that, we failed to do this. We are building a simple 2D open world's top-down, for which we have created a lot of tiles / spray for various institutions (rabbits, trees, rock etc.) Need to load
At first we had only one tile set, h Indicating included trees and background tiles now, however, the map spread out a 'sample' 50x50 tile-map to 1500x1500 tile-map. Result: The game seemed to be stationary, but it was loading instead of tiles / images.
Our solution: Create a loading screen where we can show the current loading progress. Since our game uses state-pattern for gamestats (or to some extent it likes), we will have a playstate and a loadstate.
We decided to use a regular stud :: thread to load all the data necessary and convert them into texture.
- Read a JSON file, with data for our map
- Process data for retrieval
- Load images and create textures
All this works without any threads (except for 'Freeze', which is just above all Loads), but with a thread, about 60% of the success / failure / 40% of hours and after hours of searching, we found the reason: SDL_Crea TeTextxture A different thread, otherwise from the main thread
Right now, we are unaware because we have no information about performing all the actions above, showing the loading screen, without having to create a separate thread in order to execute those actions. So our question: Can a loading screen be achieved, the way we described it above?
-
call IMG_LoadTtexture () until it There is no time to display the current frame until your files are in a loop.
-
Submit a simple image to display progress
-
If there are more textures to load, geto 1 < / P>
This is done in a single thread.
Comments
Post a Comment