diff src/video/SDL_renderer_sw.c @ 1970:db3ba6c0d0df

Allow the render context to do necessary work when the video mode changes.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Aug 2006 04:39:13 +0000
parents a788656ca29a
children 5432b63cc919
line wrap: on
line diff
--- a/src/video/SDL_renderer_sw.c	Sun Aug 06 00:09:04 2006 +0000
+++ b/src/video/SDL_renderer_sw.c	Sun Aug 06 04:39:13 2006 +0000
@@ -31,6 +31,8 @@
 /* SDL surface based renderer implementation */
 
 static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
+static int SW_ActivateRenderer(SDL_Renderer * renderer);
+static int SW_DisplayModeChanged(SDL_Renderer * renderer);
 static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
 static int SW_QueryTexturePixels(SDL_Renderer * renderer,
                                  SDL_Texture * texture, void **pixels,
@@ -179,7 +181,8 @@
         SDL_OutOfMemory();
         return NULL;
     }
-
+    renderer->ActivateRenderer = SW_ActivateRenderer;
+    renderer->DisplayModeChanged = SW_DisplayModeChanged;
     renderer->CreateTexture = SW_CreateTexture;
     renderer->QueryTexturePixels = SW_QueryTexturePixels;
     renderer->SetTexturePalette = SW_SetTexturePalette;
@@ -270,6 +273,32 @@
 }
 
 static int
+SW_ActivateRenderer(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (data->renderer && data->renderer->ActivateRenderer) {
+        if (data->renderer->ActivateRenderer(data->renderer) < 0) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int
+SW_DisplayModeChanged(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (data->renderer && data->renderer->DisplayModeChanged) {
+        if (data->renderer->DisplayModeChanged(data->renderer) < 0) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int
 SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {