Added removal of [..] from names returned from glGetActiveUniform results to avoid issues with name lookups when the driver add the [..] for uniform arrays.

This commit is contained in:
Robert Osfield
2011-09-19 10:12:53 +00:00
parent f9dffdba2c
commit 6e01f05853

View File

@@ -34,6 +34,8 @@
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
#include <string.h>
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 )