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