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

查看:42
本文介绍了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.

在使用库时,常量的实际值对您来说无关紧要 - 重要的实现细节是每个常量的二进制表示不会相互重叠.正是这种特性使您可以将多个常量的按位 OR 传递给对 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天全站免登陆