If the window is resizable, reset the viewport by default if the window size changes.
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Sep 2012 01:12:40 -0700
changeset 6513 c781fb99ce39
parent 6512 4beb596ccfae
child 6514 e94c2eaaa1ab
If the window is resizable, reset the viewport by default if the window size changes.
test/common.c
--- a/test/common.c	Sat Sep 29 01:10:53 2012 -0700
+++ b/test/common.c	Sat Sep 29 01:12:40 2012 -0700
@@ -1058,6 +1058,24 @@
     switch (event->type) {
     case SDL_WINDOWEVENT:
         switch (event->window.event) {
+        case SDL_WINDOWEVENT_SIZE_CHANGED:
+            {
+                SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
+                if (window) {
+                    for (i = 0; i < state->num_windows; ++i) {
+                        if (window == state->windows[i] &&
+                            (state->window_flags & SDL_WINDOW_RESIZABLE)) {
+                            SDL_Rect viewport;
+
+                            viewport.x = 0;
+                            viewport.y = 0;
+                            SDL_GetWindowSize(window, &viewport.w, &viewport.h);
+                            SDL_RenderSetViewport(state->renderers[i], &viewport);
+                        }
+                    }
+                }
+            }
+            break;
         case SDL_WINDOWEVENT_CLOSE:
 			{
                 SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);