CPS 124/296.3
Fall 2001

Advanced Effects Using Buffers

OpenGL Buffers

Color Buffers
stores color values, either RGBA or index, for each pixel
used for drawing onto window --- only buffer that produces visible results
separate left and right buffers for stereo viewing
separate front and back buffers for animation using double-buffering
 
Depth Buffer
stores depth, or z, value from which color comes for each pixel
typically used for determining visible objects
Select Buffer
stores finite amount of pick information for each pixel rendered
pick information is of the following format
number of names for object found
z value of near intersection
z value of far intersection
all names, really IDs, for given object selected
typically used for selecting, or picking, objects in scene with mouse
works by intersecting ray cast from mouse point with objects in scene
 
Stencil Buffer
stores single mask value for each pixel rendered
typically used for masking irregularly shaped regions of screen, e.g., view from windshield of car
dissolving floor
mirror
Accumulation Buffer
stores color values, RGBA only, for each pixel
typically used to combine a series of images, or renders, into a final, composite, image
works by combining rectangular blocks of colors
aliased shapes
averaged, or anti-aliased, shapes

Selecting Buffers for Reading and Writing

In OpenGL you can draw into nearly any buffer you want. By default, in GLUT_SINGLE mode, the front buffer is enabled, and in GLUT_DOUBLE mode, the back buffer is enabled. But you can change this if you want, using glDrawBuffer().
glDrawBuffer(GL_FRONT);
selects the front buffer for drawing/writing, while
glDrawBuffer(GL_BACK);
selects the back buffer.

There are similar glReadBuffer(), glClear() call that selects a buffer for reading.

Examples

pickdepth.cpp
uses select buffer to pick object based on depth from ray cast into scene through mouse point
picksquare.cpp
uses select buffer to pick object based on "hierarchical" name of objects
shadow.cpp
uses depth buffer to implement z-buffer algorithm for generating shadows
antialias.cpp
uses accumulation buffer to implement sub-pixel sampling averaging for anti-aliasing
mirror.cpp
uses stencil, depth, and color buffers to render simplified mirror (assumed to be on the xy plane)

References

Notes on graphics algorithms
Accumulation Buffer: Hardware Support for High-Quality Rendering by P. Haeberli and K. Akeley, ACM SIGGRAPH 90
David Blythe's SIGGRAPH 99 Advanced OpenGL Course Notes
 

Feedback?