Fixed bug 1810 - xxx_RenderReadPixels - incorrect behaviour in certain conditions
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Jul 2013 00:55:04 -0700
changeset 7420 fe82b639c4d6
parent 7419 a22566f42281
child 7421 4086afac6a7e
Fixed bug 1810 - xxx_RenderReadPixels - incorrect behaviour in certain conditions PoopiSan GLES2_RenderReadPixels, GLES_RenderReadPixels, GL_RenderReadPixels and possibly other backends is incorrectly implemented. If the current target viewport is different than window size the function is reading garbage and according to the function documentation should work with any rendering target "Read pixels from the current rendering target.". this seems to be caused by this line: ... SDL_GetWindowSize(window, &w, &h);
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
--- a/src/render/opengl/SDL_render_gl.c	Fri Jul 12 00:43:16 2013 -0700
+++ b/src/render/opengl/SDL_render_gl.c	Fri Jul 12 00:55:04 2013 -0700
@@ -1233,7 +1233,6 @@
                     Uint32 pixel_format, void * pixels, int pitch)
 {
     GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
     Uint32 temp_format = SDL_PIXELFORMAT_ARGB8888;
     void *temp_pixels;
     int temp_pitch;
@@ -1253,7 +1252,7 @@
 
     convert_format(data, temp_format, &internalFormat, &format, &type);
 
-    SDL_GetWindowSize(window, &w, &h);
+    SDL_GetRendererOutputSize(renderer, &w, &h);
 
     data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
     data->glPixelStorei(GL_PACK_ROW_LENGTH,
--- a/src/render/opengles/SDL_render_gles.c	Fri Jul 12 00:43:16 2013 -0700
+++ b/src/render/opengles/SDL_render_gles.c	Fri Jul 12 00:55:04 2013 -0700
@@ -1006,7 +1006,6 @@
                     Uint32 pixel_format, void * pixels, int pitch)
 {
     GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
     Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
     void *temp_pixels;
     int temp_pitch;
@@ -1022,7 +1021,7 @@
         return SDL_OutOfMemory();
     }
 
-    SDL_GetWindowSize(window, &w, &h);
+    SDL_GetRendererOutputSize(renderer, &w, &h);
 
     data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
 
--- a/src/render/opengles2/SDL_render_gles2.c	Fri Jul 12 00:43:16 2013 -0700
+++ b/src/render/opengles2/SDL_render_gles2.c	Fri Jul 12 00:55:04 2013 -0700
@@ -1508,7 +1508,6 @@
                     Uint32 pixel_format, void * pixels, int pitch)
 {
     GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
-    SDL_Window *window = renderer->window;
     Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888;
     void *temp_pixels;
     int temp_pitch;
@@ -1524,7 +1523,7 @@
         return SDL_OutOfMemory();
     }
 
-    SDL_GetWindowSize(window, &w, &h);
+    SDL_GetRendererOutputSize(renderer, &w, &h);
 
     rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1);