I’ve recently been developing a level manager (reading levels from file and creating the level within the game)- all the game levels utilise a common format of using the same floor and wall textures (to be swapped out later by other members of the development team for the project). These textures are loaded from file multiple times, putting additional load on the computer’s resources (specifically its disk and memory).
That got me thinking.
What if textures are loaded only once, where additional attempts to load it result in returning of a copy of the original texture in memory (or even a reference to the original texture in memory) from a buffer? That would result in a significant drop in system resource usage for the same task without the buffering system.
Meet the file buffering system.
This system will live inside the game scene manager’s node system (where a node is something (it can be anything) and is attached to a scene inside the scene manager) and be utilised when a texture file is to be loaded. Instead of the current system of simply loading the same texture again and again, the system will maintain a buffer of textures that have already been loaded (mapped to their file paths via std::map) and simply copy the memory contents of that texture if we try to load it more than once.
This buffering system would work for any game asset (but not files such as profile storage files, since those files could be modified between read attempts) and at the same time, increase game performance on weaker systems (lower memory and disk usage can only be a good thing).
No responses yet