glTexParameterf, glTexParameteri,
glTexParameterfv, glTexParameteriv: set texture parameters.
C Specification |
Parameters |
Description |
Notes |
Errors |
Associated Gets |
See Also
void glTexParameterf(
GLenum target,
GLenum pname,
GLfloat param)
void glTexParameteri(
GLenum target,
GLenum pname,
GLint param)
void glTexParameterfv(
GLenum target,
GLenum pname,
const GLfloat *params)
void glTexParameteriv(
GLenum target,
GLenum pname,
const GLint *params)
For scalar versions (see param):
- target
- Specifies the target texture, which must be either
GL_TEXTURE_1D, GL_TEXTURE_2D or
GL_TEXTURE_3D_EXT.
- pname
- Specifies the symbolic name of a single-valued texture parameter.
pname can be one of the following:
GL_TEXTURE_MIN_FILTER,
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_WRAP_S,
GL_TEXTURE_WRAP_T, GL_TEXTURE_PRIORITY,
GL_TEXTURE_COMPARE_EXT, or
GL_TEXTURE_COMPARE_OPERATOR_EXT.
- param
- Specifies the value of pname.
For vector versions (see params):
- target
- Specifies the target texture, which must be either
GL_TEXTURE_1D or GL_TEXTURE_2D.
- pname
- Specifies the symbolic name of a texture parameter. pname
can be one of the following: GL_TEXTURE_MIN_FILTER,
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_WRAP_S,
GL_TEXTURE_WRAP_T,
GL_TEXTURE_BORDER_COLOR, or
GL_TEXTURE_PRIORITY.
- params
- Specifies a pointer to an array where the value or values of
pname are stored.
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 params
to the texture parameter specified as pname.
target defines the target texture, either
GL_TEXTURE_1D or 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: 2a for 1D mipmaps,
2a2b for 2D mipmaps, and
2a2b2c for 3D mipmaps.
For example, if a 2D texture has dimensions
2m2n, there are max(m,
n) + 1 mipmaps. The first mipmap is the original texture,
with dimensions 2m2n. Each subsequent mipmap has
dimensions 2k-12l-1, where
2k2l are the dimensions of the previous
mipmap, until either k=0 or l=0.
At that point, subsequent mipmaps have dimension 12l-1 or
2k-11 until the final mipmap, which has dimension 11. To define the mipmaps, call
glTexImage1D, glTexImage2D, glCopyTexImage1D, glCopyTexImage2D, or glCopyTexImage3DEXT with the
level argument indicating the order of the mipmaps. Level
0 is the original texture; level max(m, n ) is
the final 11
mipmap. params 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. The initial value of
GL_TEXTURE_MAG_FILTER is GL_LINEAR.
- 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_TEXTURE_WRAP_S
- Sets the wrap parameter for texture coordinate s to
GL_CLAMP, GL_REPEAT, GL_CLAMP_TO_BORDER_EXT, or
GL_CLAMP_TO_EDGE_EXT. 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_REPEAT causes the integer part
of the s coordinate to be ignored; the GL uses only the fractional
part, thereby creating a repeating pattern. GL_CLAMP_TO_BORDER_EXT causes s
coordinates to be clamped to a range 1/2 texel outside [0,
1]; this prevents the "half border, half edge" color artifact.
GL_CLAMP_TO_EDGE_EXT causes s coordinates to be
clamped to a range 1/2 texel inside [0, 1]; this prevents any
border colors from showing up in the image. Border texture
elements are accessed only if wrapping is set to GL_CLAMP
or GL_CLAMP_TO_BORDER_EXT.
Initially, GL_TEXTURE_WRAP_S is set to
GL_REPEAT.
- GL_TEXTURE_WRAP_T
- Sets the wrap parameter for texture coordinate t to
GL_CLAMP, GL_REPEAT, GL_CLAMP_TO_BORDER_EXT, or
GL_CLAMP_TO_EDGE_EXT. See the discussion under
GL_TEXTURE_WRAP_S. Initially,
GL_TEXTURE_WRAP_T is set to GL_REPEAT.
- GL_TEXTURE_WRAP_R_EXT
- Sets the wrap parameter for texture coordinate r
to GL_CLAMP, GL_REPEAT,
GL_CLAMP_TO_BORDER_EXT, or
GL_CLAMP_TO_EDGE_EXT. See the discussion under
GL_TEXTURE_WRAP_S. Initially,
GL_TEXTURE_WRAP_R_EXT is set to
GL_REPEAT.
- GL_TEXTURE_BORDER_COLOR
- Sets a border color. params contains four values that
comprise the RGBA color of the texture border. Integer color components
are interpreted linearly such that the most positive integer maps to 1.0,
and the most negative integer maps to 1.0. The values are clamped to the range [0, 1] when
they are specified. Initially, the border color is (0, 0, 0,
0).
- GL_TEXTURE_PRIORITY
- Specifies the texture residence priority of the currently bound texture.
Permissible values are in the range [0, 1]. See glPrioritizeTextures and glBindTexture for more information.
- GL_GENERATE_MIPMAP_EXT
- Specifies whether MIP levels should be automatically
filtered when the base level (level 0) of a texture map is modified with
glTexImage1D, glTexImage2D,
glTexImage3DEXT, glTexSubImage1D. glTexSubImage2D,
glTexSubImage3DEXT, glCopyTexImage1D, glCopyTexImage2D, glCopyTexSubImage1D, glCopyTexSubImage2D, or
glCopyTexSubImage3DEXT. The default is GL_FALSE (no
automatic generation of MIP levels).
- GL_TEXTURE_COMPARE_EXT
- Specifies whether the depth texture comparision operator
is in effect. param is either GL_TRUE or
GL_FALSE. The default is GL_FALSE, meaning that the
depth texture comparison operator is not in effect (see
GL_TEXTURE_COMPARE_OPERATOR_EXT, below).
- GL_TEXTURE_COMPARE_OPERATOR_EXT
- Specifies the comparision operator to be used when the
depth texture comparison operator is in effect and the texture format is
one of the GL_DEPTH formats. param is one of
GL_TEXTURE_LEQUAL_R_EXT or
GL_TEXTURE_GEQUAL_R_EXT. When the depth texture
comparision operator is enabled, the r coordinate is interpolated
over the primitive and compared with the depth value found at the
interpolated s and t coordinate location in the texture map.
This comparison is either less-than-or-equal-to
(GL_TEXTURE_LEQUAL_R_EXT) or greater-than-or-equal-to
(GL_TEXTURE_GEQUAL_R_EXT). The result of the comparison
is 0.0 if it fails, or 1.0 if it passes. If texture filtering is enabled,
this comparison is performed for all of the texels involved in the
filtering operation, and the resulting values interpolated (note that only
GL_LINEAR and GL_NEAREST minification and
magnification filters are supported for depth texture comparision). This
result is passed down as the alpha component of the texture color to
subsequent texture application; the red, green, and blue components are
set to 0.0. The depth comparison operator is typically used to produce
shadow effects.
Suppose that a program has enabled texturing (by calling glEnable with argument
GL_TEXTURE_1D or 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 glTexImage1D,
glTexImage2D, glCopyTexImage1D, 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 only in 2D
textures. In 1D textures, linear filtering accesses the two nearest texture
elements. In 3D textures, linear filtering accesses the
eight nearest texture elements.
The GL_CLAMP_TO_BORDER_EXT param to
GL_WRAP_S, GL_WRAP_T, and
GL_WRAP_R_EXT is only supported if the extension
GL_EXT_texture_border_clamp is supported.
The GL_CLAMP_TO_EDGE_EXT param to
GL_WRAP_S, GL_WRAP_T, and
GL_WRAP_R_EXT is only supported if the extension
GL_EXT_texture_edge_clamp is supported.
GL_TEXTURE_WRAP_R_EXT and the target
GL_TEXTURE_3D_EXT are only supported if the extension
GL_EXT_texture3D is supported.
GL_GENERATE_MIPMAP_EXTis only supported if
the extension GL_EXT_generate_mipmap is supported.
GL_TEXTURE_COMPARE_EXT and
GL_TEXTURE_COMPARE_OPERATOR_EXT are only supported if the extension
GL_EXT_shadow is supported.
- GL_INVALID_ENUM is generated if target or
pname is not one of the accepted defined values.
- GL_INVALID_ENUM is generated if params
should have a defined constant value (based on the value of
pname) and does not.
- GL_INVALID_OPERATION is generated if glTexParameter is executed between
the execution of glBegin and the
corresponding execution of glEnd.
glGetTexParameter
glGetTexLevelParameter
glBindTexture,
glCopyPixels,
glCopyTexImage1D,
glCopyTexImage2D,
glCopyTexSubImage1D,
glCopyTexSubImage2D,
glDrawPixels,
glPixelStore,
glPixelTransfer,
glPrioritizeTextures,
glTexEnv,
glTexGen,
glTexImage1D,
glTexImage2D,
glTexSubImage1D,
glTexSubImage2D