/*! * @file shader_data.h * @brief Definition of the Shader rendering class */ #ifndef _SHADER_DATA_H #define _SHADER_DATA_H #include "base_object.h" #include "glincl.h" #include #include "count_pointer.h" // FORWARD DECLARATION //! The ShaderData is a Class-wrapper around the OpenGL Shader Language (GLSL). class ShaderData : public BaseObject { ObjectListDeclaration(ShaderData); //! The Type of Shader. typedef enum { None = 0, //!< No Type at all Fragment = 1, //!< Fragment Shader. Vertex = 2, //!< Vertex Shader. Program = 4, //!< Compiled Shader Programm. } Type; public: typedef CountPointer Pointer; public: ShaderData(); virtual ~ShaderData(); bool load(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = ""); GLhandleARB getProgram() const { return this->shaderProgram; } GLhandleARB getVertexS() const { return this->vertexShader; } GLhandleARB getFragmentS() const { return this->fragmentShader; } void activateShader(); void debug() const; private: void bindShader(const char* name, const float* value, size_t size); void linkShaderProgram(); bool readShader(const std::string& fileName, std::string& output); bool loadShaderProgramm(ShaderData::Type type, const std::string& fileName); void deleteProgram(ShaderData::Type type); static void printError(GLhandleARB program); private: std::string fragmentShaderFile; std::string vertexShaderFile; GLhandleARB shaderProgram; GLhandleARB vertexShader; GLhandleARB fragmentShader; }; #endif /* _SHADER_DATA_H */