private void SetGLLight( int index, Light l )
{
All glIndex = All.Light0 + index;
if ( l == null )
{
// Disable in the scene
OpenGL.Disable( glIndex );
}
else
{
switch ( l.Type )
{
case LightType.Spotlight:
OpenGL.Light( glIndex, All.SpotCutoff, 0.5f * l.SpotlightOuterAngle );
GLESConfig.GlCheckError( this );
OpenGL.Light( glIndex, All.SpotExponent, l.SpotlightFalloff );
GLESConfig.GlCheckError( this );
break;
default:
OpenGL.Light( glIndex, All.SpotCutoff, 180.0f );
break;
}
//// Color
ColorEx col = l.Diffuse;
float[] f4Vals = new float[] { col.r, col.g, col.b, col.a };
OpenGL.Light( glIndex, All.Diffuse, f4Vals );
GLESConfig.GlCheckError( this );
col = l.Specular;
f4Vals[ 0 ] = col.r;
f4Vals[ 1 ] = col.g;
f4Vals[ 2 ] = col.b;
f4Vals[ 3 ] = col.a;
OpenGL.Light( glIndex, All.Specular, f4Vals );
GLESConfig.GlCheckError( this );
// Disable ambient light for movables;
f4Vals[ 0 ] = 0;
f4Vals[ 1 ] = 0;
f4Vals[ 2 ] = 0;
f4Vals[ 3 ] = 1;
OpenGL.Light( glIndex, All.Ambient, f4Vals );
GLESConfig.GlCheckError( this );
SetGLLightPositionDirection( l, glIndex );
// Attenuation
OpenGL.Light( glIndex, All.ConstantAttenuation, l.AttenuationConstant );
GLESConfig.GlCheckError( this );
OpenGL.Light( glIndex, All.LinearAttenuation, l.AttenuationLinear );
GLESConfig.GlCheckError( this );
OpenGL.Light( glIndex, All.QuadraticAttenuation, l.AttenuationQuadratic );
GLESConfig.GlCheckError( this );
// Enable in the scene
OpenGL.Enable( glIndex );
GLESConfig.GlCheckError( this );
}
}
/// <summary>