SDL_PIXELLAYOUT(3)

πŸ’– SDL_PIXELLAYOUT πŸ’–

okay bestie come CLOSE, because this one is a macro in the SDL3 function family and she is tiny but she is mighty πŸŽ€


✨ NAME ✨

SDL_PIXELLAYOUT β€” a macro to retrieve the layout of an SDL_PixelFormat. that's it. that's the whole job. she does one thing and she slays at it πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_pixels.h>

#define SDL_PIXELLAYOUT(format)  (((format) >> 16) & 0x0F)

yes ma'am, that's the whole thing. a right shift and a mask. bit math but make it fashion ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so like, what even is the layout, you ask? πŸ₯Ί it's usually a value from the SDL_PackedLayout enumeration. iconic. love that for her.

or β€” and hear me out β€” it's zero if a layout doesn't make sense for the format type. like sometimes the answer is just "nope, doesn't apply here" and honestly? valid. we respect it. no cap πŸ’€


πŸŽ€ MACRO PARAMETERS πŸŽ€

  • format β€” an SDL_PixelFormat to check. that's the one you're passing in, bestie. give her the format and she'll tell you the vibe 🌈

⭐ RETURN VALUE ⭐

returns the layout of format. short, sweet, to the point. she ate and left no crumbs πŸ‘‘


🧚 THREAD SAFETY 🧚

it is safe to call this macro from any thread. yes literally any of them. go wild. no locks, no drama, no stress 🫢


πŸ’œ AVAILABILITY πŸ’œ

this macro has been available since SDL 3.2.0. so if you're on something older... bestie. it's giving outdated. time to update πŸ™ˆ


lowkey the whole trick is that the layout lives in bits 16 through 19 of the format value, and 0x0F masks off everything else. the way that >> 16 and & 0x0F team up?? obsessed. that's the bit-manipulation equivalent of a duet πŸ”₯

okay that's the page!! no notes, she's perfect πŸ’– this was served up by the Simple Directmedia Layer crew, SDL 3.4.18 era, and you were reading SDL_PIXELLAYOUT(3) β€” mwah, bye bestie!! πŸŽ€βœ¨πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from