Pike v8.1 release 6

Method GL.glTexEnv()


Method glTexEnv

void glTexEnv(int target, int pname, float|int|array(float|int) param)

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 glTexImage1D, glTexImage2D, glCopyTexImage1D, and glCopyTexImage2D). In a one-component image, L sub t indicates that single component. A two-component image uses L sub t and A sub t. A three-component image has only a color value, C sub t. A four-component image has both a color value C sub t and an alpha value A sub t.

.ne .TS center box tab(:) ; ci || ci s s s ci || c c c c c || c | c | c | c. Base internal:Texture functions format:GL_MODULATE:GL_DECAL:GL_BLEND:GL_REPLACE = GL_ALPHA:C sub v = C sub f:undefined:C sub v = C sub f:C sub v = C sub f \^ :A sub v = A sub f A sub t:\^:A sub v = A sub f:A sub v = A sub t _ GL_LUMINANCE:C sub v = L sub t C sub f:undefined:C sub v = ( 1 - L sub t ) C sub f:C sub v = L sub t 1: : :+ L sub t C sub c: : : : : : A sub v = A sub f:\^: A sub v = A sub f:A sub v = A sub f _ GL_LUMINANCE:C sub v = L sub t C sub f:undefined:C sub v = ( 1 - L sub t ) C sub f :C sub v = L sub t \_ALPHA: : : + L sub t C sub c 2: : : : :A sub v = A sub t A sub f:\^:A sub v = A sub t A sub f:A sub v = A sub t _ GL_INTENSITY:C sub v = C sub f I sub t:undefined:C sub v = ( 1 - I sub t ) C sub f :C sub v = I sub t : : :+ I sub t C sub c : : : : \^ :A sub v = A sub f I sub t:\^:A sub v = ( 1 - I sub t ) A sub f :A sub v = I sub t : : :+ I sub t A sub c: _ GL_RGB:C sub v = C sub t C sub f:C sub v = C sub t:C sub v = (1 - C sub t) C sub f :C sub v = C sub t 3: : : + C sub t C sub c : : : : :A sub v = A sub f:A sub v = A sub f:A sub v = A sub f:A sub v = A sub f _ GL_RGBA:C sub v = C sub t C sub f:C sub v = ( 1 - A sub t ) C sub f :C sub v = (1 - C sub t) C sub f :C sub v = C sub t 4: :+ A sub t C sub t: + C sub t C sub c : : : : :A sub v = A sub t A sub f:A sub v = A sub f:A sub v = A sub t A sub f:A sub v = A sub t .TE .sp 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 sub c takes these four values.

GL_TEXTURE_ENV_MODE defaults to GL_MODULATE and GL_TEXTURE_ENV_COLOR defaults to (0, 0, 0, 0).

Parameter target

Specifies a texture environment. Must be GL_TEXTURE_ENV.

Parameter pname

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

Parameter param

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

Parameter target

Specifies a texture environment. Must be GL_TEXTURE_ENV.

Parameter pname

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

Parameter params

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

Throws

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_OPERATION is generated if glTexEnv is executed between the execution of glBegin and the corresponding execution of glEnd.