SDL_GetPixelFormatForMasks(3)

πŸ’– SDL_GetPixelFormatForMasks(3) πŸ’–

okay bestie, so this one lives in the SDL3 FUNCTIONS crew, and it's genuinely one of those lil utility functions that just does the thing for you. no cap.


✨ NAME ✨

SDL_GetPixelFormatForMasks β€” take a bpp value plus some RGBA masks and turn them into an enumerated pixel format. it's giving translator energy 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_pixels.h>

SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you hand it your masks and it hands you back a pixel format. iconic behaviour fr fr.

but listen β€” if the conversion wasn't possible, it will return SDL_PIXELFORMAT_UNKNOWN. that's the "idk bestie, couldn't do it" answer πŸ’€ so always check what you got back, okay?


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • bpp β€” the bits per pixel value. usually 15, 16, or 32 but like, that's the usual crowd, not a rule.
  • Rmask β€” the red mask for the format πŸ’„
  • Gmask β€” the green mask for the format 🌿
  • Bmask β€” the blue mask for the format πŸ’™
  • Amask β€” the alpha mask for the format πŸ«₯

⭐ RETURN VALUE ⭐

it returns the SDL_PixelFormat value that matches your format masks β€” main character moment ✨ β€” OR it returns SDL_PIXELFORMAT_UNKNOWN if there isn't a match. no match, no format, periodt.


πŸ’… THREAD SAFETY πŸ’…

it is safe to call this function from any thread. yes queen, go off, call it wherever you want πŸ”₯


🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0 πŸ‘‘


πŸ‘‘ SEE ALSO πŸ‘‘


mwah πŸ’‹ that's the whole page. this lil manual comes to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 β€” and it's literally the SDL_GetPixelFormatForMasks(3) page, so you know exactly where you are πŸ’œ byeeeee πŸŽ€

πŸ“¦ where this page comes from