//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011, Computer Graphics Group RWTH Aachen University // // All rights reserved. // //////////////////////////////////////////////////////////////////////////////// #ifndef ACGL_OPENGL_OBJECTS_SHADER_HH #define ACGL_OPENGL_OBJECTS_SHADER_HH #include #include #include #include #include #include namespace ACGL{ namespace OpenGL{ class Shader { ACGL_NOT_COPYABLE(Shader) // ===================================================================================================== \/ // ============================================================================================ TYPEDEFS \/ // ===================================================================================================== \/ public: typedef std::vector AttributeVec; typedef std::vector FragmentDataVec; // ========================================================================================================= \/ // ============================================================================================ CONSTRUCTORS \/ // ========================================================================================================= \/ public: Shader(GLenum _type) : mContext(0), mType(_type) { mContext = glCreateShader(mType); } virtual ~Shader(void) { // "DeleteShader will silently ignore the value zero." - GL Spec glDeleteShader(mContext); } // ==================================================================================================== \/ // ============================================================================================ GETTERS \/ // ==================================================================================================== \/ public: inline GLuint getContext (void) const { return mContext; } inline GLenum getType (void) const { return mType; } inline const std::vector& getAttributes() const { return mAttributes; } inline const std::vector& getFragmentData() const { return mFragmentData; } // ==================================================================================================== \/ // ============================================================================================ METHODS \/ // ==================================================================================================== \/ public: bool setFromFile (const std::string &_filename); bool setSource (const std::string &_source ); protected: bool compile (const char *_pProgramText) const; // =================================================================================================== \/ // ============================================================================================ FIELDS \/ // =================================================================================================== \/ protected: GLuint mContext; GLenum mType; AttributeVec mAttributes; FragmentDataVec mFragmentData; }; ACGL_SHARED_TYPEDEF(Shader) } // OpenGL } // ACGL #endif // ACGL_OPENGL_OBJECTS_SHADER_HH