SDL_ISPIXELFORMAT_ALPHA(3)
π SDL_ISPIXELFORMAT_ALPHA π
okay bestie so this is from the SDL3 FUNCTIONS part of the manual, and it's literally the little macro that tells you whether an SDL_PixelFormat has an alpha channel. that's it. that's the whole job. she's small but she's important π«Ά
β¨ NAME β¨
SDL_ISPIXELFORMAT_ALPHA β a macro to determine if an SDL_PixelFormat has an alpha channel.
like. does this pixel format have transparency or not. yes or no. that's the vibe check πΈ
π SYNOPSIS π
#include <SDL3/SDL_pixels.h>
#define SDL_ISPIXELFORMAT_ALPHA(format) \
((SDL_ISPIXELFORMAT_PACKED(format) && \
((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \
(SDL_ISPIXELFORMAT_ARRAY(format) && \
((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \
(SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \
(SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \
(SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA))))
look at her go. packed formats check SDL_PACKEDORDER_ARGB, SDL_PACKEDORDER_RGBA, SDL_PACKEDORDER_ABGR, SDL_PACKEDORDER_BGRA, and array formats check SDL_ARRAYORDER_ARGB, SDL_ARRAYORDER_RGBA, SDL_ARRAYORDER_ABGR, SDL_ARRAYORDER_BGRA. if the pixel order says there's an A in there, we're in business. periodt β¨
π DESCRIPTION π
β οΈ okay this is the important part, no cap: this macro double-evaluates its parameter, so do NOT pass in expressions with side-effects here. like, don't put i++ or a function call that does stuff in there. she will run it twice and you will simply have a bad time π
π¦ MACRO PARAMETERS π¦
formatβ anSDL_PixelFormatto check. that's the one and only thing you hand her π
π RETURN VALUE π
Returns true if the format has alpha, false otherwise. binary. iconic. no in-between π
π§ THREAD SAFETY π§
It is safe to call this macro from any thread. so go off, thread queen, no locks required π
β AVAILABILITY β
This macro is available since SDL 3.2.0. if you're on anything older she simply does not exist yet, sorry bestie π
mwah π that's the whole page. go check your pixel formats, you got this.
signing off from the Simple Directmedia Layer crew β this is the SDL 3.4.18 era of the docs, page SDL_ISPIXELFORMAT_ALPHA(3), and yes she ate. πβ¨π«Ά
π¦ 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