Added window resize support for the software renderer
authorSam Lantinga <slouken@libsdl.org>
Sun, 06 Aug 2006 04:57:28 +0000
changeset 1971 5432b63cc919
parent 1970 db3ba6c0d0df
child 1972 a0e278364188
Added window resize support for the software renderer
src/video/SDL_renderer_sw.c
--- a/src/video/SDL_renderer_sw.c	Sun Aug 06 04:39:13 2006 +0000
+++ b/src/video/SDL_renderer_sw.c	Sun Aug 06 04:57:28 2006 +0000
@@ -289,12 +289,30 @@
 SW_DisplayModeChanged(SDL_Renderer * renderer)
 {
     SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
+    int i, n;
 
     if (data->renderer && data->renderer->DisplayModeChanged) {
         if (data->renderer->DisplayModeChanged(data->renderer) < 0) {
             return -1;
         }
     }
+
+    /* Recreate the textures for the new window size */
+    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
+        n = 2;
+    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
+        n = 3;
+    } else {
+        n = 1;
+    }
+    for (i = 0; i < n; ++i) {
+        if (data->texture[i]) {
+            DestroyTexture(data->renderer, data->texture[i]);
+        }
+        data->texture[i] =
+            CreateTexture(data->renderer, data->format, window->w, window->h);
+    }
     return 0;
 }