1.5. 状态 State

本文介绍了OpenGL作为状态机的工作原理,详细解释了如何通过各种状态设置来控制几何原语、图像和位图转换为屏幕像素的过程。OpenGL的状态设置相互独立,共同定义了渲染管线的行为以及原始数据如何转换为显示设备上的像素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.5. 状态 State


OpenGL was designed as a state machine for updating the contents of a frame buffer. The

process of turning geometric primitives, images, and bitmaps into pixels on the screen is

controlled by a fairly large number of state settings. These state settings are orthogonal to one

anothersetting one piece of state does not affect the others. Cumulatively, the state settings

define the behavior of the OpenGL rendering pipeline and the way in which primitives are

transformed into pixels on the display device.

OpenGL state is collected into a data structure called a graphics context. Window-systemspecific

functions create and delete graphics contexts. Another window-system-specific call

designates a graphics context and an OpenGL frame buffer that are used as the targets for

subsequent OpenGL commands.

Quite a few server-side state values in OpenGL have just two states: on or off. To turn a mode

on, you must pass the appropriate symbolic constant to the OpenGL command glEnable. To turn

a mode off, you pass the symbolic constant to glDisable. You enable client-side state (such as

pointers that define vertex arrays) with glEnableClientState and disable it with glDisableClientState.

OpenGL maintains a server-side stack for pushing and popping any or all of the defined state

values. This stack can be manipulated with glPushAttrib and glPopAttrib. Similarly, client state can

be manipulated on a second stack with glPushClientAttrib and glPopClientAttrib.

glGet is a generic function that can query many of the components of a graphics context.

Symbolic constants are defined for simple state items (e.g., GL_CURRENT_COLOR and

GL_LINE_WIDTH), and these values can be passed as arguments to glGet to retrieve the current

value of the indicated component of a graphics context. Variants of glGet return the state value

as an integer, float, double, or boolean. More complex state values are returned by "get"

functions that are specific to that state value, for instance, glGetClipPlane, glGetLight, and

glGetMaterial. Error conditions can be detected with the glGetError function.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值