.\" This manpage content is licensed under Creative Commons .\" Attribution 4.0 International (CC BY 4.0) .\" https://creativecommons.org/licenses/by/4.0/ .\" This manpage was generated from SDL's wiki page for SDL_PollEvent: .\" https://wiki.libsdl.org/SDL_PollEvent .\" Generated with SDL/build-scripts/wikiheaders.pl .\" revision SDL-3.1.0 .\" Please report issues in this manpage's content at: .\" https://github.com/libsdl-org/sdlwiki/issues/new .\" Please report issues in the generation of this manpage from the wiki at: .\" https://github.com/libsdl-org/SDL/issues/new?title=Misgenerated%20manpage%20for%20SDL_PollEvent .\" SDL can be found at https://libsdl.org/ .de URL \$2 \(laURL: \$1 \(ra\$3 .. .if \n[.g] .mso www.tmac .TH SDL_PollEvent 3 "SDL 3.1.0" "SDL" "SDL3 FUNCTIONS" .SH NAME SDL_PollEvent \- Poll for currently pending events\[char46] .SH SYNOPSIS .nf .B #include \(dqSDL3/SDL.h\(dq .PP .BI "SDL_bool SDL_PollEvent(SDL_Event *event); .fi .SH DESCRIPTION If .BR event is not NULL, the next event is removed from the queue and stored in the .BR SDL_Event structure pointed to by .BR event \[char46] The 1 returned refers to this event, immediately stored in the SDL Event structure -- not an event to follow\[char46] If .BR event is NULL, it simply returns 1 if there is an event in the queue, but will not remove it from the queue\[char46] As this function may implicitly call .BR SDL_PumpEvents (), you can only call this function in the thread that set the video mode\[char46] .BR SDL_PollEvent () is the favored way of receiving system events since it can be done from the main loop and does not suspend the main loop while waiting on an event to be posted\[char46] The common practice is to fully process the event queue once every frame, usually as a first step before updating the game's state: .BR .BR c while (game_is_still_running) { SDL_Event event; while (SDL_PollEvent(&event)) { // poll until all events are handled! // decide what to do with this event\[char46] } // update game state, draw the current frame } .BR .SH FUNCTION PARAMETERS .TP .I event the .BR SDL_Event structure to be filled with the next event from the queue, or NULL .SH RETURN VALUE Returns .BR SDL_TRUE if this got an event or .BR SDL_FALSE if there are none available\[char46] .SH AVAILABILITY This function is available since SDL 3\[char46]0\[char46]0\[char46] .SH SEE ALSO .BR SDL_PushEvent (3), .BR SDL_WaitEvent (3), .BR SDL_WaitEventTimeout (3)