diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-01 23:07:56 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-01 23:07:56 +0200 |
commit | e172cde8c082fa3e338b3eb11079b36952874936 (patch) | |
tree | 90f65a54ce7b6a663ead31496549e0b9338c81d8 /shader.h | |
parent | 3b360c21777aad02394a643b32be2ab25362bba1 (diff) |
Terrain shader lighting - work in progress.
Diffstat (limited to 'shader.h')
-rw-r--r-- | shader.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/shader.h b/shader.h new file mode 100644 index 0000000..70f2361 --- /dev/null +++ b/shader.h @@ -0,0 +1,47 @@ +#ifndef SHADER_H +#define SHADER_H + +#define GL_GLEXT_PROTOTYPES +#include <GL/gl.h> +#include <GL/glu.h> + +class GLBaseShader { + friend class GLShaderProgram; + + protected: + void shader_source(const char *filename); + void shader_source(std::string& filename); + unsigned int shader; + public: + GLBaseShader(GLenum); + ~GLBaseShader(); +}; + +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(); + ~GLShaderProgram(); + + void attach(GLBaseShader&); + void detach(GLBaseShader&); + void link(); + void use(); +}; + +#endif |