• Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 539 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. :)
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »18.01.17 - 13:21
    Profile Visit Website