|

OpenGL/ FPC - Chapter 15 - by Delax
Now to the last type of light. And as usual, we do need additional variables fo it.
AmbientLight : array[0..3] of glFloat = (0.5,0.5,0.5,1.0);
DiffuseLight : array[0..3] of glFloat = (1.0,1.0,1.0,1.0);
SpecularLight : array[0..3] of glFloat = (1.0,1.0,1.0,1.0);
SpecularReflection : array[0..3] of glFloat = (0.4,0.4,0.4,1.0);
LightPosition : array[0..3] of glFloat;
SpecularLight contains the definitions of our light and SpecularReflection is the intensity of the reflections on materials.
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0,GL_AMBIENT, @AmbientLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE, @DiffuseLight);
glLightfv(GL_LIGHT0,GL_SPECULAR, @SpecularLight);
glEnable(GL_LIGHT0);
LightPosition[0] := 0.0; LightPosition[1] := 0.0;
LightPosition[2] := 0.0; LightPosition[3] := 1.0;
glLightfv(GL_LIGHT0,GL_POSITION,@LightPosition);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glMaterialfv(GL_FRONT, GL_SPECULAR, @SpecularReflection);
glMateriali(GL_FRONT,GL_SHININESS,10);
Now we create our LIGHT0 with the new values for specular light. We also set some new definitions in our material definitions. We tell OpenGL that our materials reflect the specular light. We also define the shininess of the materials with glMateriali(GL_FRONT,GL_SHININESS,10);
The main scene stays the same. Only the light is different now. As always: play around with it. Get the example here.
Delax/ Sundancer Inc.
[delax@sundancerinc.de]
Back to previous page
|