Idle callback

If this was answered previously, i could not find it in the archives manually.

is there a way to set a callback function for when there is no user input, or
is the best way to do that is by using SDL_PollEvent instead if SDL_WaitEvent?

thank you,
– ag

Adam Grossman wrote:

If this was answered previously, i could not find it in the archives manually.

is there a way to set a callback function for when there is no user input, or
is the best way to do that is by using SDL_PollEvent instead if SDL_WaitEvent?

yes, you’ve got the right answer here.

when using most GUI libraries, you call some sort of “run” or "mainloop"
function that runs forever until the program exits. in these types of
programs, if you want to be able to do something while nothing is
happening, you usually use these idle functions, or some sort of timer.

under SDL your program is in full control of the mainloop, so there’s no
need for any sort of “idle” function. (although you can still use timers
sort of like you do with a gui library).

using SDL_WaitEvent will not return until an event has occured. so if
there is no input, the game cannot do any animation. calling
SDL_PollEvent returns immediately, so if there is no event available, it
just returns without an event.