📄 light.html
字号:
<HTML>
<BODY>
<PRE>
<STRONG>NAME</STRONG>
<STRONG>glLightf,</STRONG> <STRONG>glLighti,</STRONG> <STRONG>glLightfv,</STRONG> <STRONG>glLightiv</STRONG> - set light source
parameters
<STRONG>C</STRONG> <STRONG>SPECIFICATION</STRONG>
void <STRONG>glLightf</STRONG>( GLenum <EM>light</EM>,
GLenum <EM>pname</EM>,
GLfloat <EM>param</EM> )
void <STRONG>glLighti</STRONG>( GLenum <EM>light</EM>,
GLenum <EM>pname</EM>,
GLint <EM>param</EM> )
<STRONG>PARAMETERS</STRONG>
<EM>light</EM> Specifies a light. The number of lights depends on
the implementation, but at least eight lights are
supported. They are identified by symbolic names of
the form <STRONG>GL_LIGHT</STRONG>i where 0 <EM><</EM> i < <STRONG>GL_MAX_LIGHTS</STRONG>.
<EM>pname</EM> Specifies a single-valued light source parameter for
<EM>light</EM>. <STRONG>GL_SPOT_EXPONENT</STRONG>, <STRONG>GL_SPOT_CUTOFF</STRONG>,
<STRONG>GL_CONSTANT_ATTENUATION</STRONG>, <STRONG>GL_LINEAR_ATTENUATION</STRONG>, and
<STRONG>GL_QUADRATIC_ATTENUATION</STRONG> are accepted.
<EM>param</EM> Specifies the value that parameter <EM>pname</EM> of light
source <EM>light</EM> will be set to.
<STRONG>C</STRONG> <STRONG>SPECIFICATION</STRONG>
void <STRONG>glLightfv</STRONG>( GLenum <EM>light</EM>,
GLenum <EM>pname</EM>,
const GLfloat *<EM>params</EM> )
void <STRONG>glLightiv</STRONG>( GLenum <EM>light</EM>,
GLenum <EM>pname</EM>,
const GLint *<EM>params</EM> )
<STRONG>PARAMETERS</STRONG>
<EM>light</EM>
Specifies a light. The number of lights depends on the
implementation, but at least eight lights are
supported. They are identified by symbolic names of
the form <STRONG>GL_LIGHT</STRONG>i where 0 <EM><</EM> i < <STRONG>GL_MAX_LIGHTS</STRONG>.
<EM>pname</EM>
Specifies a light source parameter for <EM>light</EM>.
<STRONG>GL_AMBIENT</STRONG>, <STRONG>GL_DIFFUSE</STRONG>, <STRONG>GL_SPECULAR</STRONG>, <STRONG>GL_POSITION</STRONG>,
<STRONG>GL_SPOT_CUTOFF</STRONG>, <STRONG>GL_SPOT_DIRECTION</STRONG>, <STRONG>GL_SPOT_EXPONENT</STRONG>,
<STRONG>GL_CONSTANT_ATTENUATION</STRONG>, <STRONG>GL_LINEAR_ATTENUATION</STRONG>, and
<STRONG>GL_QUADRATIC_ATTENUATION</STRONG> are accepted.
<EM>params</EM>
Specifies a pointer to the value or values that
parameter <EM>pname</EM> of light source <EM>light</EM> will be set to.
<STRONG>DESCRIPTION</STRONG>
<STRONG>glLight</STRONG> sets the values of individual light source
parameters. <EM>light</EM> names the light and is a symbolic name of
the form <STRONG>GL_LIGHT</STRONG>i, where 0 <EM><</EM> i < <STRONG>GL_MAX_LIGHTS</STRONG>. <EM>pname</EM>
specifies one of ten light source parameters, again by
symbolic name. <EM>params</EM> is either a single value or a pointer
to an array that contains the new values.
To enable and disable lighting calculation, call <STRONG>glEnable</STRONG>
and <STRONG>glDisable</STRONG> with argument <STRONG>GL_LIGHTING</STRONG>. Lighting is
initially disabled. When it is enabled, light sources that
are enabled contribute to the lighting calculation. Light
source i is enabled and disabled using <STRONG>glEnable</STRONG> and
<STRONG>glDisable</STRONG> with argument <STRONG>GL_LIGHT</STRONG>i.
The ten light parameters are as follows:
<STRONG>GL_AMBIENT</STRONG> <EM>params</EM> contains four integer or
floating-point values that specify the
ambient RGBA intensity of the light.
Integer values are mapped linearly such
that the most positive representable
value maps to 1.0, and the most negative
representable value maps to -1.0.
Floating-point values are mapped
directly. Neither integer nor
floating-point values are clamped. The
initial ambient light intensity is (0,
0, 0, 1).
<STRONG>GL_DIFFUSE</STRONG> <EM>params</EM> contains four integer or
floating-point values that specify the
diffuse RGBA intensity of the light.
Integer values are mapped linearly such
that the most positive representable
value maps to 1.0, and the most negative
representable value maps to -1.0.
Floating-point values are mapped
directly. Neither integer nor
floating-point values are clamped. The
initial value for <STRONG>GL_LIGHT0</STRONG> is (1, 1, 1,
1); for other lights, the initial value
is (0, 0, 0, 0).
<STRONG>GL_SPECULAR</STRONG> <EM>params</EM> contains four integer or
floating-point values that specify the
specular RGBA intensity of the light.
Integer values are mapped linearly such
that the most positive representable
value maps to 1.0, and the most negative
representable value maps to -1.0.
Floating-point values are mapped
directly. Neither integer nor
floating-point values are clamped. The
initial value for <STRONG>GL_LIGHT0</STRONG> is (1, 1, 1,
1); for other lights, the initial value
is (0, 0, 0, 0).
<STRONG>GL_POSITION</STRONG> <EM>params</EM> contains four integer or
floating-point values that specify the
position of the light in homogeneous
object coordinates. Both integer and
floating-point values are mapped
directly. Neither integer nor
floating-point values are clamped.
The position is transformed by the
modelview matrix when <STRONG>glLight</STRONG> is called
(just as if it were a point), and it is
stored in eye coordinates. If the w
component of the position is 0, the
light is treated as a directional
source. Diffuse and specular lighting
calculations take the light's direction,
but not its actual position, into
account, and attenuation is disabled.
Otherwise, diffuse and specular lighting
calculations are based on the actual
location of the light in eye
coordinates, and attenuation is enabled.
The initial position is (0, 0, 1, 0);
thus, the initial light source is
directional, parallel to, and in the
direction of the -z axis.
<STRONG>GL_SPOT_DIRECTION</STRONG> <EM>params</EM> contains three integer or
floating-point values that specify the
direction of the light in homogeneous
object coordinates. Both integer and
floating-point values are mapped
directly. Neither integer nor
floating-point values are clamped.
The spot direction is transformed by the
inverse of the modelview matrix when
<STRONG>glLight</STRONG> is called (just as if it were a
normal), and it is stored in eye
coordinates. It is significant only
when <STRONG>GL_SPOT_CUTOFF</STRONG> is not 180, which it
is initially. The initial direction is
(0, 0, -1).
<STRONG>GL_SPOT_EXPONENT</STRONG> <EM>params</EM> is a single integer or floating-
point value that specifies the intensity
distribution of the light. Integer and
floating-point values are mapped
directly. Only values in the range
[0,128] are accepted.
Effective light intensity is attenuated
by the cosine of the angle between the
direction of the light and the direction
from the light to the vertex being
lighted, raised to the power of the spot
exponent. Thus, higher spot exponents
result in a more focused light source,
regardless of the spot cutoff angle (see
<STRONG>GL_SPOT_CUTOFF</STRONG>, next paragraph). The
initial spot exponent is 0, resulting in
uniform light distribution.
<STRONG>GL_SPOT_CUTOFF</STRONG> <EM>params</EM> is a single integer or floating-
point value that specifies the maximum
spread angle of a light source. Integer
and floating-point values are mapped
directly. Only values in the range
[0,90] and the special value 180 are
accepted. If the angle between the
direction of the light and the direction
from the light to the vertex being
lighted is greater than the spot cutoff
angle, the light is completely masked.
Otherwise, its intensity is controlled
by the spot exponent and the attenuation
factors. The initial spot cutoff is
180, resulting in uniform light
distribution.
<STRONG>GL_CONSTANT_ATTENUATION</STRONG>
<STRONG>GL_LINEAR_ATTENUATION</STRONG>
<STRONG>GL_QUADRATIC_ATTENUATION</STRONG>
<EM>params</EM> is a single integer or floating-
point value that specifies one of the
three light attenuation factors.
Integer and floating-point values are
mapped directly. Only nonnegative
values are accepted. If the light is
positional, rather than directional, its
intensity is attenuated by the
reciprocal of the sum of the constant
factor, the linear factor times the
distance between the light and the
vertex being lighted, and the quadratic
factor times the square of the same
distance. The initial attenuation
factors are (1, 0, 0), resulting in no
attenuation.
<STRONG>NOTES</STRONG>
It is always the case that <STRONG>GL_LIGHT</STRONG>i = <STRONG>GL_LIGHT0</STRONG> + i.
<STRONG>ERRORS</STRONG>
<STRONG>GL_INVALID_ENUM</STRONG> is generated if either <EM>light</EM> or <EM>pname</EM> is not
an accepted value.
<STRONG>GL_INVALID_VALUE</STRONG> is generated if a spot exponent value is
specified outside the range [0,128], or if spot cutoff is
specified outside the range [0,90] (except for the special
value 180), or if a negative attenuation factor is
specified.
<STRONG>GL_INVALID_OPERATION</STRONG> is generated if <STRONG>glLight</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>glGetLight</STRONG>
<STRONG>glIsEnabled</STRONG> with argument <STRONG>GL_LIGHTING</STRONG>
<STRONG>SEE</STRONG> <STRONG>ALSO</STRONG>
<STRONG>glColorMaterial</STRONG>, <STRONG>glLightModel</STRONG>, <STRONG>glMaterial</STRONG>
</PRE>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -