glTexParameterf
, glTexParameterx
- set texture parameters
void glTexParameterf(GLenum target, GLenum pname, GLfloat param) void glTexParameterx(GLenum target, GLenum pname, GLfixed param)
target
Specifies the target texture, which must be GL_TEXTURE_2D
.
pname
Specifies the symbolic name of a single-valued texture parameter. Which can be one of the following: GL_TEXTURE_MIN_FILTER
, GL_TEXTURE_MAG_FILTER
, GL_TEXTURE_WRAP_S
, GL_TEXTURE_WRAP_T
, or GL_GENERATE_MIPMAP
.
param
Specifies the value of pname
.
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 (s, t) 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.
glTexParameter
assigns the value or values in param
to the texture parameter specified as pname
. target
defines the target texture, which must be GL_TEXTURE_2D
.
The following symbols are accepted in pname
:
GL_TEXTURE_MIN_FILTER
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.
A mipmap is an ordered set of arrays representing the same image at progressively lower resolutions. If the texture has dimensions 2n × 2m, there are max (n, m) + 1 mipmaps. The first mipmap is the original texture, with dimensions 2n × 2m. Each subsequent mipmap has dimensions 2k - 1 × 2l - 1, where 2k × 2l are the dimensions of the previous mipmap, until either k = 0 or l = 0. At that point, subsequent mipmaps have dimension 1 × 2l - 1 or 2k - 1 × 1 until the final mipmap, which has dimension 1 × 1. To define the mipmaps, call glTexImage2D
or glCopyTexImage2D
with the level
argument indicating the order of the mipmaps. Level 0 is the original texture. Level max (n, m) is the final 1 × 1 mipmap.
param
supplies a function for minifying the texture as one of the following:
GL_NEAREST
Returns the value of the texture element that is nearest (in Manhattan distance) to the center of the pixel being textured.
GL_LINEAR
Returns the weighted average of the four texture elements that are closest to the center of the pixel being textured. These can include border texture elements, depending on the values of GL_TEXTURE_WRAP_S
and GL_TEXTURE_WRAP_T
, and on the exact mapping.
GL_NEAREST_MIPMAP_NEAREST
Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_NEAREST
criterion (the texture element nearest to the center of the pixel) to produce a texture value.
GL_LINEAR_MIPMAP_NEAREST
Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_LINEAR
criterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value.
GL_NEAREST_MIPMAP_LINEAR
Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_NEAREST
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.
GL_LINEAR_MIPMAP_LINEAR
Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_LINEAR
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.
As more texture elements are sampled in the minification process, fewer aliasing artifacts will be apparent. While the GL_NEAREST
and GL_LINEAR
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.
The initial value of GL_TEXTURE_MIN_FILTER
is GL_NEAREST_MIPMAP_LINEAR
.
GL_TEXTURE_MAG_FILTER
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 GL_NEAREST
or GL_LINEAR
(see below). GL_NEAREST
is generally faster than GL_LINEAR
, but it can produce textured images with sharper edges because the transition between texture elements is not as smooth.
GL_NEAREST
Returns the value of the texture element that is nearest (in Manhattan distance) to the center of the pixel being textured.
GL_LINEAR
Returns the weighted average of the four texture elements that are closest to the center of the pixel being textured. These can include border texture elements, depending on the values of GL_TEXTURE_WRAP_S
and GL_TEXTURE_WRAP_T
, and on the exact mapping.
The initial value of GL_TEXTURE_MAG_FILTER
is GL_LINEAR
.
GL_TEXTURE_WRAP_S
Sets the wrap parameter for texture coordinate s to either GL_CLAMP
, GL_CLAMP_TO_EDGE
, or GL_REPEAT
.
GL_CLAMP
causes s coordinates to be clamped to the range [0, 1] and is useful for preventing wrapping artifacts when mapping a single image onto an object.
GL_CLAMP_TO_EDGE
causes s coordinates to be clamped to the range [ 1/2N , 1 - 1/2N ] , where N is the size of the texture in the direction of clamping.
GL_REPEAT
causes the integer part of the s coordinate to be ignored; the GL uses only the fractional part, thereby creating a repeating pattern. Border texture elements are accessed only if wrapping is set to GL_CLAMP
.
The initial value of GL_TEXTURE_WRAP_S
is GL_REPEAT
.
GL_TEXTURE_WRAP_T
Sets the wrap parameter for texture coordinate t to either GL_CLAMP
, GL_CLAMP_TO_EDGE
, or GL_REPEAT
. See the discussion under GL_TEXTURE_WRAP_S
.
The initial value of GL_TEXTURE_WRAP_T
is GL_REPEAT
.
GL_GENERATE_MIPMAP
Sets the automatic mipmap generation parameter. If set to GL_TRUE
, making any change to the interior or border texels of the levelbase array of a mipmap will also compute a complete set of mipmap arrays derived from the modified levelbase array. Array levels levelbase + 1 through p are replaced with the derived arrays, regardless of their previous contents. All other mipmap arrays, including the levelbase array, are left unchanged by this computation.
The initial value of GL_GENERATE_MIPMAP
is GL_FALSE
.
Suppose that a program has enabled texturing (by calling glEnable
with argument GL_TEXTURE_2D
and has set GL_TEXTURE_MIN_FILTER
to one of the functions that requires a mipmap. If either the dimensions of the texture images currently defined (with previous calls to glTexImage2D
, or glCopyTexImage2D
) 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.
Linear filtering accesses the four nearest texture elements.
glTexParameter
specifies the texture parameters for the active texture unit, specified by calling glActiveTexture
.
GL_INVALID_ENUM
is generated if target
or pname
is not one of the accepted defined values.
GL_INVALID_ENUM
is generated if param
should have a defined constant value (based on the value of pname
) and does not.
Copyright © 2003-2004 Silicon Graphics, Inc.
This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.
glActiveTexture
, glBindTexture
, glCopyTexImage2D
, glCopyTexSubImage2D
, glEnable
, glPixelStore
, glTexEnv
, glTexImage2D
, glTexSubImage2D