SDL_FOURCC(3)
π SDL_FOURCC π
okay bestie, welcome to SDL_FOURCC β it's a macro from the SDL3 FUNCTIONS lineup (yes that's the manual section, we're fancy here), and it's literally just: define a four character code as a Uint32. that's the whole vibe. four lil characters in, one big number out. slay. π
β¨ SYNOPSIS β¨
include the header first, always:
#include <SDL3/SDL_stdinc.h>
#define SDL_FOURCC(A, B, C, D) \
((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
look at her. four casts, four shifts, three ORs. she's packing those bytes like a girl packing a carry-on. π
πΈ MACRO PARAMETERS πΈ
Aβ the first ASCII character. she goes in the lowest spot (shift 0), first in line, main character energy πBβ the second ASCII character.Cβ the third ASCII character.Dβ the fourth ASCII character. she gets the highest spot (shift 24), living her best life at the top π¦
β RETURN VALUE β
returns the four characters converted into a Uint32, one character per byte. so yeah, all four of them squeezed into one number, each one minding her own byte. iconic honestly. β¨
π§ THREAD SAFETY π§
it is safe to call this macro from any thread. no drama, no locks, no fighting. everyone can use her at the same time, no cap. π«Ά
π AVAILABILITY π
this macro has been available since SDL 3.2.0. so if you're on something olderβ¦ babe. π
reminder bestie: this is a macro, not a function β the compiler just yeets the expression in wherever you write it. the exact expansion above is the one and only, don't go inventing your own. π
and that's the whole page!! no SEE ALSO, no bugs, no authors listed β just pure four-character-code excellence. π
written up by Simple Directmedia Layer, version SDL 3.4.18, dated SDL_FOURCC(3). mwah. π
πΈ
π¦ 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