This Shader Program Wrapper enables the user to dynamically edit shaders at runtime. It can be either used for debugging shaders or while presenting the effects of changes to the shader code.
Tested with GLFW and GLAD. Header file might have to be modified to fit your project.
- Initialize the Shader Program Wrapper with a Vertex Shader and a Fragment Shader:
ShaderProgramWrapper spw("shaders/vertex_shader.shader",
"shaders/fragment_shader.shader",
true);
If the last parameter is set to false, the shader files will not be watched.
- Use the underlying Shader Program to render:
spw.UseShaderProgram();
- You can edit the shader files at runtime and changes will apply after saving.
Window, console and fragment shader which is ready to be edited:
Saving with errors in the shader does show them in the console:
Saving without errors in the shader yields the expected results: