Esempio n. 1
0
//---------------------------------------------------------------------------
void Material::SetUniform3fv( const std::string& name, const std::vector< Vec3f >& values )
{
// 	std::vector< float > floatValues;
// 	floatValues.reserve( values.size() * 3 );
// 
// 	for ( unsigned int index = 0; index < values.size(); ++index )
// 	{
// 		const Vec3f& currentValue = values[ index ];
// 		floatValues.push_back( currentValue.x );
// 		floatValues.push_back( currentValue.y );
// 		floatValues.push_back( currentValue.z );
// 	}
// 
// 	SetUniform3fv( name, values.size(), floatValues.data() );
	SetUniform3fv( name, values.size(), &values[ 0 ].x );
}
Esempio n. 2
0
GLvoid
glLightfv(GLenum light, GLenum pname, GLfloat *params)
{
    wes_vertbuffer_flush();

    GLuint ind = light - GL_LIGHT0;
    switch(pname)
    {
        case GL_AMBIENT:
            SetUniform4fv(uLight[ind].ColorAmbient, params); break;
        case GL_DIFFUSE:
            SetUniform4fv(uLight[ind].ColorDiffuse, params); break;
        case GL_SPECULAR:
            SetUniform4fv(uLight[ind].ColorSpec, params); break;

        case GL_POSITION:{
            GLfloat tmp[4];
            wes_matvec4(m_modelview, params, tmp);
            SetUniform4fv(uLight[ind].Position, tmp);
            break;
        }

        case GL_SPOT_DIRECTION:{
            GLfloat tmp[4];
            wes_matvec4(m_modelview, params, tmp);
            SetUniform3fv(uLight[ind].SpotDir, tmp);
            break;
            }

        case GL_SPOT_EXPONENT:
            SetUniformIndex(uLight[ind].SpotVar, 0, *params);   break;
        case GL_SPOT_CUTOFF:
            SetUniformIndex(uLight[ind].SpotVar, 1, *params);   break;
        case GL_CONSTANT_ATTENUATION:
            SetUniformIndex(uLight[ind].Attenuation, 0, *params);   break;
        case GL_LINEAR_ATTENUATION:
            SetUniformIndex(uLight[ind].Attenuation, 1, *params);   break;
        case GL_QUADRATIC_ATTENUATION:
            SetUniformIndex(uLight[ind].Attenuation, 2, *params);   break;

        default:
            PRINT_ERROR("Invalid glLightfv parameter name\n");
    }
}