diff --git a/dlls/ddraw/d3d_private.h b/dlls/ddraw/d3d_private.h index 27802e0022b..0f00145c2fa 100644 --- a/dlls/ddraw/d3d_private.h +++ b/dlls/ddraw/d3d_private.h @@ -59,6 +59,9 @@ struct IDirect3DImpl /* Used as a callback for Devices to tell to the D3D object it's been created */ HRESULT (*added_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device); HRESULT (*removed_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device); + + /* This is needed for delayed texture creation and Z buffer blits */ + IDirect3DDeviceImpl *current_device; }; /***************************************************************************** diff --git a/dlls/ddraw/d3ddevice/mesa.c b/dlls/ddraw/d3ddevice/mesa.c index 3f973630d27..468e0c0d8a6 100644 --- a/dlls/ddraw/d3ddevice/mesa.c +++ b/dlls/ddraw/d3ddevice/mesa.c @@ -924,7 +924,7 @@ inline static void handle_xyz(D3DVALUE *coords) { glVertex3fv(coords); } inline static void handle_xyzrhw(D3DVALUE *coords) { - if (coords[3] < 0.00001) + if (coords[3] < 1e-8) glVertex3fv(coords); else { GLfloat w = 1.0 / coords[3]; @@ -1977,6 +1977,7 @@ d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfa object->set_context(object); ENTER_GL(); TRACE(" current context set\n"); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glDrawBuffer(buffer); diff --git a/dlls/ddraw/d3dexecutebuffer.c b/dlls/ddraw/d3dexecutebuffer.c index 0b85b447fc5..7ffbf1b398f 100644 --- a/dlls/ddraw/d3dexecutebuffer.c +++ b/dlls/ddraw/d3dexecutebuffer.c @@ -125,7 +125,7 @@ static void _dump_D3DEXECUTEBUFFERDESC(LPD3DEXECUTEBUFFERDESC lpDesc) { ((col >> 8) & 0xFF) / 255.0, \ ((col >> 0) & 0xFF) / 255.0); \ glTexCoord2f(vx->u7.tu, vx->u8.tv); \ - if (vx->u4.rhw < 0.01) \ + if (vx->u4.rhw < 1e-8) \ glVertex3f(vx->u1.sx, \ vx->u2.sy, \ vx->u3.sz); \ diff --git a/dlls/ddraw/d3dtexture.c b/dlls/ddraw/d3dtexture.c index 96c21eb32c7..5c59cd9425e 100644 --- a/dlls/ddraw/d3dtexture.c +++ b/dlls/ddraw/d3dtexture.c @@ -662,14 +662,12 @@ ICOM_VTABLE(IDirect3DTexture) VTABLE_IDirect3DTexture = HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main) { - IDirect3DGLImpl *gl_d3d = (IDirect3DGLImpl *) d3d; - /* First, initialize the texture vtables... */ ICOM_INIT_INTERFACE(surf, IDirect3DTexture, VTABLE_IDirect3DTexture); ICOM_INIT_INTERFACE(surf, IDirect3DTexture2, VTABLE_IDirect3DTexture2); /* Only create all the private stuff if we actually have an OpenGL context.. */ - if (gl_d3d->current_device != NULL) { + if (d3d->current_device != NULL) { IDirect3DTextureGLImpl *private; private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTextureGLImpl)); diff --git a/dlls/ddraw/direct3d/mesa.c b/dlls/ddraw/direct3d/mesa.c index 6583a31d72e..1ada33fd235 100644 --- a/dlls/ddraw/direct3d/mesa.c +++ b/dlls/ddraw/direct3d/mesa.c @@ -379,9 +379,7 @@ ICOM_VTABLE(IDirect3D) VTABLE_IDirect3D = static HRESULT d3d_add_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device) { - IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This; - - if (glThis->current_device == NULL) { + if (This->current_device == NULL) { /* Create delayed textures now that we have an OpenGL context... For that, go through all surface attached to our DDraw object and create OpenGL textures for all textures.. */ @@ -396,16 +394,14 @@ static HRESULT d3d_add_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device) } } /* For the moment, only one device 'supported'... */ - glThis->current_device = device; + This->current_device = device; return DD_OK; } static HRESULT d3d_remove_device(IDirect3DImpl *This, IDirect3DDeviceImpl *device) { - IDirect3DGLImpl *glThis = (IDirect3DGLImpl *) This; - - glThis->current_device = NULL; + This->current_device = NULL; return DD_OK; } diff --git a/dlls/ddraw/dsurface/fakezbuffer.c b/dlls/ddraw/dsurface/fakezbuffer.c index f3e92609e5b..552acce0ad6 100644 --- a/dlls/ddraw/dsurface/fakezbuffer.c +++ b/dlls/ddraw/dsurface/fakezbuffer.c @@ -34,6 +34,7 @@ #include "ddcomimpl.h" #include "ddraw_private.h" +#include "d3d_private.h" #include "dsurface/main.h" #include "dsurface/fakezbuffer.h" @@ -114,6 +115,33 @@ FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx) { + ICOM_THIS(IDirectDrawSurfaceImpl,iface); + + if (TRACE_ON(ddraw)) { + TRACE("(%p)->(%p,%p,%p,%08lx,%p)\n", This,rdst,src,rsrc,dwFlags,lpbltfx); + if (rdst) TRACE("\tdestrect :%dx%d-%dx%d\n",rdst->left,rdst->top,rdst->right,rdst->bottom); + if (rsrc) TRACE("\tsrcrect :%dx%d-%dx%d\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom); + TRACE("\tflags: "); + DDRAW_dump_DDBLT(dwFlags); + if (dwFlags & DDBLT_DDFX) { + TRACE("\tblitfx: "); + DDRAW_dump_DDBLTFX(lpbltfx->dwDDFX); + } + } + + /* We only support the BLT with DEPTH_FILL for now */ + if (This->ddraw_owner->d3d != NULL) { + if (This->ddraw_owner->d3d->current_device != NULL) { + This->ddraw_owner->d3d->current_device->clear(This->ddraw_owner->d3d->current_device, + 0, NULL, /* Clear the whole screen */ + D3DCLEAR_ZBUFFER, + 0x00000000, + ((double) lpbltfx->u5.dwFillDepth) / 4294967295.0, + 0x00000000); + return DD_OK; + } + } + return cant_do_that("blt to a"); } @@ -122,6 +150,21 @@ FakeZBuffer_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx, DWORD dsty, LPDIRECTDRAWSURFACE7 src, LPRECT rsrc, DWORD trans) { + ICOM_THIS(IDirectDrawSurfaceImpl,iface); + + if (TRACE_ON(ddraw)) { + FIXME("(%p)->(%ld,%ld,%p,%p,%08lx)\n", + This,dstx,dsty,src,rsrc,trans + ); + FIXME("\ttrans:"); + if (FIXME_ON(ddraw)) + DDRAW_dump_DDBLTFAST(trans); + if (rsrc) + FIXME("\tsrcrect: %dx%d-%dx%d\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom); + else + FIXME(" srcrect: NULL\n"); + } + return cant_do_that("bltfast to a"); } diff --git a/dlls/ddraw/mesa_private.h b/dlls/ddraw/mesa_private.h index 360322f40ae..ea3d38769b6 100644 --- a/dlls/ddraw/mesa_private.h +++ b/dlls/ddraw/mesa_private.h @@ -82,9 +82,6 @@ typedef struct IDirect3DGLImpl struct IDirect3DImpl parent; int free_lights; void (*light_released)(IDirect3DImpl *, GLenum light_num); - - /* This is needed for delayed texture creation */ - struct IDirect3DDeviceImpl *current_device; } IDirect3DGLImpl; typedef struct IDirect3DLightGLImpl