SDL_SetSurfacePalette(3)

πŸ’– SDL_SetSurfacePalette(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, this one's called SDL_SetSurfacePalette and it's literally the glow-up artist for your surface's colour palette πŸ’…


✨ NAME ✨

SDL_SetSurfacePalette β€” set the palette used by a surface, periodt 🎨


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: when you set the palette, SDL keeps an internal reference to it. which means β€” and this is the iconic part β€” you can safely destroy your palette afterwards. she's holding onto it for you, no cap 🫢

also, one single palette can be shared with many surfaces. it's giving communal wardrobe, it's giving "we all borrow each other's clothes", highkey efficient 🌈


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • surface β€” the SDL_Surface structure you wanna update. this is the main character getting the makeover ✨
  • palette β€” the SDL_Palette structure to use. this is the outfit she's changing into πŸ’œ

⭐ RETURN VALUE ⭐

Returns true on success or false on failure. and if it's a flop? call SDL_GetError() for more information, she'll tell you what went wrong 😭


🧚 THREAD SAFETY 🧚

good news bestie β€” this function can be called on different threads, as long as you're using different surfaces. so like, everybody gets their own surface and nobody's fighting. we love a peaceful household πŸ•ŠοΈ


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. so if you're on something older... babes, it's not there πŸ’€


πŸ’œ SEE ALSO πŸ’œ


lowkey reminder that this is your friendly neighbourhood rewrite and the facts above are the facts β€” no invented behaviour, no made-up defaults, just the manpage with a whole lot more sparkle 🌟

anyway that's the page, go forth and palette your surfaces, i'm obsessed, bye πŸŽ€


with love from the Simple Directmedia Layer girlies β€” this is SDL 3.4.18, and yes the original page really is SDL_SetSurfacePalette(3) all the way at the bottom too, we just folded it in up top because we're cute like that πŸ’–

πŸ“¦ where this page comes from