I am currently creating a game in SFML using C++ and I'm wondering: what is good practise for a location for textures? Should I store it with my project? Or my executable? Or even in something like the Documents folder? What would be the most efficient when the game would theoretically be released, as it will not simply include the project but rather a compiled and build version of it?


Well you want to store any game assets in a place that people won't usually mess with. Putting them in the documents folder will make it likely that someone comes across them, doesn't recognise them and deletes them.

Storing them in the executable file itself will result in the executable getting extremely large as you add more game assets, this isn't a problem by itself depending on how the OS you're running on handels executable files and memory. But if you ever need to update the game, fix a bug, slightly modify a texture, etc. your users will most likely have to redownload the entire file (which can be massive). Keeping your assets separate should allow you to reuse unchanged parts of the game, reducing download times.

Typically games store their assets with the executable in the installation folder. Usually this is inside ProgramFiles on windows but can be other places depending on how it's distributed (Steams game folder for instance).

How you handle the files is another matter, as long as you know where the assets are you should be able to load them in using their location on the hard drive. This could be a relative location, like saying executable path + Resources + image.png for instance.

The most efficient way to load your data will depend largely on your game and how it uses textures. Are they all on screen at the same time? Then load everything when the level is loaded in. Are your textures larger than what can fit into memory? Then you need to look into texture streaming or make smaller textures. Do you want to load in standard images and parse the data to make it easier to work with or do you really need more speed in which case you can write a program that will parse it into the same memory format that the game will have and then save that binary data so there is slightly less for the engine todo as it loads it.

In the end the most efficient way will change over time as your OS is updated, can vary from platform to platform, and could be different from one machine to another. Best thing is to make something which works well and focus on your game, if it's closer to release and you have loading issues you can always optimize later especially since you will know how the game uses the data and where the bottlenecks are.

Hope this helps

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.