diff --git a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp index 502c31d2..182e060a 100644 --- a/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp +++ b/MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp @@ -473,7 +473,7 @@ namespace MobileGL { return; } - if (location >= programObject->GetUniformCount() || location < -1) { + if (location > programObject->GetMaxUniformLocation() || location < -1) { MG_State::pGLContext->RecordError( ErrorCode::InvalidOperation, MakeShared("MG_Impl/GLImpl", __func__, diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h index dcf265b2..5cb84aba 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramObject.h @@ -25,7 +25,9 @@ namespace MobileGL { Uint GetMaxUniformLocation() const { return m_maxUniformLocation; } Int GetUniformLocation(const String& name) { const auto it = m_uniformLocations.find(name); - return (it == m_uniformLocations.end()) ? -1 : (Int)it->second; + if (it == m_uniformLocations.end()) + return -1; + return (Int)it->second; } GLenum GetUniformType(Uint index) const { return m_uniformTypes[index]; }