Gl.TexEnvi (gb.opengl)
Static Sub TexEnvi ( Target As Integer, Pname As Integer, Param As Integer )
Set texture environment parameters.
Parameters
- target
-
Specifies a texture environment.
May be Gl.TEXTURE_ENV, Gl.TEXTURE_FILTER_CONTROL or Gl.POINT_SPRITE.
- pname
-
Specifies the symbolic name of a single-valued texture environment parameter.
May be either Gl.TEXTURE_ENV_MODE, Gl.TEXTURE_LOD_BIAS,
Gl.COMBINE_RGB,
Gl.COMBINE_ALPHA,
Gl.SRC0_RGB,
Gl.SRC1_RGB,
Gl.SRC2_RGB,
Gl.SRC0_ALPHA,
Gl.SRC1_ALPHA,
Gl.SRC2_ALPHA,
Gl.OPERAND0_RGB,
Gl.OPERAND1_RGB,
Gl.OPERAND2_RGB,
Gl.OPERAND0_ALPHA,
Gl.OPERAND1_ALPHA,
Gl.OPERAND2_ALPHA,
Gl.RGB_SCALE,
Gl.ALPHA_SCALE, or
Gl.COORD_REPLACE.
- param
-
Specifies a single symbolic constant, one of Gl.ADD,
Gl.ADD_SIGNED, Gl.INTERPOLATE, Gl.MODULATE, Gl.DECAL,
Gl.BLEND, Gl.REPLACE, Gl.SUBTRACT, Gl.COMBINE,
Gl.TEXTURE, Gl.CONSTANT, Gl.PRIMARY_COLOR, Gl.PREVIOUS,
Gl.SRC_COLOR, Gl.ONE_MINUS_SRC_COLOR, Gl.SRC_ALPHA,
Gl.ONE_MINUS_SRC_ALPHA,
a single boolean value for the point sprite texture coordinate replacement,
a single floating-point value for the texture level-of-detail bias,
or 1.0, 2.0, or 4.0 when specifying the Gl.RGB_SCALE or Gl.ALPHA_SCALE.
C Specification
void glTexEnvfv( | GLenum target, |
| GLenum pname, |
| const GLfloat params); |
void glTexEnviv( | GLenum target, |
| GLenum pname, |
| const GLint params); |
Parameters
- target
-
Specifies a texture environment.
May be either Gl.TEXTURE_ENV, or Gl.TEXTURE_FILTER_CONTROL.
- pname
-
Specifies the symbolic name of a texture environment parameter.
Accepted values are Gl.TEXTURE_ENV_MODE, Gl.TEXTURE_ENV_COLOR, or
Gl.TEXTURE_LOD_BIAS.
- params
-
Specifies a pointer to a parameter array that contains
either a single symbolic constant, single floating-point number, or an RGBA
color.
Description
A texture environment specifies how texture values are interpreted when a
fragment is textured. When
target is Gl.TEXTURE_FILTER_CONTROL,
pname must be Gl.TEXTURE_LOD_BIAS. When
target is
Gl.TEXTURE_ENV,
pname can be Gl.TEXTURE_ENV_MODE,
Gl.TEXTURE_ENV_COLOR,
Gl.COMBINE_RGB,
Gl.COMBINE_ALPHA,
Gl.RGB_SCALE,
Gl.ALPHA_SCALE,
Gl.SRC0_RGB, Gl.SRC1_RGB, Gl.SRC2_RGB,
Gl.SRC0_ALPHA, Gl.SRC1_ALPHA, or Gl.SRC2_ALPHA.
If
pname is Gl.TEXTURE_ENV_MODE,
then
params is (or points to) the symbolic name of a texture function.
Six texture functions may be specified:
Gl.ADD,
Gl.MODULATE,
Gl.DECAL,
Gl.BLEND,
Gl.REPLACE, or
Gl.COMBINE.
The following table shows the correspondence of filtered texture
values
,
,
,
,
,
to texture source components.
and
are used by the texture functions described below.
Texture Base Internal Format
|
|
|
---|
Gl.ALPHA
|
(0, 0, 0)
|
|
Gl.LUMINANCE
|
(
,
,
)
|
1
|
Gl.LUMINANCE_ALPHA
|
(
,
,
)
|
|
Gl.INTENSITY
|
(
,
,
)
|
|
Gl.RGB
|
(
,
,
)
|
1
|
Gl.RGBA
|
(
,
,
)
|
|
A texture function acts on the fragment to be textured using
the texture image value that applies to the fragment
(see Gl.TexParameter)
and produces an RGBA color for that fragment.
The following table shows how the RGBA color is produced for each
of the first five texture functions that can be chosen.
is a triple of color values (RGB) and
is the associated alpha value.
RGBA values extracted from a texture image are in the range
/wiki/0,1.
The subscript
refers to the color computed from the previous texture stage (or the incoming fragment if processing texture stage 0),
the subscript
to the texture source color,
the subscript
to the texture environment color,
and the subscript
indicates a value produced by the texture function.
Texture Base Internal Format
|
Value
|
Gl.REPLACE Function
|
Gl.MODULATE Function
|
Gl.DECAL Function
|
Gl.BLEND Function
|
Gl.ADD Function
|
---|
Gl.ALPHA
|
|
|
|
undefined
|
|
|
|
|
|
|
|
|
|
Gl.LUMINANCE
|
|
|
|
undefined
|
|
|
(or 1)
|
|
|
|
|
|
|
Gl.LUMINANCE_ALPHA
|
|
|
|
undefined
|
|
|
(or 2)
|
|
|
|
|
|
|
Gl.INTENSITY
|
|
|
|
undefined
|
|
|
|
|
|
|
|
|
|
Gl.RGB
|
|
|
|
|
|
|
(or 3)
|
|
|
|
|
|
|
Gl.RGBA
|
|
|
|
|
|
|
(or 4)
|
|
|
|
|
|
|
If
pname is Gl.TEXTURE_ENV_MODE, and
params is Gl.COMBINE, the
form of the texture function depends on the values of Gl.COMBINE_RGB
and Gl.COMBINE_ALPHA.
The following describes how the texture sources, as specified by
Gl.SRC0_RGB, Gl.SRC1_RGB, Gl.SRC2_RGB,
Gl.SRC0_ALPHA, Gl.SRC1_ALPHA, and Gl.SRC2_ALPHA,
are combined to produce a final texture color. In the following tables,
Gl.SRC0_c is represented by
,
Gl.SRC1_c is
represented by
,
and Gl.SRC2_c is represented by
.
Gl.COMBINE_RGB accepts any of Gl.REPLACE, Gl.MODULATE,
Gl.ADD, Gl.ADD_SIGNED, Gl.INTERPOLATE, Gl.SUBTRACT,
Gl.DOT3_RGB, or Gl.DOT3_RGBA.
Gl.COMBINE_RGB
|
Texture Function
|
---|
Gl.REPLACE
|
|
Gl.MODULATE
|
|
Gl.ADD
|
|
Gl.ADD_SIGNED
|
|
Gl.INTERPOLATE
|
|
Gl.SUBTRACT
|
|
Gl.DOT3_RGB
or
Gl.DOT3_RGBA
|
|
The scalar results for Gl.DOT3_RGB and Gl.DOT3_RGBA are placed
into each of the 3 (RGB) or 4 (RGBA) components on output.
Likewise, Gl.COMBINE_ALPHA accepts any of Gl.REPLACE,
Gl.MODULATE, Gl.ADD, Gl.ADD_SIGNED, Gl.INTERPOLATE, or
Gl.SUBTRACT. The following table describes how alpha values are
combined:
Gl.COMBINE_ALPHA
|
Texture Function
|
---|
Gl.REPLACE
|
|
Gl.MODULATE
|
|
Gl.ADD
|
|
Gl.ADD_SIGNED
|
|
Gl.INTERPOLATE
|
|
Gl.SUBTRACT
|
|
In the following tables, the value
represents the color sampled
from the currently bound texture,
represents the constant
texture-environment color,
represents the primary color of the
incoming fragment, and
represents the color computed from the
previous texture stage or
if processing texture stage 0. Likewise,
,
,
,
and
represent the respective
alpha values.
The following table describes the values assigned to
,
,
and
based upon the RGB sources and operands:
Gl.SRCn_RGB
|
Gl.OPERANDn_RGB
|
Argument Value
|
---|
Gl.TEXTURE
|
Gl.SRC_COLOR
|
|
|
Gl.ONE_MINUS_SRC_COLOR
|
|
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.TEXTUREn
|
Gl.SRC_COLOR
|
|
|
Gl.ONE_MINUS_SRC_COLOR
|
|
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.CONSTANT
|
Gl.SRC_COLOR
|
|
|
Gl.ONE_MINUS_SRC_COLOR
|
|
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.PRIMARY_COLOR
|
Gl.SRC_COLOR
|
|
|
Gl.ONE_MINUS_SRC_COLOR
|
|
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.PREVIOUS
|
Gl.SRC_COLOR
|
|
|
Gl.ONE_MINUS_SRC_COLOR
|
|
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
For Gl.TEXTUREn sources,
and
represent the color
and alpha, respectively, produced from texture stage
.
The follow table describes the values assigned to
,
,
and
based upon the alpha sources and operands:
Gl.SRCn_ALPHA
|
Gl.OPERANDn_ALPHA
|
Argument Value
|
---|
Gl.TEXTURE
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.TEXTUREn
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.CONSTANT
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.PRIMARY_COLOR
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
Gl.PREVIOUS
|
Gl.SRC_ALPHA
|
|
|
Gl.ONE_MINUS_SRC_ALPHA
|
|
The RGB and alpha results of the texture function are multipled by the
values of Gl.RGB_SCALE and Gl.ALPHA_SCALE, respectively, and
clamped to the range
.
If
pname is Gl.TEXTURE_ENV_COLOR,
params is a pointer to an array that holds an RGBA color consisting of four
values.
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
/wiki/0,1 when they are specified.
takes these four values.
If
pname is Gl.TEXTURE_LOD_BIAS, the value specified is added to the
texture level-of-detail parameter, that selects which mipmap, or mipmaps
depending upon the selected Gl.TEXTURE_MIN_FILTER, will be sampled.
Gl.TEXTURE_ENV_MODE defaults to Gl.MODULATE and
Gl.TEXTURE_ENV_COLOR defaults to (0, 0, 0, 0).
If
target is Gl.POINT_SPRITE and
pname is Gl.COORD_REPLACE, the boolean value specified
is used to either enable or disable point sprite texture coordinate replacement. The default value is Gl.FALSE.
Notes
Gl.REPLACE may only be used if the GL version is 1.1 or greater.
Gl.TEXTURE_FILTER_CONTROL and Gl.TEXTURE_LOD_BIAS may only be
used if the GL version is 1.4 or greater.
Gl.COMBINE mode and its associated constants may only be used if the
GL version is 1.3 or greater.
Gl.TEXTUREn may only be used if the GL version is 1.4 or greater.
Internal formats other than 1, 2, 3, or 4 may only be used if the GL
version is 1.1 or greater.
For OpenGL versions 1.3 and greater, or when the ARB_multitexture extension is supported,
Gl.TexEnv controls
the texture environment for the current active texture unit, selected by
Gl.ActiveTexture.
Gl.POINT_SPRITE and Gl.COORD_REPLACE are available
only if the GL version is 2.0 or greater.
Errors
Gl.INVALID_ENUM is generated when
target or
pname is not
one of the accepted defined values,
or when
params should have a defined constant value
(based on the value of
pname)
and does not.
Gl.INVALID_VALUE is generated if the
params value for
Gl.RGB_SCALE or
Gl.ALPHA_SCALE are not one of 1.0, 2.0,
or 4.0.
Gl.INVALID_OPERATION is generated if
Gl.TexEnv
is executed between the execution of Gl.Begin
and the corresponding execution of Gl.End.
Associated Gets
Gl.GetTexEnv
See also
Gl.CopyTexSubImage1D,
Gl.CopyTexSubImage2D,
Gl.CopyTexSubImage3D,
Gl.TexImage3D,
Gl.TexParameter,
Gl.TexSubImage1D,
Gl.TexSubImage2D,
Gl.TexSubImage3D
See original documentation on OpenGL website