Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed bug 1810 - xxx_RenderReadPixels - incorrect behaviour in certai…

…n 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);
  • Loading branch information
slouken committed Jul 12, 2013
1 parent be28778 commit 3314a3c939c3d1d93ae8439fe1e2479199f548b0
@@ -1233,7 +1233,6 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
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 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,

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,
@@ -1006,7 +1006,6 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
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 @@ GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
return SDL_OutOfMemory();
}

SDL_GetWindowSize(window, &w, &h);
SDL_GetRendererOutputSize(renderer, &w, &h);

data->glPixelStorei(GL_PACK_ALIGNMENT, 1);

@@ -1508,7 +1508,6 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
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 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
return SDL_OutOfMemory();
}

SDL_GetWindowSize(window, &w, &h);
SDL_GetRendererOutputSize(renderer, &w, &h);

rdata->glPixelStorei(GL_PACK_ALIGNMENT, 1);

0 comments on commit 3314a3c

Please sign in to comment.