gl.TexParameter(target, pname, param)
gl.TexParameter()
assigns the value or values in param
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
A mipmap is an ordered set of arrays representing the same image at progressively lower resolutions: 2^a for 1D mipmaps and 2^a*2^b for 2D mipmaps.
For example, if a 2D texture has dimensions 2^m*2^n, there are max(m, n) + 1 mipmaps. The first mipmap is the original
texture, with dimensions 2^m*2^n. Each subsequent mipmap has dimensions 2^k-1*2^l-1, where 2^k*2^l are the dimensions of
the previous mipmap, until either k=0 or l=0. At that point, subsequent mipmaps have dimension 1*2^l-1 or 2^k-1*1 until
the final mipmap, which has dimension 1x1. To define the mipmaps, call gl.TexImage1D(),
gl.TexImage2D(), or gl.CopyTexImage() with the level argument indicating
the order of the mipmaps. Level 0 is the original texture; level max(m, n ) is the final 1x1 mipmap. param
supplies a
function for minifying the texture as one of the following:
#GL_NEAREST
#GL_LINEAR
#GL_TEXTURE_WRAP_S
and #GL_TEXTURE_WRAP_T
, and on the exact mapping.
#GL_NEAREST_MIPMAP_NEAREST
#GL_NEAREST
criterion (the texture
element nearest to the center of the pixel) to produce a texture value.
#GL_LINEAR_MIPMAP_NEAREST
#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
#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
#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
#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
#GL_LINEAR
#GL_TEXTURE_WRAP_S
and #GL_TEXTURE_WRAP_T
, and on the exact mapping.
#GL_TEXTURE_WRAP_S
#GL_CLAMP
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_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
. Initially, #GL_TEXTURE_WRAP_S
is set to #GL_REPEAT
.
#GL_TEXTURE_WRAP_T
#GL_CLAMP
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_EXT
#GL_CLAMP
or #GL_REPEAT
. See the discussion under #GL_TEXTURE_WRAP_S
. Initially,
#GL_TEXTURE_WRAP_R_EXT
is set to #GL_REPEAT
.
#GL_TEXTURE_BORDER_COLOR
param
must be a table containing four floating-point values that comprise the RGBA color of the texture border.
Initially, the border color is (0, 0, 0, 0).
#GL_TEXTURE_PRIORITY
Suppose that a program has enabled texturing (by calling gl.Enable() 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 gl.TexImage1D(), gl.TexImage2D() or gl.CopyTexImage())
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.
Please consult an OpenGL reference manual for more information.
#GL_TEXTURE_1D
or #GL_TEXTURE_2D
pname
#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.
#GL_INVALID_OPERATION
is generated if gl.TexParameter()
is executed between the execution of gl.Begin() and the corresponding execution of gl.End().