OpenGL-Examples icon indicating copy to clipboard operation
OpenGL-Examples copied to clipboard

Define the base assets path using CMake.

Open 3a2l opened this issue 4 years ago • 2 comments

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

3a2l avatar Nov 04 '20 11:11 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.

yahiaetman avatar Nov 06 '20 15:11 yahiaetman

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.

3a2l avatar Nov 07 '20 20:11 3a2l