next up previous
Next: Blending and Fog: Up: OpenGL Quick Reference Guide Previous: Options:


In OpenGL there may be up to 8 light sources (GL_LIGHT0 through GL_LIGHT7). If lighting is enabled (see glEnable()) then the shading of each object depends on which light sources are turned on (enabled) and the materials and surface normals of each of the objects in the scene. Note that when lighting is enabled, it is important that each vertex be associated with a proper normal vector (by calling glNormal*()) prior to generating the vertex.

glShadeModel(GLenum mode):
The mode may be either GL_FLAT or GL_SMOOTH. In flat shading every point on a polygon is shaded according to its first vertex. In smooth shading the shading from each of the various vertices is interpolated.

glLightModelf(GLenum pname, GLfloat param):
glLightModelfv(GLenum pname, const GLfloat *params):
Defines general lighting model parameters. The first version is for defining scalar parameters, and the second is for vector parameters. One important parameter is the global intensity of ambient light (independent of any light sources). Its pname is GL_LIGHT_MODEL_AMBIENT and params is a pointer to an RGBA vector.

glLightf(GLenum light, GLenum pname, GLfloat param):
glLightfv(GLenum light, GLenum pname, const GLfloat *params):
Defines parameters for a single light source. The first version is for defining scalar parameters, and the second is for vector parameters. The first argument indicates which light source this applies to. The argument pname gives one of the properties to be assigned. These include the following: By default, illumination intensity does not decrease, or attenuate, with distance. In general, if d is the distance from the light source to the object, and the light source is not a point at infinity, then the intensity attenuation is given by 1/(a + bd + cd*d) where a, b, and c are specified by the following parameters: Normally light sources send light uniformly in all directions. To define a spotlight, set the following parameters. Note: In addition to defining these properties, each light source must also be enabled. See glEnable().
glMaterialf(GLenum face, GLenum pname, GLfloat param):
glMaterialfv(GLenum face, GLenum pname, const GLfloat *params):
Defines surface material parameters for subsequently defined objects. The first version is for defining scalar parameters, and the second is for vector parameters. Polygonal objects in OpenGL have two sides. You can assign properties either to the front, back, or both sides. (The front side is the one from which the vertices appear in counterclockwise order.) The first argument indicates the side. The possible values are GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK. The second argument is the specific property. Possbilities include:

Please report any errors or send comments to Dave Mount

Last updated: Sat, Feb 8, 2003.