You use it for
You use it by
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ACCUM | GLUT_DEPTH);
glClear(GL_ACCUM_BUFFER_BIT);
glAccum(GL_ACCUM, 1.0/numJitters);
glAccum(GL_RETURN, 1.0);
twKeyCallback('m',keys,"toggle motion blur");
twKeyCallback('s',keys,"toggle small motion");
twKeyCallback('+',keys,"increase frames");
twKeyCallback('-',keys,"decrease frames");
twKeyCallback('a',keys,"toggle anti-aliasing");
twKeyCallback('1',keys,"show the teapot");
twKeyCallback('2',keys,"show the wire cube");
twKeyCallback('3',keys,"show the solid cube");
twKeyCallback('4',keys,"show the solid sphere");
A nice application of this is antialiasing the Wellesley "favicon":
First, run the AntiAliasing demo on the Mac. You'll see some banding. Why?
Different graphics cards have different limits. You can find out some of the limits by running demos/accumulation/OpenGL-Limits.py.
Now, try running demos/accumulation/AntiAliasing.py again, but this time supply a command-line argument about the number of iterations to do. Supply a number like 1 or 8 or 64.
Here's an example. Suppose we're averaging a bunch of numbers all around 20:
19, 19, 20, 20, 20, 21, 21, 21, 22, 22
We do that by multiplying each by 0.1 and summing:
1.9+1.9+2.0+2.0+2.0+2.1+2.1+2.1+2.2+2.2 = 20.5
Now, suppose we're doing the same thing on a machine that can't store the decimal place:
We do that by multiplying each by 0.1 and summing:
1+1+2+2+2+2+2+2+2+2 = 18
Furthermore, the values we get will be 18, 19, 20, 21, or 22; we can't get 20.5
Our accumulation operation is right-shifting by 3 bits, thereby losing precision.
Fog is not nearly as cool as you think it is. It just fogs stuff that is far from the camera, depending on how far it is. This is nice for not having to worry about details far away, but it can't do ground fog and stuff like that.
The main demos are:
Written by Scott D. Anderson
scott.anderson@acm.org

This work is licensed under a Creative Commons
License.