SDL_SetTexturePalette(3)

πŸ“¦
version 3.4.18 Β· 5 versions
, in fedora 43, fedora 44

πŸ’– 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 β€” the SDL_Palette structure 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