SDL_GetPixelFormatDetails(3)

πŸ’– SDL_GetPixelFormatDetails πŸ’–

okay bestie, welcome to SDL3 FUNCTIONS πŸŽ€ this one's literally called SDL_GetPixelFormatDetails, and no cap, it's about to hand you the whole lore on a pixel format. periodt.


✨ NAME ✨

SDL_GetPixelFormatDetails β€” create an SDL_PixelFormatDetails structure that corresponds to a pixel format. it's giving "tell me everything about this format" and honestly? iconic πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_pixels.h>

const SDL_PixelFormatDetails * SDL_GetPixelFormatDetails(SDL_PixelFormat format);

πŸ’… DESCRIPTION πŸ’…

so here's the tea, and it's important: the structure you get back may come from a shared global cache β€” meaning it's not newly allocated for you. it's the communal one. the group-chat one. everybody's using it.

which means: do NOT modify it. especially the palette. do not touch. hands off. πŸ™ˆ

and if you do mess with it? you get weird errors, like Blit combination not supported popping up out of nowhere, and you'll be sitting there like 😭 because nothing about your code looks wrong. it's not you, it's the shared struct you vandalized. fr fr.


🧚 FUNCTION PARAMETERS 🧚

  • format β€” one of the SDL_PixelFormat values. that's it, that's the whole ask. πŸ‘‘

⭐ RETURN VALUE ⭐

  • Returns a pointer to an SDL_PixelFormatDetails structure, or NULL on failure. if you get NULL, hit up SDL_GetError() for more info β€” she'll tell you what went wrong. 🫢

🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. go off, multithreaded queen. πŸ’œ


πŸ“ AVAILABILITY πŸ“

this function has been available since SDL 3.2.0. so if you're on something older, that's a you problem bestie, go update. ✨


reminder: shared cache = shared responsibility. read it, love it, don't write to it. πŸ’€

and that's the whole page, mwah πŸ’‹ brought to you by Simple Directmedia Layer, SDL 3.4.18, page SDL_GetPixelFormatDetails(3). slay, go render some pixels πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from