SDL_ISPIXELFORMAT_INDEXED(3)

πŸ’– SDL_ISPIXELFORMAT_INDEXED πŸ’–

okay bestie, welcome to the SDL_ISPIXELFORMAT_INDEXED page from the SDL3 FUNCTIONS corner of the manual ✨ it's a lil macro, it's a lil vibe check for your pixel formats, and it's here to tell you if a format is an indexed one. no cap.


✨ NAME ✨

SDL_ISPIXELFORMAT_INDEXED β€” a macro that determines whether an SDL_PixelFormat is an indexed format πŸŽ€


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_pixels.h>

#define SDL_ISPIXELFORMAT_INDEXED(format)   \
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))

like, literally the whole macro is right there, she's not hiding anything πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, and it's important tea: this macro double-evaluates its parameter 😭 meaning it looks at your argument more than once. so do not pass it expressions with side-effects, bestie. that's giving undefined chaos energy and we are not doing that today.

⚠️ real talk: side effects in the argument = bad time. if your expression changes something every time it's evaluated, it's gonna change it multiple times here. do not do this. πŸ™ˆ

πŸŽ€ MACRO PARAMETERS πŸŽ€

  • format β€” an SDL_PixelFormat that you wanna check πŸ‘€ just hand it over and she'll tell you what's what.

πŸ’œ RETURN VALUE πŸ’œ

returns true if the format is indexed, and false otherwise. simple as that, periodt. ✨


🌈 THREAD SAFETY 🌈

it is safe to call this macro from any thread 🫢 go off, multi-threaded queen, this one's got you.


⭐ AVAILABILITY ⭐

this macro has been available since SDL 3.2.0 πŸ‘‘ a modern icon, truly.


and that's the whole page, bestie!! mwah πŸ’–

this lil rewrite came from the Simple Directmedia Layer crew, rockin' SDL 3.4.18, and you just read the SDL_ISPIXELFORMAT_INDEXED(3) page. stay indexed, stay iconic, ily πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from