2003-2004 Silicon Graphics, Inc.
glMaterial 3G
glMaterial glMaterialf glMaterialx glMaterialfv glMaterialxv specify material parameters for the lighting model

## C Specification

void `glMaterialf` GLenum face GLenum pname GLfloat param void `glMaterialx` GLenum face GLenum pname GLfixed param

## Parameters

face

  Specifies which face or faces are being updated. Must be `GL_FRONT_AND_BACK`.

pname

  Specifies the single-valued material parameter of the face or faces that is being updated. Must be `GL_SHININESS`.

param

  Specifies the value that parameter `GL_SHININESS` will be set to.

## C Specification

void `glMaterialfv` GLenum face GLenum pname const GLfloat * params void `glMaterialxv` GLenum face GLenum pname const GLfixed * params

## Parameters

face

  Specifies which face or faces are being updated. Must be `GL_FRONT_AND_BACK`.

pname

  Specifies the material parameter of the face or faces that is being updated. Must be one of `GL_AMBIENT`, `GL_DIFFUSE`, `GL_SPECULAR`, `GL_EMISSION`, `GL_SHININESS`, or `GL_AMBIENT_AND_DIFFUSE`.

params

  Specifies a pointer to the value or values that pname will be set to.

## Description

`glMaterial` assigns values to material parameters. There are two matched sets of material parameters. One, the front-facing set, is used to shade points, lines, and all polygons (when two-sided lighting is disabled), or just front-facing polygons (when two-sided lighting is enabled). The other set, back-facing, is used to shade back-facing polygons only when two-sided lighting is enabled. Refer to the glLightModel reference page for details concerning one- and two-sided lighting calculations.

`glMaterial` takes three arguments. The first, face, must be `GL_FRONT_AND_BACK` and specifies that both front and back materials will be modified. The second, pname, specifies which of several parameters in one or both sets will be modified. The third, params, specifies what value or values will be assigned to the specified parameter.

Material parameters are used in the lighting equation that is optionally applied to each vertex. The equation is discussed in the glLightModel reference page. The parameters that can be specified using `glMaterial`, and their interpretations by the lighting equation, are as follows:

`GL_AMBIENT`

  params contains four fixed-point or floating-point values that specify the ambient RGBA reflectance of the material. The values are not clamped. The initial ambient reflectance is (0.2, 0.2, 0.2, 1.0).

`GL_DIFFUSE`

  params contains four fixed-point or floating-point values that specify the diffuse RGBA reflectance of the material. The values are not clamped. The initial diffuse reflectance is (0.8, 0.8, 0.8, 1.0).

`GL_SPECULAR`

  params contains four fixed-point or floating-point values that specify the specular RGBA reflectance of the material. The values are not clamped. The initial specular reflectance is (0, 0, 0, 1).

`GL_EMISSION`

  params contains four fixed-point or floating-point values that specify the RGBA emitted light intensity of the material. The values are not clamped. The initial emission intensity is (0, 0, 0, 1).

`GL_SHININESS`

  params is a single fixed-point or floating-point value that specifies the RGBA specular exponent of the material. Only values in the range [0, 128] are accepted. The initial specular exponent 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`.

## Notes

To change the diffuse and ambient material per vertex, color material can be used. To enable and disable `GL_COLOR_MATERIAL`, call glEnable and glDisable with argument `GL_COLOR_MATERIAL`. Color material is initially disabled.

While the ambient, diffuse, specular and emission material parameters all have alpha components, only the diffuse alpha component is used in the lighting computation.

## Errors

`GL_INVALID_ENUM` is generated if either face or pname is not an accepted value.

`GL_INVALID_VALUE` is generated if a specular exponent outside the range [0, 128] is specified.

## Associated Gets

glGetMaterial

## See Also

glEnable, glLight, glLightModel

## Copyright

Copyright 2003-2004 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.