SDL_ISPIXELFORMAT_ARRAY(3)

πŸ’– SDL_ISPIXELFORMAT_ARRAY πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_ISPIXELFORMAT_ARRAY β€” a macro that tells you whether an SDL_PixelFormat is an array format or not. no cap, that's the whole gig. πŸŽ€


✨ NAME ✨

SDL_ISPIXELFORMAT_ARRAY β€” a macro to determine if an SDL_PixelFormat is an array format. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_pixels.h>

#define SDL_ISPIXELFORMAT_ARRAY(format) \
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, and it's important tea: this macro double-evaluates its parameter. like, it looks at your format more than once. so please, do not pass it expressions with side-effects, because those side effects would happen twice and you'd be sitting there like 😭 wondering why your counter jumped by two. don't do it. periodt.


πŸ‘‘ MACRO PARAMETERS πŸ‘‘

  • format β€” an SDL_PixelFormat to check. that's the one, that's the input, hand it over 🫢

⭐ RETURN VALUE ⭐

  • returns true if the format is an array β€” iconic ✨
  • returns false otherwise β€” not an array, moving on πŸ’€

🧚 THREAD SAFETY 🧚

it is safe to call this macro from any thread. go off, multithreaded queen πŸ‘‘


🌈 AVAILABILITY 🌈

this macro is available since SDL 3.2.0. so if you're on something older... it's giving vintage, and not in a cute way πŸ™ˆ


lowkey reminder: the side-effects warning in DESCRIPTION is not a vibe, it's a real rule. double evaluation is double evaluation fr fr.

Simple Directmedia Layer made this, SDL 3.4.18 is the version, and this whole page is filed under SDL_ISPIXELFORMAT_ARRAY(3). mwah, thanks for reading bestie, go check your pixel formats πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from