From da22747f2bfccfa0a6fec598d647c6bfd87c39dd Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Sat, 20 Dec 2008 20:10:13 -0800 Subject: Fix glReadPixels call from read_from_framebuffer Fix the call to readpixels so that 2d blts going thru the pbo path end up in the right place --- dlls/wined3d/surface.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 0eedf23..3f4cd1e 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -783,18 +783,33 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v bpp = This->bytesPerPixel; } + GLint rowLen = 0; + GLint skipPix = 0; + GLint skipRow = 0; if(This->Flags & SFLAG_PBO) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo)); checkGLcall("glBindBufferARB"); + glGetIntegerv(GL_PACK_ROW_LENGTH, &rowLen); + glPixelStorei(GL_PACK_ROW_LENGTH, This->currentDesc.Width); + glGetIntegerv(GL_PACK_SKIP_PIXELS, &skipPix); + glPixelStorei(GL_PACK_SKIP_PIXELS, local_rect.left); + glGetIntegerv(GL_PACK_SKIP_ROWS, &skipRow); + glPixelStorei(GL_PACK_SKIP_ROWS, local_rect.top); + mem = NULL; } - glReadPixels(local_rect.left, local_rect.top, + glReadPixels(local_rect.left, (!srcIsUpsideDown) ? (This->currentDesc.Height - local_rect.bottom) : local_rect.top , local_rect.right - local_rect.left, local_rect.bottom - local_rect.top, fmt, type, mem); checkGLcall("glReadPixels"); if(This->Flags & SFLAG_PBO) { + /* Reset to previous pack row length */ + glPixelStorei(GL_PACK_ROW_LENGTH, rowLen); + glPixelStorei(GL_PACK_SKIP_PIXELS, skipPix); + glPixelStorei(GL_PACK_SKIP_ROWS, skipRow); + checkGLcall("glPixelStorei"); GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0)); checkGLcall("glBindBufferARB"); @@ -828,7 +843,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v } top = mem + pitch * local_rect.top; - bottom = mem + pitch * ( local_rect.bottom - local_rect.top - 1); + bottom = mem + pitch * (local_rect.bottom - 1); for(i = 0; i < (local_rect.bottom - local_rect.top) / 2; i++) { memcpy(row, top + off, len); memcpy(top + off, bottom + off, len); -- 1.6.0.2