Name

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

C Specification

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

Parameters

target

Specifies a texture environment. Must be GL_TEXTURE_ENV.

pname

Specifies the symbolic name of a single-valued texture environment parameter. Must be GL_TEXTURE_ENV_MODE.

param

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

C Specification

void glTexEnvfv(GLenum pname, const GLfloat * params)
void glTexEnvxv(GLenum pname, const GLfixed * params)

Parameters

target

Specifies a texture environment. Must be GL_TEXTURE_ENV.

pname

Specifies the symbolic name of a texture environment parameter. Accepted values are GL_TEXTURE_ENV_MODE and GL_TEXTURE_ENV_COLOR.

params

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

Description

A texture environment specifies how texture values are interpreted when a fragment is textured. target must be GL_TEXTURE_ENV. pname can be either GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR.

If pname is GL_TEXTURE_ENV_MODE, then params is (or points to) the symbolic name of a texture function. Four texture functions may be specified: GL_MODULATE, GL_DECAL, GL_BLEND, and GL_REPLACE.

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.

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

If pname is GL_TEXTURE_ENV_COLOR, 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).

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.

Copyright

Copyright © 2003 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