Commit 4951e563 authored by Frédéric Larue's avatar Frédéric Larue

New functions to set uniforms in GPU::Shader added.

parent f22893b3
......@@ -435,6 +435,60 @@ void GPU::Shader::SetUniform( const std::string& name,
}
void GPU::Shader::SetUniform( const std::string& name, GLint value )
{
UniformMap::iterator uu = m_Uniforms.find( name );
if( uu != m_Uniforms.end() )
{
GLuint activeProgBackup;
gpuAssert( activeProgBackup = glGetHandleARB( GL_PROGRAM_OBJECT_ARB ) );
gpuAssert( glUseProgramObjectARB( Id() ) );
Uniform &u = uu->second;
assert( (u.type == GL_INT || u.type == GL_BOOL_ARB) && u.size == 1 );
gpuAssert( glUniform1ivARB( u.location, u.size, &value ) );
gpuAssert( glUseProgramObjectARB( activeProgBackup ) );
}
}
void GPU::Shader::SetUniform( const std::string& name, GLfloat value )
{
UniformMap::iterator uu = m_Uniforms.find( name );
if( uu != m_Uniforms.end() )
{
GLuint activeProgBackup;
gpuAssert( activeProgBackup = glGetHandleARB( GL_PROGRAM_OBJECT_ARB ) );
gpuAssert( glUseProgramObjectARB( Id() ) );
Uniform &u = uu->second;
assert( u.type == GL_FLOAT && u.size == 1 );
gpuAssert( glUniform1fvARB( u.location, u.size, &value ) );
gpuAssert( glUseProgramObjectARB( activeProgBackup ) );
}
}
void GPU::Shader::SetUniform( const std::string& name, GLdouble value )
{
UniformMap::iterator uu = m_Uniforms.find( name );
if( uu != m_Uniforms.end() )
{
GLuint activeProgBackup;
gpuAssert( activeProgBackup = glGetHandleARB( GL_PROGRAM_OBJECT_ARB ) );
gpuAssert( glUseProgramObjectARB( Id() ) );
Uniform &u = uu->second;
assert( u.type == GL_DOUBLE && u.size == 1 );
gpuAssert( glUniform1dv( u.location, u.size, &value ) );
gpuAssert( glUseProgramObjectARB( activeProgBackup ) );
}
}
void GPU::Shader::SetSamplers( const std::string& name,
const GLint* texUnit )
{
......
......@@ -212,6 +212,10 @@ namespace GPU
void SetUniform( const std::string& name,
const void *value );
void SetUniform( const std::string& name, GLint value );
void SetUniform( const std::string& name, GLfloat value );
void SetUniform( const std::string& name, GLdouble value );
inline void SetSampler( const std::string& name,
const GLint texUnit ) { SetSamplers( name, &texUnit ); }
void SetSamplers( const std::string& name,
......
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