Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

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

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

parent f22893b3
...@@ -435,6 +435,60 @@ void GPU::Shader::SetUniform( const std::string& name, ...@@ -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, void GPU::Shader::SetSamplers( const std::string& name,
const GLint* texUnit ) const GLint* texUnit )
{ {
......
...@@ -212,6 +212,10 @@ namespace GPU ...@@ -212,6 +212,10 @@ namespace GPU
void SetUniform( const std::string& name, void SetUniform( const std::string& name,
const void *value ); 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, inline void SetSampler( const std::string& name,
const GLint texUnit ) { SetSamplers( name, &texUnit ); } const GLint texUnit ) { SetSamplers( name, &texUnit ); }
void SetSamplers( const std::string& name, 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