SDL_Palette(3)

πŸ’– SDL_Palette(3) πŸ’–

okay bestie, welcome to the SDL API Reference β€” this is the SDL_Palette page and honestly it's short, sweet, and iconic. let's get into it ✨


🌈 NAME 🌈

SDL_Palette β€” the color palette for 8-bit pixel formats 🎨


🧚 STRUCTURE DEFINITION 🧚

here's the whole vibe, literally verbatim:

typedef struct{
  int ncolors;
  SDL_Color *colors;
} SDL_Palette;

πŸŽ€ STRUCTURE DATA πŸŽ€

the two fields, no notes skipped:

  • ncolors β€” the number of colors used in this palette πŸ’…
  • colors β€” a pointer to the SDL_Color structures that make up the palette πŸ¦‹

✨ DESCRIPTION ✨

so here's the tea, fr fr: every pixel in an 8-bit surface is an index into the colors field of the SDL_Palette structure stored in SDL_PixelFormat.

and like β€” you should never need to create an SDL_Palette manually. not ever. it gets created automatically when SDL allocates an SDL_PixelFormat for a surface 🫢

and if you wanna change the colors? the color values of an SDL_Surface's palette can be set with SDL_SetColors. that's the move πŸ’–

bestie reminder: manual creation is not the assignment here. SDL handles it. you just vibe with the palette it hands you 😌

πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_Color
  • SDL_Surface
  • SDL_SetColors
  • SDL_SetPalette

k that's the whole page, you ate it πŸ’…βœ¨

this lil masterpiece came from the SDL crew, dated Tue 11 Sep 2001, 23:01, and it lives at SDL_Palette(3) β€” mwah, stan forever πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from