From 6e01f05853389793323e2de87c4126995ff5fc3b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 19 Sep 2011 10:12:53 +0000 Subject: [PATCH] Added removal of [..] from names returned from glGetActiveUniform results to avoid issues with name lookups when the driver add the [..] for uniform arrays. --- src/osg/Program.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/osg/Program.cpp b/src/osg/Program.cpp index c37d42a4e..8cb978f35 100644 --- a/src/osg/Program.cpp +++ b/src/osg/Program.cpp @@ -34,6 +34,8 @@ #include #include +#include + using namespace osg; /////////////////////////////////////////////////////////////////////////// @@ -733,6 +735,15 @@ void Program::PerContextProgram::linkProgram(osg::State& state) _extensions->glGetActiveUniform( _glProgramHandle, i, maxLen, 0, &size, &type, name ); + int pos = strlen(name); + if (pos>0 && name[pos-1]==']') + { + // need to trim [..] from end of name as some drivers append this causing problems with look up. + --pos; + while(pos>0 && name[pos]!='[') { --pos; } + name[pos] = 0; + } + GLint loc = _extensions->glGetUniformLocation( _glProgramHandle, name ); if( loc != -1 )