forked from BSVino/docs.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glTexParameter.xhtml
370 lines (311 loc) · 22.3 KB
/
glTexParameter.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<div class="refentry" title="glTexParameter"><a id="glTexParameter"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glTexParameter — set texture parameters</p></div><div class="refsynopsisdiv" title="C Specification"><h2>C Specification</h2><div class="funcsynopsis"><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glTexParameterf</b>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfloat <var class="pdparam">param</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glTexParameteri</b>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLint <var class="pdparam">param</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glTexParameterx</b>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfixed <var class="pdparam">param</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Parameters"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term">
<em class="parameter"><code>target</code></em>
</span></dt><dd><p>Specifies the target texture, which must be
<code class="constant">GL_TEXTURE_2D</code>.</p></dd><dt><span class="term">
<em class="parameter"><code>pname</code></em>
</span></dt><dd><p>Specifies the symbolic name of a single-valued texture
parameter. Which can be one of the following:
<code class="constant">GL_TEXTURE_MIN_FILTER</code>,
<code class="constant">GL_TEXTURE_MAG_FILTER</code>,
<code class="constant">GL_TEXTURE_WRAP_S</code>,
<code class="constant">GL_TEXTURE_WRAP_T</code>, or
<code class="constant">GL_GENERATE_MIPMAP</code>.</p></dd><dt><span class="term">
<em class="parameter"><code>param</code></em>
</span></dt><dd><p>Specifies the value of <em class="parameter"><code>pname</code></em>.</p></dd></dl></div></div><div class="refsynopsisdiv" title="C Specification"><h2>C Specification</h2><div class="funcsynopsis"><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glTexParameterfv</b>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfloat * <var class="pdparam">params</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glTexParameteriv</b>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLint * <var class="pdparam">params</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">glTexParameterxv</b>(</code></td><td>GLenum <var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLenum <var class="pdparam">pname</var>, </td></tr><tr><td> </td><td>GLfixed * <var class="pdparam">params</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Parameters"><a id="parameters2"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term">
<em class="parameter"><code>target</code></em>
</span></dt><dd><p>Specifies the target texture, which must be
<code class="constant">GL_TEXTURE_2D</code>.</p></dd><dt><span class="term">
<em class="parameter"><code>pname</code></em>
</span></dt><dd><p>Specifies the symbolic name of a texture parameter. Which can
be one of the following: <code class="constant">GL_TEXTURE_MIN_FILTER</code>,
<code class="constant">GL_TEXTURE_MAG_FILTER</code>,
<code class="constant">GL_TEXTURE_WRAP_S</code>,
<code class="constant">GL_TEXTURE_WRAP_T</code>, or
<code class="constant">GL_GENERATE_MIPMAP</code>.</p></dd><dt><span class="term">
<em class="parameter"><code>params</code></em>
</span></dt><dd><p>Specifies a pointer to an array where the value or values of
<em class="parameter"><code>pname</code></em> are stored.</p></dd></dl></div></div><div class="refsect1" title="Description"><a id="description"></a><h2>Description</h2><p>Texture mapping is a technique that applies an image onto an
object's surface as if the image were a decal or cellophane shrink-wrap.
The image is created in texture space, with an <math overflow="scroll">
<mfenced>
<mi>s</mi>
<mi>t</mi>
</mfenced>
</math> coordinate system. A texture is a one- or
two-dimensional image and a set of parameters that determine how samples
are derived from the image.</p><p><code class="function">glTexParameter</code> assigns the value in
<em class="parameter"><code>param</code></em> or <em class="parameter"><code>params</code></em> to the
texture parameter specified as <em class="parameter"><code>pname</code></em>.
<em class="parameter"><code>target</code></em> defines the target texture, which must be
<code class="constant">GL_TEXTURE_2D</code>.</p><p>The following symbols are accepted in
<em class="parameter"><code>pname</code></em>:</p><div class="variablelist"><dl><dt><span class="term">
<code class="constant">GL_TEXTURE_MIN_FILTER</code>
</span></dt><dd><p>The texture minifying function is used whenever the pixel
being textured maps to an area greater than one texture element.
There are six defined minifying functions. Two of them use the
nearest one or nearest four texture elements to compute the texture
value. The other four use mipmaps.</p><p>A mipmap is an ordered set of arrays representing the same
image at progressively lower resolutions. If the texture has
dimensions <math overflow="scroll">
<msup>
<mn>2</mn>
<mi>n</mi>
</msup>
<mo>x</mo>
<msup>
<mn>2</mn>
<mi>m</mi>
</msup>
</math>, there are <math overflow="scroll">
<mo>max</mo>
<mfenced>
<mi>n</mi>
<mi>m</mi>
</mfenced>
<mo>+</mo>
<mn>1</mn>
</math> mipmaps. The first mipmap is the original
texture, with dimensions <math overflow="scroll">
<msup>
<mn>2</mn>
<mi>n</mi>
</msup>
<mo>x</mo>
<msup>
<mn>2</mn>
<mi>m</mi>
</msup>
</math>. Each subsequent mipmap has dimensions
<math overflow="scroll">
<msup>
<mn>2</mn>
<mrow>
<mi>k</mi>
<mo>-</mo>
<mn>1</mn>
</mrow>
</msup>
<mo>x</mo>
<msup>
<mn>2</mn>
<mrow>
<mi>l</mi>
<mo>-</mo>
<mn>1</mn>
</mrow>
</msup>
</math>, where <math overflow="scroll">
<msup>
<mn>2</mn>
<mi>k</mi>
</msup>
<mo>x</mo>
<msup>
<mn>2</mn>
<mi>l</mi>
</msup>
</math> are the dimensions of the previous mipmap, until
either <math overflow="scroll">
<mi>k</mi>
<mo>=</mo>
<mn>0</mn>
</math> or <math overflow="scroll">
<mi>l</mi>
<mo>=</mo>
<mn>0</mn>
</math>. At that point, subsequent mipmaps have
dimension <math overflow="scroll">
<mn>1</mn>
<mo>x</mo>
<msup>
<mn>2</mn>
<mrow>
<mi>l</mi>
<mo>-</mo>
<mn>1</mn>
</mrow>
</msup>
</math> or <math overflow="scroll">
<msup>
<mn>2</mn>
<mrow>
<mi>k</mi>
<mo>-</mo>
<mn>1</mn>
</mrow>
</msup>
<mo>x</mo>
<mn>1</mn>
</math> until the final mipmap, which has dimension
<math overflow="scroll">
<mn>1</mn>
<mo>x</mo>
<mn>1</mn>
</math>. To define the mipmaps, call <a class="citerefentry" href="glTexImage2D"><span class="citerefentry"><span class="refentrytitle">glTexImage2D</span></span></a> or <a class="citerefentry" href="glCopyTexImage2D"><span class="citerefentry"><span class="refentrytitle">glCopyTexImage2D</span></span></a> with the <em class="parameter"><code>level</code></em> argument
indicating the order of the mipmaps. Level 0 is the original
texture. Level <math overflow="scroll">
<mo>max</mo>
<mfenced>
<mi>n</mi>
<mi>m</mi>
</mfenced>
</math> is the final <math overflow="scroll">
<mn>1</mn>
<mo>x</mo>
<mn>1</mn>
</math> mipmap.</p><p><em class="parameter"><code>param</code></em> supplies a function for minifying
the texture as one of the following:</p><p>
</p><div class="variablelist"><dl><dt><span class="term">
<code class="constant">GL_NEAREST</code>
</span></dt><dd><p>Returns the value of the texture element that is nearest (in
Manhattan distance) to the center of the pixel being
textured.</p></dd><dt><span class="term">
<code class="constant">GL_LINEAR</code>
</span></dt><dd><p>Returns the weighted average of the four texture elements
that are closest to the center of the pixel being textured. These
can include repeated or wrapped elements, depending on the values
of <code class="constant">GL_TEXTURE_WRAP_S</code> and
<code class="constant">GL_TEXTURE_WRAP_T</code>, and on the exact
mapping.</p></dd><dt><span class="term">
<code class="constant">GL_NEAREST_MIPMAP_NEAREST</code>
</span></dt><dd><p>Chooses the mipmap that most closely matches the size of the
pixel being textured and uses the <code class="constant">GL_NEAREST</code>
criterion (the texture element nearest to the center of the pixel)
to produce a texture value.</p></dd><dt><span class="term">
<code class="constant">GL_LINEAR_MIPMAP_NEAREST</code>
</span></dt><dd><p>Chooses the mipmap that most closely matches the size of the
pixel being textured and uses the <code class="constant">GL_LINEAR</code>
criterion (a weighted average of the four texture elements that
are closest to the center of the pixel) to produce a texture
value.</p></dd><dt><span class="term">
<code class="constant">GL_NEAREST_MIPMAP_LINEAR</code>
</span></dt><dd><p>Chooses the two mipmaps that most closely match the size of
the pixel being textured and uses the
<code class="constant">GL_NEAREST</code> criterion (the texture element
nearest to the center of the pixel) to produce a texture value
from each mipmap. The final texture value is a weighted average of
those two values.</p></dd><dt><span class="term">
<code class="constant">GL_LINEAR_MIPMAP_LINEAR</code>
</span></dt><dd><p>Chooses the two mipmaps that most closely match the size of
the pixel being textured and uses the
<code class="constant">GL_LINEAR</code> criterion (a weighted average of
the four texture elements that are closest to the center of the
pixel) to produce a texture value from each mipmap. The final
texture value is a weighted average of those two values.</p><p>As more texture elements are sampled in the minification
process, fewer aliasing artifacts will be apparent. While the
<code class="constant">GL_NEAREST</code> and <code class="constant">GL_LINEAR</code>
minification functions can be faster than the other four, they
sample only one or four texture elements to determine the texture
value of the pixel being rendered and can produce moire patterns
or ragged transitions.</p></dd></dl></div><p>
</p><p>The initial value of <code class="constant">GL_TEXTURE_MIN_FILTER</code> is
<code class="constant">GL_NEAREST_MIPMAP_LINEAR</code>.</p></dd><dt><span class="term">
<code class="constant">GL_TEXTURE_MAG_FILTER</code>
</span></dt><dd><p>The texture magnification function is used when the pixel
being textured maps to an area less than or equal to one texture
element. It sets the texture magnification function to either
<code class="constant">GL_NEAREST</code> or <code class="constant">GL_LINEAR</code>
(see below). <code class="constant">GL_NEAREST</code> is generally faster
than <code class="constant">GL_LINEAR</code>, but it can produce textured
images with sharper edges because the transition between texture
elements is not as smooth.</p><p>
</p><div class="variablelist"><dl><dt><span class="term">
<code class="constant">GL_NEAREST</code>
</span></dt><dd><p>Returns the value of the texture element that is nearest (in
Manhattan distance) to the center of the pixel being
textured.</p></dd><dt><span class="term">
<code class="constant">GL_LINEAR</code>
</span></dt><dd><p>Returns the weighted average of the four texture elements
that are closest to the center of the pixel being textured. These
can include repeated or wrapped elements, depending on the values
of <code class="constant">GL_TEXTURE_WRAP_S</code> and
<code class="constant">GL_TEXTURE_WRAP_T</code>, and on the exact
mapping.</p></dd></dl></div><p>
</p><p>The initial value of <code class="constant">GL_TEXTURE_MAG_FILTER</code> is
<code class="constant">GL_LINEAR</code>.</p></dd><dt><span class="term">
<code class="constant">GL_TEXTURE_WRAP_S</code>
</span></dt><dd><p>Sets the wrap parameter for texture coordinate
<em class="replaceable"><code>s</code></em> to either
<code class="constant">GL_CLAMP_TO_EDGE</code> or
<code class="constant">GL_REPEAT</code>.</p><p>
</p><div class="variablelist"><dl><dt><span class="term">
<code class="constant">GL_CLAMP_TO_EDGE</code>
</span></dt><dd><p>causes <em class="replaceable"><code>s</code></em> coordinates to be
clamped to the range <math overflow="scroll">
<mo>[</mo>
<mfrac>
<mn>1</mn>
<mrow>
<mn>2</mn>
<mi>N</mi>
</mrow>
</mfrac>
<mo>,</mo>
<mn>1</mn>
<mo>-</mo>
<mfrac>
<mn>1</mn>
<mrow>
<mn>2</mn>
<mi>N</mi>
</mrow>
</mfrac>
<mo>]</mo>
</math>, where <em class="replaceable"><code>N</code></em> is the
size of the texture in the direction of clamping.</p></dd><dt><span class="term">
<code class="constant">GL_REPEAT</code>
</span></dt><dd><p>causes the integer part of the
<em class="replaceable"><code>s</code></em> coordinate to be ignored; the GL
uses only the fractional part, thereby creating a repeating
pattern.</p></dd></dl></div><p>
</p><p>The initial value of <code class="constant">GL_TEXTURE_WRAP_S</code> is
<code class="constant">GL_REPEAT</code>.</p></dd><dt><span class="term">
<code class="constant">GL_TEXTURE_WRAP_T</code>
</span></dt><dd><p>Sets the wrap parameter for texture coordinate
<em class="replaceable"><code>t</code></em> to either
<code class="constant">GL_CLAMP_TO_EDGE</code> or
<code class="constant">GL_REPEAT</code>. See the discussion under
<code class="constant">GL_TEXTURE_WRAP_S</code>.</p><p>The initial value of <code class="constant">GL_TEXTURE_WRAP_T</code> is
<code class="constant">GL_REPEAT</code>.</p></dd><dt><span class="term">
<code class="constant">GL_GENERATE_MIPMAP</code>
</span></dt><dd><p>Sets the automatic mipmap generation parameter. If set to
<code class="constant">GL_TRUE</code>, making any change to the interior
texels of the <math overflow="scroll">
<msub>
<mi>level</mi>
<mi>base</mi>
</msub>
</math> array of a mipmap will also compute a complete
set of mipmap arrays derived from the modified <math overflow="scroll">
<msub>
<mi>level</mi>
<mi>base</mi>
</msub>
</math> array. Array levels <math overflow="scroll"><msub>
<mi>level</mi>
<mi>base</mi>
</msub> <mo>+</mo><mi>1</mi> through
<mi>p</mi></math> are replaced with the derived arrays, regardless
of their previous contents. All other mipmap arrays, including the
<math overflow="scroll">
<msub>
<mi>level</mi>
<mi>base</mi>
</msub>
</math> array, are left unchanged by this
computation.</p><p>The initial value of <code class="constant">GL_GENERATE_MIPMAP</code>
is <code class="constant">GL_FALSE</code>.</p></dd></dl></div></div><div class="refsect1" title="Notes"><a id="notes"></a><h2>Notes</h2><p>Suppose that a program has enabled texturing (by calling
<a class="citerefentry" href="glEnable"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a> with argument <code class="constant">GL_TEXTURE_2D</code> and has
set <code class="constant">GL_TEXTURE_MIN_FILTER</code> to one of the functions
that requires a mipmap. If either the dimensions of the texture images
currently defined (with previous calls to <a class="citerefentry" href="glTexImage2D"><span class="citerefentry"><span class="refentrytitle">glTexImage2D</span></span></a>, or <a class="citerefentry" href="glCopyTexImage2D"><span class="citerefentry"><span class="refentrytitle">glCopyTexImage2D</span></span></a>) do not follow the proper sequence for mipmaps
(described above), or there are fewer texture images defined than are
needed, or the set of texture images have differing numbers of texture
components, then it is as if texture mapping were disabled.</p><p>Linear filtering accesses the four nearest texture elements.</p><p><code class="function">glTexParameter</code> specifies the texture parameters
for the texture bound to the active texture unit, specified by calling <a class="citerefentry" href="glActiveTexture"><span class="citerefentry"><span class="refentrytitle">glActiveTexture</span></span></a>.</p></div><div class="refsect1" title="Errors"><a id="errors"></a><h2>Errors</h2><p><code class="constant">GL_INVALID_ENUM</code> is generated if
<em class="parameter"><code>target</code></em> or <em class="parameter"><code>pname</code></em> is not one
of the accepted defined values.</p><p><code class="constant">GL_INVALID_ENUM</code> is generated if
<em class="parameter"><code>param</code></em> should have a defined constant value (based
on the value of <em class="parameter"><code>pname</code></em>) and does not.</p></div><div class="refsect1" title="See Also"><a id="seealso"></a><h2>See Also</h2><p><a class="citerefentry" href="glActiveTexture"><span class="citerefentry"><span class="refentrytitle">glActiveTexture</span></span></a>, <a class="citerefentry" href="glBindTexture"><span class="citerefentry"><span class="refentrytitle">glBindTexture</span></span></a>, <a class="citerefentry" href="glCopyTexImage2D"><span class="citerefentry"><span class="refentrytitle">glCopyTexImage2D</span></span></a>, <a class="citerefentry" href="glCopyTexSubImage2D"><span class="citerefentry"><span class="refentrytitle">glCopyTexSubImage2D</span></span></a>, <a class="citerefentry" href="glEnable"><span class="citerefentry"><span class="refentrytitle">glEnable</span></span></a>, <a class="citerefentry" href="glPixelStorei"><span class="citerefentry"><span class="refentrytitle">glPixelStorei</span></span></a>, <a class="citerefentry" href="glTexEnv"><span class="citerefentry"><span class="refentrytitle">glTexEnv</span></span></a>, <a class="citerefentry" href="glTexImage2D"><span class="citerefentry"><span class="refentrytitle">glTexImage2D</span></span></a>, <a class="citerefentry" href="glTexSubImage2D"><span class="citerefentry"><span class="refentrytitle">glTexSubImage2D</span></span></a></p></div><div class="refsect1" title="Copyright"><a id="copyright"></a><h2>Copyright</h2><p>Copyright © 2003-2004 Silicon
Graphics, Inc. This document is licensed under the SGI Free Software B
</p></div></div>