glClear

来源:互联网 发布:java字节码 编辑:程序博客网 时间:2024/04/29 15:26

1. glClear

Bitwise OR of masks that indicate the buffers to be cleared. The four masks are as follows. Mask Buffer to be Cleared 可以使用|运算符组合不同的缓冲标志位,表明需要清除的缓冲,例如glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)表示要清除颜色缓冲以及深度缓冲

glClear

The glClear function clears buffers to preset values.

void glClear(

GLbitfield mask

);

 

参数

Parameters

mask当前可写的颜色缓冲

GL_DEPTH_BUFFER_BIT The depth buffer.深度缓冲

GL_ACCUM_BUFFER_BIT The accumulation buffer.累积缓冲

GL_STENCIL_BUFFER_BIT The stencil buffer.模板缓冲

 

//注释

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()的唯一参数表示需要被清除的缓冲区。

0 0
原创粉丝点击