set_palette_range(3alleg4)

πŸ’– set_palette_range β€” Allegro manual, bestie edition πŸ’–

okay so you're in the Allegro game programming library, poking at palettes, and you want to update just a lil slice of it instead of the whole thing? say less. this is the one. ✨


✨ NAME ✨

set_palette_range β€” sets a specific range of the palette. literally just that. Allegro game programming library, mwah πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

void set_palette_range(const PALETTE p, int from, int to, int vsync);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: set_palette_range sets the palette entries between from and to, and yes bestie, that's inclusive on both ends 🫢. want the entire palette? pass 0 and 255 and you're done, no cap.

now the vsync parameter, okay, this is the important part:

  • if vsync is set, it waits for the vertical retrace before doing the thing
  • otherwise it just sets the colors immediately

both are valid, just depends on whether you want to be polite to your display or not 😌

example time, here's the exact one:

PALETTE palette;
...
/* Modify the first 16 entries. */
change_first_16_colors(palette);
/* Now update them waiting for vsync. */
set_palette_range(palette, 0, 15, 1);

see how 0, 15, 1 is giving "first sixteen entries, and yeah wait for vsync please"? iconic. πŸ‘‘


🌈 SEE ALSO 🌈


k that's the whole page bestie, go forth and recolor πŸ’œ

this was the Allegro manual, version 4.4.3 β€” thanks for reading, ily, bye!! πŸŽ€βœ¨πŸ¦‹