glTexParameter
NAME
glTexParameterf, glTexParameteri, glTexParameterfv,
glTexParameteriv - set texture parameters
C SPECIFICATION
void glTexParameterf(GLenum target,
GLenum pname,
GLfloat param)
void glTexParameteri(GLenum target,
GLenum pname,
GLint param)
PARAMETERS
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_MIN_LOD_EXT,
GL_TEXTURE_MAX_LOD_EXT, GL_TEXTURE_BASE_LEVEL_EXT, GL_TEXTURE_MAX_LEVEL_EXT,
GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_TEXTURE_WRAP_R_EXT,
GL_TEXTURE_PRIORITY, or GL_GENERATE_MIPMAP_EXT.
|
param
| Specifies the value of pname.
|
C SPECIFICATION
void glTexParameterfv(GLenum target,
GLenum pname,
const GLfloat *params)
void glTexParameteriv(GLenum target,
GLenum pname,
const GLint *params)
PARAMETERS
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 texture parameter.
pname can be one of the following: GL_TEXTURE_MIN_FILTER,
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_LOD_EXT, GL_TEXTURE_MAX_LOD_EXT,
GL_TEXTURE_BASE_LEVEL_EXT, GL_TEXTURE_MAX_LEVEL_EXT, GL_TEXTURE_WRAP_S,
GL_TEXTURE_WRAP_T, GL_TEXTURE_WRAP_R_EXT, GL_TEXTURE_BORDER_COLOR,
GL_TEXTURE_PRIORITY, or GL_GENERATE_MIPMAP_EXT.
|
params
| Specifies a pointer to an array where the value or
values of pname are stored.
|
DESCRIPTION
glTexParameter assigns the value or values in params to
the texture parameter specified as pname. target defines
the target texture, either GL_TEXTURE_1D, GL_TEXTURE_2D,
or GL_TEXTURE_3D_EXT. 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.
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
GL_TEXTURE_WRAP_T, and GL_TEXTURE_WRAP_R_EXT,
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.
- 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
GL_TEXTURE_WRAP_T, and GL_TEXTURE_WRAP_R_EXT,
and on the exact mapping.
- GL_TEXTURE_MIN_LOD_EXT
-
Specifies the minimum level-of-detail (LOD) that is allowed. The
minimum LOD is set to the value specified by params. Unlike the
GL_TEXTURE_MAX_LEVEL_EXT, the minimum LOD can be varied
continuously over the full range of the mipmap levels. Setting the
minimum LOD allows the application to smoothly manage the transition to
a higher- or lower-resolution texture. The default values is -1000.
- GL_TEXTURE_MAX_LOD_EXT
-
Specifies the maximum level-of-detail (LOD) that is allowed. The
maximum LOD is set to the value specified by params. Unlike the
GL_TEXTURE_MAX_LEVEL_EXT, the maximum LOD can be varied
continuously over the full range of the mipmap levels. Setting the
maximum LOD allows the application to smoothly manage the transition to
a higher- or lower-resolution texture. The default values is 1000.
- GL_TEXTURE_BASE_LEVEL_EXT
-
Specifies the base level of the set of mipmap image arrays. The base
level is set to the integer value specified by params. Setting
the base level to a value other than 0 permits a subset of mipmaps to be
loaded and initially used at a low resolution. Only the levels between
base level and max level (inclusive) must be loaded. (Other levels may
be loaded, but only the levels from base through max will be used). The
default value is 0.
- GL_TEXTURE_MAX_LEVEL_EXT
-
Specifies the maximum level for the set of mipmap image arrays. The
maximum level is set to the integer value specified by params.
Only the levels between base level and max level (inclusive) must be
loaded. (Other levels may be loaded, but only the levels from base
through max will be used). The default value is 1000.
- GL_TEXTURE_WRAP_S
-
Sets the wrap parameter for texture coordinate s to either
GL_REPEAT, GL_CLAMP, GL_CLAMP_TO_BORDER_EXT, or
GL_CLAMP_TO_EDGE_EXT. 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
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_BORDER_EXT
causes s coordinates to be clamped to 1/2 texel outside of the
map such that the texture filter only samples the border or border color
for coordinates outside of the texture map and its border.
GL_CLAMP_TO_EDGE_EXT causes s coordinates to be clamped to
1/2 texel within the map such that the texture filter never samples a
border texel. 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 either
GL_REPEAT, GL_CLAMP, 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 either
GL_REPEAT, GL_CLAMP, 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 the automatic generation of mipmap images whenever the
base level map is modified. If params is GL_TRUE,
the generation of mipmaps is enabled. If params is GL_FALSE,
the generation of mipmaps is disabled. Only mipmaps used to
"complete" the mipmap array are generated. The method used to
generate the mipmap images is implementation-dependent. The
GL_GENERATE_MIPMAP_HINT_EXT hint can be used to indicate
whether performance or quality is important when generating
mipmap images.
NOTES
Suppose an application has enabled texturing
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 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 and 3D textures. In 1D textures, linear filtering
accesses the two nearest texture elements.
EXTENSIONS
Some routines and constants for this function are part of an extension, not part of the
core GL command set. The following extension names must be present in the string returned by
glGetString when called with argument GL_EXTENSIONS
to use these routines and constants.
- GL_EXT_texture_border_clamp
-
GL_CLAMP_TO_BORDER_EXT
is part of the EXT_texture_border_clamp extension.
- GL_EXT_texture_edge_clamp
-
GL_CLAMP_TO_EDGE_EXT
is part of the EXT_texture_edge_clamp extension.
- GL_EXT_generate_mipmap
-
GL_GENERATE_MIPMAP_EXT and GL_GENERATE_MIPMAP_HINT_EXT
are part of the EXT_generate_mipmap extension.
- GL_EXT_texture_lod
-
GL_TEXTURE_MIN_LOD_EXT, GL_TEXTURE_MAX_LOD_EXT, GL_TEXTURE_BASE_LEVEL_EXT, and
GL_TEXTURE_MAX_LEVEL_EXT
are part of the EXT_texture_lod extension.
- GL_EXT_texture3D
-
GL_TEXTURE_3D_EXT and GL_TEXTURE_WRAP_R_EXT
are part of the EXT_texture3D extension.
ERRORS
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_VALUE is generated if the GL_TEXTURE_BASE_LEVEL_EXT
or GL_TEXTURE_MAX_LEVEL_EXT is negative.
GL_INVALID_OPERATION is generated if glTexParameter is
executed between the execution of glBegin and
the corresponding execution of glEnd.
ASSOCIATED GETS
glGetTexParameter
glGetTexLevelParameter
SEE ALSO
glBindTexture,
glCopyPixels,
glCopyTexImage1D,
glCopyTexImage2D,
glCopyTexSubImage1D,
glCopyTexSubImage2D,
glDrawPixels,
glPixelStore,
glPixelTransfer,
glPrioritizeTextures,
glTexEnv,
glTexGen,
glTexImage1D,
glTexImage2D,
glTexImage3DEXT,
glTexSubImage1D,
glTexSubImage2D,
glTexSubImage3DEXT