SDL_BITSPERPIXEL(3)
π SDL_BITSPERPIXEL(3) π
ok so bestie, welcome to the SDL3 FUNCTIONS corner of the group chat, where today's main character is SDL_BITSPERPIXEL π
β¨ NAME β¨
SDL_BITSPERPIXEL β a macro that figures out an SDL_PixelFormat's bits per pixel. that's it, that's the whole job, and it does it flawlessly, no notes π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_pixels.h>
#define SDL_BITSPERPIXEL(format) \
(SDL_ISPIXELFORMAT_FOURCC(format) ? 0 : (((format) >> 8) & 0xFF))
β¨ DESCRIPTION β¨
ok so real talk π«Ά β this macro double-evaluates its parameter. like, it looks at format more than once. so pls pls pls do not hand it expressions with side-effects, because they will run twice and that is giving chaos, not giving slay π
and FourCC formats? they report zero here. because honestly, measuring a FourCC per-pixel rarely makes sense β it's just not that kind of format, and we respect that π
β¨ MACRO PARAMETERS β¨
formatβ anSDL_PixelFormatto check. that's the one, the only, the icon π
β¨ RETURN VALUE β¨
returns the bits-per-pixel of format. periodt β¨
β¨ THREAD SAFETY β¨
it is safe to call this macro from any thread. yes, literally any of them. go wild, bestie π
β¨ AVAILABILITY β¨
this macro has been available since SDL 3.2.0 π¦
β¨ SEE ALSO β¨
SDL_BYTESPERPIXEL(3)β the sibling, the counterpart, the other half of the duo π«Ά
ngl if you're passing something with side-effects in here, pls stop, i'm begging π the double-evaluation is not a vibe.
and that's the whole page, bestie!! πΈ this lil gem comes to you from the Simple Directmedia Layer girlies, SDL 3.4.18 edition, dated the day of this very manual page. mwah π go check your bits per pixel, you absolute legend πβ¨
π¦ 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