root / Community Core Vision / Linux / addons / ofxNCore / src / Filters / ShaderProgram.h @ 9
View | Annotate | Download (1.1 KB)
| 1 | /*
|
|---|---|
| 2 | * ShaderProgram.h |
| 3 | * |
| 4 | * |
| 5 | * Created on 2/2/09. |
| 6 | * Copyright 2009 NUI Group. All rights reserved. |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef SHADERPROGRAM_H_
|
| 11 | #define SHADERPROGRAM_H_
|
| 12 | |
| 13 | #ifdef __APPLE_CC__
|
| 14 | #include "GLee.h" |
| 15 | #include <OpenGL/gl.h> |
| 16 | #include <GLUT/glut.h> |
| 17 | #else
|
| 18 | #include <stdlib.h> //needed to avoid redefinition of exit |
| 19 | #include "GLee.h" |
| 20 | #include <GL/gl.h> |
| 21 | #endif
|
| 22 | |
| 23 | |
| 24 | class ShaderProgram {
|
| 25 | |
| 26 | private:
|
| 27 | GLuint vertex_shader_id; |
| 28 | GLuint geometry_shader_id; |
| 29 | GLuint fragment_shader_id; |
| 30 | GLuint program; |
| 31 | |
| 32 | public:
|
| 33 | ShaderProgram(const char* vertexSourceFile, const char* geometrySourceFile, const char* fragmentSourceFile); //pass NULL or 0 where you want the fixed funtion pipeline |
| 34 | inline void enable(void) { glUseProgram(program); }; |
| 35 | inline void disable(void) { glUseProgram(0); }; |
| 36 | inline void setUniform1f(const char* name, float val){ glUniform1f(glGetUniformLocation(this->program, name), val); }; |
| 37 | inline void setUniform1i(const char* name, int val){ glUniform1i(glGetUniformLocation(this->program, name), val); }; |
| 38 | virtual ~ShaderProgram(); |
| 39 | |
| 40 | }; |
| 41 | |
| 42 | |
| 43 | #endif //SHADERPROGRAM_H_ |
