next up previous contents index
Next: 4.2.4 The Accumulation Buffer Up: 4.2 Whole Framebuffer Operations Previous: 4.2.2 Fine Control of

4.2.3 Clearing the Buffers

 

The GL provides a means for setting portions of every pixel in a particular buffer to the same value. The argument to

void Clear ( bitfield buf ) ;

is the bitwise OR of a number of values indicating which buffers are to be cleared. The values are COLOR_BUFFER_BIT, DEPTH_BUFFER_BIT, STENCIL_BUFFER_BIT, and ACCUM_BUFFER_BIT, indicating the buffers currently enabled for color writing, the depth buffer, the stencil buffer, and the accumulation buffer (see below), respectively. The value to which each buffer is cleared depends on the setting of the clear value for that buffer. If the mask is not a bitwise OR of the specified values, then the error INVALID_VALUE is generated.

void ClearColor ( clampf r, clampf g, clampf b, clampf a ) ;

sets the clear value for the color buffers in RGBA mode. Each of the specified components is clamped to and converted to fixed-point according to the rules of section 2.13.9.

void ClearIndex ( float index ) ;

sets the clear color index. index is converted to a fixed-point value with unspecified precision to the left of the binary point; the integer part of this value is then masked with , where m is the number of bits in a color index value stored in the framebuffer.

void ClearDepth ( clampd d ) ;

takes a floating-point value that is clamped to the range and converted to fixed-point according to the rules for a window z value given in section 2.10.1. Similarly,

void ClearStencil ( int s ) ;

takes a single integer argument that is the value to which to clear the stencil buffer. s is masked to the number of bitplanes in the stencil buffer.

void ClearAccum ( float r, float g, float b, float a ) ;

takes four floating-point arguments that are the values, in order, to which to set the R, G, B, and A values of the accumulation buffer (see the next section). These values are clamped to the range when they are specified.

When Clear  is called, the only per-fragment operations that are applied (if enabled) are the pixel ownership test, the scissor test, and dithering. The masking operations described in the last section (4.2.2) are also effective. If a buffer is not present, then a Clear  directed at that buffer has no effect.

The state required for clearing is a clear value for each of the color buffer, the depth buffer, the stencil buffer, and the accumulation buffer. Initially, the RGBA color clear value is (0,0,0,0), the clear color index is 0, and the stencil buffer and accumulation buffer clear values are all 0. The depth buffer clear value is initially 1.0.



next up previous contents index
Next: 4.2.4 The Accumulation Buffer Up: 4.2 Whole Framebuffer Operations Previous: 4.2.2 Fine Control of



David Blythe
Sat Mar 29 02:23:21 PST 1997