openGL API 之glDrawBuffer(GL_NONE);

openGL系列文章目录

前言

openGL API 之glDrawBuffer(GL_NONE);详解

在这里插入图片描述

一、glDrawBuffer官网

glDrawBuffer官网说明

Name
glDrawBuffer, glNamedFramebufferDrawBuffer — specify which color buffers are to be drawn into

C Specification
void glDrawBuffer( GLenum buf);

void glNamedFramebufferDrawBuffer( GLuint framebuffer,
GLenum buf);

Parameters
framebuffer
Specifies the name of the framebuffer object for glNamedFramebufferDrawBuffer function. Must be zero or the name of a framebuffer object.

buf
For default framebuffer, the argument specifies up to four color buffers to be drawn into. Symbolic constants GL_NONE, GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT, GL_BACK_RIGHT, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, and GL_FRONT_AND_BACK are accepted. The initial value is GL_FRONT for single-buffered contexts, and GL_BACK for double-buffered contexts. For framebuffer objects, GL_COLOR_ATTACHMENT m m m and GL_NONE enums are accepted, where m m m is a value between 0 and GL_MAX_COLOR_ATTACHMENTS.

Description
When colors are written to the frame buffer, they are written into the color buffers specified by glDrawBuffer. One of the following values can be used for default framebuffer:

GL_NONE
No color buffers are written.

GL_FRONT_LEFT
Only the front left color buffer is written.

GL_FRONT_RIGHT
Only the front right color buffer is written.

GL_BACK_LEFT
Only the back left color buffer is written.

GL_BACK_RIGHT
Only the back right color buffer is written.

GL_FRONT
Only the front left and front right color buffers are written. If there is no front right color buffer, only the front left color buffer is written.

GL_BACK
Only the back left and back right color buffers are written. If there is no back right color buffer, only the back left color buffer is written.

GL_LEFT
Only the front left and back left color buffers are written. If there is no back left color buffer, only the front left color buffer is written.

GL_RIGHT
Only the front right and back right color buffers are written. If there is no back right color buffer, only the front right color buffer is written.

GL_FRONT_AND_BACK
All the front and back color buffers (front left, front right, back left, back right) are written. If there are no back color buffers, only the front left and front right color buffers are written. If there are no right color buffers, only the front left and back left color buffers are written. If there are no right or back color buffers, only the front left color buffer is written.

If more than one color buffer is selected for drawing, then blending or logical operations are computed and applied independently for each color buffer and can produce different results in each buffer.

Monoscopic contexts include only left buffers, and stereoscopic contexts include both left and right buffers. Likewise, single-buffered contexts include only front buffers, and double-buffered contexts include both front and back buffers. The context is selected at GL initialization.

For framebuffer objects, GL_COLOR_ATTACHMENT m m m and GL_NONE enums are accepted, where m m m is a value between 0 and GL_MAX_COLOR_ATTACHMENTS. glDrawBuffer will set the draw buffer for fragment colors other than zero to GL_NONE.

Errors
GL_INVALID_OPERATION error is generated by glNamedFramebufferDrawBuffer if framebuffer is not zero or the name of an existing framebuffer object.

GL_INVALID_ENUM is generated if buf is not an accepted value.

GL_INVALID_OPERATION is generated if the default framebuffer is affected and none of the buffers indicated by buf exists.

GL_INVALID_OPERATION is generated if a framebuffer object is affected and buf is not equal to GL_NONE or GL_COLOR_ATTACHMENT m m m, where m m m is a value between 0 and GL_MAX_COLOR_ATTACHMENTS.

Associated Gets
glGet with argument GL_DRAW_BUFFER

Version Support
OpenGL Version
Function / Feature Name 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5
glDrawBuffer ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
glNamedFramebufferDrawBuffer - - - - - - - - - - - ✔
See Also
glBlendFunc, glColorMask, glDrawBuffers, glLogicOp, glReadBuffer

Copyright
Copyright © 1991-2006 Silicon Graphics, Inc. Copyright © 2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see https://khronos.org/registry/OpenGL-Refpages/LICENSES/LicenseRef-FreeB.txt.

二、翻译

glDrawBuffer 函数
项目
2021/09/14
2 contributors

GlDrawBuffer 函数指定要绘制到的颜色缓冲区。

语法
C++

复制
void glDrawBuffer(
GLenum mode
);
参数
mode

指定最多四个颜色缓冲区,其中包含以下可接受的符号常数。

表 1
值 含义
GL _ 无
不写入任何颜色缓冲区。
总帐 _ 前面 _ 左侧
仅写入前左颜色缓冲区。
总帐 _ 前 _ 右
仅编写右颜色缓冲区。
GL _ 向 _ 左
仅写入反左颜色缓冲区。
GL _ 向 _ 右
仅写入右手颜色缓冲区。
总帐 _ 前期
仅写入左、前右颜色缓冲区。 如果没有右颜色缓冲区,则只写入前左颜色缓冲区。
GL _ 回
仅写入左右和右颜色缓冲区。 如果没有右右颜色缓冲区,则只写入反左的颜色缓冲区。
总帐 _ 剩余
仅写入左和后左颜色缓冲区。 如果没有左的颜色缓冲区,则只写入前左颜色缓冲区。
总帐 _ 权限
仅写入上右和右右颜色缓冲区。 如果没有右右颜色缓冲区,则只写入上右的颜色缓冲区。
总帐 _ 前后 _ _
所有前面和背面的颜色缓冲区 (都将写入左、上、右、左、右) 。 如果没有背面的颜色缓冲区,则只写入前左和前右颜色缓冲区。 如果没有正确的颜色缓冲区,则只会写入左右左颜色缓冲区。 如果没有右侧或背面的颜色缓冲区,则只写入前左颜色缓冲区。
总帐 _ AUXi
仅写入辅助 *颜色缓冲区;*i 在0和总帐 _ AUX _ 缓冲器-1 之间。 (总帐 _ 辅助 _ 缓冲区不是上限; 请使用 glGet 查询可用辅助缓冲区的数目。 )
_对于单缓冲上下文,默认值为 gl 前部, _ 对于双缓冲上下文,默认值为 gl。

返回值
此函数不返回值。

错误代码
GlGetError函数可以检索以下错误代码。

错误代码
名称 含义
总帐 _ 无效 _ 枚举
模式 不是接受的值。
总帐 _ 无效 _ 操作
模式 不存在指示的任何缓冲区。
总帐 _ 无效 _ 操作
调用 glBegin 和对 glEnd的相应调用之间调用了函数。
备注
将颜色写入帧缓冲区时,会将这些颜色写入 glDrawBuffer 指定的颜色缓冲区。

如果为绘图选择了多个颜色缓冲区,则会为每个颜色缓冲区单独计算和应用混合或逻辑操作,并可以在每个缓冲区中产生不同的结果。

Monoscopic 上下文仅包括左侧缓冲区,stereoscopic 上下文包括左缓冲区和右缓冲区。 同样,单缓冲上下文只包含前台缓冲区,而双缓冲的上下文包括前端和后台缓冲区。 在 OpenGL 初始化时选择上下文。

通常情况下,GL _ 辅助 i = gl _ AUX0 + i。

以下函数检索与 glDrawBuffer 函数相关的信息:

glGet 参数总帐 _ 绘制 _ 缓冲区

带参数的 glGet _ 辅助 _ 缓冲区

要求
要求
要求 值
最低受支持的客户端
Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器
Windows 2000 Server [仅限桌面应用]
标头
Gl。h

Opengl32
DLL
Opengl32.dll
请参阅
glBegin

glBlendFunc

glColorMask

glEnd

glGet

glIndexMask

glLogicOp

glReadBuffer

GL_FRONT: 单缓存的默认值
GL_FRONT_RIGHT:
GL_NONE:不写入颜色缓冲区,如果存在片段着色器则不启用该着色器
GL_FRONT_LEFT:
GL_FRONT_AND_BACK:
GL_RIGHT:
GL_AUXi: i表示第几个辅助缓存.
GL_LEFT:
GL_BACK_RIGHT:
GL_BACK: 双缓存的默认值
GL_BA
对于帧缓冲区对象而言,可以取GL_COLOR_ATTACHMENT m m m and GL_NONE,m为0~GL_MAX_COLOR_ATTACHMENTS
注意: 启用多个缓存用于写操作时, 只要其中一个缓存存在, 就不会发生错误. 如果指定的缓存都不存在, 就发生错误.CK_LEFT:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值