From bc2a37c2f84f7b9374c38ba25ddf007d767e7e60 Mon Sep 17 00:00:00 2001 From: Nick Burns Date: Sat, 20 Dec 2008 22:30:17 -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..6c492bf 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -691,6 +691,9 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v BOOL bpp; RECT local_rect; BOOL srcIsUpsideDown; + GLint rowLen = 0; + GLint skipPix = 0; + GLint skipRow = 0; if(wined3d_settings.rendertargetlock_mode == RTL_DISABLE) { static BOOL warned = FALSE; @@ -786,15 +789,27 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v 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