set_palette(3)
π set_palette(3) β Allegro manual π
okay bestie, pull up a chair because this one is literally the glow-up function of the whole Allegro manual β¨
πΈ NAME πΈ
set_palette β sets the entire palette of 256 colors, brought to you by the Allegro game programming library π
π¦ SYNOPSIS π¦
#include <allegro.h>
void set_palette(const PALETTE p);
π DESCRIPTION π
So. You know how a palette is 256 colors and you're sitting there like "not me manually setting each one π"? Yeah, no. set_palette does the whole thing in one go β the entire palette of 256 colors, slayed, periodt π
You hand it an array of 256 RGB structures. That's the whole assignment. That's it. You're done.
And here's the part that's lowkey iconic: unlike set_color(), there is no need to call vsync() before this function. No waiting, no syncing, no drama. You just call it. Main character energy fr fr π
Example, because we love a visual:
BITMAP *bmp;
PALETTE palette;
...
bmp = load_bitmap(filename, palette);
if (!bmp)
abort_on_error("Couldn't load bitmap!");
set_palette(palette);
see how load_bitmap(filename, palette) just hands the palette straight over and then set_palette(palette) eats it up? chef's kiss, no notes π₯
β SEE ALSO β
go read those too, iykyk π«Ά
π a lil sign-off π
that's the whole page bestie!! this one came from the Allegro manual, and it's sitting pretty at version 4.4.3 π take care of your palettes and they'll take care of you πβ¨
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms