Example #1
0
void IGLUShaderVariable::operator= ( float3 val )
{
	// Check for a valid shader index
	if ( m_varIdx < 0 ) return;

	// Check for type mismatches
	if ( m_isAttribute )
	{
		AssignmentToAttribute( "vec3" );
		return;
	}
	if ( m_varType != GL_FLOAT_VEC3 && m_varType != GL_DOUBLE_VEC3 )
		TypeMismatch( "vec3" );

	// Ensure this program is currently bound, or setting shader values fails!
	m_parent->PushProgram();

	// For types of variable that can be assigned from our input value, assign them here
	if ( m_varType == GL_FLOAT_VEC3 )
		glUniform3fv( m_varIdx, 1, val.GetConstDataPtr() );
	if ( m_varType == GL_DOUBLE_VEC3 )
		glUniform3d( m_varIdx, val.X(), val.Y(), val.Z() );

	// We have a short "program stack" so make sure to pop off.
	m_parent->PopProgram();
}