Gl.TexParameteri (gb.opengl)
Static Sub TexParameteri ( Target As Integer, Pname As Integer, Param As Integer )
Set texture parameters.
Parameters
- target
-
Specifies the target texture,
which must be either Gl.TEXTURE_1D, Gl.TEXTURE_2D,
Gl.TEXTURE_3D, Gl.TEXTURE_1D_ARRAY,
Gl.TEXTURE_2D_ARRAY, Gl.TEXTURE_RECTANGLE,
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_BASE_LEVEL,
Gl.TEXTURE_COMPARE_FUNC,
Gl.TEXTURE_COMPARE_MODE,
Gl.TEXTURE_LOD_BIAS,
Gl.TEXTURE_MIN_FILTER,
Gl.TEXTURE_MAG_FILTER,
Gl.TEXTURE_MIN_LOD,
Gl.TEXTURE_MAX_LOD,
Gl.TEXTURE_MAX_LEVEL,
Gl.TEXTURE_SWIZZLE_R,
Gl.TEXTURE_SWIZZLE_G,
Gl.TEXTURE_SWIZZLE_B,
Gl.TEXTURE_SWIZZLE_A,
Gl.TEXTURE_WRAP_S,
Gl.TEXTURE_WRAP_T, or
Gl.TEXTURE_WRAP_R.
- param
-
Specifies the value of pname.
Parameters
- target
-
Specifies the target texture,
which must be either Gl.TEXTURE_1D, Gl.TEXTURE_2D,
Gl.TEXTURE_3D, Gl.TEXTURE_1D_ARRAY,
Gl.TEXTURE_2D_ARRAY, Gl.TEXTURE_RECTANGLE,
or Gl.TEXTURE_CUBE_MAP.
- pname
-
Specifies the symbolic name of a texture parameter.
pname can be one of the following:
Gl.TEXTURE_BASE_LEVEL,
Gl.TEXTURE_BORDER_COLOR,
Gl.TEXTURE_COMPARE_FUNC,
Gl.TEXTURE_COMPARE_MODE,
Gl.TEXTURE_LOD_BIAS,
Gl.TEXTURE_MIN_FILTER,
Gl.TEXTURE_MAG_FILTER,
Gl.TEXTURE_MIN_LOD,
Gl.TEXTURE_MAX_LOD,
Gl.TEXTURE_MAX_LEVEL,
Gl.TEXTURE_SWIZZLE_R,
Gl.TEXTURE_SWIZZLE_G,
Gl.TEXTURE_SWIZZLE_B,
Gl.TEXTURE_SWIZZLE_A,
Gl.TEXTURE_SWIZZLE_RGBA,
Gl.TEXTURE_WRAP_S,
Gl.TEXTURE_WRAP_T, or
Gl.TEXTURE_WRAP_R.
- params
-
Specifies a pointer to an array where the value or values of pname
are stored.
Description
Gl.TexParameter 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, Gl.TEXTURE_1D_ARRAY,
Gl.TEXTURE_2D_ARRAY, Gl.TEXTURE_RECTANGLE, or Gl.TEXTURE_3D.
The following symbols are accepted in
pname:
- 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_BORDER_COLOR
-
The data in params specifies four values that define the border values that
should be used for border texels. If a texel is sampled from the border of the texture, the
values of Gl.TEXTURE_BORDER_COLOR are interpreted as an RGBA color to match the
texture's internal format and substituted for the non-existent texel data. If the texture contains depth
components, the first component of Gl.TEXTURE_BORDER_COLOR is interpreted as a depth value.
The initial value is
.
If the values for Gl.TEXTURE_BORDER_COLOR are specified with Gl.TexParameterIiv
or Gl.TexParameterIuiv, the values are stored unmodified with an internal data type of
integer. If specified with Gl.TexParameteriv, they are converted to floating point with the following
equation:
.
If specified with Gl.TexParameterfv, they are stored unmodified as floating-point values.
- Gl.TEXTURE_COMPARE_FUNC
-
Specifies the comparison operator used when Gl.TEXTURE_COMPARE_MODE is
set to Gl.COMPARE_REF_TO_TEXTURE. Permissible values are:
Texture Comparison Function
|
Computed result
|
---|
Gl.LEQUAL
|
|
Gl.GEQUAL
|
|
Gl.LESS
|
|
Gl.GREATER
|
|
Gl.EQUAL
|
|
Gl.NOTEQUAL
|
|
Gl.ALWAYS
|
|
Gl.NEVER
|
|
where
is the current interpolated texture coordinate, and
is the depth texture value sampled from the currently bound depth texture.
is assigned to the the red channel.
- 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
Gl.TexImage2D)
Permissible values are:
- Gl.COMPARE_REF_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 the red channel.
- Gl.NONE
-
Specifies that the red channel should be assigned the
appropriate value from the currently bound depth texture.
- Gl.TEXTURE_LOD_BIAS
-
params specifies a fixed bias value that is to be added to the level-of-detail
parameter for the texture before texture sampling. The specified value is added to the shader-supplied
bias value (if any) and subsequently clamped into the implementation-defined range
,
where
is the value of the implementation defined constant Gl.MAX_TEXTURE_LOD_BIAS. The initial value is 0.0.
- Gl.TEXTURE_MIN_FILTER
-
The texture minifying function is used whenever the level-of-detail function
used when sampling from the texture determines that the texture should be minified.
There are six defined minifying functions.
Two of them use either the nearest texture elements or a weighted average of multiple 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 Gl.TexImage1D, Gl.TexImage2D,
Gl.TexImage3D,
Gl.CopyTexImage1D, or Gl.CopyTexImage2D
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 specified texture coordinates.
- Gl.LINEAR
-
Returns the weighted average of the four texture elements
that are closest to the specified texture coordinates.
These can include items wrapped or repeated from other parts of a texture,
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 closest to the specified texture coordinates)
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 specified texture coordinates)
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 closest to the specified texture coordinates )
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 texture elements that are closest to the specified texture coordinates)
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 multiple 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 whenever the level-of-detail function
used when sampling from the texture determines that the texture should be magified.
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 specified texture coordinates.
- Gl.LINEAR
-
Returns the weighted average of the texture elements
that are closest to the specified texture coordinates.
These can include items wrapped or repeated from other parts of a texture,
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_MAX_LEVEL
-
Sets the index of the highest defined mipmap level. This is an integer
value. The initial value is 1000.
- Gl.TEXTURE_SWIZZLE_R
-
Sets the swizzle that will be applied to the
component of a texel before it is returned to the shader. Valid values for param are Gl.RED,
Gl.GREEN, Gl.BLUE, Gl.ALPHA, Gl.ZERO and
Gl.ONE.
If Gl.TEXTURE_SWIZZLE_R is Gl.RED, the value for
will be taken from the first
channel of the fetched texel.
If Gl.TEXTURE_SWIZZLE_R is Gl.GREEN, the value for
will be taken from the second
channel of the fetched texel.
If Gl.TEXTURE_SWIZZLE_R is Gl.BLUE, the value for
will be taken from the third
channel of the fetched texel.
If Gl.TEXTURE_SWIZZLE_R is Gl.ALPHA, the value for
will be taken from the fourth
channel of the fetched texel.
If Gl.TEXTURE_SWIZZLE_R is Gl.ZERO, the value for
will be subtituted with
.
If Gl.TEXTURE_SWIZZLE_R is Gl.ONE, the value for
will be subtituted with
.
The initial value is Gl.RED.
- Gl.TEXTURE_SWIZZLE_G
-
Sets the swizzle that will be applied to the
component of a texel before it is returned to the shader. Valid values for param and their effects are similar to
those of Gl.TEXTURE_SWIZZLE_R.
The initial value is Gl.GREEN.
- Gl.TEXTURE_SWIZZLE_B
-
Sets the swizzle that will be applied to the
component of a texel before it is returned to the shader. Valid values for param and their effects are similar to
those of Gl.TEXTURE_SWIZZLE_R.
The initial value is Gl.BLUE.
- Gl.TEXTURE_SWIZZLE_A
-
Sets the swizzle that will be applied to the
component of a texel before it is returned to the shader. Valid values for param and their effects are similar to
those of Gl.TEXTURE_SWIZZLE_R.
The initial value is Gl.ALPHA.
- Gl.TEXTURE_SWIZZLE_RGBA
-
Sets the swizzles that will be applied to the
,
,
, and
components of a texel before they are returned to the shader. Valid values for params and their effects are similar to
those of Gl.TEXTURE_SWIZZLE_R, except that all channels are specified simultaneously.
Setting the value of Gl.TEXTURE_SWIZZLE_RGBA is equivalent (assuming no errors are generated) to
setting the parameters of each of Gl.TEXTURE_SWIZZLE_R,
Gl.TEXTURE_SWIZZLE_G,
Gl.TEXTURE_SWIZZLE_B, and
Gl.TEXTURE_SWIZZLE_A successively.
- Gl.TEXTURE_WRAP_S
-
Sets the wrap parameter for texture coordinate
to either Gl.CLAMP_TO_EDGE, Gl.CLAMP_TO_BORDER,
Gl.MIRRORED_REPEAT, or
Gl.REPEAT. 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.CLAMP_TO_BORDER evaluates coordinates in a similar manner to Gl.CLAMP_TO_EDGE.
However, in cases where clamping would have occurred in Gl.CLAMP_TO_EDGE mode, the fetched texel data
is substituted with the values specified by Gl.TEXTURE_BORDER_COLOR.
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
.
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_TO_EDGE, Gl.CLAMP_TO_BORDER,
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_TO_EDGE, Gl.CLAMP_TO_BORDER,
Gl.MIRRORED_REPEAT, or
Gl.REPEAT. See the discussion under Gl.TEXTURE_WRAP_S.
Initially, Gl.TEXTURE_WRAP_R is set to Gl.REPEAT.
Notes
Suppose that a program attempts to sample from a texture 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,
Gl.TexImage3D,
Gl.CopyTexImage1D, or
Gl.CopyTexImage2D) 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 the texture is considered
incomplete.
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.
Gl.TexParameter specifies the texture parameters for the active texture unit, specified
by calling
Gl.ActiveTexture.
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.
Associated Gets
Gl.GetTexParameter
Gl.GetTexLevelParameter
See also
Gl.CopyTexSubImage1D,
Gl.CopyTexSubImage2D,
Gl.CopyTexSubImage3D,
Gl.PixelStore,
Gl.SamplerParameter,
Gl.TexImage3D,
Gl.TexSubImage1D,
Gl.TexSubImage2D,
Gl.TexSubImage3D
See original documentation on OpenGL website