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)表示要清除顏色緩衝以及深度緩衝

GL_COLOR_BUFFER_BIT The buffers currently enabled for color writing.

基本介紹

  • 中文名:glClear
  • 外文名:無
  • 語言:c
  • 學科:OpenGL
glClear,名字,C 語言,參數,函式說明,

glClear

名字

glClear -- 清除viewport的緩衝區

C 語言

void glClear(GLbitfield mask);

參數

mask
可以使用 | 運算符組合不同的緩衝標誌位,表明需要清除的緩衝,例如glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)表示要清除顏色緩衝以及深度緩衝,可以使用以下標誌位
  • GL_COLOR_BUFFER_BIT: 當前可寫的顏色緩衝
  • GL_DEPTH_BUFFER_BIT: 深度緩衝
  • GL_ACCUM_BUFFER_BIT: 累積緩衝
  • GL_STENCIL_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()的唯一參數表示需要被清除的緩衝區。

相關詞條

熱門詞條

聯絡我們