wined3d: Simplify texture target handling in surface_blt_to_drawable().

This commit is contained in:
Henri Verbeet 2008-10-15 13:35:32 +02:00 committed by Alexandre Julliard
parent c777f962a2
commit e22bda24c6
1 changed files with 95 additions and 119 deletions

View File

@ -4132,6 +4132,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
IWineD3DBaseTexture *texture = NULL; IWineD3DBaseTexture *texture = NULL;
HRESULT hr; HRESULT hr;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
GLenum bind_target;
if(rect_in) { if(rect_in) {
rect = *rect_in; rect = *rect_in;
@ -4142,74 +4143,38 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
rect.bottom = This->currentDesc.Height; rect.bottom = This->currentDesc.Height;
} }
ActivateContext(device, (IWineD3DSurface*)This, CTXUSAGE_BLIT); switch(This->glDescription.target)
ENTER_GL(); {
case GL_TEXTURE_2D:
if(This->glDescription.target == GL_TEXTURE_RECTANGLE_ARB) { bind_target = GL_TEXTURE_2D;
glEnable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)");
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, This->glDescription.textureName);
checkGLcall("GL_TEXTURE_RECTANGLE_ARB, This->glDescription.textureName)");
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
coords[0].x = rect.left;
coords[0].z = 0;
coords[1].x = rect.left;
coords[1].z = 0;
coords[2].x = rect.right;
coords[2].z = 0;
coords[3].x = rect.right;
coords[3].z = 0;
coords[0].y = rect.top;
coords[1].y = rect.bottom;
coords[2].y = rect.bottom;
coords[3].y = rect.top;
} else if(This->glDescription.target == GL_TEXTURE_2D) {
glEnable(GL_TEXTURE_2D);
checkGLcall("glEnable(GL_TEXTURE_2D)");
glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName);
checkGLcall("GL_TEXTURE_2D, This->glDescription.textureName)");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
coords[0].x = (float)rect.left / This->pow2Width; coords[0].x = (float)rect.left / This->pow2Width;
coords[0].y = (float)rect.top / This->pow2Height;
coords[0].z = 0; coords[0].z = 0;
coords[1].x = (float)rect.left / This->pow2Width; coords[1].x = (float)rect.left / This->pow2Width;
coords[1].y = (float)rect.bottom / This->pow2Height;
coords[1].z = 0; coords[1].z = 0;
coords[2].x = (float)rect.right / This->pow2Width; coords[2].x = (float)rect.right / This->pow2Width;
coords[2].y = (float)rect.bottom / This->pow2Height;
coords[2].z = 0; coords[2].z = 0;
coords[3].x = (float)rect.right / This->pow2Width; coords[3].x = (float)rect.right / This->pow2Width;
coords[3].z = 0;
coords[0].y = (float)rect.top / This->pow2Height;
coords[1].y = (float)rect.bottom / This->pow2Height;
coords[2].y = (float)rect.bottom / This->pow2Height;
coords[3].y = (float)rect.top / This->pow2Height; coords[3].y = (float)rect.top / This->pow2Height;
} else { coords[3].z = 0;
/* Must be a cube map */ break;
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)"); case GL_TEXTURE_RECTANGLE_ARB:
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, This->glDescription.textureName); bind_target = GL_TEXTURE_RECTANGLE_ARB;
checkGLcall("GL_TEXTURE_CUBE_MAP_ARB, This->glDescription.textureName)"); coords[0].x = rect.left; coords[0].y = rect.top; coords[0].z = 0;
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); coords[1].x = rect.left; coords[1].y = rect.bottom; coords[1].z = 0;
checkGLcall("glTexParameteri"); coords[2].x = rect.right; coords[2].y = rect.bottom; coords[2].z = 0;
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); coords[3].x = rect.right; coords[3].y = rect.top; coords[3].z = 0;
checkGLcall("glTexParameteri"); break;
switch(This->glDescription.target) {
case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
coords[0].x = 1; coords[0].y = -1; coords[0].z = 1; coords[0].x = 1; coords[0].y = -1; coords[0].z = 1;
coords[1].x = 1; coords[1].y = 1; coords[1].z = 1; coords[1].x = 1; coords[1].y = 1; coords[1].z = 1;
coords[2].x = 1; coords[2].y = 1; coords[2].z = -1; coords[2].x = 1; coords[2].y = 1; coords[2].z = -1;
@ -4217,6 +4182,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break; break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
coords[0].x = -1; coords[0].y = -1; coords[0].z = 1; coords[0].x = -1; coords[0].y = -1; coords[0].z = 1;
coords[1].x = -1; coords[1].y = 1; coords[1].z = 1; coords[1].x = -1; coords[1].y = 1; coords[1].z = 1;
coords[2].x = -1; coords[2].y = 1; coords[2].z = -1; coords[2].x = -1; coords[2].y = 1; coords[2].z = -1;
@ -4224,6 +4190,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break; break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
coords[0].x = -1; coords[0].y = 1; coords[0].z = 1; coords[0].x = -1; coords[0].y = 1; coords[0].z = 1;
coords[1].x = 1; coords[1].y = 1; coords[1].z = 1; coords[1].x = 1; coords[1].y = 1; coords[1].z = 1;
coords[2].x = 1; coords[2].y = 1; coords[2].z = -1; coords[2].x = 1; coords[2].y = 1; coords[2].z = -1;
@ -4231,6 +4198,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break; break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
coords[0].x = -1; coords[0].y = -1; coords[0].z = 1; coords[0].x = -1; coords[0].y = -1; coords[0].z = 1;
coords[1].x = 1; coords[1].y = -1; coords[1].z = 1; coords[1].x = 1; coords[1].y = -1; coords[1].z = 1;
coords[2].x = 1; coords[2].y = -1; coords[2].z = -1; coords[2].x = 1; coords[2].y = -1; coords[2].z = -1;
@ -4238,6 +4206,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break; break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
coords[0].x = -1; coords[0].y = -1; coords[0].z = 1; coords[0].x = -1; coords[0].y = -1; coords[0].z = 1;
coords[1].x = 1; coords[1].y = -1; coords[1].z = 1; coords[1].x = 1; coords[1].y = -1; coords[1].z = 1;
coords[2].x = 1; coords[2].y = -1; coords[2].z = 1; coords[2].x = 1; coords[2].y = -1; coords[2].z = 1;
@ -4245,6 +4214,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break; break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
coords[0].x = -1; coords[0].y = -1; coords[0].z = -1; coords[0].x = -1; coords[0].y = -1; coords[0].z = -1;
coords[1].x = 1; coords[1].y = -1; coords[1].z = -1; coords[1].x = 1; coords[1].y = -1; coords[1].z = -1;
coords[2].x = 1; coords[2].y = -1; coords[2].z = -1; coords[2].x = 1; coords[2].y = -1; coords[2].z = -1;
@ -4252,11 +4222,21 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break; break;
default: default:
ERR("Unexpected texture target\n"); ERR("Unexpected texture target %#x\n", This->glDescription.target);
LEAVE_GL();
return; return;
} }
}
ActivateContext(device, (IWineD3DSurface*)This, CTXUSAGE_BLIT);
ENTER_GL();
glEnable(bind_target);
checkGLcall("glEnable(bind_target)");
glBindTexture(bind_target, This->glDescription.textureName);
checkGLcall("bind_target, This->glDescription.textureName)");
glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord3fv(&coords[0].x); glTexCoord3fv(&coords[0].x);
@ -4273,13 +4253,9 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
glEnd(); glEnd();
checkGLcall("glEnd"); checkGLcall("glEnd");
if(This->glDescription.target != GL_TEXTURE_2D) { glDisable(bind_target);
glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(bind_target)");
checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
} else {
glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable(GL_TEXTURE_2D)");
}
LEAVE_GL(); LEAVE_GL();
hr = IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain); hr = IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DSwapChain, (void **) &swapchain);