#ifndef _SHADER_H_ #define _SHADER_H_ #include #include #define GL_GLEXT_PROTOTYPES #ifndef __APPLE__ #include #include #else #include #include #endif class GLBaseShader { friend class GLShaderProgram; protected: bool shader_source(const char *filename); bool shader_source(std::string& filename); unsigned int shader; public: GLBaseShader(GLenum); }; class GLVertexShader : public GLBaseShader { public: GLVertexShader() : GLBaseShader(GL_VERTEX_SHADER) {}; GLVertexShader(const char *s) : GLBaseShader(GL_VERTEX_SHADER) { shader_source(s); }; GLVertexShader(std::string& s) : GLBaseShader(GL_VERTEX_SHADER) { shader_source(s); }; }; class GLFragmentShader : public GLBaseShader { public: GLFragmentShader() : GLBaseShader(GL_FRAGMENT_SHADER) {}; GLFragmentShader(const char *s) : GLBaseShader(GL_FRAGMENT_SHADER) { shader_source(s); }; GLFragmentShader(std::string& s) : GLBaseShader(GL_FRAGMENT_SHADER) { shader_source(s); }; }; class GLShaderProgram { protected: unsigned int program; public: GLShaderProgram(); bool attach(GLBaseShader&); bool detach(GLBaseShader&); bool link(); bool use(); void remove(); }; void print_ogl_error(GLenum); bool print_check_ogl_error(); #endif