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 β€” an SDL_PixelFormat to 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