Gambas文档
编译和安装
错误消息
代码片段
待办事项
废弃的组件
教程
开发环境文档
开发者文档
名词解释
如何操作
说明
维基手册
维基搜索
维基许可协议
文档
应用程序仓库
语言概览
语言索引
主题
组件
gb
gb.args
gb.cairo
gb.chart
gb.clipper
gb.complex
gb.compress
gb.crypt
gb.data
gb.db
gb.db.form
gb.db.mysql
gb.db.odbc
gb.db.postgresql
gb.db.sqlite2
gb.db.sqlite3
gb.dbus
gb.dbus.trayicon
gb.debug
gb.desktop
gb.desktop.x11
gb.eval
gb.eval.highlight
gb.form
gb.form.dialog
gb.form.editor
gb.form.htmlview
gb.form.mdi
gb.form.print
gb.form.terminal
gb.gmp
gb.gsl
gb.gtk
gb.gtk3
gb.gtk3.opengl
gb.gtk3.webview
gb.gui
gb.gui.qt
gb.gui.qt.ext
gb.gui.trayicon
gb.gui.webview
gb.hash
gb.highlight
gb.image
gb.image.effect
gb.image.io
gb.inotify
gb.logging
gb.map
gb.media
gb.media.form
gb.mime
gb.mongodb
gb.mysql
gb.ncurses
gb.net
gb.net.curl
gb.net.pop3
gb.net.smtp
gb.opengl
Gl
gb.opengl.glsl
gb.opengl.glu
gb.opengl.sge
gb.openssl
gb.option
gb.pcre
gb.pdf
gb.poppler
gb.qt4
gb.qt4.ext
gb.qt4.opengl
gb.qt4.webkit
gb.qt4.webview
gb.qt5
gb.qt5.ext
gb.qt5.opengl
gb.qt5.webview
gb.qt6
gb.qt6.ext
gb.qt6.opengl
gb.qt6.webview
gb.report
gb.report2
gb.sdl
gb.sdl2
gb.sdl2.audio
gb.settings
gb.signal
gb.term
gb.test
gb.util
gb.util.web
gb.v4l
gb.vb
gb.web
gb.web.feed
gb.web.form
gb.web.gui
gb.xml
gb.xml.html
gb.xml.rpc
gb.xml.xslt
最近的修改

Gl.Lightf (gb.opengl)

Static Sub Lightf ( Light As Integer, Pname As Integer, Param As Float )

Set light source parameters.

Parameters

light

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 Gl.LIGHT i, where i ranges from 0 to the value of Gl.MAX_LIGHTS - 1.
pname

Specifies a single-valued light source parameter for light. Gl.SPOT_EXPONENT, Gl.SPOT_CUTOFF, Gl.CONSTANT_ATTENUATION, Gl.LINEAR_ATTENUATION, and Gl.QUADRATIC_ATTENUATION are accepted.
param

Specifies the value that parameter pname of light source light will be set to.

Parameters

light

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 Gl.LIGHT i, where i ranges from 0 to the value of Gl.MAX_LIGHTS - 1.
pname

Specifies a light source parameter for light. Gl.AMBIENT, Gl.DIFFUSE, Gl.SPECULAR, Gl.POSITION, Gl.SPOT_CUTOFF, Gl.SPOT_DIRECTION, Gl.SPOT_EXPONENT, Gl.CONSTANT_ATTENUATION, Gl.LINEAR_ATTENUATION, and Gl.QUADRATIC_ATTENUATION are accepted.
params

Specifies a pointer to the value or values that parameter pname of light source light will be set to.

Description

Gl.Light sets the values of individual light source parameters. light names the light and is a symbolic name of the form Gl.LIGHT i, where i ranges from 0 to the value of Gl.MAX_LIGHTS - 1. pname specifies one of ten light source parameters, again by symbolic name. params is either a single value or a pointer to an array that contains the new values.

To enable and disable lighting calculation, call Gl.Enable and Gl.Disable with argument Gl.LIGHTING. 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 Gl.Enable and Gl.Disable with argument Gl.LIGHT i.

The ten light parameters are as follows:
Gl.AMBIENT

params 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).
Gl.DIFFUSE

params 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 Gl.LIGHT0 is (1, 1, 1, 1); for other lights, the initial value is (0, 0, 0, 1).
Gl.SPECULAR

params 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 Gl.LIGHT0 is (1, 1, 1, 1); for other lights, the initial value is (0, 0, 0, 1).
Gl.POSITION

params 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 Gl.Light 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.
Gl.SPOT_DIRECTION

params 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 upper 3x3 of the modelview matrix when Gl.Light is called, and it is stored in eye coordinates. It is significant only when Gl.SPOT_CUTOFF is not 180, which it is initially. The initial direction is 0 0 -1 .
Gl.SPOT_EXPONENT

params 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 Gl.SPOT_CUTOFF, next paragraph). The initial spot exponent is 0, resulting in uniform light distribution.
Gl.SPOT_CUTOFF

params 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.
Gl.CONSTANT_ATTENUATION
Gl.LINEAR_ATTENUATION
Gl.QUADRATIC_ATTENUATION

params 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.

Notes

It is always the case that Gl.LIGHT i = Gl.LIGHT0 + i.

Errors

Gl.INVALID_ENUM is generated if either light or pname is not an accepted value.

Gl.INVALID_VALUE 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.

Gl.INVALID_OPERATION is generated if Gl.Light is executed between the execution of Gl.Begin and the corresponding execution of Gl.End.

Associated Gets

Gl.GetLight

Gl.IsEnabled with argument Gl.LIGHTING

See also

Gl.LightModel, Gl.Material

See original documentation on OpenGL website