set_palette(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– 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