0

I'm having a problem with shader code. To use them, I load in the file containing the shader code into main.c and then compiling in the main.c file.

This is good, but the way I have implemented it causes the file to be loaded relative to my working directory. This causes the file to only be loaded when I'm in a specific directory causing the executable to not be able to run anywhere else.

For example:

game/build/bin     
game/obj/main.o    
game/src/shader/shader.vert     
game/src/shader/shader.frag     
game/src/main.c 

This barebones file structure is similar to mine.

The problem is that the binary can only work when running it in the game/ directory.

Is it possible to compile the shaders into the executable so it can be moved to any of directory and still work?

I have tried searching for solutions online but I can't find a solution yet. I have went to the opengl documentation but can't see anything that would work.

Hextav
  • 1
  • 1
  • Is this what you want: [How to embed a file into an executable?](https://stackoverflow.com/questions/7288279/how-to-embed-a-file-into-an-executable)? I should add that it is very common for applications to only work when they are started from the correct working directory. Dlls are usually also searched in the directory of the application. – BDL Jul 21 '23 at 13:17

0 Answers0