Shaders can handle integer parameters (uniforms).

This commit is contained in:
Maciej Suminski 2013-07-03 13:08:43 +02:00
parent 97f914ccb3
commit fe6c901a9f
2 changed files with 14 additions and 4 deletions

View File

@ -117,7 +117,7 @@ bool SHADER::Link()
}
void SHADER::AddParameter( const std::string& aParameterName )
int SHADER::AddParameter( const std::string& aParameterName )
{
GLint location = glGetUniformLocation( programNumber, aParameterName.c_str() );
@ -125,15 +125,23 @@ void SHADER::AddParameter( const std::string& aParameterName )
{
parameterLocation.push_back( location );
}
return location;
}
void SHADER::SetParameter( int parameterNumber, float value )
void SHADER::SetParameter( int parameterNumber, float value ) const
{
glUniform1f( parameterLocation[parameterNumber], value );
}
void SHADER::SetParameter( int parameterNumber, int value ) const
{
glUniform1i( parameterLocation[parameterNumber], value );
}
int SHADER::GetAttribute( std::string aAttributeName ) const
{
return glGetAttribLocation( programNumber, aAttributeName.c_str() );

View File

@ -141,8 +141,9 @@ public:
* method using the queue position.
*
* @param aParameterName is the name of the parameter.
* @return the added parameter location.
*/
void AddParameter( const std::string& aParameterName );
int AddParameter( const std::string& aParameterName );
/**
* @brief Set a parameter of the shader.
@ -150,7 +151,8 @@ public:
* @param aParameterNumber is the number of the parameter.
* @param aValue is the value of the parameter.
*/
void SetParameter( int aParameterNumber, float aValue );
void SetParameter( int aParameterNumber, float aValue ) const;
void SetParameter( int aParameterNumber, int aValue ) const;
/**
* @brief Gets an attribute location.