Some time ago, someone (David Olafson, I think) asked for doing color
cycling when you can’t really use hardware palette.
Color cycling is an old trick to make movement effect only by doing a
palette rotation that cost nothing compared to sprite movement. Tou can see
this effect, for exemple, in animated fountains or waterfalls (like in
Sonic). It was still in use in DOS VGA 256-color games, so it’s required
when porting old games to SDL.
The problem is that in 15-or-more bits modes, there is no more hardware
palette; the pixels store their RGB(+alpha) into themselves. To do an
equivalent effect, you need to reserve a range of colors (to keep cycling
pixel position) and to replace on-the-fly theses pixels by the good color
values. It’s CPU intensive, and unhandy.
The way I found to achieve this effect is the following one.
If you want to do color cycling on sprites/pictures, you should have
these pictures in 8 bits format. To load them fine in SDL, you need to load
their palettes as well (in my_surface->format->palette). Alright ? Don’t you
see where I am going ? Yes: just do the palette rotation into the pictures’
palettes. So when you blit them on your screen, SDL will use the newly
changed palettes. Not so diffucult, you see !
The only counterpart of this method is that you mustn’t convert the
pictures’ display format to the screen’ (this is a well known way to improve
blitting speed). Otherwise you could lost your palettes, and prevent color
Am I wrong ? If yes, please correct this stuff.
ifrance.com, l’email gratuit le plus complet de l’Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP…