Commit bb9837d2 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- added some tracing in the fake ZBuffer methods

- added support for the DEPTH_FILL BLT - set by defaut perspective correction to nicest. - decrease the limit where 'w' is ignored
parent f0541aa5
......@@ -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;
};
/*****************************************************************************
......
......@@ -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);
......
......@@ -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); \
......
......@@ -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));
......
......@@ -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;
}
......
......@@ -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");
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment