gdSPDefLights gdSPDefLights (macro)

Loads parameters defining the lights into light structures

Syntax

#include "gbi.h"     /* gbi.h */
typedef struct {
        Ambient a;
        Light l[M];
} LightsM;

LightsM gdSPDefLightsM(
        signed char ar, signed char ag, signed char ab,
        signed char d1r, signed char d1g, signed char d1b,
        signed char n1x, signed char n1y, signed char n1z,

        ...

        signed char dMr, signed char dMg, signed char dMb,
        signed char nMx, signed char nMy, signed char nMz)

Arguments

ar, ag, ab
red, green, blue components of ambient light color.

d1r, d1g, d1b
red, green, blue components of first diffuse light color.

n1x, n1y, n1z
x, y, z components of the first diffuse litght direction.

dMr, dMg, dMb
red, green, blue components of Mth diffuse light color.

nMx, nMy, nMz
x, y, z components of Mth diffuse light direction.

Description

gdSPDefLights M loads parameters defining the lights into light structures. The diffuse light direction coordinates specify the direction from the origin to the diffuse light. The macro name is actually gdSPDefLightsM where the letter M represents the number of diffuse lights in the scene. In the macro and in the structure (LightsM), M must be an actual integer in the range of 0 to 7.

For example, with three diffuse lights, the command is gdSPDefLights3, and the corresponding structure is Lights3. In this case, arguments for colors of the ambient light and both colors and directions of 3 diffuse lights must be supplied. When M is 0, only the arguments for colors of the ambient light need be supplied.

Example

The following code defines an ambient and a diffuse light in a variable named "lite". The ambient color is a very dark gray, while the diffuse color is a bright red. As this example shows, the diffuse light direction vector does not need to be normalized. If the scale of the model view matrix is S and the magnitude of the light direction is L then try to keep 1 < L*S < 23040.

Lights1 lite = gdSPDefLights1(
        0x05, 0x05, 0x05,        /* amb col */
        0xc0, 0x00, 0x00,        /* col 1 */
        13, 25, 30);             /* dir 1 */

The variable ("lite" in this example) may be used in the gSPSetLightsM macro or the gSPLight macro to set the lighting state of the RSP.

See Also

gSPSetLightsM

Revision History

1999/04/30 Changed Format