First, we'll use a custom exception class for errors that might occur during compilation or linking:
class GLSLProgramException : public std::runtime_error { public: GLSLProgramException( const string & msg ) : std::runtime_error(msg) { } };
We'll use enum for the various shader types:
namespace GLSLShader { enum GLSLShaderType { VERTEX = GL_VERTEX_SHADER, FRAGMENT = GL_FRAGMENT_SHADER, GEOMETRY = GL_GEOMETRY_SHADER, TESS_CONTROL = GL_TESS_CONTROL_SHADER, TESS_EVALUATION = GL_TESS_EVALUATION_SHADER, COMPUTE = GL_COMPUTE_SHADER }; };
The program class itself has the following interface:
class GLSLProgram { private: int handle; bool linked; std::map<string, int> uniformLocations; GLint getUniformLocation(const char *); // ...