diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-16 21:44:32 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-16 21:44:32 +0200 |
commit | a524cfdd2756ac945040ca9bed576fb2f68f8c9f (patch) | |
tree | 000874591e87ae5ce7f162214337b49bc1ba0e0b /shader.h |
Imported project.
Diffstat (limited to 'shader.h')
-rw-r--r-- | shader.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/shader.h b/shader.h new file mode 100644 index 0000000..d2ec9d4 --- /dev/null +++ b/shader.h @@ -0,0 +1,51 @@ +#ifndef _SHADER_H_ +#define _SHADER_H_ + +#include <iostream> +#include <string> +#define GL_GLEXT_PROTOTYPES +#include <GL/gl.h> +#include <GL/glu.h> + +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 |