1
0
Fork 0
spectre/source/GfxDriver/OpenGL/OpenGLShaderProgram.h

70 lines
1.6 KiB
C++

#ifndef SPECTRE_GFXDRIVER_OPENGL_OPENGLSHADERPROGRAM_H
#define SPECTRE_GFXDRIVER_OPENGL_OPENGLSHADERPROGRAM_H
#include <Graphics/GL/gl.h>
#include <Spectre/GfxDriver/ShaderProgram.h>
namespace sp {
class OpenGLShaderProgram : public ShaderProgram
{
public:
OpenGLShaderProgram();
virtual ~OpenGLShaderProgram();
// Load a shader from memory.
virtual bool loadFromMemory(const std::string& source, ShaderType type);
// Link the program.
virtual bool link();
// Enable this shader
// All shader operations after this call will affect this shader.
virtual void enable() const;
// Disable this shader
// Operations will no longer affect this shader after this call.
virtual void disable() const;
// ---------------------
// Variables.
// ---------------------
virtual bool setMVPMatrix(const Matrix4f& matrix);
// ---------------------
// General Variables.
// ---------------------
virtual bool setAttribute(const std::string& name, float value) const;
virtual bool setAttribute(const std::string& name, const Matrix4f& matrix) const;
virtual bool setUniform(const std::string& name, const Matrix4f& matrix) const;
virtual bool setUniform(const std::string& name, const Color& color) const;
protected :
// Compile a shader.
bool compileShader(GLuint id);
// Attach shader to program.
bool attachShader(GLuint id);
bool getAttribLoc(const std::string& name, int& loc) const;
bool getUniformLoc(const std::string& name, int& loc) const;
std::string fetchErrorLog() const;
protected :
// Program ID
GLuint m_id;
};
} // namespace sp
#endif /* SPECTRE_GFXDRIVER_OPENGL_OPENGLSHADERPROGRAM_H */