GLfloat white[] = {1,1,1,1}; // light color
GLfloat lightPosition[]={-1,1,1,1}; // light position
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); // setlight position
glLightfv(GL_LIGHT0, GL_DIFFUSE, white); // set diffuse light color
glLightfv(GL_LIGHT0, GL_SPECULAR, white); // set specular light color
glEnable(GL_LIGHT0);
The glLightfv() command takes three arguments. The first is the
light number, which should be one of the OpenGL constants GL_LIGHTi. The second is
the lighting parameter to be set, also one of the OpenGL constants. The final argument
is the
value the parameter should be set to. In this case,the value is a vector of floats, as specified by the
fv in the command glLightfv(). (See Woo for a full description of argument specifications.)
Note that OpenGL lighting is more flexible than the model we used for raytracing in that a
light can provide different colors for diffuse and specular. (For more details on the
possible parameters see Woo chapter 5.)