Fixed GL_RenderReadPixels() - thanks Ryan!
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404188
This commit is contained in:
parent
2d9880b962
commit
a192c6e6bc
1 changed files with 4 additions and 5 deletions
|
@ -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,
|
||||||
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);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue