removed const from draw functions

This commit is contained in:
Lauchmelder 2021-12-25 15:01:08 +01:00
parent 1e44994bb4
commit 46e3ec5848
5 changed files with 21 additions and 4 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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
*

View file

@ -3,7 +3,7 @@
namespace lol
{
void Drawable::Draw(const CameraBase& camera) const
void Drawable::Draw(const CameraBase& camera)
{
shader->Bind();
vao->Bind();

View file

@ -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());