20 #include "AttributeSet.h"
49 ShaderBase(
const std::string& vertexShaderCode,
const std::string& fragmentShaderCode,
50 const AttributeSetPtr& attributes,
const std::vector<std::string>& uniformNames);
54 virtual bool isValid()
const override;
61 virtual void begin()
override;
62 virtual void end()
override;
70 virtual void compile()
override;
93 bool mCurrentShader =
false;
95 bool mCompiled =
false;
96 bool mProgramCreated =
false;
97 GLuint mProgramId = 0;
98 bool mVertexShaderCreated =
false;
99 GLuint mVertexShaderId = 0;
100 bool mFragmentShaderCreated =
false;
101 GLuint mFragmentShaderId = 0;
102 std::string mVertexShaderCode;
103 std::string mFragmentShaderCode;
104 std::vector<int> mAttributeLocations;
105 std::vector<int> mUniformLocations;
108 #endif // SHADERBASE_H
virtual void begin() override
Binds this shader, compiling if necessary.
virtual void compile() override
Compiles this Shader's GLSL code and links it into a GL program.
void dispose()
Destroys GL resources that were allocated for this ShaderBase.
Header declaring and including types common to renderer classes such as Vector2. Also includes GL hea...
virtual void performCompile()
Compiles and initializes the GL shader program from shader code.
Implementation of Shader which compiles itself from shader code.
Definition: ShaderBase.h:37
virtual GLuint getProgramId() const override
Returns the GL program id for this shader.
Shader program abstract base class.
Definition: Shader.h:47
std::shared_ptr< AttributeSet > AttributeSetPtr
Shared pointer typedef for AttributeSet.
Definition: PointerDeclarations.h:63
virtual void end() override
Unbinds this shader if bound by a corresponding call to begin().
virtual int getUniformLocation(int index) const override
Returns the location of an indexed uniform.
virtual bool isValid() const override
Returns whether or not this shader is valid (compiled and linked) and can be used for rendering...
virtual int getAttributeLocation(int index) const override
Returns the location of an indexed Attribute.
ShaderBase(const std::string &vertexShaderCode, const std::string &fragmentShaderCode, const AttributeSetPtr &attributes, const std::vector< std::string > &uniformNames)
Constructs a ShaderBase with the given code for its vertex and fragment shader.
virtual bool isCurrent() const override
Returns whether or not this shader is bound.
virtual std::string getErrorLog() const override
Retrieves the string describing compilation errors, if the call to compile() failed and isValid() is ...
virtual bool isCompiled() const override
Returns whether or not this shader has been processed for compilation.