1GLTEXGEN(3G) OpenGL Manual GLTEXGEN(3G)
2
3
4
6 glTexGen - control the generation of texture coordinates
7
9 void glTexGeni(GLenum coord, GLenum pname, GLint param);
10
11 void glTexGenf(GLenum coord, GLenum pname, GLfloat param);
12
13 void glTexGend(GLenum coord, GLenum pname, GLdouble param);
14
16 coord
17 Specifies a texture coordinate. Must be one of GL_S, GL_T, GL_R, or
18 GL_Q.
19
20 pname
21 Specifies the symbolic name of the texture-coordinate generation
22 function. Must be GL_TEXTURE_GEN_MODE.
23
24 param
25 Specifies a single-valued texture generation parameter, one of
26 GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP, or
27 GL_REFLECTION_MAP.
28
30 void glTexGeniv(GLenum coord, GLenum pname, const GLint * params);
31
32 void glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params);
33
34 void glTexGendv(GLenum coord, GLenum pname, const GLdouble * params);
35
37 coord
38 Specifies a texture coordinate. Must be one of GL_S, GL_T, GL_R, or
39 GL_Q.
40
41 pname
42 Specifies the symbolic name of the texture-coordinate generation
43 function or function parameters. Must be GL_TEXTURE_GEN_MODE,
44 GL_OBJECT_PLANE, or GL_EYE_PLANE.
45
46 params
47 Specifies a pointer to an array of texture generation parameters.
48 If pname is GL_TEXTURE_GEN_MODE, then the array must contain a
49 single symbolic constant, one of GL_OBJECT_LINEAR, GL_EYE_LINEAR,
50 GL_SPHERE_MAP, GL_NORMAL_MAP, or GL_REFLECTION_MAP. Otherwise,
51 params holds the coefficients for the texture-coordinate generation
52 function specified by pname.
53
55 glTexGen selects a texture-coordinate generation function or supplies
56 coefficients for one of the functions. coord names one of the (s, t,
57 r, q) texture coordinates; it must be one of the symbols GL_S, GL_T,
58 GL_R, or GL_Q. pname must be one of three symbolic constants:
59 GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, or GL_EYE_PLANE. If pname is
60 GL_TEXTURE_GEN_MODE, then params chooses a mode, one of
61 GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP, or
62 GL_REFLECTION_MAP. If pname is either GL_OBJECT_PLANE or GL_EYE_PLANE,
63 params contains coefficients for the corresponding texture generation
64 function.
65
66 If the texture generation function is GL_OBJECT_LINEAR, the function
67
68 g = p 1 × x o + p 2 × y o + p 3 × z o + p 4 × w o
69
70 is used, where g is the value computed for the coordinate named in
71 coord, p 1, p 2, p 3, and p 4 are the four values supplied in params,
72 and x o, y o, z o, and w o are the object coordinates of the vertex.
73 This function can be used, for example, to texture-map terrain using
74 sea level as a reference plane (defined by p 1, p 2, p 3, and p 4). The
75 altitude of a terrain vertex is computed by the GL_OBJECT_LINEAR
76 coordinate generation function as its distance from sea level; that
77 altitude can then be used to index the texture image to map white snow
78 onto peaks and green grass onto foothills.
79
80 If the texture generation function is GL_EYE_LINEAR, the function
81
82 g = p 1 ″ × x e + p 2 ″ × y e + p 3 ″ × z e + p 4 ″ × w e
83
84 is used, where
85
86 p 1 ″ p 2 ″ p 3 ″ p 4 ″ = p 1 p 2 p 3 p 4 M -1
87
88 and x e, y e, z e, and w e are the eye coordinates of the vertex, p 1,
89 p 2, p 3, and p 4 are the values supplied in params, and M is the
90 modelview matrix when glTexGen is invoked. If M is poorly conditioned
91 or singular, texture coordinates generated by the resulting function
92 may be inaccurate or undefined.
93
94 Note that the values in params define a reference plane in eye
95 coordinates. The modelview matrix that is applied to them may not be
96 the same one in effect when the polygon vertices are transformed. This
97 function establishes a field of texture coordinates that can produce
98 dynamic contour lines on moving objects.
99
100 If the texture generation function is GL_SPHERE_MAP and coord is either
101 GL_S or GL_T, s and t texture coordinates are generated as follows. Let
102 u be the unit vector pointing from the origin to the polygon vertex (in
103 eye coordinates). Let n sup prime be the current normal, after
104 transformation to eye coordinates. Let
105
106 f = f x f y f z T be the reflection vector such that
107
108 f = u - 2 n ″ n ″ T u
109
110 Finally, let m = 2 f x 2 + f y 2 + f z + 1 2. Then the values
111 assigned to the s and t texture coordinates are
112
113 s = f x m + 1 2
114
115 t = f y m + 1 2
116
117 To enable or disable a texture-coordinate generation function, call
118 glEnable() or glDisable() with one of the symbolic texture-coordinate
119 names (GL_TEXTURE_GEN_S, GL_TEXTURE_GEN_T, GL_TEXTURE_GEN_R, or
120 GL_TEXTURE_GEN_Q) as the argument. When enabled, the specified texture
121 coordinate is computed according to the generating function associated
122 with that coordinate. When disabled, subsequent vertices take the
123 specified texture coordinate from the current set of texture
124 coordinates. Initially, all texture generation functions are set to
125 GL_EYE_LINEAR and are disabled. Both s plane equations are (1, 0, 0,
126 0), both t plane equations are (0, 1, 0, 0), and all r and q plane
127 equations are (0, 0, 0, 0).
128
129 When the ARB_multitexture extension is supported, glTexGen sets the
130 texture generation parameters for the currently active texture unit,
131 selected with glActiveTexture().
132
134 GL_INVALID_ENUM is generated when coord or pname is not an accepted
135 defined value, or when pname is GL_TEXTURE_GEN_MODE and params is not
136 an accepted defined value.
137
138 GL_INVALID_ENUM is generated when pname is GL_TEXTURE_GEN_MODE, params
139 is GL_SPHERE_MAP, and coord is either GL_R or GL_Q.
140
141 GL_INVALID_OPERATION is generated if glTexGen is executed between the
142 execution of glBegin() and the corresponding execution of glEnd().
143
145 glGetTexGen()
146
147 glIsEnabled() with argument GL_TEXTURE_GEN_S
148
149 glIsEnabled() with argument GL_TEXTURE_GEN_T
150
151 glIsEnabled() with argument GL_TEXTURE_GEN_R
152
153 glIsEnabled() with argument GL_TEXTURE_GEN_Q
154
156 glActiveTexture(), glCopyPixels(), glCopyTexImage2D(),
157 glCopyTexSubImage1D(), glCopyTexSubImage2D(), glCopyTexSubImage3D(),
158 glTexEnv(), glTexImage1D(), glTexImage2D(), glTexImage3D(),
159 glTexParameter(), glTexSubImage1D(), glTexSubImage2D(),
160 glTexSubImage3D()
161
163 Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed
164 under the SGI Free Software B License. For details, see
165 http://oss.sgi.com/projects/FreeB/.
166
168 opengl.org
169
170
171
172opengl.org 07/13/2018 GLTEXGEN(3G)