Sets texture environment parameters.
OpenGL C bindings library: libGL.a
void glTexEnvf(GLenum Target, GLenum pName, GLfloat Parameter)
void glTexEnvi(GLenum Target, GLenum pName, GLint Parameter)
void glTexEnvfv(GLenum Target, GLenum pName, const GLfloat *Parameters)
void glTexEnviv(GLenum Target, GLenum pName, const GLint *Parameters)
A texture environment specifies how texture values are interpreted when a fragment is textured. The Target parameter must be GL_TEXTURE_ENV. The pName parameter can be either GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR.
If the pName parameter is GL_TEXTURE_ENV_MODE, the Parameters parameter is (or points to) the symbolic name of a texture function. Three texture functions are defined: GL_MODULATE, GL_DECAL, GL_BLEND, or GL_REPLACE.
A texture function acts on the fragment to be textured using the texture image value that applies to the fragment and produces a red, green, blue, alpha (RGBA) color for that fragment. (See the glTexParameter subroutine for details on setting texture parameters.) The following table shows how the RGBA color is produced for each of the four 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 the glTexImage1D subroutine, the glTexImage2D subroutine, and the glTexImage3DEXT subroutine.) 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.
Note: In the following table, "It" equals the texture intensity.
Texture Functions | ||||
Internal Formats | GL_MODULATE | GL_DECAL | GL_BLEND | GL_REPLACE |
GL_LUMINANCE or 1 | Cv=LtCf Av=Af | undefined | Cv=(1-Lt) Cf+LtCc Av=Af | Cv=Lt Av=Af |
GL_LUMINANCE_ALPHA or 2 | Cv=LtCf Av=AtAf | undefined | Cv=(1-Lt) Cf+LtCc Av=AtAf | Cv=Lt Av=At |
GL_RGB or 3 | Cv=CtCf Av=Af | Cv=Ct Av=Af | Cv=(1-Ct) Cf+CtCc Av=Af | Cv=Ct Av=Af |
GL_RGB or 4 | Cv=CtCf Av=AtAf | Cv=(1-At) Cf+AtCt Av=Af | Cv=(1-Ct) Cf+CtCc Av=AtAf | Cv=Ct Av=At |
GL_INTENSITY | Cv=ItCf Av=ItAf | undefined | Cv=(1-It) Cf+ItCc Av=(1-It) Af+ItAc | Cv=It Av=It |
GL_ALPHA | Cv=Cf Av=AtAf | undefined | Cv=Cf Av=AtAf | Cv=Cf Av=At |
If the pName parameter is GL_TEXTURE_ENV_COLOR, the Parameters parameter 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. Cc takes these four values.
GL_TEXTURE_ENV_MODE defaults to GL_MODULATE and GL_TEXTURE_ENV_COLOR defaults to (0,0,0,0).
Associated gets for the glTexEnv subroutine are as follows. (See the glGet subroutine for more information.)
/usr/include/GL/gl.h | Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL. |
The glBegin or glEnd subroutine, glGetTexEnv subroutine, glTexImage1D subroutine, glTexImage2D subroutine, glTexParameter subroutine.