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β theSDL_Surfacestructure you wanna update. this is the main character getting the makeover β¨paletteβ theSDL_Palettestructure 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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms