When writing a game, you always add some data (images, sounds, …). On Unix like systems I usually install them to ${PREFIX}/share/project/data where ${PREFIX} may be controlled by the build system like CMake or autotools.
In this case, it’s easy to setup the data directory directly with some #define that are automatically generated by the build system.
On Windows I absolutely have no idea how to find the data directory, because applications installer always ask where to install the project, and the code is already compiled it is not possible to control this by some #define.
I have two ideas for this problem:
-
Use a .bat script that starts the binary and add a switch to the data directory. Then user will only starts this .bat file.
-
Generate a new file by the application installer that contains paths to data directory and install it somewhere in the Common App Data folder.
What do you advise me to do?
If you’re targeting win32 exclusively then you should use the Resource Compiler.
It allows you to include arbitrary files in the executable itself, and automatically generates macros with which to refer to them and you can use the win32 API to load them. The User-Defined Resource allows you to store arbitrary blobs in the build.
The drawbacks are that it’s not portable at all and you need to have some moderate Microsoft fu in order to get it to work.