Commit fe6c901a authored by Maciej Suminski's avatar Maciej Suminski

Shaders can handle integer parameters (uniforms).

parent 97f914cc
......@@ -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() );
......
......@@ -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.
......
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