The example code for the shader class is very error-prone to use for users. This is from experience from some of my mates using this as a template for their project. This is because the public interface of the shader class has methods that are meant to be used in private implementations.
E.g. Someone with some knowledge of setting up OpenGL shaders, will know they have to first create the shader before attaching them. As such, they will call the method in this order:
However, the correct use of this is to actually just use the attach method.
The example for the shader class in the README omitted the step to link the shaders
There is a step missing from the example code given for the sample shader class, which is that the user has to call link to link the shaders to the shader program.
Someone, knowing no better, will be confused and trust the example code instead, while trying to fix seemingly non-existing bugs.
Solution
I've cleaned up the public interface of the shader class by moving methods that are meant to be called internally to the private region.
I've updated the README for the shader example so that the step to call link is included.
Testing
[x] I've compiled a simple program that uses the modified shader class and ensured that it works.
Problem
Example shader class interface is error-prone
The example code for the shader class is very error-prone to use for users. This is from experience from some of my mates using this as a template for their project. This is because the public interface of the shader class has methods that are meant to be used in private implementations.
E.g. Someone with some knowledge of setting up OpenGL shaders, will know they have to first create the shader before attaching them. As such, they will call the method in this order:
However, the correct use of this is to actually just use the
attach
method.The example for the shader class in the README omitted the step to link the shaders
There is a step missing from the example code given for the sample shader class, which is that the user has to call
link
to link the shaders to the shader program.Someone, knowing no better, will be confused and trust the example code instead, while trying to fix seemingly non-existing bugs.
Solution
link
is included.Testing