SDL_GetSurfaceColorKey(3)

✨ SDL_GetSurfaceColorKey ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual πŸ’– this one's about finding out which pixel your surface is treating as "invisible". it's giving detective energy, fr fr.


🌸 NAME 🌸

SDL_GetSurfaceColorKey β€” get the color key (transparent pixel) for a surface 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_surface.h>

bool SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);

πŸ’… DESCRIPTION πŸ’…

so the color key is a pixel of the format used by the surface, as generated by SDL_MapRGB(). that's the one pixel value that gets treated as transparent. iconic behaviour honestly.

and here's the tea: if the surface doesn't have color key enabled, this function returns false. no color key, no answer, sorry babe 😭


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • surface β€” the SDL_Surface structure to query. this is the one we're snooping on πŸ‘€
  • key β€” a pointer filled in with the transparent pixel. you hand it the spot, it fills it in. mutual trust πŸ’œ

⭐ RETURN VALUE ⭐

Returns true on success or false on failure; call SDL_GetError() for more information. so like, if it fails, go ask SDL_GetError() what's wrong, she always knows πŸ”₯


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. yes bestie, ANY thread. go wild, main character energy, no locks required πŸ‘‘


🧚 AVAILABILITY 🧚

This function is available since SDL 3.2.0. so if you're on something older, that's a you problem, go update πŸ“


πŸ’– SEE ALSO πŸ’–


and that's the whole page, periodt ✨ this one came to you straight from the Simple Directmedia Layer girlies, running on SDL 3.4.18, and it's filed under SDL_GetSurfaceColorKey(3) β€” mwah, take care of her πŸ’…πŸ’–

πŸ“¦ where this page comes from