[9806] | 1 | |
---|
| 2 | |
---|
| 3 | #ifndef _SHADER_TYPES_H |
---|
| 4 | #define _SHADER_TYPES_H |
---|
| 5 | |
---|
| 6 | #include "glincl.h" |
---|
| 7 | |
---|
| 8 | namespace Shaders |
---|
| 9 | { |
---|
| 10 | class Uniform |
---|
| 11 | { |
---|
| 12 | public: |
---|
| 13 | Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; } |
---|
| 14 | Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; }; |
---|
| 15 | Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; }; |
---|
| 16 | |
---|
| 17 | void set(float v0) const { glUniform1f(this->uniform, v0); } |
---|
| 18 | void set(float v0, float v1) const { glUniform2f(this->uniform, v0, v1); } |
---|
| 19 | void set(float v0, float v1, float v2) const { glUniform3f(this->uniform, v0, v1, v2); } |
---|
| 20 | void set(float v0, float v1, float v2, float v3) const { glUniform4f(this->uniform, v0, v1, v2, v3); } |
---|
| 21 | |
---|
| 22 | void set(int v0) const { glUniform1i(this->uniform, v0); } |
---|
| 23 | void set(int v0, int v1) const { glUniform2i(this->uniform, v0, v1); } |
---|
| 24 | void set(int v0, int v1, int v2) const { glUniform3i(this->uniform, v0, v1, v2); } |
---|
| 25 | void set(int v0, int v1, int v2, int v3) const { glUniform4i(this->uniform, v0, v1, v2, v3); } |
---|
| 26 | |
---|
| 27 | void setV(unsigned int count, float* vv) const; |
---|
| 28 | void setV(unsigned int count, int* vv) const; |
---|
| 29 | |
---|
| 30 | private: |
---|
| 31 | GLint uniform; |
---|
| 32 | }; |
---|
| 33 | |
---|
| 34 | //! The Type of Shader. |
---|
| 35 | typedef enum |
---|
| 36 | { |
---|
| 37 | None = 0, //!< No Type at all |
---|
| 38 | Fragment = 1, //!< Fragment Shader. |
---|
| 39 | Vertex = 2, //!< Vertex Shader. |
---|
| 40 | Program = 4, //!< Compiled Shader Programm. |
---|
| 41 | } Type; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | #endif /* _SHADER_TYPES_H */ |
---|