OpenGL-Examples
OpenGL-Examples copied to clipboard
Define the base assets path using CMake.
Hi Yahia,
This fixes a bug where the examples will fail to load or run because the paths to assets (shaders, models, etc.) are using relative paths.
I defined a base ASSETS_DIR
using CMake (for all projects) and concatenated that with the existing strings (minus the "assets" part).
I tested a few examples and they seem to work now.
3a2l
That's a really good idea. The only problem with this approach is that the absolute path will be hardcoded and thus it can't be packaged as a portable application after build. Though this shouldn't be a problem if the code is meant for educational purposes only, I still want to keep an option for it to be built and packaged (since this will be used as a reference for a course project). I think I'll add an option to CMake to control whether the path should be absolute or relative.
Could perhaps add an option for reading an environment variable ASSETS_PATH
(or something similar). So the behaviour becomes:
- Read environment variable, if defined, use it.
- If not defined, fall back to the compile time definition (to be controlled during compilation with the CMake script).
I'm fine with implementing this if you like this approach.