| [4838] | 1 | /*! |
|---|
| [9806] | 2 | * @file shader_data.h |
|---|
| [5261] | 3 | * @brief Definition of the Shader rendering class |
|---|
| [3245] | 4 | */ |
|---|
| [1853] | 5 | |
|---|
| [9806] | 6 | #ifndef _SHADER_DATA_H |
|---|
| 7 | #define _SHADER_DATA_H |
|---|
| [1853] | 8 | |
|---|
| [3543] | 9 | #include "base_object.h" |
|---|
| [9806] | 10 | |
|---|
| [9818] | 11 | #include "glincl.h" |
|---|
| [7164] | 12 | #include <vector> |
|---|
| [9818] | 13 | #include "count_pointer.h" |
|---|
| [1853] | 14 | |
|---|
| [8037] | 15 | // FORWARD DECLARATION |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| [9806] | 19 | //! The ShaderData is a Class-wrapper around the OpenGL Shader Language (GLSL). |
|---|
| 20 | class ShaderData : public BaseObject |
|---|
| [5261] | 21 | { |
|---|
| [9806] | 22 | ObjectListDeclaration(ShaderData); |
|---|
| [9818] | 23 | //! The Type of Shader. |
|---|
| 24 | typedef enum { |
|---|
| 25 | None = 0, //!< No Type at all |
|---|
| 26 | Fragment = 1, //!< Fragment Shader. |
|---|
| 27 | Vertex = 2, //!< Vertex Shader. |
|---|
| 28 | Program = 4, //!< Compiled Shader Programm. |
|---|
| 29 | } Type; |
|---|
| 30 | |
|---|
| 31 | public: |
|---|
| 32 | typedef CountPointer<ShaderData> Pointer; |
|---|
| [8037] | 33 | public: |
|---|
| [9818] | 34 | ShaderData(); |
|---|
| [9806] | 35 | virtual ~ShaderData(); |
|---|
| [5261] | 36 | |
|---|
| [9818] | 37 | bool load(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = ""); |
|---|
| [5261] | 38 | |
|---|
| [9818] | 39 | |
|---|
| [9806] | 40 | GLhandleARB getProgram() const { return this->shaderProgram; } |
|---|
| 41 | GLhandleARB getVertexS() const { return this->vertexShader; } |
|---|
| 42 | GLhandleARB getFragmentS() const { return this->fragmentShader; } |
|---|
| [3543] | 43 | |
|---|
| [9806] | 44 | void activateShader(); |
|---|
| [3543] | 45 | |
|---|
| [9806] | 46 | void debug() const; |
|---|
| 47 | private: |
|---|
| [8255] | 48 | void bindShader(const char* name, const float* value, size_t size); |
|---|
| [9806] | 49 | void linkShaderProgram(); |
|---|
| 50 | bool readShader(const std::string& fileName, std::string& output); |
|---|
| [9818] | 51 | bool loadShaderProgramm(ShaderData::Type type, const std::string& fileName); |
|---|
| 52 | void deleteProgram(ShaderData::Type type); |
|---|
| [5317] | 53 | |
|---|
| [9818] | 54 | static void printError(GLhandleARB program); |
|---|
| 55 | |
|---|
| [8037] | 56 | private: |
|---|
| [9818] | 57 | |
|---|
| [8037] | 58 | std::string fragmentShaderFile; |
|---|
| 59 | std::string vertexShaderFile; |
|---|
| 60 | |
|---|
| 61 | GLhandleARB shaderProgram; |
|---|
| 62 | |
|---|
| 63 | GLhandleARB vertexShader; |
|---|
| 64 | GLhandleARB fragmentShader; |
|---|
| [1853] | 65 | }; |
|---|
| 66 | |
|---|
| [9806] | 67 | #endif /* _SHADER_DATA_H */ |
|---|