Open GL Super Bible

Previous Table of Contents Next


Using the Accumulation Buffer for Anti-Aliasing

Another application of the accumulation buffer is full-scene anti-aliasing. The basic strategy is to jitter the image one-half a pixel in several directions, to blur the edges of an image but not the solid areas. Accumulating as little as four of these “jittered” scenes will produce remarkably smoother images. The Microsoft Visual C++ compiler includes many OpenGL examples that use jitter for anti-aliasing. See the file OPENGL\BOOK\JITTER.H from the Visual C++ CD-ROM for many different sets of jitter values.

Anti-aliasing with the accumulation buffer does carry a price in speed, however. If you want to do any real-time anti-aliased animation, you’ll have to look at graphics hardware that supports multisampling to do your anti-aliasing for you. The accumulation buffer is just too slow for interactive work.

If you are generating stills or stop-motion animations, the accumulation buffer will give you anti-aliasing and simulated depth-of-field that simply are not possible with multisampling.

Reference Section

glAccum

Purpose
Operates on the accumulation buffer to establish pixel values.
Include File
<GL/gl.h>
Syntax
void glAccum(GLenum func, GLfloat value);
Description
This function operates on the accumulation buffer. Except for GL_RETURN, color values are scaled by the value parameter and added or stored into the accumulation buffer. For GL_RETURN, the accumulation buffer’s color values are scaled by the value parameter and stored in the current color buffer.

Parameters

func
GLenum: The accumulation function to apply. Valid functions are as follows:
GL_ACCUM Add scaled color-buffer values to the accumulation buffer.
GL_LOAD Load scaled color-buffer values into the accumulation buffer, replacing whatever was there before.
GL_ADD Add a constant color to the accumulation buffer values.
GL_MULT Multiply color values in the accumulation buffer by a constant color (filtering effects).
GL_RETURN Copy the accumulation buffer into the main color buffer.
Returns
None.
Example
See the CH15\MOTION.C example on the source code CD-ROM.
See Also
ChoosePixelFormat, SetPixelFormat

glClearColor

Purpose
Specifies a color value for the color buffer.
Include File
<GL/gl.h>
Syntax
void glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
Description
This function sets the color value that will be used when clearing the color buffer with glClear(GL_COLOR_BUFFER_BIT).

Parameters

red
GLfloat: The red color value for the color buffer.
green
GLfloat: The green color value for the color buffer.
blue
GLfloat: The blue color value for the color buffer.
alpha
GLfloat: The alpha color value for the color buffer.
Returns
None.
See Also
ChoosePixelFormat, SetPixelFormat

glClearDepth

Purpose
Specifies a depth value for the depth buffer.
Include File
<GL/gl.h>
Syntax
void glClearDepth(GLclampd depth);
Description
This function sets the depth value that will be used when clearing the depth buffer with glClear(GL_DEPTH_BUFFER_BIT).

Parameters

depth
GLclampd: The clear value for the depth buffer.
Returns
None.
See Also
ChoosePixelFormat, SetPixelFormat

glClearIndex

Purpose
Specifies a color index value for the color buffer.
Include File
<GL/gl.h>
Syntax
void glClearIndex(GLfloat index);
Description
This function sets the color index value that will be used when clearing the color buffer with glClear(GL_COLOR_BUFFER_BIT).

Parameters

index
GLfloat: The color index value for the color buffer.
Returns
None.
See Also
ChoosePixelFormat, SetPixelFormat


Previous Table of Contents Next