Specifies a texture environment. May be either GL_TEXTURE_ENV, or GL_TEXTURE_FILTER_CONTROL.
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.
Specifies a pointer to a parameter array that contains either a single symbolic constant, single floating-point number, or an RGBA color.
Generated using TypeDoc
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.
A texture function acts on the fragment to be textured using the texture image value that applies to the fragment (see glTexParameter) 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 [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.
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.
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:
In the following tables, the value Cโ represents the color sampled from the currently bound texture, C๐ represents the constant texture-environment color, C๐ represents the primary color of the incoming fragment, and Cโ represents the color computed from the previous texture stage or C๐ if processing texture stage 0. Likewise, Aโ, A๐ A๐ and Aโ represent the respective alpha values.
The following table describes the values assigned to Arg0, Arg1 and Arg2 based upon the RGB sources and operands:
For GL_TEXTUREn sources, Cโ and Aโ represent the color and alpha, respectively, produced from texture stage ๐ง.
The follow table describes the values assigned to Arg0, Arg1, and Arg2 based upon the alpha sources and operands:
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 [0,1] when they are specified. 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.