SDL_WaitEvent(3)

πŸ’€ SDL_WaitEvent(3) πŸ’€

okay bestie, we're in the SDL3 FUNCTIONS section of the manual and this one is literally just "chill until something happens" ✨


✨ NAME ✨

SDL_WaitEvent β€” wait indefinitely for the next available event. like, no timer, no vibes check, just vibes. you sit there. you wait. 🫢


✨ SYNOPSIS ✨

#include <SDL3/SDL_events.h>

bool SDL_WaitEvent(SDL_Event *event);

✨ DESCRIPTION ✨

okay so here's the tea β˜• β€” if event is not NULL, the next event gets removed from the queue and stored in the SDL_Event structure pointed to by event. it's giving "gimme the next one, I'll hold it" πŸ’…

⚠️ important bestie!! because this function may implicitly call SDL_PumpEvents(), you can only call this function in the thread that initialized the video subsystem. do not try to be cute and call it from some random thread. that's not the move. 🚫🧡

✨ FUNCTION PARAMETERS ✨

  • event β€” the SDL_Event structure to be filled in with the next event from the queue, or NULL. that's it. that's the whole parameter. simple queen behaviour πŸ‘‘

✨ RETURN VALUE ✨

  • returns true on success πŸŽ‰
  • returns false if there was an error while waiting for events 😭

if you get false, call SDL_GetError() for more information β€” she will tell you what went wrong, fr fr.


✨ THREAD SAFETY ✨

this function should only be called on the main thread. periodt. πŸ’…


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. so if you're on anything older, no she's not there yet, sorry babe πŸŽ€


✨ SEE ALSO ✨


and that's the whole page bestie!! this one came to you from Simple Directmedia Layer, running SDL 3.4.18 β€” go forth and wait for events responsibly, mwah πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from