glClear
清除viewport的缓冲区
glClear 是 OpenGL 图形库中定义的一个函数。
名字
glClear -- 清除viewport的缓冲区
C语言
void glClear(GLbitfield mask);
参数
mask
可以使用 | 运算符组合不同的缓冲标志位,表明需要清除的缓冲,例如glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)表示要清除颜色缓冲以及深度缓冲,可以使用以下标志位
函数说明
Remarks
The glClear function sets the bitplane area of the window to values previously selected by glClearColor, glClearIndex, glClearDepth, glClearStencil, and glClearAccum. You can clear multiple color buffers simultaneously by selecting more than one buffer at a time using glDrawBuffer.
The pixel-ownership test, the scissor test, dithering, and the buffer writemasks affect the operation of glClear. The scissor box bounds the cleared region. The alpha function, blend function, logical operation, stenciling, texture mapping, and z-buffering are ignored by glClear.
The glClear function takes a single argument (mask) that is the bitwise OR of several values indicating which buffer is to be cleared.
The value to which each buffer is cleared depends on the setting of the clear value for that buffer.
If a buffer is not present, a glClear call directed at that buffer has no effect.
The following functions retrieve information related to glClear:
glGet with argument GL_ACCUM_CLEAR_VALUE
glGet with argument GL_DEPTH_CLEAR_VALUE
glGet with argument GL_INDEX_CLEAR_VALUE
glGet with argument GL_COLOR_CLEAR_VALUE
glGet with argument GL_STENCIL_CLEAR_VALUE
以下参考机械工业出版社的《OpenGL编程指南》第五版p18-p20。
glClear()语句的作用是用当前缓冲区清除值,也就是glClearColor或者glClearDepth等函数所指定的值来清除指定的缓冲区。比如:
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
第一条语句表示清除颜色设为黑色,第二条语句表示把整个窗口清除为当前的清除颜色,glClear()的参数表示需要被清除的缓冲区。
参考资料
最新修订时间:2024-12-06 17:21
目录
概述
名字
C语言
参数
参考资料