glGetMaterialfv, glGetMaterialiv

The glGetMaterialfv and glGetMaterialiv functions return material parameters.

void glGetMaterialfv(
  GLenum face,
  GLenum pname,
  GLfloat *params
);

void glGetMaterialiv(
  GLenum face,
  GLenum pname,
  GLint *params
);

Parameters

face
Specifies which of the two materials is being queried. GL_FRONT or GL_BACK are accepted, representing the front and back materials, respectively.
pname
The material parameter to return. The following values are accepted:
Value Meaning
GL_AMBIENT The params parameter returns four integer or floating-point values representing the ambient reflectance of the material. Integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value, and 1.0 maps to the most negative representable integer value. If the internal value is outside the range [1,1], the corresponding integer return value is undefined.
GL_DIFFUSE The params parameter returns four integer or floating-point values representing the diffuse reflectance of the material. Integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value, and 1.0 maps to the most negative representable integer value. If the internal value is outside the range [1,1], the corresponding integer return value is undefined.
GL_SPECULAR The params parameter returns four integer or floating-point values representing the specular reflectance of the material. Integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value, and 1.0 maps to the most negative representable integer value. If the internal value is outside the range [1,1], the corresponding integer return value is undefined.
GL_EMISSION The params parameter returns four integer or floating-point values representing the emitted light intensity of the material. Integer values, when requested, are linearly mapped from the internal floating-point representation such that 1.0 maps to the most positive representable integer value, and 1.0 maps to the most negative representable integer value. If the internal value is outside the range [1,1], the corresponding integer return value is undefined.
GL_SHININESS The params parameter returns one integer or floating-point value representing the specular exponent of the material. Integer values, when requested, are computed by rounding the internal floating-point value to the nearest integer value.
GL_COLOR_INDEXES The params parameter returns three integer or floating-point values representing the ambient, diffuse, and specular indexes of the material. Use these indexes only for color-index lighting. (The other parameters are all used only for RGBA lighting.) Integer values, when requested, are computed by rounding the internal floating-point values to the nearest integer values.

params
Returns the requested data.

Remarks

The glGetMaterial function returns in params the value or values of parameter pname of material face.

If an error is generated, no change is made to the contents of params.

Error Codes

The following are the error codes generated and their conditions.

Error code Condition
GL_INVALID_ENUM face or pname was not an accepted value.
GL_INVALID_OPERATION glGetMaterial was called between a call to glBegin and the corresponding call to glEnd.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Gl.h.
  Library: Use Opengl32.lib.

See Also

glBegin, glEnd, glMaterial


  

Community Additions

Show: