diff --git a/include/lol/Camera.hpp b/include/lol/Camera.hpp index 830298b..fe8aba8 100644 --- a/include/lol/Camera.hpp +++ b/include/lol/Camera.hpp @@ -54,7 +54,7 @@ namespace lol * * @param drawable A Drawable that should be rendered through this camera */ - inline void Draw(const Drawable& drawable) const + inline void Draw(Drawable& drawable) const { drawable.Draw(*this); } diff --git a/include/lol/Drawable.hpp b/include/lol/Drawable.hpp index 9b9ea33..ef70106 100644 --- a/include/lol/Drawable.hpp +++ b/include/lol/Drawable.hpp @@ -23,14 +23,14 @@ namespace lol * * @param camera The camera with which this object is rendered. */ - virtual void PreRender(const CameraBase& camera) const { }; + virtual void PreRender(const CameraBase& camera) { }; /** * @brief Bind the shader and draw the VAO * * @param camera The camera with which this object is rendered. */ - void Draw(const CameraBase& camera) const; + void Draw(const CameraBase& camera); /** * @brief The VAO can be rendered as a mesh, a set of lines, loops, strips etc diff --git a/include/lol/Shader.hpp b/include/lol/Shader.hpp index 04e06f5..16a5e02 100644 --- a/include/lol/Shader.hpp +++ b/include/lol/Shader.hpp @@ -39,6 +39,14 @@ namespace lol void Bind(); void Unbind(); + /** + * Set a float uniform + * + * @param name Name of the uniform + * @param value Value of the uniform + */ + void SetUniform(const std::string& name, float value); + /** * Set a 4x4 matrix uniform * diff --git a/src/Drawable.cpp b/src/Drawable.cpp index e4dc50c..efa29c2 100644 --- a/src/Drawable.cpp +++ b/src/Drawable.cpp @@ -3,7 +3,7 @@ namespace lol { - void Drawable::Draw(const CameraBase& camera) const + void Drawable::Draw(const CameraBase& camera) { shader->Bind(); vao->Bind(); diff --git a/src/Shader.cpp b/src/Shader.cpp index 4340c84..df51bb8 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -86,6 +86,15 @@ namespace lol glUseProgram(0); } + void Shader::SetUniform(const std::string& name, float value) + { + GLint location = glGetUniformLocation(id, name.c_str()); + if (location == -1) + return; + + glUniform1f(location, value); + } + void Shader::SetUniform(const std::string& name, const glm::mat4& value) { GLint location = glGetUniformLocation(id, name.c_str());