Understanding Inline Resources

Tonight I decided to work on fixing an issue with file paths. The other day I realised that hard coding relative paths had a downside, in that there is no flexibility for if the Game.lua for example is within the same path, in a subdirectory, or somewhere else.

So tonight I added a new part of the boot sequence that searches for Game.lua in several commonly known locations. It then sets the base path for all other assets on the Game.lua files location, or exits with an error telling the user what went wrong.

This is really useful, as now when I compile the game in either MSVCC or GCC, I can debug without changing the relative path prefixes, and yet when the binaries are ever published, the paths will just adjust to their environment.


So one thing I wanted to research tonight was how to include resource files in the engine. In C# I am used to just defining them in the solution properties using Visual Studio, but C++ seems an entirely different kettle of fish.

After doing some digging, I discovered that there are a few solutions out there, but most are OS specific. I think I’ve found what I need though in a project called incbin. This utility allows you to write a macro to turn non-code files into variables on build. So say I want a .lua file to be included as a char array, I’d add the macro, and at runtime a variable would become available that allows me to access the data embedded in the exe

Here is a link to the project: https://github.com/graphitemaster/incbin