diff --git a/src/libprojectM/Renderer/Shader.cpp b/src/libprojectM/Renderer/Shader.cpp index b5ddfff89..69deb516c 100644 --- a/src/libprojectM/Renderer/Shader.cpp +++ b/src/libprojectM/Renderer/Shader.cpp @@ -109,6 +109,16 @@ void Shader::SetUniformFloat2(const char* uniform, const glm::vec2& values) cons glUniform2fv(location, 1, glm::value_ptr(values)); } +void Shader::SetUniformInt2(const char* uniform, const glm::ivec2& values) const +{ + auto location = glGetUniformLocation(m_shaderProgram, uniform); + if (location < 0) + { + return; + } + glUniform2iv(location, 1, glm::value_ptr(values)); +} + void Shader::SetUniformFloat3(const char* uniform, const glm::vec3& values) const { auto location = glGetUniformLocation(m_shaderProgram, uniform); @@ -119,6 +129,16 @@ void Shader::SetUniformFloat3(const char* uniform, const glm::vec3& values) cons glUniform3fv(location, 1, glm::value_ptr(values)); } +void Shader::SetUniformInt3(const char* uniform, const glm::ivec3& values) const +{ + auto location = glGetUniformLocation(m_shaderProgram, uniform); + if (location < 0) + { + return; + } + glUniform3iv(location, 1, glm::value_ptr(values)); +} + void Shader::SetUniformFloat4(const char* uniform, const glm::vec4& values) const { auto location = glGetUniformLocation(m_shaderProgram, uniform); @@ -129,6 +149,16 @@ void Shader::SetUniformFloat4(const char* uniform, const glm::vec4& values) cons glUniform4fv(location, 1, glm::value_ptr(values)); } +void Shader::SetUniformInt4(const char* uniform, const glm::ivec4& values) const +{ + auto location = glGetUniformLocation(m_shaderProgram, uniform); + if (location < 0) + { + return; + } + glUniform4iv(location, 1, glm::value_ptr(values)); +} + void Shader::SetUniformMat3x4(const char* uniform, const glm::mat3x4& values) const { auto location = glGetUniformLocation(m_shaderProgram, uniform); @@ -202,4 +232,4 @@ auto Shader::GetShaderLanguageVersion() -> Shader::GlslVersion int versionMinor = std::stoi(shaderLanguageVersionString.substr(dotPos + 1)); return {versionMajor, versionMinor}; -} +} \ No newline at end of file diff --git a/src/libprojectM/Renderer/Shader.hpp b/src/libprojectM/Renderer/Shader.hpp index 338b57da9..56b6b2820 100644 --- a/src/libprojectM/Renderer/Shader.hpp +++ b/src/libprojectM/Renderer/Shader.hpp @@ -112,6 +112,14 @@ public: */ void SetUniformFloat2(const char* uniform, const glm::vec2& values) const; + /** + * @brief Sets an int vec2 uniform. + * The program must be bound before calling this method! + * @param uniform The uniform name + * @param values The values to set. + */ + void SetUniformInt2(const char* uniform, const glm::ivec2& values) const; + /** * @brief Sets a float vec3 uniform. * The program must be bound before calling this method! @@ -120,6 +128,14 @@ public: */ void SetUniformFloat3(const char* uniform, const glm::vec3& values) const; + /** + * @brief Sets an int vec3 uniform. + * The program must be bound before calling this method! + * @param uniform The uniform name + * @param values The values to set. + */ + void SetUniformInt3(const char* uniform, const glm::ivec3& values) const; + /** * @brief Sets a float vec4 uniform. * The program must be bound before calling this method! @@ -128,6 +144,14 @@ public: */ void SetUniformFloat4(const char* uniform, const glm::vec4& values) const; + /** + * @brief Sets an int vec4 uniform. + * The program must be bound before calling this method! + * @param uniform The uniform name + * @param values The values to set. + */ + void SetUniformInt4(const char* uniform, const glm::ivec4& values) const; + /** * @brief Sets a float 3x4 matrix uniform. * The program must be bound before calling this method!