Loading content (meshes, textures, sounds) in the background
- by Boreal
In my game, I am aiming for a continuous world, that is, a world where you can go anywhere without breaking the immersion through load times and "virtual seams".
My world is broken up into regions, which are nodes in a graph. A region is considered adjacent to another if it can be travelled to or seen from that region. In order to keep this continuous, I want to preload the assets needed in the adjacent regions (such as world meshes, textures, and music) before they are actually used.
As for actually loading the content, I use a manager that keeps at most one copy of each asset in memory at a time, accessible by its filename. When I try to access an asset, it loads it (if necessary) and then returns it. I can then unload any asset that is currently loaded to save memory.
Clearly, I want to do this in the background so there are no hiccups. I assume I have to use threads in some way, but I'm not sure how.