2001-01-04 23:44:55 +01:00
|
|
|
/* DirectDraw/Direct3D Z-Buffer stand in
|
|
|
|
*
|
|
|
|
* Copyright 2000 TransGaming Technologies Inc.
|
|
|
|
*
|
|
|
|
* This class provides a DirectDrawSurface implementation that represents
|
|
|
|
* a Z-Buffer surface. However it does not store an image and does not
|
|
|
|
* support Lock/Unlock or GetDC. It is merely a placeholder required by the
|
|
|
|
* Direct3D architecture.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-01-04 23:44:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2001-01-25 23:23:08 +01:00
|
|
|
#include "ddraw.h"
|
|
|
|
#include "d3d.h"
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
#include "ddcomimpl.h"
|
|
|
|
#include "ddraw_private.h"
|
2003-01-02 20:58:21 +01:00
|
|
|
#include "d3d_private.h"
|
2001-01-04 23:44:55 +01:00
|
|
|
#include "dsurface/main.h"
|
|
|
|
#include "dsurface/fakezbuffer.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectDrawSurface7) FakeZBuffer_IDirectDrawSurface7_VTable;
|
|
|
|
|
|
|
|
HRESULT FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
|
|
|
|
IDirectDrawImpl *pDD,
|
|
|
|
const DDSURFACEDESC2 *pDDSD)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
assert(pDDSD->ddsCaps.dwCaps & DDSCAPS_ZBUFFER);
|
|
|
|
|
|
|
|
hr = Main_DirectDrawSurface_Construct(This, pDD, pDDSD);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
|
|
|
|
FakeZBuffer_IDirectDrawSurface7_VTable);
|
|
|
|
|
|
|
|
This->final_release = FakeZBuffer_DirectDrawSurface_final_release;
|
|
|
|
This->duplicate_surface = FakeZBuffer_DirectDrawSurface_duplicate_surface;
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Not an API */
|
|
|
|
HRESULT FakeZBuffer_DirectDrawSurface_Create(IDirectDrawImpl* pDD,
|
|
|
|
const DDSURFACEDESC2* pDDSD,
|
|
|
|
LPDIRECTDRAWSURFACE7* ppSurf,
|
|
|
|
IUnknown* pUnkOuter)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl* This;
|
|
|
|
HRESULT hr;
|
|
|
|
assert(pUnkOuter == NULL);
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(*This)
|
|
|
|
+ sizeof(FakeZBuffer_DirectDrawSurfaceImpl));
|
|
|
|
if (This == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->private = (FakeZBuffer_DirectDrawSurfaceImpl*)(This+1);
|
|
|
|
|
|
|
|
hr = FakeZBuffer_DirectDrawSurface_Construct(This, pDD, pDDSD);
|
|
|
|
if (FAILED(hr))
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
else
|
|
|
|
*ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FakeZBuffer_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
|
|
|
|
{
|
2002-07-03 03:20:07 +02:00
|
|
|
Main_DirectDrawSurface_final_release(This);
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
|
|
FakeZBuffer_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
|
|
|
|
LPDIRECTDRAWSURFACE7* ppDup)
|
|
|
|
{
|
|
|
|
return FakeZBuffer_DirectDrawSurface_Create(This->ddraw_owner,
|
|
|
|
&This->surface_desc, ppDup,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put your breakpoint/abort call here */
|
|
|
|
static HRESULT cant_do_that(const char *s)
|
|
|
|
{
|
|
|
|
FIXME("attempt to %s fake z-buffer\n", s);
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
FakeZBuffer_DirectDrawSurface_Blt(LPDIRECTDRAWSURFACE7 iface, LPRECT rdst,
|
|
|
|
LPDIRECTDRAWSURFACE7 src, LPRECT rsrc,
|
|
|
|
DWORD dwFlags, LPDDBLTFX lpbltfx)
|
|
|
|
{
|
2003-01-02 20:58:21 +01:00
|
|
|
ICOM_THIS(IDirectDrawSurfaceImpl,iface);
|
|
|
|
|
|
|
|
if (TRACE_ON(ddraw)) {
|
|
|
|
TRACE("(%p)->(%p,%p,%p,%08lx,%p)\n", This,rdst,src,rsrc,dwFlags,lpbltfx);
|
2003-01-08 22:09:25 +01:00
|
|
|
if (rdst) TRACE("\tdestrect :%ldx%ld-%ldx%ld\n",rdst->left,rdst->top,rdst->right,rdst->bottom);
|
|
|
|
if (rsrc) TRACE("\tsrcrect :%ldx%ld-%ldx%ld\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom);
|
2003-01-02 20:58:21 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return cant_do_that("blt to a");
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
FakeZBuffer_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
|
|
|
|
DWORD dsty, LPDIRECTDRAWSURFACE7 src,
|
|
|
|
LPRECT rsrc, DWORD trans)
|
|
|
|
{
|
2003-01-02 20:58:21 +01:00
|
|
|
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)
|
2003-01-08 22:09:25 +01:00
|
|
|
FIXME("\tsrcrect: %ldx%ld-%ldx%ld\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom);
|
2003-01-02 20:58:21 +01:00
|
|
|
else
|
|
|
|
FIXME(" srcrect: NULL\n");
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
return cant_do_that("bltfast to a");
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
FakeZBuffer_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC)
|
|
|
|
{
|
|
|
|
return cant_do_that("get a DC for a");
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
FakeZBuffer_DirectDrawSurface_ReleaseDC(LPDIRECTDRAWSURFACE7 iface, HDC hDC)
|
|
|
|
{
|
|
|
|
return cant_do_that("release a DC for a");
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
FakeZBuffer_DirectDrawSurface_Restore(LPDIRECTDRAWSURFACE7 iface)
|
|
|
|
{
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
FakeZBuffer_DirectDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface,
|
|
|
|
LPDDSURFACEDESC2 pDDSD,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
/* XXX */
|
|
|
|
abort();
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectDrawSurface7) FakeZBuffer_IDirectDrawSurface7_VTable=
|
|
|
|
{
|
2002-11-06 20:53:45 +01:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
2001-01-04 23:44:55 +01:00
|
|
|
Main_DirectDrawSurface_QueryInterface,
|
|
|
|
Main_DirectDrawSurface_AddRef,
|
|
|
|
Main_DirectDrawSurface_Release,
|
|
|
|
Main_DirectDrawSurface_AddAttachedSurface,
|
|
|
|
Main_DirectDrawSurface_AddOverlayDirtyRect,
|
|
|
|
FakeZBuffer_DirectDrawSurface_Blt,
|
|
|
|
Main_DirectDrawSurface_BltBatch,
|
|
|
|
FakeZBuffer_DirectDrawSurface_BltFast,
|
|
|
|
Main_DirectDrawSurface_DeleteAttachedSurface,
|
|
|
|
Main_DirectDrawSurface_EnumAttachedSurfaces,
|
|
|
|
Main_DirectDrawSurface_EnumOverlayZOrders,
|
|
|
|
Main_DirectDrawSurface_Flip,
|
|
|
|
Main_DirectDrawSurface_GetAttachedSurface,
|
|
|
|
Main_DirectDrawSurface_GetBltStatus,
|
|
|
|
Main_DirectDrawSurface_GetCaps,
|
|
|
|
Main_DirectDrawSurface_GetClipper,
|
|
|
|
Main_DirectDrawSurface_GetColorKey,
|
|
|
|
FakeZBuffer_DirectDrawSurface_GetDC,
|
|
|
|
Main_DirectDrawSurface_GetFlipStatus,
|
|
|
|
Main_DirectDrawSurface_GetOverlayPosition,
|
|
|
|
Main_DirectDrawSurface_GetPalette,
|
|
|
|
Main_DirectDrawSurface_GetPixelFormat,
|
|
|
|
Main_DirectDrawSurface_GetSurfaceDesc,
|
|
|
|
Main_DirectDrawSurface_Initialize,
|
|
|
|
Main_DirectDrawSurface_IsLost,
|
|
|
|
Main_DirectDrawSurface_Lock,
|
|
|
|
FakeZBuffer_DirectDrawSurface_ReleaseDC,
|
|
|
|
FakeZBuffer_DirectDrawSurface_Restore,
|
|
|
|
Main_DirectDrawSurface_SetClipper,
|
|
|
|
Main_DirectDrawSurface_SetColorKey,
|
|
|
|
Main_DirectDrawSurface_SetOverlayPosition,
|
|
|
|
Main_DirectDrawSurface_SetPalette,
|
|
|
|
Main_DirectDrawSurface_Unlock,
|
|
|
|
Main_DirectDrawSurface_UpdateOverlay,
|
|
|
|
Main_DirectDrawSurface_UpdateOverlayDisplay,
|
|
|
|
Main_DirectDrawSurface_UpdateOverlayZOrder,
|
|
|
|
Main_DirectDrawSurface_GetDDInterface,
|
|
|
|
Main_DirectDrawSurface_PageLock,
|
|
|
|
Main_DirectDrawSurface_PageUnlock,
|
|
|
|
FakeZBuffer_DirectDrawSurface_SetSurfaceDesc,
|
|
|
|
Main_DirectDrawSurface_SetPrivateData,
|
|
|
|
Main_DirectDrawSurface_GetPrivateData,
|
|
|
|
Main_DirectDrawSurface_FreePrivateData,
|
|
|
|
Main_DirectDrawSurface_GetUniquenessValue,
|
|
|
|
Main_DirectDrawSurface_ChangeUniquenessValue,
|
|
|
|
Main_DirectDrawSurface_SetPriority,
|
|
|
|
Main_DirectDrawSurface_GetPriority,
|
|
|
|
Main_DirectDrawSurface_SetLOD,
|
|
|
|
Main_DirectDrawSurface_GetLOD
|
|
|
|
};
|