Double buffering is an extremely powerful concept that has
helped make some of today’s flicker-free animation and game
play possible. It reduces flicker by performing all the graphics
functions on a hidden image that resides in memory instead of
drawing directly to the screen. Then, the entire image is dis-
played all at once instead of having to update the screen every
time a new bit of graphics is drawn.
If we removed the double buffering technique from our applet,
you would see the screen flicker every time the text moved even a
little bit. (As an experiment, you might want to try changing the
applet code so that the double buffering gets disabled.) If we
were drawing any extra graphics or additional text, you would
also see flickers for each of those events. These flashes and flick-
ers occur because the screen is updated multiple times during the
drawing of the object and the Applet class’ paint() method clears
the screen before it redraws it. With text, the screen can some-
times be redrawn for each letter! This causes the flicker and can
actually slow things down if you are drawing many items.
Double buffering improves performance because the graphics
can be drawn into memory faster than they can be drawn onto
the screen. Even with the extra step of blasting the graphics to
the screen, double buffering is still much faster.
The double buffering technique we used in our TickerTape applethelped make some of today’s flicker-free animation and game
play possible. It reduces flicker by performing all the graphics
functions on a hidden image that resides in memory instead of
drawing directly to the screen. Then, the entire image is dis-
played all at once instead of having to update the screen every
time a new bit of graphics is drawn.
If we removed the double buffering technique from our applet,
you would see the screen flicker every time the text moved even a
little bit. (As an experiment, you might want to try changing the
applet code so that the double buffering gets disabled.) If we
were drawing any extra graphics or additional text, you would
also see flickers for each of those events. These flashes and flick-
ers occur because the screen is updated multiple times during the
drawing of the object and the Applet class’ paint() method clears
the screen before it redraws it. With text, the screen can some-
times be redrawn for each letter! This causes the flicker and can
actually slow things down if you are drawing many items.
Double buffering improves performance because the graphics
can be drawn into memory faster than they can be drawn onto
the screen. Even with the extra step of blasting the graphics to
the screen, double buffering is still much faster.
is very general, and you can apply it to many of the applets that
you write that need to perform flicker free animation. We sug-
gest you experiment with these concepts—you may come up
some of your own for writing optimized applets.
Comments
Post a Comment