Manual Reference Pages - EXSPRITE (3)
exsprite - Datafiles access and sprite animation. Allegro game programming library.
This example demonstrates how to use datafiles, various sprite
drawing routines and flicker-free animation.
Why is the animate() routine coded in that way? As you
probably know, VIDEO RAM is much slower than "normal"
RAM, so its advisable to reduce VRAM blits to a minimum.
Drawing sprite on the screen (meaning in VRAM) and then
clearing a background for it is not very fast. This example
uses a different method which is much faster, but require a
bit more memory.
First the buffer is cleared (its a normal BITMAP), then the
sprite is drawn on it, and when the drawing is finished this
buffer is copied directly to the screen. So the end result is
that there is a single VRAM blit instead of blitting/clearing
the background and drawing a sprite on it. Its a good method
even when you have to restore the background. And of course,
it completely removes any flickering effect.
When one uses a big (ie. 800x600 background) and draws
something on it, its wise to use a copy of background
somewhere in memory and restore background using this
"virtual background". When blitting from VRAM in SVGA modes,
its probably, that drawing routines have to switch banks on
video card. I think, I dont have to remind how slow is it.
Note that on modern systems, the above isnt true anymore, and
you usually get the best performance by caching all your
animations in video ram and doing only VRAM->VRAM blits, so
there is no more RAM->VRAM transfer at all anymore. And usually,
such transfers can run in parallel on the graphics cards
processor as well, costing virtually no main cpu time at all.
See the exaccel example for an example of this.
|Allegro ||EXSPRITE (3) ||version 4.4.2 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.