From 9f92cab6b884711ca8be050b500a2880a955f001 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 23 Jun 2018 15:49:21 +0100 Subject: Switching to east const This is compared to const west, which is not very consistent, as const always acts on what is on its left, and if there isn't anything on the left, it will act on what is on its right. By always placing const on the right of what it should act on, the rule becomes more consistent. --- yage/render/shader.cpp | 12 ++++++------ yage/render/shader.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'yage/render') diff --git a/yage/render/shader.cpp b/yage/render/shader.cpp index e35c5099..b3aca539 100644 --- a/yage/render/shader.cpp +++ b/yage/render/shader.cpp @@ -20,7 +20,7 @@ using std::runtime_error; namespace yage { -Shader::Shader(const std::string &vertex_path, const std::string &fragment_path) +Shader::Shader(std::string const &vertex_path, std::string const &fragment_path) { std::string vertex_source, fragment_source; std::ifstream vertex_file, fragment_file; @@ -85,22 +85,22 @@ void Shader::use() const glUseProgram(program_id_); } -void Shader::setUniform(const std::string &name, int value) const +void Shader::setUniform(std::string const &name, int value) const { glUniform1i(getUniformLocation(name), static_cast(value)); } -void Shader::setUniform(const std::string &name, float value) const +void Shader::setUniform(std::string const &name, float value) const { glUniform1f(getUniformLocation(name), static_cast(value)); } -void Shader::setUniform(const std::string &name, const glm::mat4 &matrix) const +void Shader::setUniform(std::string const &name, const glm::mat4 &matrix) const { glUniformMatrix4fv(getUniformLocation(name), 1, GL_FALSE, &(matrix[0][0])); } -GLint Shader::getUniformLocation(const std::string &uniform_name) const +GLint Shader::getUniformLocation(std::string const &uniform_name) const { GLuint location = glGetUniformLocation(program_id_, uniform_name.c_str()); if (location == GL_INVALID_INDEX) { @@ -109,7 +109,7 @@ GLint Shader::getUniformLocation(const std::string &uniform_name) const return location; } -void Shader::errorCheck(GLuint shader, const std::string &shader_type) const +void Shader::errorCheck(GLuint shader, std::string const &shader_type) const { int success; char info_log[1024]; diff --git a/yage/render/shader.h b/yage/render/shader.h index d91753cb..75a24c6d 100644 --- a/yage/render/shader.h +++ b/yage/render/shader.h @@ -20,7 +20,7 @@ namespace yage class Shader { public: - Shader(const std::string &vertex_path, const std::string &fragment_path); + Shader(std::string const &vertex_path, std::string const &fragment_path); Shader(const Shader &) = delete; Shader(Shader &&) = delete; ~Shader(); @@ -32,16 +32,16 @@ public: void use() const; /// set uniforms of different type - void setUniform(const std::string &name, int value) const; - void setUniform(const std::string &name, float value) const; - void setUniform(const std::string &name, const glm::mat4 &matrix) const; + void setUniform(std::string const &name, int value) const; + void setUniform(std::string const &name, float value) const; + void setUniform(std::string const &name, const glm::mat4 &matrix) const; private: /// compiled shader program id GLuint program_id_ = 0; - GLint getUniformLocation(const std::string &uniform_name) const; - void errorCheck(GLuint shader, const std::string &shader_type) const; + GLint getUniformLocation(std::string const &uniform_name) const; + void errorCheck(GLuint shader, std::string const &shader_type) const; }; } // namespace yage -- cgit