GL_COLOR_BUFFER_BIT和GL_DEPTH_BUFFER_BIT的目的是什么? [英] What is the purpose of GL_COLOR_BUFFER_BIT and GL_DEPTH_BUFFER_BIT?

查看:1889
本文介绍了GL_COLOR_BUFFER_BIT和GL_DEPTH_BUFFER_BIT的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为OpenGL初学者,我想知道它们的作用以及为什么需要这些.例如通话中

As an OpenGL beginner I would like to know what do they do and why these are required. For instance in the call

 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

推荐答案

GL_COLOR_BUFFER_BITGL_DEPTH_BUFFER_BIT不是函数,它们是常量.您可以使用它们告诉glClear()您要清除的缓冲区-在您的示例中,深度缓冲区和当前为彩色写入启用的缓冲区".您还可以传递GL_ACCUM_BUFFER_BIT清除累积缓冲区和/或GL_STENCIL_BUFFER_BIT清除模板缓冲区.

GL_COLOR_BUFFER_BIT and GL_DEPTH_BUFFER_BIT aren't functions, they're constants. You use them to tell glClear() which buffers you want it to clear - in your example, the depth buffer and the "buffers currently enabled for color writing". You can also pass GL_ACCUM_BUFFER_BIT to clear the accumulation buffer and/or GL_STENCIL_BUFFER_BIT to clear the stencil buffer.

使用库时,常量的实际值对您而言无关紧要-重要的实现细节是每个常量的二进制表示形式不会相互重叠.正是这种特性使您可以将多个常量的按位或"传递给对glClear()的单个调用.

The actual values of the constants shouldn't matter to you when using the library - the important implementation detail is that the binary representations for each constant don't overlap with each other. It's that characteristic that lets you pass the bitwise OR of multiple constants to a single call to glClear().

查看 glClear()文档了解更多信息.

Check out the glClear() documention for more details.

这篇关于GL_COLOR_BUFFER_BIT和GL_DEPTH_BUFFER_BIT的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆