Commit acfd206f authored by Tim Übelhör's avatar Tim Übelhör

added activation of the shader when setting uniforms

parent d1e4fd9b
......@@ -30,109 +30,148 @@ void Shader::set_program_id(GLuint id)
void Shader::setBool(const std::string &name, bool value) const
{
activate();
glUniform1i(glGetUniformLocation(program_id, name.c_str()), (int)value);
deactivate();
}
void Shader::setInt(const std::string &name, int value) const
{
activate();
glUniform1i(glGetUniformLocation(program_id, name.c_str()), value);
deactivate();
}
void Shader::setUInt(const std::string &name, uint32_t value) const
{
activate();
glUniform1ui(glGetUniformLocation(program_id, name.c_str()), value);
deactivate();
}
void Shader::setFloat(const std::string &name, float value) const
{
activate();
glUniform1f(glGetUniformLocation(program_id, name.c_str()), value);
deactivate();
}
void Shader::setVec2(const std::string &name, const glm::vec2 &value) const
{
activate();
glUniform2fv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
deactivate();
}
void Shader::setVec2(const std::string &name, float x, float y) const
{
activate();
glUniform2f(glGetUniformLocation(program_id, name.c_str()), x, y);
deactivate();
}
void Shader::setVec3(const std::string &name, const glm::vec3 &value) const
{
activate();
glUniform3fv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
deactivate();
}
void Shader::setVec3(const std::string &name, float x, float y, float z) const
{
activate();
glUniform3f(glGetUniformLocation(program_id, name.c_str()), x, y, z);
deactivate();
}
void Shader::setVec4(const std::string &name, const glm::vec4 &value) const
{
activate();
glUniform4fv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
deactivate();
}
void Shader::setVec4(const std::string &name, float x, float y, float z,
float w) const
{
activate();
glUniform4f(glGetUniformLocation(program_id, name.c_str()), x, y, z, w);
deactivate();
}
void Shader::setMat2(const std::string &name, const glm::mat2 &mat) const
{
activate();
glUniformMatrix2fv(glGetUniformLocation(program_id, name.c_str()), 1,
GL_FALSE, &mat[0][0]);
deactivate();
}
void Shader::setMat3(const std::string &name, const glm::mat3 &mat) const
{
activate();
glUniformMatrix3fv(glGetUniformLocation(program_id, name.c_str()), 1,
GL_FALSE, &mat[0][0]);
deactivate();
}
void Shader::setMat4(const std::string &name, const glm::mat4 &mat) const
{
activate();
glUniformMatrix4fv(glGetUniformLocation(program_id, name.c_str()), 1,
GL_FALSE, &mat[0][0]);
deactivate();
}
void Shader::setUVec2(const std::string &name, const glm::uvec2 &value) const
{
activate();
glUniform2uiv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
deactivate();
}
void Shader::setUVec3(const std::string &name, const glm::uvec3 &value) const
{
activate();
glUniform3uiv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
deactivate();
}
void Shader::setUVec4(const std::string &name, const glm::uvec4 &value) const
{
activate();
glUniform4uiv(glGetUniformLocation(program_id, name.c_str()), 1, &value[0]);
deactivate();
}
void Shader::setUVec2(const std::string &name, uint32_t x, uint32_t y) const
{
activate();
glUniform2ui(glGetUniformLocation(program_id, name.c_str()), x, y);
deactivate();
}
void Shader::setUVec3(const std::string &name,
uint32_t x, uint32_t y, uint32_t z) const
{
activate();
glUniform3ui(glGetUniformLocation(program_id, name.c_str()), x, y, z);
deactivate();
}
void Shader::setUVec4(const std::string &name,
uint32_t x, uint32_t y, uint32_t z, uint32_t w) const
{
activate();
glUniform4ui(glGetUniformLocation(program_id, name.c_str()), x, y, z, w);
deactivate();
}
void Shader::setFloatArray(
const std::string &name, const float array[], int count) const
{
activate();
glUniform1fv(glGetUniformLocation(program_id, name.c_str()), count, array);
deactivate();
}
} // namespace scigl_render
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment