Spotlights

Normally, local light source shine equally in all directions.

Using the spotlight features, you can have a light shine in a particular direction.

A spotlight's beam is a cone starting from the light position and pointing in the spotlight direction. The angle of the cone is defined by the GL_SPOT_CUTOFF value.

By default, anything within the cone is illuminated by the full intensity of the light source. Using the GL_SPOT_EXPONENT value, you can soften this effect, so that the light is brightest at its center and falls off toward the edges of the cone.

    glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection);
    glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, spotCutoff);
    glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, spotExponent);


Example code: spotlight.c



next