Commit d670eb42 authored by Frédéric Larue's avatar Frédéric Larue

Functions to set up an array of samplers in Shaders added.

parent 7aad66e6
......@@ -410,8 +410,8 @@ void GPU::Shader::SetUniform( const std::string& name,
}
void GPU::Shader::SetSampler( const std::string& name,
const GLint* texUnit )
void GPU::Shader::SetSamplers( const std::string& name,
const GLint* texUnit )
{
UniformMap::iterator s = m_Samplers.find( name );
if( s != m_Samplers.end() )
......@@ -426,6 +426,28 @@ void GPU::Shader::SetSampler( const std::string& name,
}
void GPU::Shader::SetSamplers( const std::string& name,
const GLint firstTexUnit )
{
UniformMap::iterator s = m_Samplers.find( name );
if( s != m_Samplers.end() )
{
GLint *texUnits = new GLint [ s->second.size ];
for( GLint i=0; i<s->second.size; ++i )
texUnits[i] = firstTexUnit + i;
GLuint activeProgBackup = glGetHandleARB( GL_PROGRAM_OBJECT_ARB );
glUseProgramObjectARB( m_Id );
glUniform1ivARB( s->second.location, s->second.size, texUnits );
glUseProgramObjectARB( activeProgBackup );
delete[] texUnits;
}
}
void GPU::Shader::SetAttrib( const std::string& name,
VBOAttribBuffer *attrib )
{
......
......@@ -186,9 +186,11 @@ namespace GPU
void SetUniform( const std::string& name,
const void *value );
inline void SetSampler( const std::string& name,
const GLint texUnit ) { SetSampler( name, &texUnit ); }
void SetSampler( const std::string& name,
const GLint* texUnit );
const GLint texUnit ) { SetSamplers( name, &texUnit ); }
void SetSamplers( const std::string& name,
const GLint* texUnit );
void SetSamplers( const std::string& name,
const GLint firstTexUnit );
void SetAttrib( const std::string& name,
VBOAttribBuffer *attrib );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment