Skip to content
Snippets Groups Projects
Commit e646c7cb authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

remove old shader class

parent 37d5c8b6
No related branches found
No related tags found
No related merge requests found
......@@ -6,73 +6,11 @@
#include <stdexcept>
/**
* FGGL OpenGL 4.x rendering backend.
*/
namespace fggl::gfx {
class Shader {
public:
Shader();
~Shader();
inline void use() const {
glUseProgram(m_handle);
}
inline GLuint uniform(const std::string &name) {
GLint loc = glGetUniformLocation(m_handle, name.c_str());
if (loc == -1) {
throw std::runtime_error("invalid shader uniform");
}
return loc;
}
inline void setInt(const std::string &name, const GLint value) {
setInt(uniform(name), value);
}
inline void setInt(GLuint idx, const GLint value) {
glUniform1i(idx, value);
}
inline void setFloat(const std::string &name, const GLfloat value) {
setFloat(uniform(name), value);
}
inline void setFloat(GLuint idx, const GLfloat value) {
glUniform1f(idx, value);
}
inline void setVec2(const std::string &name, const GLfloat *vec) {
setVec2(uniform(name), vec);
}
inline void setVec2(GLuint idx, const GLfloat *vec) {
glUniform2f(idx, vec[0], vec[1]);
}
inline void setVec3(const std::string &name, const GLfloat *vec) {
setVec3(uniform(name), vec);
}
inline void setVec3(GLuint idx, const GLfloat *vec) {
glUniform3f(idx, vec[0], vec[1], vec[2]);
}
inline void setMat4(const std::string &name, const GLfloat *mat) {
setMat4(uniform(name), mat);
}
inline void setMat4(GLuint idx, const GLfloat *mat) {
glUniformMatrix4fv(idx, 1, GL_FALSE, mat);
}
private:
int m_handle;
};
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment