From 596f7a841b562063d41c1039c9b017b79379e53b Mon Sep 17 00:00:00 2001 From: jmacey Date: Mon, 22 May 2023 20:02:52 +0100 Subject: [PATCH] started to add return flag to the set uniform methods to make checking easier. Also added tests for array uniform types as last errors didn't spot this when using the light demo and edit shaders --- include/ngl/ShaderLib.h | 22 +++++------ include/ngl/ShaderProgram.h | 16 ++++---- src/ShaderLib.cpp | 59 +++++++++++++++++------------- src/ShaderProgram.cpp | 45 +++++++++++++++++++---- tests/ShaderLibTests.cpp | 38 ++++++++++++++----- tests/files/testUniformVertex.glsl | 6 ++- 6 files changed, 123 insertions(+), 63 deletions(-) diff --git a/include/ngl/ShaderLib.h b/include/ngl/ShaderLib.h index 9ad09506..77d95bc8 100644 --- a/include/ngl/ShaderLib.h +++ b/include/ngl/ShaderLib.h @@ -243,8 +243,8 @@ class NGL_DLLEXPORT ShaderLib /// @param[in] _paramName the name of the Uniform to set /// @param[in] _v0 the float value of the parameter to set //---------------------------------------------------------------------------------------------------------------------- - static void setUniform(std::string_view _paramName, Real _v0) noexcept; - static void getUniform(std::string_view _paramName, Real &o_v0) noexcept; + static bool setUniform(std::string_view _paramName, Real _v0) noexcept; + static bool getUniform(std::string_view _paramName, Real &o_v0) noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief overloaded method to set shader Uniforms the shader /// must be the currently active shader of else this will fail @@ -252,9 +252,9 @@ class NGL_DLLEXPORT ShaderLib /// @param[in] _v0 the float value of the parameter to set /// @param[in] _v1 the float value of the parameter to set //---------------------------------------------------------------------------------------------------------------------- - static void setUniform(std::string_view _paramName, Real _v0, Real _v1) noexcept; - static void getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1) noexcept; - static void getUniform(std::string_view _paramName, Vec2 &o_v3) noexcept; + static bool setUniform(std::string_view _paramName, Real _v0, Real _v1) noexcept; + static bool getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1) noexcept; + static bool getUniform(std::string_view _paramName, Vec2 &o_v3) noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief overloaded method to set shader Uniforms the shader /// must be the currently active shader of else this will fail @@ -263,9 +263,9 @@ class NGL_DLLEXPORT ShaderLib /// @param[in] _v1 the float value of the parameter to set /// @param[in] _v2 the float value of the parameter to set //---------------------------------------------------------------------------------------------------------------------- - static void setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2) noexcept; - static void getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2) noexcept; - static void getUniform(std::string_view _paramName, Vec3 &o_v) noexcept; + static bool setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2) noexcept; + static bool getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2) noexcept; + static bool getUniform(std::string_view _paramName, Vec3 &o_v) noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief overloaded method to set shader Uniforms the shader /// must be the currently active shader of else this will fail @@ -275,9 +275,9 @@ class NGL_DLLEXPORT ShaderLib /// @param[in] _v2 the float value of the parameter to set /// @param[in] _v3 the float value of the parameter to set //---------------------------------------------------------------------------------------------------------------------- - static void setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2, Real _v3) noexcept; - static void getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2, Real &o_v3) noexcept; - static void getUniform(std::string_view _paramName, Vec4 &o_v) noexcept; + static bool setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2, Real _v3) noexcept; + static bool getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2, Real &o_v3) noexcept; + static bool getUniform(std::string_view _paramName, Vec4 &o_v) noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief overloaded method to set shader Uniforms the shader /// must be the currently active shader of else this will fail diff --git a/include/ngl/ShaderProgram.h b/include/ngl/ShaderProgram.h index e653340c..45f5641d 100644 --- a/include/ngl/ShaderProgram.h +++ b/include/ngl/ShaderProgram.h @@ -125,8 +125,8 @@ class NGL_DLLEXPORT ShaderProgram /// @param _varname - name of the uniform variable /// @param _v0 - new value for the variable //---------------------------------------------------------------------------------------------------------------------- - void setRegisteredUniform1f(std::string_view _varname, float _v0) const noexcept; - void getRegisteredUniform1f(std::string_view _varname, float &o_v0) const noexcept; + bool setRegisteredUniform1f(std::string_view _varname, float _v0) const noexcept; + bool getRegisteredUniform1f(std::string_view _varname, float &o_v0) const noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief sets the registered uniform to a single float @@ -134,8 +134,8 @@ class NGL_DLLEXPORT ShaderProgram /// @param _v0 - new value for the variable /// @param _v1 - new value for the variable //---------------------------------------------------------------------------------------------------------------------- - void setRegisteredUniform2f(std::string_view _varname, float _v0, float _v1) const noexcept; - void getRegisteredUniform2f(std::string_view _varname, float &o_v0, float &o_v1) const noexcept; + bool setRegisteredUniform2f(std::string_view _varname, float _v0, float _v1) const noexcept; + bool getRegisteredUniform2f(std::string_view _varname, float &o_v0, float &o_v1) const noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief sets the registered uniform to a single float @@ -144,8 +144,8 @@ class NGL_DLLEXPORT ShaderProgram /// @param _v1 - new value for the variable /// @param _v2 - new value for the variable //---------------------------------------------------------------------------------------------------------------------- - void setRegisteredUniform3f(std::string_view _varname, float _v0, float _v1, float _v2) const noexcept; - void getRegisteredUniform3f(std::string_view _varname, float &_v0, float &_v1, float &_v2) const noexcept; + bool setRegisteredUniform3f(std::string_view _varname, float _v0, float _v1, float _v2) const noexcept; + bool getRegisteredUniform3f(std::string_view _varname, float &_v0, float &_v1, float &_v2) const noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief sets the registered uniform to a single float /// @param _varname - name of the uniform variable @@ -154,8 +154,8 @@ class NGL_DLLEXPORT ShaderProgram /// @param _v2 - new value for the variable /// @param _v3 - new value for the variable /////---------------------------------------------------------------------------------------------------------------------- - void setRegisteredUniform4f(std::string_view _varname, float _v0, float _v1, float _v2, float _v3) const noexcept; - void getRegisteredUniform4f(std::string_view _varname, float &_v0, float &_v1, float &_v2, float &o_v3) const noexcept; + bool setRegisteredUniform4f(std::string_view _varname, float _v0, float _v1, float _v2, float _v3) const noexcept; + bool getRegisteredUniform4f(std::string_view _varname, float &_v0, float &_v1, float &_v2, float &o_v3) const noexcept; //---------------------------------------------------------------------------------------------------------------------- /// @brief sets the registered uniform to a single int /// @param _varname - name of the uniform variable diff --git a/src/ShaderLib.cpp b/src/ShaderLib.cpp index c41defee..56c18ae4 100644 --- a/src/ShaderLib.cpp +++ b/src/ShaderLib.cpp @@ -818,65 +818,74 @@ void ShaderLib::printProperties() noexcept } } -void ShaderLib::setUniform(std::string_view _paramName, Real _v0) noexcept +bool ShaderLib::setUniform(std::string_view _paramName, Real _v0) noexcept { - m_shaderPrograms[m_currentShader]->setRegisteredUniform1f(_paramName.data(), _v0); + return m_shaderPrograms[m_currentShader]->setRegisteredUniform1f(_paramName.data(), _v0); } -void ShaderLib::getUniform(std::string_view _paramName, Real &o_v0) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, Real &o_v0) noexcept { - m_shaderPrograms[m_currentShader]->getRegisteredUniform1f(_paramName.data(), o_v0); + return m_shaderPrograms[m_currentShader]->getRegisteredUniform1f(_paramName.data(), o_v0); } -void ShaderLib::getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1) noexcept { - m_shaderPrograms[m_currentShader]->getRegisteredUniform2f(_paramName.data(), o_v0, o_v1); + return m_shaderPrograms[m_currentShader]->getRegisteredUniform2f(_paramName.data(), o_v0, o_v1); } -void ShaderLib::getUniform(std::string_view _paramName, ngl::Vec2 &o_v) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, ngl::Vec2 &o_v) noexcept { - float x, y; - m_shaderPrograms[m_currentShader]->getRegisteredUniform2f(_paramName.data(), x, y); + float x=0.0f; + float y=0.0f; + auto ret= m_shaderPrograms[m_currentShader]->getRegisteredUniform2f(_paramName.data(), x, y); o_v.set(x, y); + return ret; } -void ShaderLib::getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2) noexcept { - m_shaderPrograms[m_currentShader]->getRegisteredUniform3f(_paramName.data(), o_v0, o_v1, o_v2); + return m_shaderPrograms[m_currentShader]->getRegisteredUniform3f(_paramName.data(), o_v0, o_v1, o_v2); } -void ShaderLib::getUniform(std::string_view _paramName, ngl::Vec3 &o_v) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, ngl::Vec3 &o_v) noexcept { - float x, y, z; - m_shaderPrograms[m_currentShader]->getRegisteredUniform3f(_paramName.data(), x, y, z); + float x=0.0f; + float y=0.0f; + float z=0.0f; + auto ret=m_shaderPrograms[m_currentShader]->getRegisteredUniform3f(_paramName.data(), x, y, z); o_v.set(x, y, z); + return ret; } -void ShaderLib::getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2, Real &o_v3) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, Real &o_v0, Real &o_v1, Real &o_v2, Real &o_v3) noexcept { - m_shaderPrograms[m_currentShader]->getRegisteredUniform4f(_paramName.data(), o_v0, o_v1, o_v2, o_v3); + return m_shaderPrograms[m_currentShader]->getRegisteredUniform4f(_paramName.data(), o_v0, o_v1, o_v2, o_v3); } -void ShaderLib::getUniform(std::string_view _paramName, ngl::Vec4 &o_v) noexcept +bool ShaderLib::getUniform(std::string_view _paramName, ngl::Vec4 &o_v) noexcept { - float x, y, z, w; - m_shaderPrograms[m_currentShader]->getRegisteredUniform4f(_paramName.data(), x, y, z, w); + float x=0.0f; + float y=0.0f; + float z=0.0f; + float w=0.0f; + auto ret=m_shaderPrograms[m_currentShader]->getRegisteredUniform4f(_paramName.data(), x, y, z, w); o_v.set(x, y, z, w); + return ret; } -void ShaderLib::setUniform(std::string_view _paramName, Real _v0, Real _v1) noexcept +bool ShaderLib::setUniform(std::string_view _paramName, Real _v0, Real _v1) noexcept { - m_shaderPrograms[m_currentShader]->setRegisteredUniform2f(_paramName.data(), _v0, _v1); + return m_shaderPrograms[m_currentShader]->setRegisteredUniform2f(_paramName.data(), _v0, _v1); } -void ShaderLib::setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2) noexcept +bool ShaderLib::setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2) noexcept { - m_shaderPrograms[m_currentShader]->setRegisteredUniform3f(_paramName.data(), _v0, _v1, _v2); + return m_shaderPrograms[m_currentShader]->setRegisteredUniform3f(_paramName.data(), _v0, _v1, _v2); } -void ShaderLib::setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2, Real _v3) noexcept +bool ShaderLib::setUniform(std::string_view _paramName, Real _v0, Real _v1, Real _v2, Real _v3) noexcept { - m_shaderPrograms[m_currentShader]->setRegisteredUniform4f(_paramName.data(), _v0, _v1, _v2, _v3); + return m_shaderPrograms[m_currentShader]->setRegisteredUniform4f(_paramName.data(), _v0, _v1, _v2, _v3); } void ShaderLib::setUniform(std::string_view _paramName, GLint _v0) noexcept diff --git a/src/ShaderProgram.cpp b/src/ShaderProgram.cpp index c362c7a9..d8a04222 100644 --- a/src/ShaderProgram.cpp +++ b/src/ShaderProgram.cpp @@ -249,50 +249,56 @@ void ShaderProgram::printActiveAttributes() const noexcept } //---------------------------------------------------------------------------------------------------------------------- -void ShaderProgram::setRegisteredUniform1f(std::string_view _varname, float _v0) const noexcept +bool ShaderProgram::setRegisteredUniform1f(std::string_view _varname, float _v0) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); // make sure we have a valid shader if(uniform != m_registeredUniforms.end()) { glUniform1f(uniform->second.loc, _v0); + return true; } else { ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } -void ShaderProgram::getRegisteredUniform1f(std::string_view _varname, float &o_v0) const noexcept +bool ShaderProgram::getRegisteredUniform1f(std::string_view _varname, float &o_v0) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); // make sure we have a valid shader if(uniform != m_registeredUniforms.end()) { glGetUniformfv(m_programID, uniform->second.loc, &o_v0); + return true; } else { ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } //---------------------------------------------------------------------------------------------------------------------- -void ShaderProgram::setRegisteredUniform2f(std::string_view _varname, float _v0, float _v1) const noexcept +bool ShaderProgram::setRegisteredUniform2f(std::string_view _varname, float _v0, float _v1) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); // make sure we have a valid shader if(uniform != m_registeredUniforms.end()) { glUniform2f(uniform->second.loc, _v0, _v1); + return true; } else { ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } -void ShaderProgram::getRegisteredUniform2f(std::string_view _varname, float &o_v0, float &o_v1) const noexcept +bool ShaderProgram::getRegisteredUniform2f(std::string_view _varname, float &o_v0, float &o_v1) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); float data[2]; @@ -302,25 +308,33 @@ void ShaderProgram::getRegisteredUniform2f(std::string_view _varname, float &o_v glGetUniformfv(m_programID, uniform->second.loc, &data[0]); o_v0 = data[0]; o_v1 = data[1]; + return true; + } + else + { + ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } //---------------------------------------------------------------------------------------------------------------------- -void ShaderProgram::setRegisteredUniform3f(std::string_view _varname, float _v0, float _v1, float _v2) const noexcept + bool ShaderProgram::setRegisteredUniform3f(std::string_view _varname, float _v0, float _v1, float _v2) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); // make sure we have a valid shader if(uniform != m_registeredUniforms.end()) { glUniform3f(uniform->second.loc, _v0, _v1, _v2); + return true; } else { ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } -void ShaderProgram::getRegisteredUniform3f(std::string_view _varname, float &o_v0, float &o_v1, float &o_v2) const noexcept +bool ShaderProgram::getRegisteredUniform3f(std::string_view _varname, float &o_v0, float &o_v1, float &o_v2) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); float data[3]; @@ -331,25 +345,33 @@ void ShaderProgram::getRegisteredUniform3f(std::string_view _varname, float &o_v o_v0 = data[0]; o_v1 = data[1]; o_v2 = data[2]; + return true; + } + else + { + ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } //---------------------------------------------------------------------------------------------------------------------- -void ShaderProgram::setRegisteredUniform4f(std::string_view _varname, float _v0, float _v1, float _v2, float _v3) const noexcept +bool ShaderProgram::setRegisteredUniform4f(std::string_view _varname, float _v0, float _v1, float _v2, float _v3) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); // make sure we have a valid shader if(uniform != m_registeredUniforms.end()) { glUniform4f(uniform->second.loc, _v0, _v1, _v2, _v3); + return true; } else { ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } } -void ShaderProgram::getRegisteredUniform4f(std::string_view _varname, float &o_v0, float &o_v1, float &o_v2, float &o_v3) const noexcept +bool ShaderProgram::getRegisteredUniform4f(std::string_view _varname, float &o_v0, float &o_v1, float &o_v2, float &o_v3) const noexcept { auto uniform = m_registeredUniforms.find(_varname.data()); float data[4]; @@ -361,7 +383,14 @@ void ShaderProgram::getRegisteredUniform4f(std::string_view _varname, float &o_v o_v1 = data[1]; o_v2 = data[2]; o_v3 = data[3]; + return true; + } + else + { + ngl::NGLMessage::addWarning(fmt::format("Uniform {0} Not found in Shader {1}", _varname, m_programName)); + return false; } + } //---------------------------------------------------------------------------------------------------------------------- diff --git a/tests/ShaderLibTests.cpp b/tests/ShaderLibTests.cpp index 9533110d..9b8d0cb1 100644 --- a/tests/ShaderLibTests.cpp +++ b/tests/ShaderLibTests.cpp @@ -109,15 +109,15 @@ TEST(ShaderLib,testSetUniform) EXPECT_TRUE(ngl::ShaderLib::loadShader(shaderName,"files/testUniformVertex.glsl","files/testUniformFragment.glsl",ngl::ErrorExit::OFF))<<"shader loaded?"; ngl::ShaderLib::use(shaderName); { - ngl::ShaderLib::setUniform("testFloat",2.25f); + EXPECT_TRUE(ngl::ShaderLib::setUniform("testFloat",2.25f)); float result; - ngl::ShaderLib::getUniform("testFloat",result); + EXPECT_TRUE(ngl::ShaderLib::getUniform("testFloat",result)); EXPECT_FLOAT_EQ(result,2.25f)<<"Testing setting a single float"; } { - ngl::ShaderLib::setUniform("testVec2",0.5f,2.0f); + EXPECT_TRUE(ngl::ShaderLib::setUniform("testVec2",0.5f,2.0f)); float resultF1,resultF2; - ngl::ShaderLib::getUniform("testVec2",resultF1,resultF2); + EXPECT_TRUE(ngl::ShaderLib::getUniform("testVec2",resultF1,resultF2)); EXPECT_FLOAT_EQ(resultF1,0.5f)<<"Test setting two floats x"; EXPECT_FLOAT_EQ(resultF2,2.0f)<<"Test setting two floats y"; ngl::Vec2 resultVec2; @@ -126,33 +126,51 @@ TEST(ShaderLib,testSetUniform) EXPECT_FLOAT_EQ(resultVec2.m_y,2.0f)<<"Test getting from ngl::Vec2 m_y";; } { - ngl::ShaderLib::setUniform("testVec3",0.5f,2.0f,-22.2f); + EXPECT_TRUE(ngl::ShaderLib::setUniform("testVec3",0.5f,2.0f,-22.2f)); ngl::Real resultF1,resultF2,resultF3; - ngl::ShaderLib::getUniform("testVec3",resultF1,resultF2,resultF3); + EXPECT_TRUE(ngl::ShaderLib::getUniform("testVec3",resultF1,resultF2,resultF3)); EXPECT_FLOAT_EQ(resultF1,0.5f)<<"test setting 3 floats x"; EXPECT_FLOAT_EQ(resultF2,2.0f)<<"test setting 3 floats x"; EXPECT_FLOAT_EQ(resultF3,-22.2f)<<"test setting 3 floats x"; ngl::Vec3 resultVec3; - ngl::ShaderLib::getUniform("testVec3",resultVec3); + EXPECT_TRUE(ngl::ShaderLib::getUniform("testVec3",resultVec3)); EXPECT_FLOAT_EQ(resultVec3.m_x,0.5f)<<"test getting ngl::Vec3 m_x"; EXPECT_FLOAT_EQ(resultVec3.m_y,2.0f)<<"test getting ngl::Vec3 m_y"; EXPECT_FLOAT_EQ(resultVec3.m_z,-22.2f)<<"test getting ngl::Vec3 m_z"; } { - ngl::ShaderLib::setUniform("testVec4",0.5f,2.0f,-22.2f,1230.4f); + EXPECT_TRUE(ngl::ShaderLib::setUniform("testVec4",0.5f,2.0f,-22.2f,1230.4f)); ngl::Real resultF1,resultF2,resultF3,resultF4; - ngl::ShaderLib::getUniform("testVec4",resultF1,resultF2,resultF3,resultF4); + EXPECT_TRUE(ngl::ShaderLib::getUniform("testVec4",resultF1,resultF2,resultF3,resultF4)); EXPECT_FLOAT_EQ(resultF1,0.5f); EXPECT_FLOAT_EQ(resultF2,2.0f); EXPECT_FLOAT_EQ(resultF3,-22.2f); EXPECT_FLOAT_EQ(resultF4,1230.4f); ngl::Vec4 resultVec4; - ngl::ShaderLib::getUniform("testVec4",resultVec4); + EXPECT_TRUE(ngl::ShaderLib::getUniform("testVec4",resultVec4)); EXPECT_FLOAT_EQ(resultVec4.m_x,0.5f); EXPECT_FLOAT_EQ(resultVec4.m_y,2.0f); EXPECT_FLOAT_EQ(resultVec4.m_z,-22.2f); EXPECT_FLOAT_EQ(resultVec4.m_w,1230.4f); } + + { + // test arrays + for(int i=0; i<3; ++i) + { + EXPECT_TRUE(ngl::ShaderLib::setUniform(fmt::format("testArray[{}]",i),0.5f,2.0f,-22.2f)); + ngl::Real resultF1,resultF2,resultF3; + EXPECT_TRUE(ngl::ShaderLib::getUniform(fmt::format("testArray[{}]",i),resultF1,resultF2,resultF3)); + EXPECT_FLOAT_EQ(resultF1,0.5f)<<"test setting 3 floats x"; + EXPECT_FLOAT_EQ(resultF2,2.0f)<<"test setting 3 floats x"; + EXPECT_FLOAT_EQ(resultF3,-22.2f)<<"test setting 3 floats x"; + ngl::Vec3 resultVec3; + EXPECT_TRUE(ngl::ShaderLib::getUniform(fmt::format("testArray[{}]",i),resultVec3)); + EXPECT_FLOAT_EQ(resultVec3.m_x,0.5f)<<"test getting ngl::Vec3 m_x"; + EXPECT_FLOAT_EQ(resultVec3.m_y,2.0f)<<"test getting ngl::Vec3 m_y"; + EXPECT_FLOAT_EQ(resultVec3.m_z,-22.2f)<<"test getting ngl::Vec3 m_z"; + } + } { ngl::ShaderLib::setUniform("testMat2",ngl::Mat2()); ngl::Mat2 result; diff --git a/tests/files/testUniformVertex.glsl b/tests/files/testUniformVertex.glsl index 73f37889..4c06e0a5 100644 --- a/tests/files/testUniformVertex.glsl +++ b/tests/files/testUniformVertex.glsl @@ -16,13 +16,17 @@ uniform mat2 testMat2; uniform mat3 testMat3; uniform mat4 testMat4; - +uniform vec3 testArray[3]; void main() { outTestFloat=testFloat; outTestVec2=testMat2*testVec2; outTestVec3=testMat3*testVec3; outTestVec4=testMat4*testVec4; + outTestVec3+=testArray[0]; + outTestVec3+=testArray[1]; + outTestVec3+=testArray[2]; + gl_Position=vec4(1); }