Priest of the Order of the Butterfly
Posts: 538 from 2003/2/25
From: France
Many SDL games work by polling (ie reading all the time) the event queue.
https://wiki.libsdl.org/SDL_PollEvent
The example code shows the ugly. while(1) { SDL_PollEvent(...); }
It kills any CPU class.
Better main loop would be with SDL_WaitEvent/SDL_WaitEventTimeout
https://wiki.libsdl.org/SDL_WaitEvent
https://wiki.libsdl.org/SDL_WaitEventTimeout
At least, those calls shouldn't eat all the CPU.
A quick search with G**gle on GitHub :
SDL_PollEvent site:github.com -> about 9500 results
SDL_WaitEvent site:github.com -> about 2200 results
SDL_WaitEventTimeout site:github.com -> about 300 results
See the disaster. :)