test/testgles.c
changeset 3194 c18c03927a77
parent 3139 7f684f249ec9
child 3397 c64ae6ee6a6d
     1.1 --- a/test/testgles.c	Thu Jun 11 05:57:32 2009 +0000
     1.2 +++ b/test/testgles.c	Thu Jun 11 06:03:05 2009 +0000
     1.3 @@ -242,6 +242,7 @@
     1.4              continue;
     1.5          }
     1.6  
     1.7 +        glViewport(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
     1.8          glMatrixMode(GL_PROJECTION);
     1.9          glLoadIdentity();
    1.10          glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
    1.11 @@ -260,10 +261,31 @@
    1.12          /* Check for events */
    1.13          ++frames;
    1.14          while (SDL_PollEvent(&event)) {
    1.15 +            switch (event.type) {
    1.16 +            case SDL_WINDOWEVENT:
    1.17 +                switch (event.window.event) {
    1.18 +                    case SDL_WINDOWEVENT_RESIZED:
    1.19 +                        for (i = 0; i < state->num_windows; ++i) {
    1.20 +                            if (event.window.windowID == state->windows[i]) {
    1.21 +                                status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
    1.22 +                                if (status) {
    1.23 +                                    printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
    1.24 +                                    break;
    1.25 +                                }
    1.26 +                                /* Change view port to the new window dimensions */
    1.27 +                                glViewport(0, 0, event.window.data1, event.window.data2);
    1.28 +                                /* Update window content */
    1.29 +                                Render();
    1.30 +                                SDL_GL_SwapWindow(state->windows[i]);
    1.31 +                                break;
    1.32 +                            }
    1.33 +                        }
    1.34 +                        break;
    1.35 +                }
    1.36 +            }
    1.37              CommonEvent(state, &event, &done);
    1.38          }
    1.39          for (i = 0; i < state->num_windows; ++i) {
    1.40 -            int w, h;
    1.41              status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
    1.42              if (status) {
    1.43                  printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
    1.44 @@ -271,8 +293,6 @@
    1.45                  /* Continue for next window */
    1.46                  continue;
    1.47              }
    1.48 -            SDL_GetWindowSize(state->windows[i], &w, &h);
    1.49 -            glViewport(0, 0, w, h);
    1.50              Render();
    1.51              SDL_GL_SwapWindow(state->windows[i]);
    1.52          }