Commit a192c6e6 authored by Sam Lantinga's avatar Sam Lantinga

Fixed GL_RenderReadPixels() - thanks Ryan!

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404188
parent 2d9880b9
...@@ -1257,6 +1257,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, ...@@ -1257,6 +1257,7 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 pixel_format, void * pixels, int pitch) Uint32 pixel_format, void * pixels, int pitch)
{ {
GL_RenderData *data = (GL_RenderData *) renderer->driverdata; GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
GLint internalFormat; GLint internalFormat;
GLenum format, type; GLenum format, type;
Uint8 *src, *dst, *tmp; Uint8 *src, *dst, *tmp;
...@@ -1276,13 +1277,10 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, ...@@ -1276,13 +1277,10 @@ GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
data->glPixelStorei(GL_PACK_ALIGNMENT, 1); data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
data->glPixelStorei(GL_PACK_ROW_LENGTH, data->glPixelStorei(GL_PACK_ROW_LENGTH,
(pitch / bytes_per_pixel(pixel_format))); (pitch / bytes_per_pixel(pixel_format)));
data->glReadBuffer(GL_FRONT);
memset(pixels, 0xff, rect->h*pitch); data->glReadPixels(rect->x, (window->h-rect->y)-rect->h, rect->w, rect->h,
data->glReadPixels(rect->x, rect->y+rect->h-1, rect->w, rect->h,
format, type, pixels); format, type, pixels);
#if 0
/* Flip the rows to be top-down */ /* Flip the rows to be top-down */
length = rect->w * bytes_per_pixel(pixel_format); length = rect->w * bytes_per_pixel(pixel_format);
src = (Uint8*)pixels + (rect->h-1)*pitch; src = (Uint8*)pixels + (rect->h-1)*pitch;
...@@ -1293,9 +1291,10 @@ memset(pixels, 0xff, rect->h*pitch); ...@@ -1293,9 +1291,10 @@ memset(pixels, 0xff, rect->h*pitch);
SDL_memcpy(tmp, dst, length); SDL_memcpy(tmp, dst, length);
SDL_memcpy(dst, src, length); SDL_memcpy(dst, src, length);
SDL_memcpy(src, tmp, length); SDL_memcpy(src, tmp, length);
dst += pitch;
src -= pitch;
} }
SDL_stack_free(tmp); SDL_stack_free(tmp);
#endif
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment