Four basic properties we set in defining a spotlight are color, position, direction and cone angle. In our example, we use magenta as the light's color for specular reflection. Although we have not done so, diffuse and ambient colors can be attached to the spot light.

Similar to a positional light, the position of a spotlight is set using the property GL_POSITION. Also, we use a nonzero value for the fourth component of the homogenous coordinates. For our example, the spotlight is located at (0.25, 0.1, 5.0).

The direction of a spotlight is a specific property chosen with the parameter GL_SPOT_DIRECTION. The easy approach in selecting the direction is to pick a "target" point in world coordinates once you have pick the position of the spotlight. The direction is then the vector obtained from the difference of the target point and the position. For our example, we use the target point (0.25, 0.0, 0.0). Thus, the direction is (0.0, -0.1, -5.0).

The cone angle is set using the constant GL_SPOT_CUTOFF. The value we give is the angle in degrees from the center of the spotlight to the edge of the light -- that is, it is one-half of the full angle. The range of values for the cone angle is restricted to [0, 90]. One value outside this range is acceptable, namely, 180 degrees. However, if we happen to use this value, the spotlight is no longer such but simply a positional light.

Last, a fifth property of a spotlight is also available. The property is GL_SPOT_EXPONENT. This property determines the light's "fall-off" -- that is, the loss of intensity of the light at its edges (see the tutorial on Specular Reflection).