SDL_FlushEvent(3)

✨ SDL_FlushEvent ✨

okay bestie, welcome to the SDL_FlushEvent(3) page from the SDL3 functions manual πŸ’– this one's a lil baddie that clears out events of one specific type from the event queue. she's simple, she's iconic, let's get into it 🫢


🌸 NAME 🌸

SDL_FlushEvent β€” Clear events of a specific type from the event queue. ✨


πŸ’… SYNOPSIS πŸ’…

#include <SDL3/SDL_events.h>

void SDL_FlushEvent(Uint32 type);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, this function will unconditionally remove any events from the queue that match type. No questions asked, no vibe check, they're just gone πŸ’€

If you need to remove a range of event types instead of just one, use SDL_FlushEvents() instead β€” she's the group version, this one's the solo act πŸ’…

ngl it's also totally normal to just ignore events you don't care about in your event loop without calling this function at all. like, you don't have to yeet them, sometimes you just look away πŸ™ˆ

important thing tho: this function only affects currently queued events. If you want to make sure that all pending OS events are flushed too, you can call SDL_PumpEvents() on the main thread immediately before the flush call ✨ like, pump first, then flush. order matters bestie πŸŽ€

and one more thing that's lowkey crucial: if you have user events with custom data that needs to be freed, you should use SDL_PeepEvents() to remove and clean up those events before calling this function. otherwise you're just leaking memory and that's not the vibe 😭 clean up your room before you throw stuff out, periodt πŸ’–


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • type β€” the type of event to be cleared; see SDL_EventType for details. πŸ‘‘

🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. yes bestie, any thread, she's flexible like that πŸ’…βœ¨


⭐ 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 came to you from the Simple Directmedia Layer girlies, rocking SDL 3.4.18, and it's literally called SDL_FlushEvent(3) in case you forgot already πŸŽ€ mwah, go clear those events, ily πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from