glMaterial

specify material parameters for the lighting model

Signature

glMaterial( )->
glMaterial( faces , constant , * args )
glMaterial -- convenience function to dispatch on argument type

    If passed a single argument in args, calls:
        glMaterialfv( faces, constant, args[0] )
    else calls:
        glMaterialf( faces, constant, *args )
    
glMaterialf( GLenum ( face ) , GLenum ( pname ) , GLfloat ( param ) )-> void
glMaterialf( face , pname , param )
glMaterialfv( GLenum ( face ) , GLenum ( pname ) , const GLfloat * ( params ) )-> void
glMaterialfv( face , pname , params )
glMateriali( GLenum ( face ) , GLenum ( pname ) , GLint ( param ) )-> void
glMateriali( face , pname , param )
glMaterialiv( GLenum ( face ) , GLenum ( pname ) , const GLint * ( params ) )-> void
glMaterialiv( face , pname , params )

Parameters

VariablesDescription
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 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.
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 GL_AMBIENT , GL_DIFFUSE , GL_SPECULAR , GL_EMISSION , GL_SHININESS , GL_AMBIENT_AND_DIFFUSE , or GL_COLOR_INDEXES .
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, bitmaps, 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 , specifies whether the GL_FRONT materials, the GL_BACK materials, or both GL_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 integer or floating-point values that specify the ambient 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 initial ambient reflectance for both front- and back-facing materials is (0.2, 0.2, 0.2, 1.0).
GL_DIFFUSE
params 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 initial diffuse reflectance for both front- and back-facing materials is (0.8, 0.8, 0.8, 1.0).
GL_SPECULAR
params 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 initial specular reflectance for both front- and back-facing materials is (0, 0, 0, 1).
GL_EMISSION
params 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 initial emission intensity for both front- and back-facing materials is (0, 0, 0, 1).
GL_SHININESS
params 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 initial specular exponent for both front- and back-facing 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
params 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. Refer to the glLightModel reference page 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 glBegin and the corresponding call to glEnd . If only a single material parameter is to be changed per vertex, however, glColorMaterial is preferred over glMaterial (see glColorMaterial ).
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

See Also

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glMaterial
Visvis wobjects/polygonalModeling.py Lines: 1002, 1003, 1004, 1005, 1006
glMaterialf
OpenGLContext OpenGLContext/scenegraph/material.py Lines: 89
OpenGL-Demo PyOpenGL-Demo/proesch/nurbs/nurbs.py Lines: 180
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 82
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 112
{LGPL} PyMT pymt/obj.py Lines: 22, 52
{GPL3} OpenGL-Programmable 05-shader.py Lines: 329
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 348
{GPL3} OpenGL-Programmable 03-array.py Lines: 254
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 337
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 252
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 273
{GPL3} OpenGL-Programmable 01-direct.py Lines: 243
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 370
glMaterialfv
OpenGLContext OpenGLContext/scenegraph/material.py Lines: 88
OpenGLContext tests/redbook_alpha3D.py Lines: 76, 77, 127, 128, 136, 137
OpenGLContext tests/redbook_surface.py Lines: 61, 62, 63
OpenGLContext tests/redbook_trim.py Lines: 89, 90, 91
OpenGLContext tests/redbook_surface_cb.py Lines: 78, 79, 80
OpenGL-Demo PyOpenGL-Demo/proesch/stereo/stereoDemo.py Lines: 119, 120, 121
OpenGL-Demo PyOpenGL-Demo/proesch/bezier/bezier.py Lines: 128, 129, 130
OpenGL-Demo PyOpenGL-Demo/proesch/nurbs/nurbs.py Lines: 154, 155, 159, 160, 179
OpenGL-Demo PyOpenGL-Demo/GLUT/gears.py Lines: 237, 243, 249
OpenGL-Demo PyOpenGL-Demo/GLUT/molehill.py Lines: 143, 144, 147, 154, 161, 168
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/text.py Lines: 77
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 33, 34, 35, 36
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 77, 79, 81
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 107, 109, 111
OpenGL-Demo PyOpenGL-Demo/tom/pick.py Lines: 15, 17
OpenGL-Demo PyOpenGL-Demo/tom/demo.py Lines: 82
OpenGL-Demo PyOpenGL-Demo/tom/conechecker.py Lines: 31, 32, 33, 34
OpenGL-Demo PyOpenGL-Demo/tom/conesave.py Lines: 14, 15, 16, 17
OpenGL-Demo PyOpenGL-Demo/tom/fog.py Lines: 58, 59, 60, 61
OpenGL-Demo PyOpenGL-Demo/tom/text.py Lines: 12
OpenGL-Demo PyOpenGL-Demo/tom/cone.py Lines: 9, 10, 11, 12
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 77, 78, 79, 80, 81
{Artistic License} PymmLib pymmlib/mmLib/OpenGLDriver.py Lines: 384, 385, 386, 387, 388, 411, 412, 413, 414, 415
{LGPL} PyMT pymt/obj.py Lines: 21, 48, 49, 50, 51
{GPL3} OpenGL-Programmable 05-shader.py Lines: 328
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 347
{GPL3} OpenGL-Programmable 03-array.py Lines: 253
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 336
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 251
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 272
{GPL3} OpenGL-Programmable 01-direct.py Lines: 242
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 369

MathML Rendering

Powered by MathJax