From c2c36d4be4c46c9ce90951af81c6bb10ce33d019 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 15 Jan 2018 21:11:01 -0500 Subject: [PATCH] redraw as fast as possible --- sdl-game-controller.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sdl-game-controller.cc b/sdl-game-controller.cc index ae547e5..dc55aa3 100644 --- a/sdl-game-controller.cc +++ b/sdl-game-controller.cc @@ -120,16 +120,23 @@ int main(int argc, char *argv[]) display(window); SDL_Event event; - while (SDL_WaitEvent(&event)) + bool exit = false; + for (;;) { - if (event.type == SDL_QUIT) - break; - else if (event.type == SDL_KEYDOWN) + while (SDL_PollEvent(&event)) { - if (event.key.keysym.sym == SDLK_ESCAPE) - break; - if (event.key.keysym.sym == SDLK_RETURN) - display(window); + if (event.type == SDL_QUIT) + exit = true; + else if (event.type == SDL_KEYDOWN) + { + if (event.key.keysym.sym == SDLK_ESCAPE) + exit = true; + } } + if (exit) + break; + display(window); } + + return 0; }