SDL_SetTexturePalette(3)
π SDL_SetTexturePalette π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, and today's main character is SDL_SetTexturePalette(3) β she's a real one, no cap. π
β¨ NAME β¨
SDL_SetTexturePalette β literally just: set the palette used by a texture. that's it, that's the whole job. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_render.h>
bool SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette);
look at her. two args, one bool. so clean. π¦
π DESCRIPTION π
So here's the tea: when you set the palette, SDL keeps an internal reference to it. which means β and this is the slay part β you can safely destroy your palette afterwards and it's still fine. no dangling drama, no use-after-free energy. β¨
And bestie, you're not limited to one texture per palette either: a single palette can be shared with many textures. it's giving community. it's giving sharing is caring. iconic honestly. π
π«Ά FUNCTION PARAMETERS π«Ά
textureβ the texture you wanna update. your girl. the one getting a glow-up. πpaletteβ theSDL_Palettestructure to use. the whole color situation. π
β RETURN VALUE β
Returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, because she will tell you exactly what went wrong. π
π₯ THREAD SAFETY π₯
main thread only, bestie!! this function should only be called on the main thread. do not be out here spawning threads and calling this. that's not the vibe. π
π§ AVAILABILITY π§
This function is available since SDL 3.4.0. so if you're on anything older, sorry babe, you're not invited to the party. π
π¦ SEE ALSO π¦
go read those next, iykyk. π
mwah π that's the whole page! brought to you by the lovely folks at Simple Directmedia Layer, running SDL 3.4.18 β and yes, this is SDL_SetTexturePalette(3), the one and only. go set some palettes, bestie, you got this. π«Άβ¨π
π¦ 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