SDL_ShouldInit(3)

✨ SDL_ShouldInit ✨

okay bestie, so this one lives in the SDL3 FUNCTIONS corner of the SDL3 man pages, and it's literally called SDL_ShouldInit β€” like, should we init?? let's find out πŸ’…


πŸŽ€ NAME πŸŽ€

SDL_ShouldInit β€” return whether initialization should be done. no cap, that's the whole job 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_mutex.h>

bool SDL_ShouldInit(SDL_InitState *state);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the way this works is: it checks the state you passed in, and if initialization should be done, it sets the status to SDL_INIT_STATUS_INITIALIZING and returns true. periodt ✨

And if another thread is already modifying this state? bestie it does not panic, it just waits until that's done before returning. so polite. so well-behaved. we love a thread-safe queen πŸ‘‘

⚠️ important, fr fr: if this function returns true, the calling code must call SDL_SetInitialized() to complete the initialization. like, that's not optional. that's the deal. don't leave it hanging πŸ™ˆ

πŸ’– FUNCTION PARAMETERS πŸ’–

  • state β€” the initialization state to check. that's the vibe check right there πŸ”

🌈 RETURN VALUE 🌈

Returns true if initialization needs to be done, false otherwise. iconic binary behavior, no in-between πŸŽ€


πŸ’œ THREAD SAFETY πŸ’œ

It is safe to call this function from any thread. every single one. go off 🧚


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on something older... yeah, she's not there yet πŸ’€


πŸ”₯ SEE ALSO πŸ”₯

iykyk β€” go read those next, they're the whole squad 🫢


Simple Directmedia Layer Β· SDL 3.4.18 β€” mwah, that's the version, and this whole page is SDL_ShouldInit(3) πŸ’… stay init'd bestie, love u, bye ✨

πŸ“¦ where this page comes from