glClear

王朝百科·作者佚名  2010-03-06  
宽屏版  字体: |||超大  

以下参考MSDN.

//函数原型

glClear

The glClear function clears buffers to preset values.

void glClear(

GLbitfield mask

);

//参数

Parameters

mask

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)表示要清除颜色缓冲以及深度缓冲

GL_COLOR_BUFFER_BIT The buffers currently enabled for color writing.

当前可写的颜色缓冲

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

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有