diff src/video/SDL_video.c @ 3435:9f62f47d989b

You can specify the format for pixel data in SDL_RenderReadPixels() and SDL_RenderWritePixels() This code still doesn't quite work yet. :)
author Sam Lantinga <slouken@libsdl.org>
date Mon, 16 Nov 2009 07:13:07 +0000
parents 36cf454ba065
children bc27e1fdd3a7
line wrap: on
line diff
--- a/src/video/SDL_video.c	Sun Nov 15 09:21:46 2009 +0000
+++ b/src/video/SDL_video.c	Mon Nov 16 07:13:07 2009 +0000
@@ -2487,7 +2487,8 @@
 }
 
 int
-SDL_RenderReadPixels(const SDL_Rect * rect, void * pixels, int pitch)
+SDL_RenderReadPixels(const SDL_Rect * rect, Uint32 format,
+                     void * pixels, int pitch)
 {
     SDL_Renderer *renderer;
     SDL_Window *window;
@@ -2503,6 +2504,10 @@
     }
     window = SDL_GetWindowFromID(renderer->window);
 
+    if (!format) {
+        format = SDL_GetDisplayFromWindow(window)->current_mode.format;
+    }
+
     real_rect.x = 0;
     real_rect.y = 0;
     real_rect.w = window->w;
@@ -2521,11 +2526,13 @@
         }
     }
 
-    return renderer->RenderReadPixels(renderer, &real_rect, pixels, pitch);
+    return renderer->RenderReadPixels(renderer, &real_rect,
+                                      format, pixels, pitch);
 }
 
 int
-SDL_RenderWritePixels(const SDL_Rect * rect, const void * pixels, int pitch)
+SDL_RenderWritePixels(const SDL_Rect * rect, Uint32 format,
+                      const void * pixels, int pitch)
 {
     SDL_Renderer *renderer;
     SDL_Window *window;
@@ -2541,6 +2548,10 @@
     }
     window = SDL_GetWindowFromID(renderer->window);
 
+    if (!format) {
+        format = SDL_GetDisplayFromWindow(window)->current_mode.format;
+    }
+
     real_rect.x = 0;
     real_rect.y = 0;
     real_rect.w = window->w;
@@ -2559,7 +2570,8 @@
         }
     }
 
-    return renderer->RenderWritePixels(renderer, &real_rect, pixels, pitch);
+    return renderer->RenderWritePixels(renderer, &real_rect,
+                                       format, pixels, pitch);
 }
 
 void