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);
This commit is contained in:
Sam Lantinga 2013-07-12 00:55:04 -07:00
parent 1bcb90ff25
commit ee12cc8585
3 changed files with 3 additions and 6 deletions

View file

@ -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,