Open expikr opened 3 weeks ago
If this is added and idea 1 (new return value) is used, then another addition can be SDL_APP_SKIPEVENTS
that can be used to force a call to SDL_AppIterate
even if the event queue is not emptied. The events left in the queue can be emptied after SDL_AppIterate
returns, unless the user returns SDL_APP_SKIPEVENTS
again.
SDL really offer quite a complete package for general app development, however one dealbreaker is the busy-wait polling of SDL_WaitEvents() making it unsuited for background apps.
With the addition of callback-based main, I think there is an opportunity here to add the ability for making truly event-driven blocking main loops.
Some ideas for how to expose this functionality as an interface:
Idea 1: add a new
SDL_APP_WAITEVENT
entry to the SDL_AppResult enum that directs control flow to a blocking event wait.Idea 2: add a hint or function call that globally switches between poll-based and wait-based event loop, then SDL_AppIterate() is called only on a timer message.
Idea 3: dynamically detect whether or not SDL_AppIterate() is defined, use wait-based event loop when absent and poll-based event loop when present.