If the window is resizable, reset the viewport by default if the window size changes.
authorSam Lantinga
Sat, 29 Sep 2012 01:12:40 -0700
changeset 6513c781fb99ce39
parent 6512 4beb596ccfae
child 6514 e94c2eaaa1ab
If the window is resizable, reset the viewport by default if the window size changes.
test/common.c
     1.1 --- a/test/common.c	Sat Sep 29 01:10:53 2012 -0700
     1.2 +++ b/test/common.c	Sat Sep 29 01:12:40 2012 -0700
     1.3 @@ -1058,6 +1058,24 @@
     1.4      switch (event->type) {
     1.5      case SDL_WINDOWEVENT:
     1.6          switch (event->window.event) {
     1.7 +        case SDL_WINDOWEVENT_SIZE_CHANGED:
     1.8 +            {
     1.9 +                SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
    1.10 +                if (window) {
    1.11 +                    for (i = 0; i < state->num_windows; ++i) {
    1.12 +                        if (window == state->windows[i] &&
    1.13 +                            (state->window_flags & SDL_WINDOW_RESIZABLE)) {
    1.14 +                            SDL_Rect viewport;
    1.15 +
    1.16 +                            viewport.x = 0;
    1.17 +                            viewport.y = 0;
    1.18 +                            SDL_GetWindowSize(window, &viewport.w, &viewport.h);
    1.19 +                            SDL_RenderSetViewport(state->renderers[i], &viewport);
    1.20 +                        }
    1.21 +                    }
    1.22 +                }
    1.23 +            }
    1.24 +            break;
    1.25          case SDL_WINDOWEVENT_CLOSE:
    1.26  			{
    1.27                  SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);