set texture parameters
Signature
Parameters
| Variables | Description |
|---|---|
| target |
Specifies the target texture,
which must be either
GL_TEXTURE_1D
,
GL_TEXTURE_2D
,
GL_TEXTURE_3D
, or
GL_TEXTURE_CUBE_MAP
.
|
| 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
,
GL_TEXTURE_MAX_LOD
,
GL_TEXTURE_BASE_LEVEL
,
GL_TEXTURE_MAX_LEVEL
,
GL_TEXTURE_WRAP_S
,
GL_TEXTURE_WRAP_T
,
GL_TEXTURE_WRAP_R
,
GL_TEXTURE_PRIORITY
,
GL_TEXTURE_COMPARE_MODE
,
GL_TEXTURE_COMPARE_FUNC
,
GL_DEPTH_TEXTURE_MODE
, or
GL_GENERATE_MIPMAP
.
|
| param |
Specifies the value of
pname
.
|
Parameters
- target
-
Specifies the target texture, which must be either GL_TEXTURE_1D , GL_TEXTURE_2D or GL_TEXTURE_3D .
- 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 , GL_TEXTURE_MAX_LOD , GL_TEXTURE_BASE_LEVEL , GL_TEXTURE_MAX_LEVEL , GL_TEXTURE_WRAP_S , GL_TEXTURE_WRAP_T , GL_TEXTURE_WRAP_R , GL_TEXTURE_BORDER_COLOR , GL_TEXTURE_PRIORITY , GL_TEXTURE_COMPARE_MODE , GL_TEXTURE_COMPARE_FUNC , GL_DEPTH_TEXTURE_MODE , or GL_GENERATE_MIPMAP .
Description
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
(
,
)
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
,
GL_TEXTURE_2D
, or
GL_TEXTURE_3D
.
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 , there are mipmaps. The first mipmap is the original texture, with dimensions . Each subsequent mipmap has dimensions , where are the dimensions of the previous mipmap, until either or . At that point, subsequent mipmaps have dimension or until the final mipmap, which has dimension . To define the mipmaps, call glTexImage1D , glTexImage2D , glTexImage3D , glCopyTexImage1D , or glCopyTexImage2D with the level argument indicating the order of the mipmaps. Level 0 is the original texture; level is the final 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_MIN_LOD
-
Sets the minimum level-of-detail parameter. This floating-point value limits the selection of highest resolution mipmap (lowest mipmap level). The initial value is -1000.
- GL_TEXTURE_MAX_LOD
-
Sets the maximum level-of-detail parameter. This floating-point value limits the selection of the lowest resolution mipmap (highest mipmap level). The initial value is 1000.
- GL_TEXTURE_BASE_LEVEL
-
Specifies the index of the lowest defined mipmap level. This is an integer value. The initial value is 0.
- GL_TEXTURE_MAX_LEVEL
-
Sets the index of the highest defined mipmap level. This is an integer value. The initial value is 1000.
- GL_TEXTURE_WRAP_S
-
Sets the wrap parameter for texture coordinate to either GL_CLAMP , GL_CLAMP_TO_BORDER , GL_CLAMP_TO_EDGE , GL_MIRRORED_REPEAT , or GL_REPEAT . GL_CLAMP causes 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 causes the coordinate to be clamped to the range , where is the size of the texture in the direction of clamping. GL_CLAMP_TO_EDGE causes coordinates to be clamped to the range , where is the size of the texture in the direction of clamping. GL_REPEAT causes the integer part of the coordinate to be ignored; the GL uses only the fractional part, thereby creating a repeating pattern. GL_MIRRORED_REPEAT causes the coordinate to be set to the fractional part of the texture coordinate if the integer part of is even; if the integer part of is odd, then the texture coordinate is set to , where represents the fractional part of . Border texture elements are accessed only if wrapping is set to GL_CLAMP or GL_CLAMP_TO_BORDER . Initially, GL_TEXTURE_WRAP_S is set to GL_REPEAT .
- GL_TEXTURE_WRAP_T
-
Sets the wrap parameter for texture coordinate to either GL_CLAMP , GL_CLAMP_TO_BORDER , GL_CLAMP_TO_EDGE , GL_MIRRORED_REPEAT , or GL_REPEAT . See the discussion under GL_TEXTURE_WRAP_S . Initially, GL_TEXTURE_WRAP_T is set to GL_REPEAT .
- GL_TEXTURE_WRAP_R
-
Sets the wrap parameter for texture coordinate to either GL_CLAMP , GL_CLAMP_TO_BORDER , GL_CLAMP_TO_EDGE , GL_MIRRORED_REPEAT , or GL_REPEAT . See the discussion under GL_TEXTURE_WRAP_S . Initially, GL_TEXTURE_WRAP_R 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 . See glPrioritizeTextures and glBindTexture for more information.
- GL_TEXTURE_COMPARE_MODE
-
Specifies the texture comparison mode for currently bound depth textures. That is, a texture whose internal format is GL_DEPTH_COMPONENT_* ; see glTexImage2D ) Permissible values are:
- GL_COMPARE_R_TO_TEXTURE
-
Specifies that the interpolated and clamped texture coordinate should be compared to the value in the currently bound depth texture. See the discussion of GL_TEXTURE_COMPARE_FUNC for details of how the comparison is evaluated. The result of the comparison is assigned to luminance, intensity, or alpha (as specified by GL_DEPTH_TEXTURE_MODE ).
- GL_NONE
-
Specifies that the luminance, intensity, or alpha (as specified by GL_DEPTH_TEXTURE_MODE ) should be assigned the appropriate value from the currently bound depth texture.
- GL_TEXTURE_COMPARE_FUNC
-
Specifies the comparison operator used when GL_TEXTURE_COMPARE_MODE is set to GL_COMPARE_R_TO_TEXTURE . Permissible values are:
where is the current interpolated texture coordinate, and is the depth texture value sampled from the currently bound depth texture. is assigned to the either the luminance, intensity, or alpha (as specified by GL_DEPTH_TEXTURE_MODE .)Texture Comparison Function Computed result GL_LEQUAL GL_GEQUAL GL_LESS GL_GREATER GL_EQUAL GL_NOTEQUAL GL_ALWAYS GL_NEVER - GL_DEPTH_TEXTURE_MODE
-
Specifies a single symbolic constant indicating how depth values should be treated during filtering and texture application. Accepted values are GL_LUMINANCE , GL_INTENSITY , and GL_ALPHA . The initial value is GL_LUMINANCE .
- GL_GENERATE_MIPMAP
-
Specifies a boolean value that indicates if all levels of a mipmap array should be automatically updated when any modification to the base level mipmap is done. The initial value is GL_FALSE .
Notes
GL_TEXTURE_3D
,
GL_TEXTURE_MIN_LOD
,
GL_TEXTURE_MAX_LOD
,
GL_CLAMP_TO_EDGE
,
GL_TEXTURE_BASE_LEVEL
, and
GL_TEXTURE_MAX_LEVEL
are
available only if the GL version is 1.2 or greater.
GL_CLAMP_TO_BORDER
is available only if the GL version is 1.3 or greater.
GL_MIRRORED_REPEAT
,
GL_TEXTURE_COMPARE_MODE
,
GL_TEXTURE_COMPARE_FUNC
,
GL_DEPTH_TEXTURE_MODE
, and
GL_GENERATE_MIPMAP
are available only if the GL version is 1.4 or
greater.
GL_TEXTURE_COMPARE_FUNC
allows the following additional comparison modes only
if the GL version is 1.5 or greater:
GL_LESS
,
GL_GREATER
,
GL_EQUAL
,
GL_NOTEQUAL
,
GL_ALWAYS
, and
GL_NEVER
.
Suppose that a program has enabled texturing (by calling
glEnable
with
argument
GL_TEXTURE_1D
,
GL_TEXTURE_2D
, or
GL_TEXTURE_3D
) 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
,
glTexImage3D
,
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.
For OpenGL versions 1.3 and greater, or when the
ARB_multitexture
extension is supported,
glTexParameter
specifies the texture parameters for the active texture unit, specified
by calling
glActiveTexture
.
Errors
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
.
See Also
glActiveTexture
,
glBindTexture
,
glCopyPixels
,
glCopyTexImage1D
,
glCopyTexImage2D
,
glCopyTexSubImage1D
,
glCopyTexSubImage2D
,
glCopyTexSubImage3D
,
glDrawPixels
,
glPixelStore
,
glPixelTransfer
,
glPrioritizeTextures
,
glTexEnv
,
glTexGen
,
glTexImage1D
,
glTexImage2D
,
glTexImage3D
,
glTexSubImage1D
,
glTexSubImage2D
,
glTexSubImage3D
Copyright
Copyright
1991-2006
Silicon Graphics, Inc. This document is licensed under the SGI
Free Software B License. For details, see
http://oss.sgi.com/projects/FreeB/
.
Sample Code References
The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.
glTexParameterf
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 879, 880
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Label.py
Lines: 205, 206
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/TexPlane.py
Lines: 137, 138
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Button.py
Lines: 257, 258
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 880, 881
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/Label.py
Lines: 205, 206
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/TexPlane.py
Lines: 137, 138
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/Button.py
Lines: 268, 269
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/TexPlane.py
Lines: 97, 98
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py
Lines: 493, 494
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/Button.py
Lines: 171, 172
{LGPL or GPL or MPL} Kamaelia
Code/Python/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 879, 880
glTexParameteri
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/Experiments/Cubes.py
Lines: 137, 138, 141, 142, 147, 148
glTexParameteriv