13.003 Computational Geometry and Visualization

Smooth redrawing


Recall that a raster display device works by sequentially scanning through a frame buffer, from the upper left to the lower right corner,to determine the RGB value associated with each pixel on the screen. The electron beam of the CRT also scans over over each screen pixel to illuminate the phosphor to the correct intensity.

On most modern displays, the entire frame buffer is traversed 60 times a second. During each traversal, approximately half of the time (120th of a second) is spent actually setting pixel intensities and half the time is spent moving to the start of the next row (horizontal retrace) or moving to the top left corner (vertical retrace).

If we can arrange to only update the frame buffer during the retrace periods, any changes to the image will appear smooth. If the image is so complex that it cannot be completely redrawn during the retrace periods, the image will appear to flicker or the drawing sequence will be apparent to the eye.

To avoid this problem, we can use two separate frame buffers, a front buffer and a back buffer. The display hardware will use one or the other of these buffers during any given traversal. If the display hardware is using the front buffer, we can update the back buffer without affecting the screen image. When the update of the back buffer is complete, we can direct the display hardware to use the back buffer, and we can then update the front buffer.

This is known as double buffering.

  ...
  /* initialize GLUT for double buffering */
  glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
  ...
  void displayCB(void)
  {
    /* draw the geometry here ... */

    glutSwapBuffers();   /* swap the front and back buffers */
  }

The GLUT library automatically manages the front and back buffers; you do not need to know which buffer is currently active. All that is necessary is to tell GLUT when you want to swap the buffers.


On to "Shading"
Back to "Surfaces and Shading"
Back to "Lectures on OpenGL and Computer Graphics"