Signature
Parameters
Description
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.
Texture Base Internal Format | ||
---|---|---|
GL_ALPHA | (0, 0, 0) | |
GL_LUMINANCE | ( , , ) | 1 |
GL_LUMINANCE_ALPHA | ( , , ) | |
GL_INTENSITY | ( , , ) | |
GL_RGB | ( , , ) | 1 |
GL_RGBA | ( , , ) |
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.
Texture Base Internal Format | Value | GL_REPLACE Function | GL_MODULATE Function | GL_DECAL Function | GL_BLEND Function | GL_ADD Function |
---|---|---|---|---|---|---|
GL_ALPHA | undefined | |||||
GL_LUMINANCE | undefined | |||||
(or 1) | ||||||
GL_LUMINANCE_ALPHA | undefined | |||||
(or 2) | ||||||
GL_INTENSITY | undefined | |||||
GL_RGB | ||||||
(or 3) | ||||||
GL_RGBA | ||||||
(or 4) |
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
,
GL_SRC1_c
is
represented by
,
and
GL_SRC2_c
is represented by
.
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
.
GL_COMBINE_RGB | Texture Function |
---|---|
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:
GL_COMBINE_ALPHA | Texture Function |
---|---|
GL_REPLACE | |
GL_MODULATE | |
GL_ADD | |
GL_ADD_SIGNED | |
GL_INTERPOLATE | |
GL_SUBTRACT |
In the following tables, the value
represents the color sampled
from the currently bound texture,
represents the constant
texture-environment color,
represents the primary color of the
incoming fragment, and
represents the color computed from the
previous texture stage or
if processing texture stage 0. Likewise,
,
,
,
and
represent the respective
alpha values.
The following table describes the values assigned to
,
,
and
based upon the RGB sources and operands:
GL_SRCn_RGB | GL_OPERANDn_RGB | Argument Value |
---|---|---|
GL_TEXTURE | GL_SRC_COLOR | |
GL_ONE_MINUS_SRC_COLOR | ||
GL_SRC_ALPHA | ||
GL_ONE_MINUS_SRC_ALPHA | ||
GL_TEXTUREn | GL_SRC_COLOR | |
GL_ONE_MINUS_SRC_COLOR | ||
GL_SRC_ALPHA | ||
GL_ONE_MINUS_SRC_ALPHA | ||
GL_CONSTANT | GL_SRC_COLOR | |
GL_ONE_MINUS_SRC_COLOR | ||
GL_SRC_ALPHA | ||
GL_ONE_MINUS_SRC_ALPHA | ||
GL_PRIMARY_COLOR | GL_SRC_COLOR | |
GL_ONE_MINUS_SRC_COLOR | ||
GL_SRC_ALPHA | ||
GL_ONE_MINUS_SRC_ALPHA | ||
GL_PREVIOUS | GL_SRC_COLOR | |
GL_ONE_MINUS_SRC_COLOR | ||
GL_SRC_ALPHA | ||
GL_ONE_MINUS_SRC_ALPHA |
For
GL_TEXTUREn
sources,
and
represent the color
and alpha, respectively, produced from texture stage
.
The follow table describes the values assigned to
,
,
and
based upon the alpha sources and operands:
GL_SRCn_ALPHA | GL_OPERANDn_ALPHA | Argument Value |
---|---|---|
GL_TEXTURE | GL_SRC_ALPHA | |
GL_ONE_MINUS_SRC_ALPHA | ||
GL_TEXTUREn | GL_SRC_ALPHA | |
GL_ONE_MINUS_SRC_ALPHA | ||
GL_CONSTANT | GL_SRC_ALPHA | |
GL_ONE_MINUS_SRC_ALPHA | ||
GL_PRIMARY_COLOR | GL_SRC_ALPHA | |
GL_ONE_MINUS_SRC_ALPHA | ||
GL_PREVIOUS | GL_SRC_ALPHA | |
GL_ONE_MINUS_SRC_ALPHA |
The RGB and alpha results of the texture function are multiplied by the
values of
GL_RGB_SCALE
and
GL_ALPHA_SCALE
, respectively, and
clamped to the range
.
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.
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).
Notes
GL_REPLACE
may only be used if the GL version is 1.1 or greater.
GL_TEXTURE_FILTER_CONTROL
and
GL_TEXTURE_LOD_BIAS
may only be
used if the GL version is 1.4 or greater.
GL_COMBINE
mode and its associated constants may only be used if the
GL version is 1.3 or greater.
GL_TEXTUREn
may only be used if the GL version is 1.4 or greater.
Internal formats other than 1, 2, 3, or 4 may only be used if the GL
version is 1.1 or greater.
For OpenGL versions 1.3 and greater, or when the
ARB_multitexture
extension is supported,
glTexEnv
controls
the texture environment for the current active texture unit, selected by
glActiveTexture
.
GL_POINT_SPRITE
and
GL_COORD_REPLACE
are available
only if the GL version is 2.0 or greater.
Errors
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_VALUE
is generated if the
params
value for
GL_RGB_SCALE
or
GL_ALPHA_SCALE
are not one of 1.0, 2.0,
or 4.0.
Associated Gets
See Also
Copyright
Copyright
1991-2006
Silicon Graphics, Inc. This document is licensed under the SGI
Free Software B License. For details, see
http://oss.sgi.com/projects/FreeB/
.
Sample Code References
The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.
glTexEnvf
{LGPL or GPL or MPL} Kamaelia
Code/Python/Kamaelia/Kamaelia/Visualisation/PhysicsGraph3D/Particles3D.py
Lines: 517, 581, 627
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 844
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Kamaelia/UI/OpenGL/PygameWrapper.py
Lines: 190
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/PygameWrapperPlane.py
Lines: 77
{LGPL or GPL or MPL} Kamaelia
Sketches/CL/Topology3D/THF/Sketches/playground/Display3D.py
Lines: 533
{LGPL or GPL or MPL} Kamaelia
Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/Visualisation/PhysicsGraph3D/Particles3D.py
Lines: 517, 581, 627
{LGPL or GPL or MPL} Kamaelia
Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 866
{LGPL or GPL or MPL} Kamaelia
Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/PygameWrapper.py
Lines: 190
{LGPL or GPL or MPL} Kamaelia
Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/Button.py
Lines: 171
{LGPL or GPL or MPL} Kamaelia
Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/TexPlane.py
Lines: 97
{LGPL or GPL or MPL} Kamaelia
Sketches/MPS/BugReports/FixTests/Kamaelia/Kamaelia/UI/OpenGL/Label.py
Lines: 146
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/OpenGLDisplay.py
Lines: 843
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/PygameWrapper.py
Lines: 190
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Button.py
Lines: 171
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/TexPlane.py
Lines: 97
{LGPL or GPL or MPL} Kamaelia
Sketches/THF/Packages/Kamaelia/Community/THF/Kamaelia/UI/OpenGL/Label.py
Lines: 146
glTexEnvfv
glTexEnvi