root / trunk / tbeta / Windows / addons / ofxNCore / Copy of src / Filters / ShaderProgram.h @ 139
View | Annotate | Download (993 Bytes)
| 1 | #ifndef SHADERPROGRAM_H_
|
|---|---|
| 2 | #define SHADERPROGRAM_H_
|
| 3 | |
| 4 | #ifdef __APPLE_CC__
|
| 5 | #include "GLee.h" |
| 6 | #include <OpenGL/gl.h> |
| 7 | #include <GLUT/glut.h> |
| 8 | #else
|
| 9 | #include <stdlib.h> //needed to avoid redefinition of exit |
| 10 | #include "GLee.h" |
| 11 | #include <GL/gl.h> |
| 12 | #endif
|
| 13 | |
| 14 | |
| 15 | class ShaderProgram {
|
| 16 | |
| 17 | private:
|
| 18 | GLuint vertex_shader_id; |
| 19 | GLuint geometry_shader_id; |
| 20 | GLuint fragment_shader_id; |
| 21 | GLuint program; |
| 22 | |
| 23 | public:
|
| 24 | ShaderProgram(const char* vertexSourceFile, const char* geometrySourceFile, const char* fragmentSourceFile); //pass NULL or 0 where you want the fixed funtion pipeline |
| 25 | inline void enable(void) { glUseProgram(program); }; |
| 26 | inline void disable(void) { glUseProgram(0); }; |
| 27 | inline void setUniform1f(const char* name, float val){ glUniform1f(glGetUniformLocation(this->program, name), val); }; |
| 28 | inline void setUniform1i(const char* name, int val){ glUniform1i(glGetUniformLocation(this->program, name), val); }; |
| 29 | virtual ~ShaderProgram(); |
| 30 | |
| 31 | }; |
| 32 | |
| 33 | |
| 34 | #endif //SHADERPROGRAM_H_ |
