Name

glTexEnvf , glTexEnvx , glTexEnvfv , glTexEnvxv - set texture environment parameters

C Specification

void glTexEnvf(GLenum target, GLenum pname, GLfloat param)
void glTexEnvx(GLenum target, GLenum pname, GLfixed param)

Parameters

target

Specifies a texture environment. Can be either GL_TEXTURE_ENV or GL_POINT_SPRITE_OES.

pname

Specifies the symbolic name of a single-valued texture environment parameter. Must be one of GL_TEXTURE_ENV_MODE, GL_TEXTURE_ENV_COLOR, GL_COMBINE_RGB, GL_COMBINE_ALPHA, or GL_COORD_REPLACE_OES.

param

Specifies a single symbolic constant, one of GL_REPLACE, GL_MODULATE, GL_DECAL, GL_BLEND, or GL_ADD.

C Specification

void glTexEnvfv(GLenum target,
    GLenum pname,
    const GLfloat * params)

void glTexEnvxv(GLenum target,
    GLenum pname,
    const GLfixed * params)

Parameters

target

Specifies a texture environment. Can be either GL_TEXTURE_ENV or GL_POINT_SPRITE_OES.

pname

Specifies the symbolic name of a single-valued texture environment parameter. Must be one of GL_TEXTURE_ENV_MODE, GL_TEXTURE_ENV_COLOR, GL_COMBINE_RGB, GL_COMBINE_ALPHA, or GL_COORD_REPLACE_OES.

params

Specifies a pointer to a parameter array that contains either a single symbolic constant or an RGBA color.

Description

If target is GL_TEXTURE_ENV, then the following applies:

A texture environment specifies how texture values are interpreted when a fragment is textured.

If pname is GL_TEXTURE_ENV_MODE, then params is (or points to) the symbolic name of a texture function:

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 three 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 [0, 1]. The subscript f refers to the incoming fragment, the subscript t to the texture image, the subscript c to the texture environment color, and subscript v indicates a value produced by the texture function.

A texture image can have up to four components per texture element (see glTexImage2D, and glCopyTexImage2D). In a one-component image, Lt indicates that single component. A two-component image uses Lt and At. A three-component image has only a color value Ct. A four-component image has both a color value Ct and an alpha value At.

For texture functions: GL_REPLACE, GL_MODULATE, GL_DECAL, GL_BLEND, or GL_ADD:

Base internal Texture functions
format GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD
GL_ALPHA Cv = Cf Cv = Cf undefined Cv = Cf Cv = Cf
Av = At Av = Af At Av = Af At Av = Af At
GL_LUMINANCE Cv = Lt Cv = Cf Lt undefined Cv = Cf (1 - Lt) + Cc Lt Cv = Cf + Lt
Av = Af Av = Af Av = Af Av = Af
GL_LUMINANCE_ALPHA Cv = Lt Cv = Cf Lt undefined Cv = Cf (1 - Lt) + Cc Lt Cv = Cf + Lt
Av = At Av = Af At Av = Af At Av = Af At
GL_RGB Cv = Ct Cv = Cf Ct Cv = Ct Cv = Cf (1 - Ct) + Cc Ct Cv = Cf + Ct
Av = Af Av = Af Av = Af Av = Af Av = Af
GL_RGBA Cv = Ct Cv = Cf Ct Cv = Cf (1 - At) + Ct At Cv = Cf (1 - Ct) + Cc Ct Cv = Cf + Ct
Av = At Av = Af At Av = Af Av = Af At Av = Af At

If the value of GL_TEXTURE_ENV_MODE is GL_COMBINE, then the form of the texture function depends on the values of GL_COMBINE_RGB and GL_COMBINE_ALPHA,

The RGB and ALPHA results of the texture function are then multiplied by the values of GL_RGB_SCALE and GL_ALPHA_SCALE, respectively.

The results are clamped to [0, 1].

The arguments Arg0, Arg1, Arg2 are determined by the values of GL_SRCn_RGB, GL_SRCn_ALPHA, GL_OPERANDn_RGB, GL_OPERANDn_ALPHA, where n = 0,1, or 2, Cs and As denote the texture source color and alpha from the texture image bound to texture unit n

The state required for the current texture environment, for each texture unit, consists of a six-valued integer indicating the texture function, an eight-valued integer indicating the RGB combiner function and a six-valued integer indicating the ALPHA combiner function, six four-valued integers indicating the combiner RGB and ALPHA source arguments, three four-valued integers indicating the combiner RGB operands, three two-valued integers indicating the combiner ALPHA operands, and four floating-point environment color values. In the initial state, the texture and combiner functions are each GL_MODULATE, the combiner RGB and ALPHA sources are each GL_TEXTURE, GL_PREVIOUS, and GL_CONSTANT for sources 0, 1, and 2 respectively, the combiner RGB operands for sources 0 and 1 are each SRC_COLOR, the combiner RGB operand for source 2, as well as for the combiner ALPHA operands, are each GL_SRC_ALPHA, and the environment color is (0, 0, 0, 0).

The state required for the texture filtering parameters, for each texture unit, consists of a single floating-point level of detail bias. The initial value of the bias is 0.0.

If pname is GL_TEXTURE_ENV_COLOR, then params is a pointer to an array that holds an RGBA color consisting of four values. The values are clamped to the range [0, 1] when they are specified. Cc takes these four values.

The initial value of GL_TEXTURE_ENV_MODE is GL_MODULATE. The initial value of GL_TEXTURE_ENV_COLOR is (0, 0, 0, 0).

If target is GL_POINT_SPRITE_OES then the following applies:

If pname is GL_COORD_REPLACE_OES, then the point sprite texture coordinate replacement mode is set from the value given by param, which may either be GL_FALSE or GL_TRUE. The default value for each texture unit is for point sprite texture coordinate replacement to be disabled.

Errors

GL_INVALID_ENUM is generated when target or pname is not one of the accepted values, or when params should have a defined constant value (based on the value of pname) and does not.

Associated Gets

glGetTexEnv

Copyright

Copyright © 2003-2004 Silicon Graphics, Inc.

This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.

See Also

glActiveTexture, glCompressedTexImage2D, glCompressedTexSubImage2D, glCopyTexImage2D, glCopyTexSubImage2D, glTexImage2D, glTexParameter, glTexSubImage2D