From 01550b96cc71ab170b17cb7f1b4c7216711c6083 Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Thu, 20 Feb 2014 16:12:11 -0300 Subject: [PATCH] Improve testgles2 exit behavior (useful on Android) --- test/testgles2.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/testgles2.c b/test/testgles2.c index 6e99827b0..ef9f38d60 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -629,7 +629,7 @@ main(int argc, char *argv[]) while (!done) { /* Check for events */ ++frames; - while (SDL_PollEvent(&event)) { + while (SDL_PollEvent(&event) && !done) { switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { @@ -654,16 +654,18 @@ main(int argc, char *argv[]) } SDLTest_CommonEvent(state, &event, &done); } - for (i = 0; i < state->num_windows; ++i) { - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + if (!done) { + for (i = 0; i < state->num_windows; ++i) { + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - /* Continue for next window */ - continue; - } - Render(state->window_w, state->window_h, &datas[i]); - SDL_GL_SwapWindow(state->windows[i]); + /* Continue for next window */ + continue; + } + Render(state->window_w, state->window_h, &datas[i]); + SDL_GL_SwapWindow(state->windows[i]); + } } }