Porting Lighting and Materials Functions

OpenGL functions for lighting and materials differ substantially from the IRIS GL functions. Unlike IRIS GL, OpenGL has separate functions for setting lights, light models and materials.

Keep the following points in mind when porting lighting and materials functions:

The following table lists IRIS GL lighting and materials functions and their equivalent OpenGL functions.

IRIS GL Function OpenGL Function Meaning
Imdef(DEFLIGHT, ...) glLight Define a light source.
Imdef(DEFLMODEL, ...) glLightModel Define a lighting model.
Imbind glEnable(GL_LIGHTi) Enable light i.
Imbind glEnable(GL_LIGHTING) Enable lighting.
Imdef(DEFMATERIAL, ...) glMaterial Define a material.
Imcolor glColorMaterial Change the effect of color commands while lighting is active.
glGetMaterial Get material parameters.

The following table lists various IRIS GL material parameters and their equivalent OpenGL parameters.

Imdef Index glMaterial Parameter Default Meaning
ALPHA GL_DIFFUSE The fourth value in the GL_DIFFUSE parameter specifies the alpha value.
AMBIENT GL_AMBIENT (0.2, 0.2, 0.2, 1.0) Ambient color.
DIFFUSE GL_DIFFUSE (0.8, 0.8, 0.8, 1.0) Diffuse color.
SPECULAR GL_SPECULAR (0.0, 0.0, 0.0, 1.0) Emissive color.
SHININESS GL_SHININESS

GL_AMBIENT_
AND_DIFFUSE

0.0 Specular exponent.

Equivalent to calling glMaterial twice with the same values.

COLORINDEXES GL_COLOR_
INDEXES
Color indexes for ambient, diffuse, and specular lighting.

When the first parameter of Imdef is DEFMODEL, the equivalent OpenGL translation is the function glLightModel. The exception is when the parameter following DEFMODEL is ATTENUATION: then the equivalent OpenGL function is glLight.

The following table lists the equivalent lighting model parameters for IRIS GL and OpenGL.

Imdef Index glLightModel Parameter Default Meaning
AMBIENT GL_LIGHT_
MODEL_AMBIENT
(0.2, 0.2, 0.2, 1.0) Ambient color of scene.
ATTENUATION See glLight.
LOCALVIEWER GL_LIGHT_MODEL_
LOCAL_VIEWER
GL_FALSE Viewer local (TRUE) or infinite (FALSE).
TWOSIDE GL_LIGHTMODEL_
TWO_SIDE
GL_FALSE Use two-sided lighting when TRUE.

When the first parameter of Imdef is DEFLIGHT, the equivalent OpenGL translation is the glLight function.

The following table lists the equivalent lighting parameters for IRIS GL and OpenGL.

Imdef Index glLight Parameter Default Meaning
AMBIENT GL_AMBIENT

GL_DIFFUSE

GL_SPECULAR

(0.0, 0.0, 0.0, 1.0)

(1.0, 1.0, 1.0, 1.0)

(1.0, 1.0, 1.0, 1.0)

Ambient intensity.

Diffuse intensity.

Specular intensity.

LCOLOR No equivalent.
POSITION GL_POSITION (0.0, 0.0, 1.0, 0.0) Position of light.
SPOTDIRECTION GL_SPOT_
DIRECTION
(0, 0, –1) Direction of spotlight.
SPOTLIGHT GL_SPOT_
EXPONENT

GL_SPOT_CUTOFF

0

180

Intensity distribution.

Maximum spread angle of light source.

DEFMODEL, ATTENUATION GL_CONSTANT_
ATTENUATION

GL_LINEAR_
ATTENUATION

GL_QUADRATIC_
ATTENUATION

(1, 0, 0) Attenuation factors.