next up previous contents
Next: 18.7.2 Optimizing Frame Rate Up: 18.7 Tuning Animation Previous: 18.7 Tuning Animation   Contents

18.7.1 Factors Contributing to Animation Speed

The smoothness of an animation depends on its frame rate. The more frames rendered per second, the smoother the motion appears.

Smooth animation also requires double buffering. In double buffering, one framebuffer holds the current frame, which is scanned out to the monitor by video hardware, while the rendering hardware is drawing into a second buffer that is not visible. When the new framebuffer is ready to be displayed, the system swaps the buffers. The system must wait until the next vertical retrace period between raster scans to swap the buffers, so that each raster scan displays an entire stable frame, rather than parts of two or more frames.

Frame rates must be integral multiples of the screen refresh time, which is 16.7 msec (milliseconds) for a 60-Hz monitor. If the draw time for a frame is slightly longer than the time for n raster scans, the system waits until the n+1st vertical retrace before swapping buffers and allowing drawing to continue, so the total frame time is (n+1)*16.7 msec. It may be very hard to make the final transition from one half of the display subsystem's refresh time to full speed, because you will need to speed up your program by a factor of at least two.

To summarize: A change in the time spent rendering a frame when double buffering has no visible effect unless it changes the total time to a different integer multiple of the screen refresh time.

If you want an observable performance increase, you must reduce the rendering time enough to take a smaller number of 16.7 msec raster scans. Alternatively, if performance is acceptable, you can add work without reducing performance, as long as the rendering time does not exceed the current multiple of the raster scan time.

To help monitor timing improvements, turn off double buffering by always drawing to the front buffer. If you do not, it is difficult to know if you are near a 16.7 msec boundary.


next up previous contents
Next: 18.7.2 Optimizing Frame Rate Up: 18.7 Tuning Animation Previous: 18.7 Tuning Animation   Contents
2001-01-10