error = glu.Build2DMipmaps(iformat, width, height, format, type, pixels)
glu.Build2DMipmaps()builds a series of prefiltered 2D texture maps of decreasing resolution. Mipmaps can be used so that textures don't appear aliased.
A return value of 0 indicates success. Otherwise a GLU error code is returned (See glu.ErrorString for details.).
glu.Build2DMipmaps() first check whether
pixels are both powers of 2. If not,
glu.Build2DMipmaps() scales a
pixels up or down to the nearest power of 2. This copy is then used as the base for subsequent mipmapping operations. For
width is 57 and
height is 23, then a copy of
pixels scales up to 64 and down to 16, respectively, before mipmapping
takes place. (If
height is exactly between powers of 2, the copy of data is scaled upward.)
If the GL version is 1.1 or greater,
glu.Build2DMipmaps() then uses proxy textures (See gl.TexImage2D for details.) to determine
whether there's enough room for the requested texture in the implementation. If not,
width is halved (and halved again) until it fits.
glu.Build2DMipmaps() then uses proxy textures (See gl.TexImage2D for details.) to determine if the implementation can store the
requested texture in texture memory. If not, both dimensions are continually halved until it fits.
glu.Build2DMipmaps() builds a series of images; it halves a copy of
type (or a scaled version of
type, if necessary) along
both dimensions until size 1x1 is reached. At each level, each texel in the halved mipmap is an average of the corresponding four
texels in the larger mipmap. (In the case of rectangular images, halving the images repeatedly eventually results in an n*1 or 1*n
configuration. Here, two texels are averaged instead.)
gl.TexImage2D() is called to load each of these images by level. If
height are both powers of 2
which fit in the implementation, level 0 is a copy of
pixels, and the highest level is log2(max(width, height)). For example, if
width is 64 and
height is 16, the following mipmaps are built: 64x16, 32x8, 16x4, 8x2, 4x1, 2x1 and 1x1. These correspond to levels
0 through 6, respectively.
iformat specifies the internal format of the texture image. See Internal pixel formats for details.
This can also be one of the special values 1, 2, 3, or 4.
format must be one of
type must be one of
Please note that this command operates directly with memory pointers. There is also a version which works with tables instead of memory pointers, but this is slower of course. See glu.BuildMipmaps for details. See Working with pointers for details on how to use memory pointers with Hollywood.
Please consult an OpenGL reference manual for more information.