libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.18k stars 1.86k forks source link

optional event-driven callback-main #11387

Open expikr opened 3 weeks ago

expikr commented 3 weeks ago

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:

namandixit commented 1 week 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.