Double Buffering

Double buffering is a technique for reducing flicker in animations that at first might seem a little counter intuitive. The problem stems from the fact that when a new animation frame is rendered, it is desirable to first clear the old frame. This causes a flicker to occur. The basic idea of double buffering is to create a virtual screen out of the user's view. At the beginning of this chapter, it was stated that a graphics device could be a screen, printer, file, or memory area. The virtual screen used as the buffer is the primary example of using a memory space as a graphics device. When paint() is called, the clearing and painting of the animation frame can occur on the virtual screen and the resulting rendered image can then be transferred to the real screen immediately upon completion. The cost of double buffering is in memory and CPU consumption. However, this cost is probably unavoidable for complex animations and usually isn't too expensive.

Another application of double buffering is in spirited animations. A sprite is a graphics object that moves over another, usually larger, graphic. The sprite itself can be a series of animated frames, thus allowing, for example, an animation of a small butterfly flitting its wings while flying over a static or dynamic texture. Another name used for sprite animations is cast-based animation, which is derived from the use of sprites as cast members who can move over texture maps. Sprites are commonly used in non-3D gaming applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset