Next | Prev | Up | Top | Contents | Index
Using Animations
Animation in its simplest form consists of drawing an image, clearing it, and drawing a new, slightly different one in its place. However, attempting to draw into a window while that window is being displayed can cause problems such as flickering. The solution is double buffering.
This section discusses double-buffered animation inside an X Window System environment, providing example code as appropriate. You learn about
Xt provides two mechanisms that are suited for continuous animation:
- "Controlling an Animation With Workprocs" results in the fastest animation possible. If you use workprocs, the program swaps buffers as fast as possible; which is useful if rendering speed is variable enough that constant speed animation is not possible. Workproc animations also give other parts of the application priority. The controls don't become less responsive just because the animation is being done. The cost of this is that the animation slows down or may stop when the user brings up a menu or uses other controls.
- "Controlling an Animation With Timeouts" results in a constant speed animation. Animations that use timeouts compete on even footing with other Xt events; the animation won't stop because the user interacts with other components of the animation.
Note: Controlling animations with workprocs and timeouts applies only to Xt-based programs.
- Swapping Buffers
-
- Controlling an Animation With Workprocs
-
- Controlling an Animation With Timeouts
-
Next | Prev | Up | Top | Contents | Index