📄 texparameter.html
字号:
<HTML>
<BODY>
<PRE>
<STRONG>NAME</STRONG>
<STRONG>glTexParameterf,</STRONG> <STRONG>glTexParameteri,</STRONG> <STRONG>glTexParameterfv,</STRONG>
<STRONG>glTexParameteriv</STRONG> - set texture parameters
<STRONG>C</STRONG> <STRONG>SPECIFICATION</STRONG>
void <STRONG>glTexParameterf</STRONG>( GLenum <EM>target</EM>,
GLenum <EM>pname</EM>,
GLfloat <EM>param</EM> )
void <STRONG>glTexParameteri</STRONG>( GLenum <EM>target</EM>,
GLenum <EM>pname</EM>,
GLint <EM>param</EM> )
<STRONG>PARAMETERS</STRONG>
<EM>target</EM> Specifies the target texture, which must be either
<STRONG>GL_TEXTURE_1D</STRONG> or <STRONG>GL_TEXTURE_2D</STRONG>.
<EM>pname</EM> Specifies the symbolic name of a single-valued
texture parameter. <EM>pname</EM> can be one of the
following: <STRONG>GL_TEXTURE_MIN_FILTER</STRONG>,
<STRONG>GL_TEXTURE_MAG_FILTER</STRONG>, <STRONG>GL_TEXTURE_WRAP_S</STRONG>,
<STRONG>GL_TEXTURE_WRAP_T</STRONG>, or <STRONG>GL_TEXTURE_PRIORITY</STRONG>.
<EM>param</EM> Specifies the value of <EM>pname</EM>.
<STRONG>C</STRONG> <STRONG>SPECIFICATION</STRONG>
void <STRONG>glTexParameterfv</STRONG>( GLenum <EM>target</EM>,
GLenum <EM>pname</EM>,
const GLfloat *<EM>params</EM> )
void <STRONG>glTexParameteriv</STRONG>( GLenum <EM>target</EM>,
GLenum <EM>pname</EM>,
const GLint *<EM>params</EM> )
<STRONG>PARAMETERS</STRONG>
<EM>target</EM>
Specifies the target texture, which must be either
<STRONG>GL_TEXTURE_1D</STRONG> or <STRONG>GL_TEXTURE_2D</STRONG>.
<EM>pname</EM>
Specifies the symbolic name of a texture parameter.
<EM>pname</EM> can be one of the following:
<STRONG>GL_TEXTURE_MIN_FILTER</STRONG>, <STRONG>GL_TEXTURE_MAG_FILTER</STRONG>,
<STRONG>GL_TEXTURE_WRAP_S</STRONG>, <STRONG>GL_TEXTURE_WRAP_T</STRONG>,
<STRONG>GL_TEXTURE_BORDER_COLOR</STRONG>, or <STRONG>GL_TEXTURE_PRIORITY</STRONG>.
<EM>params</EM>
Specifies a pointer to an array where the value or
values of <EM>pname</EM> are stored.
<STRONG>DESCRIPTION</STRONG>
Texture mapping is a technique that applies an image onto an
object's surface as if the image were a decal or cellophane
shrink-wrap. The image is created in texture space, with an
(s, t) coordinate system. A texture is a one- or two-
dimensional image and a set of parameters that determine how
samples are derived from the image.
<STRONG>glTexParameter</STRONG> assigns the value or values in <EM>params</EM> to the
texture parameter specified as <EM>pname</EM>. <EM>target</EM> defines the
target texture, either <STRONG>GL_TEXTURE_1D</STRONG> or <STRONG>GL_TEXTURE_2D</STRONG>. The
following symbols are accepted in <EM>pname</EM>:
<STRONG>GL_TEXTURE_MIN_FILTER</STRONG>
The texture minifying function is used whenever
the pixel being textured maps to an area greater
than one texture element. There are six defined
minifying functions. Two of them use the nearest
one or nearest four texture elements to compute
the texture value. The other four use mipmaps.
A mipmap is an ordered set of arrays representing
the same image at progressively lower resolutions.
If the texture has dimensions 2nx2m, there are
max(n,m)+1 mipmaps. The first mipmap is the
original texture, with dimensions 2nx2m. Each
subsequent mipmap has dimensions 2k-1x2l-1, where
2kx2l are the dimensions of the previous mipmap,
until either k=0 or l=0. At that point,
subsequent mipmaps have dimension 1x2l-1 or 2k-1x1
until the final mipmap, which has dimension 1x1.
To define the mipmaps, call <STRONG>glTexImage1D</STRONG>,
<STRONG>glTexImage2D</STRONG>, <STRONG>glCopyTexImage1D</STRONG>, or
<STRONG>glCopyTexImage2D</STRONG> with the <EM>level</EM> argument
indicating the order of the mipmaps. Level 0 is
the original texture; level max(n,m) is the final
1x1 mipmap.
<EM>params</EM> supplies a function for minifying the
texture as one of the following:
<STRONG>GL_NEAREST</STRONG>
Returns the value of the texture element
that is nearest (in Manhattan distance)
to the center of the pixel being
textured.
<STRONG>GL_LINEAR</STRONG> Returns the weighted average of the four
texture elements that are closest to the
center of the pixel being textured.
These can include border texture
elements, depending on the values of
<STRONG>GL_TEXTURE_WRAP_S</STRONG> and <STRONG>GL_TEXTURE_WRAP_T</STRONG>,
and on the exact mapping.
<STRONG>GL_NEAREST_MIPMAP_NEAREST</STRONG>
Chooses the mipmap that most closely
matches the size of the pixel being
textured and uses the <STRONG>GL_NEAREST</STRONG>
criterion (the texture element nearest
to the center of the pixel) to produce a
texture value.
<STRONG>GL_LINEAR_MIPMAP_NEAREST</STRONG>
Chooses the mipmap that most closely
matches the size of the pixel being
textured and uses the <STRONG>GL_LINEAR</STRONG>
criterion (a weighted average of the
four texture elements that are closest
to the center of the pixel) to produce a
texture value.
<STRONG>GL_NEAREST_MIPMAP_LINEAR</STRONG>
Chooses the two mipmaps that most
closely match the size of the pixel
being textured and uses the <STRONG>GL_NEAREST</STRONG>
criterion (the texture element nearest
to the center of the pixel) to produce a
texture value from each mipmap. The
final texture value is a weighted
average of those two values.
<STRONG>GL_LINEAR_MIPMAP_LINEAR</STRONG>
Chooses the two mipmaps that most
closely match the size of the pixel
being textured and uses the <STRONG>GL_LINEAR</STRONG>
criterion (a weighted average of the
four texture elements that are closest
to the center of the pixel) to produce a
texture value from each mipmap. The
final texture value is a weighted
average of those two values.
As more texture elements are sampled in the
minification process, fewer aliasing artifacts
will be apparent. While the <STRONG>GL_NEAREST</STRONG> and
<STRONG>GL_LINEAR</STRONG> minification functions can be faster
than the other four, they sample only one or four
texture elements to determine the texture value of
the pixel being rendered and can produce moire
patterns or ragged transitions. The initial value
of <STRONG>GL_TEXTURE_MIN_FILTER</STRONG> is
<STRONG>GL_NEAREST_MIPMAP_LINEAR</STRONG>.
<STRONG>GL_TEXTURE_MAG_FILTER</STRONG>
The texture magnification function is used when
the pixel being textured maps to an area less than
or equal to one texture element. It sets the
texture magnification function to either
<STRONG>GL_NEAREST</STRONG> or <STRONG>GL_LINEAR</STRONG> (see below). <STRONG>GL_NEAREST</STRONG> is
generally faster than <STRONG>GL_LINEAR</STRONG>, but it can
produce textured images with sharper edges because
the transition between texture elements is not as
smooth. The initial value of <STRONG>GL_TEXTURE_MAG_FILTER</STRONG>
is <STRONG>GL_LINEAR</STRONG>.
<STRONG>GL_NEAREST</STRONG>
Returns the value of the texture element
that is nearest (in Manhattan distance)
to the center of the pixel being
textured.
<STRONG>GL_LINEAR</STRONG> Returns the weighted average of the four
texture elements that are closest to the
center of the pixel being textured.
These can include border texture
elements, depending on the values of
<STRONG>GL_TEXTURE_WRAP_S</STRONG> and <STRONG>GL_TEXTURE_WRAP_T</STRONG>,
and on the exact mapping.
<STRONG>GL_TEXTURE_WRAP_S</STRONG>
Sets the wrap parameter for texture coordinate <EM>s</EM>
to either <STRONG>GL_CLAMP</STRONG> or <STRONG>GL_REPEAT</STRONG>. <STRONG>GL_CLAMP</STRONG> causes
s coordinates to be clamped to the range [0,1] and
is useful for preventing wrapping artifacts when
mapping a single image onto an object. <STRONG>GL_REPEAT</STRONG>
causes the integer part of the s coordinate to be
ignored; the GL uses only the fractional part,
thereby creating a repeating pattern. Border
texture elements are accessed only if wrapping is
set to <STRONG>GL_CLAMP</STRONG>. Initially, <STRONG>GL_TEXTURE_WRAP_S</STRONG> is
set to <STRONG>GL_REPEAT</STRONG>.
<STRONG>GL_TEXTURE_WRAP_T</STRONG>
Sets the wrap parameter for texture coordinate <EM>t</EM>
to either <STRONG>GL_CLAMP</STRONG> or <STRONG>GL_REPEAT</STRONG>. See the
discussion under <STRONG>GL_TEXTURE_WRAP_S</STRONG>. Initially,
<STRONG>GL_TEXTURE_WRAP_T</STRONG> is set to <STRONG>GL_REPEAT</STRONG>.
<STRONG>GL_TEXTURE_BORDER_COLOR</STRONG>
Sets a border color. <EM>params</EM> contains four values
that comprise the RGBA color of the texture
border. 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. Initially, the border
color is (0, 0, 0, 0).
<STRONG>GL_TEXTURE_PRIORITY</STRONG>
Specifies the texture residence priority of the
currently bound texture. Permissible values are
in the range [0, 1]. See <STRONG>glPrioritizeTextures</STRONG> and
<STRONG>glBindTexture</STRONG> for more information.
<STRONG>NOTES</STRONG>
Suppose that a program has enabled texturing (by calling
<STRONG>glEnable</STRONG> with argument <STRONG>GL_TEXTURE_1D</STRONG> or <STRONG>GL_TEXTURE_2D</STRONG>) and
has set <STRONG>GL_TEXTURE_MIN_FILTER</STRONG> to one of the functions that
requires a mipmap. If either the dimensions of the texture
images currently defined (with previous calls to
<STRONG>glTexImage1D</STRONG>, <STRONG>glTexImage2D</STRONG>, <STRONG>glCopyTexImage1D</STRONG>, or
<STRONG>glCopyTexImage2D</STRONG>) do not follow the proper sequence for
mipmaps (described above), or there are fewer texture images
defined than are needed, or the set of texture images have
differing numbers of texture components, then it is as if
texture mapping were disabled.
Linear filtering accesses the four nearest texture elements
only in 2D textures. In 1D textures, linear filtering
accesses the two nearest texture elements.
<STRONG>ERRORS</STRONG>
<STRONG>GL_INVALID_ENUM</STRONG> is generated if <EM>target</EM> or <EM>pname</EM> is not one
of the accepted defined values.
<STRONG>GL_INVALID_ENUM</STRONG> is generated if <EM>params</EM> should have a defined
constant value (based on the value of <EM>pname</EM>) and does not.
<STRONG>GL_INVALID_OPERATION</STRONG> is generated if <STRONG>glTexParameter</STRONG> is
executed between the execution of <STRONG>glBegin</STRONG> and the
corresponding execution of <STRONG>glEnd</STRONG>.
<STRONG>ASSOCIATED</STRONG> <STRONG>GETS</STRONG>
<STRONG>glGetTexParameter</STRONG>
<STRONG>glGetTexLevelParameter</STRONG>
<STRONG>SEE</STRONG> <STRONG>ALSO</STRONG>
<STRONG>glBindTexture</STRONG>, <STRONG>glCopyPixels</STRONG>, <STRONG>glCopyTexImage1D</STRONG>,
<STRONG>glCopyTexImage2D</STRONG>, <STRONG>glCopyTexSubImage1D</STRONG>, <STRONG>glCopyTexSubImage2D</STRONG>,
<STRONG>glDrawPixels</STRONG>, <STRONG>glPixelStore</STRONG>, <STRONG>glPixelTransfer</STRONG>,
<STRONG>glPrioritizeTextures</STRONG>, <STRONG>glTexEnv</STRONG>, <STRONG>glTexGen</STRONG>, <STRONG>glTexImage1D</STRONG>,
<STRONG>glTexImage2D</STRONG>, <STRONG>glTexSubImage1D</STRONG>, <STRONG>glTexSubImage2D</STRONG>
</PRE>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -