Graphics Reference
In-Depth Information
If you have multiple draw buffers in a framebuffer object (see the
Multiple
Render Targets
section), you can clear a specific draw buffer with the
following calls:
void
glClearBufferiv
(GLenum
buffer
, GLint
drawBuffer
,
const GLint *
value
)
void
glClearBufferuiv
(GLenum
buffer
, GLint
drawBuffer
,
const GLuint *
value
)
void
glClearBufferfv
(GLenum
buffer
, GLint
drawBuffer
,
const GLfloat *
value
)
specifies the type of buffer to clear. Can be
GL_COLOR
,
GL_FRONT
,
GL_BACK
,
GL_FRONT_AND_BACK
,
GL_LEFT
,
GL_RIGHT
,
GL_DEPTH
(
glClearBufferfv
only) or
GL_STENCIL
(
glClearBufferiv
only).
specifies the draw buffer name to clear. Must be zero
for depth or stencil buffers. Otherwise, must be less than
GL_MAX_DRAW_BUFFERS
for color buffers.
specifies a pointer to a four-element vector (for color
buffers) or to a single value (for depth or stencil buffers)
to clear the buffer to.
buffer
drawBuffer
value
To reduce the number of function calls, you can clear the depth and
stencil buffers at the same time using
glClearBufferfi
.
void
glClearBufferfi
(GLenum
buffer
, GLint
drawBuffer
,
GLfloat
depth
, GLint
stencil
)
specifies the type of buffer to clear; must be
GL_DEPTH_STENCIL
specifies the draw buffer name to clear; must be zero
specifies the value to clear the depth buffer to
specifies the value to clear the stencil buffer to
buffer
drawBuffer
depth
stencil
You can also control which buffers, or components, in the case of the
color buffer, are writable by specifying a buffer write mask. Before a pixel's