Proper way of handling multiple shaders

I have an application with multiple shaders, that right now I am loading from files (ie basic.vs basic.fs). I was wondering what is the best way to handle shaders. External files or embedded in the source code? I’m trying to use CMake to compile my app, and I don’t want to include the shaders in the same folder as the executable. Do I have to tell CMake where the sahders are? Is there a way to load the shaders code from file on c++ compilation?

Best depends on your needs. You can do any of what you describe. You can also cache off precompiled shader binaries so that further runs on the same GPU/driver are fast.

CMake is an ancillary issue not directly related to your question.

[QUOTE=Dark Photon;1255985]Best depends on your needs. You can do any of what you describe. You can also cache off precompiled shader binaries so that further runs on the same GPU/driver are fast.

CMake is an ancillary issue not directly related to your question.[/QUOTE]

Thanks for the answer.

I’m interested in what you said about caching precompiled shader binaries, could you elaborate more?

In OpenGL 4, you can use glGetProgramBinary to retrieve the object code for a program, and glProgramBinary to create a program from object code.

I found GLSW, a OpenGL shader wrangler. It helped me a lot of organize the shaders when they got a little more complex.

Thanks for all the answers! GLSW looks sweet, decissions, decissions…