The Shader class contains only the Shader part. It creates a shader and
compiles it.
A template is present to simplify the construction of a shader.
Shader::Vertex(code);
The Programm class builds a program, attach shaders, and link them.
Then, it detaches the shaders.
Program is built with a list of Shader as a parameter:
new Shader::Program({
Shader::Vertex(code_vertex),
Shader::Fragment(code_fragment)
});
Both Shader and Program cannot be copied (to avoid use after free), but
they implement move semantics (thus allowing the construction above).
They have been but in a namespace since they are all related to shaders,
and to avoid duplicating the name Shader everywhere in the class names.
The Program also has a cache of the uniforma locations to avoid calling glGetUniformLocation function.
The Shader class contains only the Shader part. It creates a shader and compiles it. A template is present to simplify the construction of a shader.
The Programm class builds a program, attach shaders, and link them. Then, it detaches the shaders. Program is built with a list of Shader as a parameter:
Both Shader and Program cannot be copied (to avoid use after free), but they implement move semantics (thus allowing the construction above).
They have been but in a namespace since they are all related to shaders, and to avoid duplicating the name Shader everywhere in the class names.
The Program also has a cache of the uniforma locations to avoid calling glGetUniformLocation function.