Gl.TexEnviv (gb.opengl)

Static Sub TexEnviv ( Target As Integer, Pname As Integer, Params 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 R t, G t, B t, A t, L t, I t to texture source components. C s and A s are used by the texture functions described below.

Texture Base Internal Format C s A s
Gl.ALPHA (0, 0, 0) A t
Gl.LUMINANCE ( L t, L t, L t ) 1
Gl.LUMINANCE_ALPHA ( L t, L t, L t ) A t
Gl.INTENSITY ( I t, I t, I t ) I t
Gl.RGB ( R t, G t, B t ) 1
Gl.RGBA ( R t, G t, B t ) A t

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. C is a triple of color values (RGB) and A is the associated alpha value. RGBA values extracted from a texture image are in the range /wiki/0,1. The subscript p refers to the color computed from the previous texture stage (or the incoming fragment if processing texture stage 0), the subscript s to the texture source color, the subscript c to the texture environment color, and the subscript v 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 C v C p C p undefined C p C p
A v A s A p A s A v A p A s A p A s
Gl.LUMINANCE C v C s C p C s undefined C p 1 - C s + C c C s C p + C s
(or 1) A v A p A p A p A p
Gl.LUMINANCE_ALPHA C v C s C p C s undefined C p 1 - C s + C c C s C p + C s
(or 2) A v A s A p A s A p A s A p A s
Gl.INTENSITY C v C s C p C s undefined C p 1 - C s + C c C s C p + C s
A v A s A p A s A p 1 - A s + A c A s A p + A s
Gl.RGB C v C s C p C s C s C p 1 - C s + C c C s C p + C s
(or 3) A v A p A p A p A p A p
Gl.RGBA C v C s C p C s C p 1 - A s + C s A s C p 1 - C s + C c C s C p + C s
(or 4) A v A s A p A s A p A p A s A p A s

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 Arg0, Gl.SRC1_c is represented by Arg1, and Gl.SRC2_c is represented by Arg2.

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 Arg0
Gl.MODULATE Arg0 × Arg1
Gl.ADD Arg0 + Arg1
Gl.ADD_SIGNED Arg0 + Arg1 - 0.5
Gl.INTERPOLATE Arg0 × Arg2 + Arg1 × 1 - Arg2
Gl.SUBTRACT Arg0 - Arg1
Gl.DOT3_RGB or Gl.DOT3_RGBA 4 × Arg0 r - 0.5 × Arg1 r - 0.5 + Arg0 g - 0.5 × Arg1 g - 0.5 + Arg0 b - 0.5 × Arg1 b - 0.5

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 Arg0
Gl.MODULATE Arg0 × Arg1
Gl.ADD Arg0 + Arg1
Gl.ADD_SIGNED Arg0 + Arg1 - 0.5
Gl.INTERPOLATE Arg0 × Arg2 + Arg1 × 1 - Arg2
Gl.SUBTRACT Arg0 - Arg1

In the following tables, the value C s represents the color sampled from the currently bound texture, C c represents the constant texture-environment color, C f represents the primary color of the incoming fragment, and C p represents the color computed from the previous texture stage or C f if processing texture stage 0. Likewise, A s , A c , A f , and A p represent the respective alpha values.

The following table describes the values assigned to Arg0, Arg1, and Arg2 based upon the RGB sources and operands:

Gl.SRCn_RGB Gl.OPERANDn_RGB Argument Value
Gl.TEXTURE Gl.SRC_COLOR C s
Gl.ONE_MINUS_SRC_COLOR 1 - C s
Gl.SRC_ALPHA A s
Gl.ONE_MINUS_SRC_ALPHA 1 - A s
Gl.TEXTUREn Gl.SRC_COLOR C s
Gl.ONE_MINUS_SRC_COLOR 1 - C s
Gl.SRC_ALPHA A s
Gl.ONE_MINUS_SRC_ALPHA 1 - A s
Gl.CONSTANT Gl.SRC_COLOR C c
Gl.ONE_MINUS_SRC_COLOR 1 - C c
Gl.SRC_ALPHA A c
Gl.ONE_MINUS_SRC_ALPHA 1 - A c
Gl.PRIMARY_COLOR Gl.SRC_COLOR C f
Gl.ONE_MINUS_SRC_COLOR 1 - C f
Gl.SRC_ALPHA A f
Gl.ONE_MINUS_SRC_ALPHA 1 - A f
Gl.PREVIOUS Gl.SRC_COLOR C p
Gl.ONE_MINUS_SRC_COLOR 1 - C p
Gl.SRC_ALPHA A p
Gl.ONE_MINUS_SRC_ALPHA 1 - A p

For Gl.TEXTUREn sources, C s and A s represent the color and alpha, respectively, produced from texture stage n.

The follow table describes the values assigned to Arg0, Arg1, and Arg2 based upon the alpha sources and operands:

Gl.SRCn_ALPHA Gl.OPERANDn_ALPHA Argument Value
Gl.TEXTURE Gl.SRC_ALPHA A s
Gl.ONE_MINUS_SRC_ALPHA 1 - A s
Gl.TEXTUREn Gl.SRC_ALPHA A s
Gl.ONE_MINUS_SRC_ALPHA 1 - A s
Gl.CONSTANT Gl.SRC_ALPHA A c
Gl.ONE_MINUS_SRC_ALPHA 1 - A c
Gl.PRIMARY_COLOR Gl.SRC_ALPHA A f
Gl.ONE_MINUS_SRC_ALPHA 1 - A f
Gl.PREVIOUS Gl.SRC_ALPHA A p
Gl.ONE_MINUS_SRC_ALPHA 1 - A p

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 0 1 .

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. C c 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