[ Previous | Next | Contents | Glossary | Home | Search ]
OpenGL 1.1 for AIX: Reference Manual

glMaterial Subroutine

Purpose

Specifies material parameters for the lighting model.

Library

OpenGL C bindings library: libGL.a

C Syntax

void glMaterialf(GLenum Face, 
      GLenum pName,
      GLfloat Parameter)
void glMateriali(GLenum Face, 
      GLenum pName,
      GLint Parameter)
void glMaterialfv(GLenum Face, 
        GLenum pName,
        const GLfloat *Parameters)
void glMaterialiv(GLenum Face, 
        GLenum pName,
        const GLint *Parameters)

Parameters

materialf and materiali

Face Specifies which face or faces are being updated. The Face parameter must be one of GL_FRONT, GL_BACK or GL_FRONT_AND_BACK.
pName Specifies the single-valued material parameter of the face or faces that is being updated. Must be GL_SHININESS.
Parameter Specifies the value to which GL_SHININESS is set.

materialfv and materialiv

Face Specifies which face or faces are being updated. Must be one of GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.
pName Specifies the material parameter of the face or faces that is being updated. Must be one of the following:

Description

The glMaterial subroutine assigns values to material parameters. There are two matched sets of material parameters. One, the frontfacing set, is used to shade points, lines, bitmaps, and all polygons (when two-sided lighting is disabled), or just frontfacing polygons (when two-sided lighting is enabled). The other set, backfacing, is used to shade backfacing polygons only when two-sided lighting is enabled. See the glLightModel subroutine for details concerning one- and two-sided lighting calculations.

The glMaterial subroutine takes three arguments:

Material parameters are used in the lighting equation that is optionally applied to each vertex. See the glLightModel subroutine for details about the lighting equation. The following parameters and their interpretations by the lighting equation can be specified using glMaterial:

GL_AMBIENT Parameters contains four integer or floating-point values that specify the ambient red, green, blue, alpha (RGBA) reflectance of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default ambient reflectance for both front and backfacing materials is (0.2, 0.2, 0.2, 1.0).
GL_DIFFUSE Parameters contains four integer or floating-point values that specify the diffuse RGBA reflectance of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default diffuse reflectance for both front and backfacing materials is (0.8, 0.8, 0.8, 1.0).
GL_SPECULAR Parameters contains four integer or floating-point values that specify the specular RGBA reflectance of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default specular reflectance for both front and backfacing materials is (0.0, 0.0, 0.0, 1.0).
GL_EMISSION Parameters contains four integer or floating-point values that specify the RGBA emitted light intensity of the material. Integer values are mapped linearly such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. Floating-point values are mapped directly. Neither integer nor floating-point values are clamped. The default emission intensity for both front and backfacing materials is (0.0, 0.0, 0.0, 1.0).
GL_SHININESS Parameters is a single integer or floating-point value that specifies the RGBA specular exponent of the material. Integer and floating-point values are mapped directly. Only values in the range [0,128] are accepted. The default specular exponent for both frontfacing and backfacing materials is 0.
GL_AMBIENT_AND_DIFFUSE    Equivalent to calling glMaterial twice with the same parameter values, once with GL_AMBIENT and once with GL_DIFFUSE.
GL_COLOR_INDEXES Parameters contains three integer or floating-point values specifying the color indices for ambient, diffuse, and specular lighting. These three values, and GL_SHININESS, are the only material values used by the color index mode lighting equation. See the glLightModel subroutine for a discussion of color index lighting.

Notes

The material parameters can be updated at any time. In particular, glMaterial can be called between a call to the glBegin subroutine and the corresponding call to the glEnd subroutine. If only a single material parameter is to be changed per vertex, however, glColorMaterial is preferred over glMaterial. (See the glColorMaterial subroutine for information on tracking the current color with the material color.)

Errors

GL_INVALID_ENUM Face or pName is not an accepted value.
GL_INVALID_VALUE A specular exponent outside the range [0,128] is specified.

Associated Gets

Associated gets for the glMaterial subroutine are as follows. (See the glGet subroutine for more information.)

glGetMaterial.

Files

/usr/include/GL/gl.h Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL.

Related Information

The glBegin or glEnd subroutine, glColorMaterial subroutine, glGetMaterial subroutine, glLight subroutine, glLightModel subroutine.

OpenGL Overview.


[ Previous | Next | Contents | Glossary | Home | Search ]