SDL_GetSurfaceColorspace(3)

✨ SDL_GetSurfaceColorspace ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages πŸ’– this one's called SDL_GetSurfaceColorspace, and no cap, it's a lil baby function that just tells you what colorspace a surface is vibing in. super simple, super useful, let's get into it πŸ¦‹


🌸 NAME 🌸

SDL_GetSurfaceColorspace β€” get the colorspace used by a surface. that's it. that's the whole job. iconic behavior honestly πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_surface.h>

SDL_Colorspace SDL_GetSurfaceColorspace(SDL_Surface *surface);

look at her. one include, one function call, zero drama πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea β˜• β€” the colorspace of your surface isn't just random, it defaults based on what kind of format the surface is using. the rules are:

  • floating point formats β†’ defaults to SDL_COLORSPACE_SRGB_LINEAR
  • 10-bit formats β†’ defaults to SDL_COLORSPACE_HDR10
  • other RGB surfaces β†’ defaults to SDL_COLORSPACE_SRGB
  • YUV textures β†’ defaults to SDL_COLORSPACE_BT709_FULL

so yeah, it's giving "the surface already knows what it is" energy 🌈


🫢 FUNCTION PARAMETERS 🫢

  • surface β€” the SDL_Surface structure you wanna query. just hand her over and she'll tell you her colorspace secrets πŸ”

⭐ RETURN VALUE ⭐

returns the colorspace used by the surface πŸŽ‰ ... BUT β€” and this is the important part bestie β€” if the surface is NULL, you get SDL_COLORSPACE_UNKNOWN back. so like, don't be surprised, it's not throwing hands, it's just telling you there's nothing there πŸ’€


🧚 THREAD SAFETY 🧚

good news!! this function can be called on different threads with different surfaces πŸ”₯ so as long as you're not poking the same surface from two threads at once, you're chilling. parallel vibes only ✨


πŸ’– AVAILABILITY πŸ’–

this function has been around since SDL 3.2.0 πŸŽ‚ so if you're on anything older, sorry babe, she's not there yet 😭


🌈 SEE ALSO 🌈


reminder bestie: getting a colorspace is read-only, it doesn't change anything. if you wanna change the vibe, go see SDL_SetSurfaceColorspace(3). iykyk πŸ’…

and that's the whole page, periodt πŸŽ€ this little love letter to the colorspace API came to you from Simple Directmedia Layer, SDL 3.4.18, and yeah she's filed under SDL_GetSurfaceColorspace(3) β€” go forth and query those surfaces, you absolute main character πŸ‘‘πŸ’–

πŸ“¦ where this page comes from