summaryrefslogtreecommitdiff
path: root/xc/extras/ogl-sample/main/doc/man/manglu/standard/build2dmipmaps.gl
blob: 73c2494bcf5f7599ca7841cc4162f216bec2e14e (plain)
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
_C_ License Applicability. Except to the extent portions of this file are
_C_ made subject to an alternative license as permitted in the SGI Free
_C_ Software License B, Version 1.1 (the "License"), the contents of this
_C_ file are subject only to the provisions of the License. You may not use
_C_ this file except in compliance with the License. You may obtain a copy
_C_ of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
_C_ Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
_C_ 
_C_ http://oss.sgi.com/projects/FreeB
_C_ 
_C_ Note that, as provided in the License, the Software is distributed on an
_C_ "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
_C_ DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
_C_ CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
_C_ PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
_C_ 
_C_ Original Code. The Original Code is: OpenGL Sample Implementation,
_C_ Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
_C_ Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
_C_ Copyright in any portions created by third parties is as indicated
_C_ elsewhere herein. All Rights Reserved.
_C_ 
_C_ Additional Notice Provisions: The application programming interfaces
_C_ established by SGI in conjunction with the Original Code are The
_C_ OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
_C_ April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
_C_ 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
_C_ Window System(R) (Version 1.3), released October 19, 1998. This software
_C_ was created using the OpenGL(R) version 1.2.1 Sample Implementation
_C_ published by SGI, but has not been independently verified as being
_C_ compliant with the OpenGL(R) version 1.2.1 Specification.
_C_
_C_ $Date: 2001/03/19 17:45:27 $ $Revision: 1.1.1.1 $
_C_ The first character in this file must be an '_'!
_C_ Anything on a line after _C_ is ignored
_define(_filters,eqn)_C_
_C_      eqn is automatically replaced with neqn for nroff
_header(Build2DMipmaps, builds a two-dimensional mipmap)
_names(Build2DMipmaps)
.EQ
delim $$
.EN
.SH PARAMETERS
_phead(_param1)
Specifies the target texture.  Must be _const(TEXTURE_2D).
_phead(_param2)
Requests the internal storage format of the texture image.  The most
current version of the SGI implementation of GLU does not check this
value for validity before passing it on to the underlying OpenGL
implementation.  A value that is not accepted by the OpenGL
implementation will lead to an OpenGL error.  The benefit of not
checking this value at the GLU level is that OpenGL extensions can add
new internal texture formats without requiring a revision of the GLU
implementation.  Older implementations of GLU check this value and
raise a GLU error if it is not 1, 2, 3, or 4 or one of the following
symbolic constants:
_const(ALPHA),
_const(ALPHA4),
_const(ALPHA8),
_const(ALPHA12),
_const(ALPHA16),
_const(LUMINANCE),
_const(LUMINANCE4),
_const(LUMINANCE8),
_const(LUMINANCE12),
_const(LUMINANCE16),
_const(LUMINANCE_ALPHA),
_const(LUMINANCE4_ALPHA4),
_const(LUMINANCE6_ALPHA2),
_const(LUMINANCE8_ALPHA8),
_const(LUMINANCE12_ALPHA4),
_const(LUMINANCE12_ALPHA12),
_const(LUMINANCE16_ALPHA16),
_const(INTENSITY),
_const(INTENSITY4),
_const(INTENSITY8),
_const(INTENSITY12),
_const(INTENSITY16),
_const(RGB),
_const(R3_G3_B2),
_const(RGB4),
_const(RGB5),
_const(RGB8),
_const(RGB10),
_const(RGB12),
_const(RGB16),
_const(RGBA),
_const(RGBA2),
_const(RGBA4),
_const(RGB5_A1),
_const(RGBA8),
_const(RGB10_A2),
_const(RGBA12) or
_const(RGBA16).
_phead(_param3 _param4)
Specifies in pixels the width and height, respectively, of the texture image. 
_phead(_param5)
Specifies the format of the pixel data.
Must be one of
_const(COLOR_INDEX),
_const(DEPTH_COMPONENT),
_const(RED),
_const(GREEN),
_const(BLUE),
_const(ALPHA),
_const(RGB),
_const(RGBA),
_const(BGR),
_const(BGRA),
_const(LUMINANCE), or
_const(LUMINANCE_ALPHA).
_phead(_param6)
Specifies the data type for _param7.
Must be one of
_const(UNSIGNED_BYTE),
_const(BYTE),
_const(BITMAP),
_const(UNSIGNED_SHORT),
_const(SHORT),
_const(UNSIGNED_INT),
_const(INT), 
_const(FLOAT), 
_const(UNSIGNED_BYTE_3_3_2),
_const(UNSIGNED_BYTE_2_3_3_REV),
_const(UNSIGNED_SHORT_5_6_5),
_const(UNSIGNED_SHORT_5_6_5_REV),
_const(UNSIGNED_SHORT_4_4_4_4),
_const(UNSIGNED_SHORT_4_4_4_4_REV),
_const(UNSIGNED_SHORT_5_5_5_1),
_const(UNSIGNED_SHORT_1_5_5_5_REV),
_const(UNSIGNED_INT_8_8_8_8),
_const(UNSIGNED_INT_8_8_8_8_REV),
_const(UNSIGNED_INT_10_10_10_2), or
_const(UNSIGNED_INT_2_10_10_10_REV).
_phead(_param7)
Specifies a pointer to the image data in memory.


.SH DESCRIPTION
_cmnd builds a series of prefiltered two-dimensional texture maps of decreasing
resolutions called a mipmap. This is used for the antialiasing of
texture-mapped primitives.
.P
A return value of zero indicates success, otherwise a GLU error code is
returned (see _cmnd(ErrorString)).
.P
Initially, the _param3 and _param4 of _param7 are checked to see if they
are a power of 2. If not, a copy of _param7 (not _param7), is scaled up
or down to the nearest power of 2. This copy will be used for subsequent
mipmapping operations described below. (If _param3 or _param4 is exactly
between powers of 2, then the copy of _param7 will scale upwards.)  For
example, if _param3 is 57 and _param4 is 23 then a copy of _param7 will
scale up to 64 in _param3 and down to 16 in depth, before mipmapping takes
place.
.P
Then, proxy textures (see _glcmnd(TexImage2D)) are used to determine if
the implementation can fit the requested texture. If not, both dimensions
are continually halved until it fits. (If the OpenGL version is \(<= 1.0,
both maximum texture dimensions are clamped to the value returned
by _glcmnd(GetIntegerv) with the argument _const(MAX_TEXTURE_SIZE).)
.P
Next, a series of mipmap levels is built by decimating a copy of _param7
in half along both dimensions until size $1 ~times~ 1$ is reached. At
each level,
each texel in the halved mipmap level is an average of the corresponding
four texels in the larger mipmap level. (In the case of rectangular
images, the decimation will ultimately reach an $N ~times~ 1$ or
$1 ~times~ N$ configuration. Here, two texels are averaged instead.)
.P
_glcmnd(TexImage2D) is called to load each of these mipmap levels.
Level 0 is a copy of _param7.  The highest level is
${log sub 2} ( max (_eqnparam3,_eqnparam4))$.  For example,
if _param3 is 64 and _param4 is 16
and the implementation can store a texture of this size, the following
mipmap levels are built: $64 ~times~ 16$, $32 ~times~ 8$, $16 ~times~ 4$,
$8 ~times~ 2$, $4 ~times~ 1$, $2 ~times~ 1$ and $1 ~times~ 1$. These correspond to
levels 0 through 6, respectively.
.P
See the _glcmnd(TexImage1D) reference page for a description of the
acceptable values for _param5 parameter. See the _glcmnd(DrawPixels) 
reference page for a description of the acceptable values 
for _param6 parameter.
.SH NOTES

Note that there is no direct way of querying the maximum level. This can
be derived indirectly via _glcmnd(GetTexLevelParameter). First, query
for the width and height actually used at level 0.  (The width and
height may not be equal to _param3 and _param4 respectively since proxy
textures might have scaled them to fit the implementation.)  Then the
maximum level can be derived from the formula
${log sub 2}( max (_param3,_param4))$.
.SH NOTES
Formats _const(BGR), and _const(BGRA), and types 
_const(UNSIGNED_BYTE_3_3_2),
_const(UNSIGNED_BYTE_2_3_3_REV),
_const(UNSIGNED_SHORT_5_6_5),
_const(UNSIGNED_SHORT_5_6_5_REV),
_const(UNSIGNED_SHORT_4_4_4_4),
_const(UNSIGNED_SHORT_4_4_4_4_REV),
_const(UNSIGNED_SHORT_5_5_5_1),
_const(UNSIGNED_SHORT_1_5_5_5_REV),
_const(UNSIGNED_INT_8_8_8_8),
_const(UNSIGNED_INT_8_8_8_8_REV),
_const(UNSIGNED_INT_10_10_10_2), and
_const(UNSIGNED_INT_2_10_10_10_REV) are only available if the GL version 
is 1.2 or greater and if the GLU version is 1.3 or greater.
.SH ERRORS
_gluconst(INVALID_VALUE) is returned if _param3, or _param4 is < 1.
.P
_gluconst(INVALID_ENUM) is returned if _param2, _param5, or _param6 is not 
legal.
.P
_gluconst(INVALID_OPERATION) is returned if _param6 is _const(UNSIGNED_BYTE_3_3_2) or _const(UNSIGNED_BYTE_2_3_3_REV)
and _param5 is not _const(RGB).
.P
_gluconst(INVALID_OPERATION) is returned if _param6 is _const(UNSIGNED_SHORT_5_6_5) or _const(UNSIGNED_SHORT_5_6_5_REV)
and _param5 is not _const(RGB).
.P
_gluconst(INVALID_OPERATION) is returned if _param6 is _const(UNSIGNED_SHORT_4_4_4_4) or _const(UNSIGNED_SHORT_4_4_4_4_REV)
and _param5 is neither _const(RGBA) nor _const(BGRA).
.P
_gluconst(INVALID_OPERATION) is returned if _param6 is _const(UNSIGNED_SHORT_5_5_5_1) or _const(UNSIGNED_SHORT_1_5_5_5_REV)
and _param5 is neither _const(RGBA) nor _const(BGRA).
.P
_gluconst(INVALID_OPERATION) is returned if _param6 is _const(UNSIGNED_INT_8_8_8_8) or _const(UNSIGNED_INT_8_8_8_8_REV)
and _param5 is neither _const(RGBA) nor _const(BGRA).
.P
_gluconst(INVALID_OPERATION) is returned if _param6 is _const(UNSIGNED_INT_10_10_10_2) or _const(UNSIGNED_INT_2_10_10_10_REV)
and _param5 is neither _const(RGBA) nor _const(BGRA).
.SH SEE ALSO
_glcmnd(DrawPixels),
_glcmnd(TexImage1D),
_glcmnd(TexImage2D), 
_glcmnd(TexImage3D),
_cmnd(Build1DMipmaps),
_cmnd(Build3DMipmaps),
_cmnd(ErrorString), 
_glcmnd(GetTexImage),
_glcmnd(GetTexLevelParameter),
_cmnd(Build1DMipmapLevels),
_cmnd(Build2DMipmapLevels),
_cmnd(Build3DMipmapLevels)