Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1810 - xxx_RenderReadPixels - incorrect behaviour in certai…
Browse files Browse the repository at this point in the history
…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 3314a3c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/render/opengl/SDL_render_gl.c
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/render/opengles/SDL_render_gles.c
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/render/opengles2/SDL_render_gles2.c
Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit 3314a3c

Please sign in to comment.