SDL_CreatePalette(3)
β¨ NAME β¨
SDL_CreatePalette β bestie, this is the one that makes you a whole new palette structure with however many color entries you want π (yes it's an SDL3 function, and yes we're gonna get you through it)
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_pixels.h>
SDL_Palette * SDL_CreatePalette(int ncolors);
π DESCRIPTION π
Okay so real talk: this gives you a brand new palette. And the vibe of the entries when you first get it? Every single one of them is initialized to white. All of them. Every color entry. White. π€
π¦ FUNCTION PARAMETERS π¦
ncolorsβ this is literally just how many color entries you want your palette to have. That's the number. That's the whole job. π
π RETURN VALUE π
On success you get a shiny new SDL_Palette structure back. π«Ά
On failure β like if there legit wasn't enough memory for it π β you get NULL. And when that happens, call SDL_GetError() to find out what went wrong, because it will tell you.
π THREAD SAFETY π
It is safe to call this function from any thread. Every thread. No gatekeeping. Go off, concurrent bestie π
β AVAILABILITY β
This function has been available since SDL 3.2.0. Not new new, but not ancient either. Iconic behavior. β¨
π SEE ALSO π
fr fr, go read SDL_DestroyPalette(3) too β you gotta clean up after yourself, bestie, no cap π
Okay that's the whole page!! Simple Directmedia Layer is the source, we're rolling on SDL 3.4.18, and this SDL_CreatePalette(3) moment is over β go make something gorgeous with your palette, mwah πππ§
π¦ 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