1GLMATERIAL(3G) GLMATERIAL(3G)
2
3
4
6 glMaterialf, glMateriali, glMaterialfv, glMaterialiv - specify material
7 parameters for the lighting model
8
9
11 void glMaterialf( GLenum face,
12 GLenum pname,
13 GLfloat param )
14 void glMateriali( GLenum face,
15 GLenum pname,
16 GLint param )
17
18
20 face Specifies which face or faces are being updated. Must be one
21 of GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.
22
23 pname Specifies the single-valued material parameter of the face or
24 faces that is being updated. Must be GL_SHININESS.
25
26 param Specifies the value that parameter GL_SHININESS will be set to.
27
29 void glMaterialfv( GLenum face,
30 GLenum pname,
31 const GLfloat *params )
32 void glMaterialiv( GLenum face,
33 GLenum pname,
34 const GLint *params )
35
36
38 face Specifies which face or faces are being updated. Must be one of
39 GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.
40
41 pname Specifies the material parameter of the face or faces that is
42 being updated. Must be one of GL_AMBIENT, GL_DIFFUSE,
43 GL_SPECULAR, GL_EMISSION, GL_SHININESS, GL_AMBIENT_AND_DIFFUSE,
44 or GL_COLOR_INDEXES.
45
46 params Specifies a pointer to the value or values that pname will be
47 set to.
48
50 glMaterial assigns values to material parameters. There are two
51 matched sets of material parameters. One, the front-facing set, is
52 used to shade points, lines, bitmaps, and all polygons (when two-sided
53 lighting is disabled), or just front-facing polygons (when two-sided
54 lighting is enabled). The other set, back-facing, is used to shade
55 back-facing polygons only when two-sided lighting is enabled. Refer to
56 the glLightModel reference page for details concerning one- and two-
57 sided lighting calculations.
58
59 glMaterial takes three arguments. The first, face, specifies whether
60 the GL_FRONT materials, the GL_BACK materials, or both
61 GL_FRONT_AND_BACK materials will be modified. The second, pname, spec‐
62 ifies which of several parameters in one or both sets will be modified.
63 The third, params, specifies what value or values will be assigned to
64 the specified parameter.
65
66 Material parameters are used in the lighting equation that is option‐
67 ally applied to each vertex. The equation is discussed in the
68 glLightModel reference page. The parameters that can be specified
69 using glMaterial, and their interpretations by the lighting equation,
70 are as follows:
71
72 GL_AMBIENT params contains four integer or floating-point val‐
73 ues that specify the ambient RGBA reflectance of
74 the material. Integer values are mapped linearly
75 such that the most positive representable value
76 maps to 1.0, and the most negative representable
77 value maps to -1.0. Floating-point values are
78 mapped directly. Neither integer nor floating-
79 point values are clamped. The initial ambient
80 reflectance for both front- and back-facing materi‐
81 als is (0.2, 0.2, 0.2, 1.0).
82
83 GL_DIFFUSE params contains four integer or floating-point val‐
84 ues that specify the diffuse RGBA reflectance of
85 the material. Integer values are mapped linearly
86 such that the most positive representable value
87 maps to 1.0, and the most negative representable
88 value maps to -1.0. Floating-point values are
89 mapped directly. Neither integer nor floating-
90 point values are clamped. The initial diffuse
91 reflectance for both front- and back-facing materi‐
92 als is (0.8, 0.8, 0.8, 1.0).
93
94 GL_SPECULAR params contains four integer or floating-point val‐
95 ues that specify the specular RGBA reflectance of
96 the material. Integer values are mapped linearly
97 such that the most positive representable value
98 maps to 1.0, and the most negative representable
99 value maps to -1.0. Floating-point values are
100 mapped directly. Neither integer nor floating-
101 point values are clamped. The initial specular
102 reflectance for both front- and back-facing materi‐
103 als is (0, 0, 0, 1).
104
105 GL_EMISSION params contains four integer or floating-point val‐
106 ues that specify the RGBA emitted light intensity
107 of the material. Integer values are mapped lin‐
108 early such that the most positive representable
109 value maps to 1.0, and the most negative repre‐
110 sentable value maps to -1.0. Floating-point values
111 are mapped directly. Neither integer nor floating-
112 point values are clamped. The initial emission
113 intensity for both front- and back-facing materials
114 is (0, 0, 0, 1).
115
116 GL_SHININESS params is a single integer or floating-point value
117 that specifies the RGBA specular exponent of the
118 material. Integer and floating-point values are
119 mapped directly. Only values in the range [0,128]
120 are accepted. The initial specular exponent for
121 both front- and back-facing materials is 0.
122
123 GL_AMBIENT_AND_DIFFUSE
124 Equivalent to calling glMaterial twice with the
125 same parameter values, once with GL_AMBIENT and
126 once with GL_DIFFUSE.
127
128 GL_COLOR_INDEXES params contains three integer or floating-point
129 values specifying the color indices for ambient,
130 diffuse, and specular lighting. These three val‐
131 ues, and GL_SHININESS, are the only material values
132 used by the color index mode lighting equation.
133 Refer to the glLightModel reference page for a dis‐
134 cussion of color index lighting.
135
137 The material parameters can be updated at any time. In particular,
138 glMaterial can be called between a call to glBegin and the correspond‐
139 ing call to glEnd. If only a single material parameter is to be
140 changed per vertex, however, glColorMaterial is preferred over
141 glMaterial (see glColorMaterial).
142
143 While the ambient, diffuse, specular and emission material parameters
144 all have alpha components, only the diffuse alpha component is used in
145 the lighting computation.
146
148 GL_INVALID_ENUM is generated if either face or pname is not an accepted
149 value.
150
151 GL_INVALID_VALUE is generated if a specular exponent outside the range
152 [0,128] is specified.
153
155 glGetMaterial
156
158 glColorMaterial(3G), glLight(3G), glLightModel(3G)
159
160
161
162 GLMATERIAL(3G)