ddraw: Rewrite most of ddraw using WineD3D.

This commit is contained in:
Stefan Dösinger 2006-06-09 19:36:12 +02:00 committed by Alexandre Julliard
parent 0fa7170dc3
commit c8901d6f62
45 changed files with 16401 additions and 23738 deletions

View File

@ -4,45 +4,31 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = ddraw.dll
IMPORTLIB = libddraw.$(IMPLIBEXT)
IMPORTS = ole32 user32 gdi32 advapi32 kernel32 ntdll
IMPORTS = wined3d ole32 user32 gdi32 advapi32 kernel32 ntdll
EXTRAINCL = @X_CFLAGS@
EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
OPENGLFILES = \
d3d_utils.c \
device_main.c \
device_opengl.c \
direct3d_main.c \
direct3d_opengl.c \
C_SRCS = \
clipper.c \
ddraw.c \
ddraw_thunks.c \
device.c \
direct3d.c \
executebuffer.c \
gamma.c \
light.c \
main.c \
material.c \
opengl_utils.c \
palette.c \
parent.c \
regsvr.c \
surface.c \
surface_thunks.c \
texture.c \
utils.c \
vertexbuffer.c \
viewport.c
C_SRCS = \
@OPENGLFILES@ \
clipper.c \
ddraw_hal.c \
ddraw_main.c \
ddraw_thunks.c \
ddraw_user.c \
ddraw_utils.c \
main.c \
palette_hal.c \
palette_main.c \
regsvr.c \
surface_dib.c \
surface_fakezbuffer.c \
surface_gamma.c \
surface_hal.c \
surface_main.c \
surface_thunks.c \
surface_user.c \
surface_wndproc.c
RC_SRCS = version.rc
SUBDIRS = tests

View File

@ -1,7 +1,8 @@
/* DirectDrawClipper implementation
*
* Copyright 2000 Marcus Meissner
* Copyright 2000 TransGaming Technologies Inc.
* Copyright 2000 (c) Marcus Meissner
* Copyright 2000 (c) TransGaming Technologies Inc.
* Copyright 2006 (c) Stefan Dösinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -36,52 +37,97 @@
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/******************************************************************************
* DirectDrawCreateClipper (DDRAW.@)
*/
/*****************************************************************************
* IUnknown methods
*****************************************************************************/
static const IDirectDrawClipperVtbl DDRAW_Clipper_VTable;
HRESULT WINAPI DirectDrawCreateClipper(
DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter
/*****************************************************************************
* IDirectDrawClipper::QueryInterface
*
* Can query the IUnknown and IDirectDrawClipper interface from a
* Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
* interface. Can't create other interfaces.
*
* Arguments:
* riid: Interface id asked for
* ppvObj: Returns the pointer to the interface
*
* Return values:
* DD_OK on success
* E_NOINTERFACE if the requested interface wasn't found.
*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
) {
IDirectDrawClipperImpl* This;
TRACE("(%08lx,%p,%p)\n", dwFlags, lplpDDClipper, pUnkOuter);
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawClipperImpl));
if (This == NULL) return E_OUTOFMEMORY;
ICOM_INIT_INTERFACE(This, IDirectDrawClipper, DDRAW_Clipper_VTable);
This->ref = 1;
This->hWnd = 0;
This->ddraw_owner = NULL;
*lplpDDClipper = ICOM_INTERFACE(This, IDirectDrawClipper);
return DD_OK;
if (IsEqualGUID(&IID_IUnknown, riid)
|| IsEqualGUID(&IID_IDirectDrawClipper, riid))
{
*ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
InterlockedIncrement(&This->ref);
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
/* This is the classfactory implementation. */
HRESULT DDRAW_CreateDirectDrawClipper(IUnknown* pUnkOuter, REFIID riid,
LPVOID* ppObj)
/*****************************************************************************
* IDirectDrawClipper::AddRef
*
* Increases the reference count of the interface, returns the new count
*
*****************************************************************************/
static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
{
HRESULT hr;
LPDIRECTDRAWCLIPPER pClip;
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
hr = DirectDrawCreateClipper(0, &pClip, pUnkOuter);
if (FAILED(hr)) return hr;
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
hr = IDirectDrawClipper_QueryInterface(pClip, riid, ppObj);
IDirectDrawClipper_Release(pClip);
return hr;
return ref;
}
/******************************************************************************
* IDirectDrawClipper
*/
HRESULT WINAPI Main_DirectDrawClipper_SetHwnd(
/*****************************************************************************
* IDirectDrawClipper::Release
*
* Decreases the reference count of the interface, returns the new count
* If the refcount is decreased to 0, the interface is destroyed.
*
*****************************************************************************/
static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
else return ref;
}
/*****************************************************************************
* IDirectDrawClipper::SetHwnd
*
* Assigns a hWnd to the clipper interface.
*
* Arguments:
* Flags: Unsupported so far
* hWnd: The hWnd to set
*
* Return values:
* DD_OK on success
* DDERR_INVALIDPARAMS if Flags was != 0
*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
@ -96,52 +142,25 @@ HRESULT WINAPI Main_DirectDrawClipper_SetHwnd(
return DD_OK;
}
static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl* This)
{
if (This->ddraw_owner != NULL)
Main_DirectDraw_RemoveClipper(This->ddraw_owner, This);
HeapFree(GetProcessHeap(), 0 ,This);
}
void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This)
{
WARN("deleting clipper %p with refcnt %lu\n", This, This->ref);
Main_DirectDrawClipper_Destroy(This);
}
ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (ref == 0)
{
Main_DirectDrawClipper_Destroy(This);
return 0;
}
else return ref;
}
/***********************************************************************
* IDirectDrawClipper::GetClipList
*
* Retrieve a copy of the clip list
*
* PARAMS
* lpRect Rectangle to be used to clip the clip list or NULL for the
* entire clip list
* lpClipList structure for the resulting copy of the clip list.
If NULL, fills lpdwSize up to the number of bytes necessary to hold
the entire clip.
* lpdwSize Size of resulting clip list; size of the buffer at lpClipList
or, if lpClipList is NULL, receives the required size of the buffer
in bytes
* RETURNS
* Either DD_OK or DDERR_*
*/
HRESULT WINAPI Main_DirectDrawClipper_GetClipList(
/*****************************************************************************
* IDirectDrawClipper::GetClipList
*
* Retrieve a copy of the clip list
*
* Arguments:
* Rect: Rectangle to be used to clip the clip list or NULL for the
* entire clip list
* ClipList: structure for the resulting copy of the clip list.
* If NULL, fills Size up to the number of bytes necessary to hold
* the entire clip.
* Size: Size of resulting clip list; size of the buffer at ClipList
* or, if ClipList is NULL, receives the required size of the buffer
* in bytes
*
* RETURNS
* Either DD_OK or DDERR_*
************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList,
LPDWORD lpdwSize)
{
@ -188,18 +207,21 @@ HRESULT WINAPI Main_DirectDrawClipper_GetClipList(
}
}
/***********************************************************************
* IDirectDrawClipper::SetClipList
*
* Sets or deletes (if lprgn is NULL) the clip list
*
* PARAMS
* lprgn Pointer to a LRGNDATA structure or NULL
* dwFlags not used, must be 0
* RETURNS
* Either DD_OK or DDERR_*
*/
HRESULT WINAPI Main_DirectDrawClipper_SetClipList(
/*****************************************************************************
* IDirectDrawClipper::SetClipList
*
* Sets or deletes (if lprgn is NULL) the clip list
*
* This implementation is a stup and returns DD_OK always to make the app
* happy.
*
* PARAMS
* lprgn Pointer to a LRGNDATA structure or NULL
* dwFlags not used, must be 0
* RETURNS
* Either DD_OK or DDERR_*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
@ -209,35 +231,18 @@ HRESULT WINAPI Main_DirectDrawClipper_SetClipList(
return DD_OK;
}
HRESULT WINAPI Main_DirectDrawClipper_QueryInterface(
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
if (IsEqualGUID(&IID_IUnknown, riid)
|| IsEqualGUID(&IID_IDirectDrawClipper, riid))
{
*ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
InterlockedIncrement(&This->ref);
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface )
{
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
HRESULT WINAPI Main_DirectDrawClipper_GetHWnd(
/*****************************************************************************
* IDirectDrawClipper::GetHwnd
*
* Returns the hwnd assigned with SetHwnd
*
* Arguments:
* hWndPtr: Address to store the HWND at
*
* Return values:
* Always returns DD_OK;
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
@ -248,7 +253,21 @@ HRESULT WINAPI Main_DirectDrawClipper_GetHWnd(
return DD_OK;
}
HRESULT WINAPI Main_DirectDrawClipper_Initialize(
/*****************************************************************************
* IDirectDrawClipper::Initialize
*
* Initializes the interface. Well, there isn't much to do for this
* implementation, but it stores the DirectDraw Interface.
*
* Arguments:
* DD: Pointer to a IDirectDraw interface
* Flags: Unsupported by now
*
* Return values:
* DD_OK on success
* DDERR_ALREADYINITIALIZED if this interface isn't initialized allready
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
) {
IDirectDrawImpl* pOwner;
@ -259,12 +278,22 @@ HRESULT WINAPI Main_DirectDrawClipper_Initialize(
pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
This->ddraw_owner = pOwner;
Main_DirectDraw_AddClipper(pOwner, This);
return DD_OK;
}
HRESULT WINAPI Main_DirectDrawClipper_IsClipListChanged(
/*****************************************************************************
* IDirectDrawClipper::IsClipListChanged
*
* This function is a stub
*
* Arguments:
* Changed:
*
* Return values:
* DD_OK, because it's a stub
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
) {
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
@ -276,15 +305,18 @@ HRESULT WINAPI Main_DirectDrawClipper_IsClipListChanged(
return DD_OK;
}
static const IDirectDrawClipperVtbl DDRAW_Clipper_VTable =
/*****************************************************************************
* The VTable
*****************************************************************************/
const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
{
Main_DirectDrawClipper_QueryInterface,
Main_DirectDrawClipper_AddRef,
Main_DirectDrawClipper_Release,
Main_DirectDrawClipper_GetClipList,
Main_DirectDrawClipper_GetHWnd,
Main_DirectDrawClipper_Initialize,
Main_DirectDrawClipper_IsClipListChanged,
Main_DirectDrawClipper_SetClipList,
Main_DirectDrawClipper_SetHwnd
IDirectDrawClipperImpl_QueryInterface,
IDirectDrawClipperImpl_AddRef,
IDirectDrawClipperImpl_Release,
IDirectDrawClipperImpl_GetClipList,
IDirectDrawClipperImpl_GetHWnd,
IDirectDrawClipperImpl_Initialize,
IDirectDrawClipperImpl_IsClipListChanged,
IDirectDrawClipperImpl_SetClipList,
IDirectDrawClipperImpl_SetHwnd
};

File diff suppressed because it is too large Load Diff

View File

@ -1,391 +0,0 @@
/* Direct3D Common functions
* Copyright (c) 1998 Lionel ULMER
*
* This file contains all common miscellaneous code that spans
* different 'objects'
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wingdi.h"
#include "ddraw.h"
#include "d3d.h"
#include "wine/debug.h"
#include "d3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
const char *_get_renderstate(D3DRENDERSTATETYPE type) {
static const char * const states[] = {
"ERR",
"D3DRENDERSTATE_TEXTUREHANDLE",
"D3DRENDERSTATE_ANTIALIAS",
"D3DRENDERSTATE_TEXTUREADDRESS",
"D3DRENDERSTATE_TEXTUREPERSPECTIVE",
"D3DRENDERSTATE_WRAPU",
"D3DRENDERSTATE_WRAPV",
"D3DRENDERSTATE_ZENABLE",
"D3DRENDERSTATE_FILLMODE",
"D3DRENDERSTATE_SHADEMODE",
"D3DRENDERSTATE_LINEPATTERN",
"D3DRENDERSTATE_MONOENABLE",
"D3DRENDERSTATE_ROP2",
"D3DRENDERSTATE_PLANEMASK",
"D3DRENDERSTATE_ZWRITEENABLE",
"D3DRENDERSTATE_ALPHATESTENABLE",
"D3DRENDERSTATE_LASTPIXEL",
"D3DRENDERSTATE_TEXTUREMAG",
"D3DRENDERSTATE_TEXTUREMIN",
"D3DRENDERSTATE_SRCBLEND",
"D3DRENDERSTATE_DESTBLEND",
"D3DRENDERSTATE_TEXTUREMAPBLEND",
"D3DRENDERSTATE_CULLMODE",
"D3DRENDERSTATE_ZFUNC",
"D3DRENDERSTATE_ALPHAREF",
"D3DRENDERSTATE_ALPHAFUNC",
"D3DRENDERSTATE_DITHERENABLE",
"D3DRENDERSTATE_ALPHABLENDENABLE",
"D3DRENDERSTATE_FOGENABLE",
"D3DRENDERSTATE_SPECULARENABLE",
"D3DRENDERSTATE_ZVISIBLE",
"D3DRENDERSTATE_SUBPIXEL",
"D3DRENDERSTATE_SUBPIXELX",
"D3DRENDERSTATE_STIPPLEDALPHA",
"D3DRENDERSTATE_FOGCOLOR",
"D3DRENDERSTATE_FOGTABLEMODE",
"D3DRENDERSTATE_FOGTABLESTART",
"D3DRENDERSTATE_FOGTABLEEND",
"D3DRENDERSTATE_FOGTABLEDENSITY",
"D3DRENDERSTATE_STIPPLEENABLE",
"D3DRENDERSTATE_EDGEANTIALIAS",
"D3DRENDERSTATE_COLORKEYENABLE",
"ERR",
"D3DRENDERSTATE_BORDERCOLOR",
"D3DRENDERSTATE_TEXTUREADDRESSU",
"D3DRENDERSTATE_TEXTUREADDRESSV",
"D3DRENDERSTATE_MIPMAPLODBIAS",
"D3DRENDERSTATE_ZBIAS",
"D3DRENDERSTATE_RANGEFOGENABLE",
"D3DRENDERSTATE_ANISOTROPY",
"D3DRENDERSTATE_FLUSHBATCH",
"D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT",
"D3DRENDERSTATE_STENCILENABLE",
"D3DRENDERSTATE_STENCILFAIL",
"D3DRENDERSTATE_STENCILZFAIL",
"D3DRENDERSTATE_STENCILPASS",
"D3DRENDERSTATE_STENCILFUNC",
"D3DRENDERSTATE_STENCILREF",
"D3DRENDERSTATE_STENCILMASK",
"D3DRENDERSTATE_STENCILWRITEMASK",
"D3DRENDERSTATE_TEXTUREFACTOR",
"ERR",
"ERR",
"ERR",
"D3DRENDERSTATE_STIPPLEPATTERN00",
"D3DRENDERSTATE_STIPPLEPATTERN01",
"D3DRENDERSTATE_STIPPLEPATTERN02",
"D3DRENDERSTATE_STIPPLEPATTERN03",
"D3DRENDERSTATE_STIPPLEPATTERN04",
"D3DRENDERSTATE_STIPPLEPATTERN05",
"D3DRENDERSTATE_STIPPLEPATTERN06",
"D3DRENDERSTATE_STIPPLEPATTERN07",
"D3DRENDERSTATE_STIPPLEPATTERN08",
"D3DRENDERSTATE_STIPPLEPATTERN09",
"D3DRENDERSTATE_STIPPLEPATTERN10",
"D3DRENDERSTATE_STIPPLEPATTERN11",
"D3DRENDERSTATE_STIPPLEPATTERN12",
"D3DRENDERSTATE_STIPPLEPATTERN13",
"D3DRENDERSTATE_STIPPLEPATTERN14",
"D3DRENDERSTATE_STIPPLEPATTERN15",
"D3DRENDERSTATE_STIPPLEPATTERN16",
"D3DRENDERSTATE_STIPPLEPATTERN17",
"D3DRENDERSTATE_STIPPLEPATTERN18",
"D3DRENDERSTATE_STIPPLEPATTERN19",
"D3DRENDERSTATE_STIPPLEPATTERN20",
"D3DRENDERSTATE_STIPPLEPATTERN21",
"D3DRENDERSTATE_STIPPLEPATTERN22",
"D3DRENDERSTATE_STIPPLEPATTERN23",
"D3DRENDERSTATE_STIPPLEPATTERN24",
"D3DRENDERSTATE_STIPPLEPATTERN25",
"D3DRENDERSTATE_STIPPLEPATTERN26",
"D3DRENDERSTATE_STIPPLEPATTERN27",
"D3DRENDERSTATE_STIPPLEPATTERN28",
"D3DRENDERSTATE_STIPPLEPATTERN29",
"D3DRENDERSTATE_STIPPLEPATTERN30",
"D3DRENDERSTATE_STIPPLEPATTERN31"
};
static const char * const states_2[] = {
"D3DRENDERSTATE_WRAP0",
"D3DRENDERSTATE_WRAP1",
"D3DRENDERSTATE_WRAP2",
"D3DRENDERSTATE_WRAP3",
"D3DRENDERSTATE_WRAP4",
"D3DRENDERSTATE_WRAP5",
"D3DRENDERSTATE_WRAP6",
"D3DRENDERSTATE_WRAP7",
"D3DRENDERSTATE_CLIPPING",
"D3DRENDERSTATE_LIGHTING",
"D3DRENDERSTATE_EXTENTS",
"D3DRENDERSTATE_AMBIENT",
"D3DRENDERSTATE_FOGVERTEXMODE",
"D3DRENDERSTATE_COLORVERTEX",
"D3DRENDERSTATE_LOCALVIEWER",
"D3DRENDERSTATE_NORMALIZENORMALS",
"D3DRENDERSTATE_COLORKEYBLENDENABLE",
"D3DRENDERSTATE_DIFFUSEMATERIALSOURCE",
"D3DRENDERSTATE_SPECULARMATERIALSOURCE",
"D3DRENDERSTATE_AMBIENTMATERIALSOURCE",
"D3DRENDERSTATE_EMISSIVEMATERIALSOURCE",
"ERR",
"ERR",
"D3DRENDERSTATE_VERTEXBLEND",
"D3DRENDERSTATE_CLIPPLANEENABLE",
};
if (type >= D3DRENDERSTATE_WRAP0) {
type -= D3DRENDERSTATE_WRAP0;
if (type >= (sizeof(states_2) / sizeof(states_2[0]))) return "ERR";
return states_2[type];
}
if (type >= (sizeof(states) / sizeof(states[0]))) return "ERR";
return states[type];
}
void
dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol)
{
DPRINTF("%f %f %f %f", lpCol->u1.r, lpCol->u2.g, lpCol->u3.b, lpCol->u4.a);
}
void
dump_D3DVECTOR(D3DVECTOR *lpVec)
{
DPRINTF("%f %f %f", lpVec->u1.x, lpVec->u2.y, lpVec->u3.z);
}
void
dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat)
{
DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(lpMat->u.diffuse)); DPRINTF("\n");
DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(lpMat->u1.ambient)); DPRINTF("\n");
DPRINTF(" - specular : "); dump_D3DCOLORVALUE(&(lpMat->u2.specular)); DPRINTF("\n");
DPRINTF(" - emissive : "); dump_D3DCOLORVALUE(&(lpMat->u3.emissive)); DPRINTF("\n");
DPRINTF(" - power : %f\n", lpMat->u4.power);
}
void
dump_D3DLIGHT7(LPD3DLIGHT7 lpLight)
{
DPRINTF(" - light type : %s\n", (lpLight->dltType == D3DLIGHT_POINT ? "D3DLIGHT_POINT" :
(lpLight->dltType == D3DLIGHT_SPOT ? "D3DLIGHT_SPOT" :
(lpLight->dltType == D3DLIGHT_DIRECTIONAL ? "D3DLIGHT_DIRECTIONAL" :
"UNSUPPORTED"))));
DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(lpLight->dcvDiffuse)); DPRINTF("\n");
DPRINTF(" - specular : "); dump_D3DCOLORVALUE(&(lpLight->dcvSpecular)); DPRINTF("\n");
DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(lpLight->dcvAmbient)); DPRINTF("\n");
DPRINTF(" - position : "); dump_D3DVECTOR(&(lpLight->dvPosition)); DPRINTF("\n");
DPRINTF(" - direction : "); dump_D3DVECTOR(&(lpLight->dvDirection)); DPRINTF("\n");
DPRINTF(" - dvRange : %f\n", lpLight->dvRange);
DPRINTF(" - dvFalloff : %f\n", lpLight->dvFalloff);
DPRINTF(" - dvAttenuation : %f %f %f\n", lpLight->dvAttenuation0, lpLight->dvAttenuation1, lpLight->dvAttenuation2);
DPRINTF(" - dvTheta : %f\n", lpLight->dvTheta);
DPRINTF(" - dvPhi : %f\n", lpLight->dvPhi);
}
void
dump_DPFLAGS(DWORD dwFlags)
{
static const flag_info flags[] =
{
FE(D3DDP_WAIT),
FE(D3DDP_OUTOFORDER),
FE(D3DDP_DONOTCLIP),
FE(D3DDP_DONOTUPDATEEXTENTS),
FE(D3DDP_DONOTLIGHT)
};
DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0]));
}
void
dump_D3DMATRIX(D3DMATRIX *mat)
{
DPRINTF(" %f %f %f %f\n", mat->_11, mat->_12, mat->_13, mat->_14);
DPRINTF(" %f %f %f %f\n", mat->_21, mat->_22, mat->_23, mat->_24);
DPRINTF(" %f %f %f %f\n", mat->_31, mat->_32, mat->_33, mat->_34);
DPRINTF(" %f %f %f %f\n", mat->_41, mat->_42, mat->_43, mat->_44);
}
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType)
{
DWORD size = 0;
int i;
if (d3dvtVertexType & D3DFVF_NORMAL) size += 3 * sizeof(D3DVALUE);
if (d3dvtVertexType & D3DFVF_DIFFUSE) size += sizeof(DWORD);
if (d3dvtVertexType & D3DFVF_SPECULAR) size += sizeof(DWORD);
if (d3dvtVertexType & D3DFVF_RESERVED1) size += sizeof(DWORD);
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
case D3DFVF_XYZ: size += 3 * sizeof(D3DVALUE); break;
case D3DFVF_XYZRHW: size += 4 * sizeof(D3DVALUE); break;
default: TRACE(" matrix weighting not handled yet...\n");
}
for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++) {
size += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i) * sizeof(D3DVALUE);
}
return size;
}
void dump_flexible_vertex(DWORD d3dvtVertexType)
{
static const flag_info flags[] = {
FE(D3DFVF_NORMAL),
FE(D3DFVF_RESERVED1),
FE(D3DFVF_DIFFUSE),
FE(D3DFVF_SPECULAR)
};
unsigned int i;
if (d3dvtVertexType & D3DFVF_RESERVED0) DPRINTF("D3DFVF_RESERVED0 ");
switch (d3dvtVertexType & D3DFVF_POSITION_MASK) {
#define GEN_CASE(a) case a: DPRINTF(#a " "); break
GEN_CASE(D3DFVF_XYZ);
GEN_CASE(D3DFVF_XYZRHW);
GEN_CASE(D3DFVF_XYZB1);
GEN_CASE(D3DFVF_XYZB2);
GEN_CASE(D3DFVF_XYZB3);
GEN_CASE(D3DFVF_XYZB4);
GEN_CASE(D3DFVF_XYZB5);
}
DDRAW_dump_flags_(d3dvtVertexType, flags, sizeof(flags)/sizeof(flags[0]), FALSE);
switch (d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) {
GEN_CASE(D3DFVF_TEX0);
GEN_CASE(D3DFVF_TEX1);
GEN_CASE(D3DFVF_TEX2);
GEN_CASE(D3DFVF_TEX3);
GEN_CASE(D3DFVF_TEX4);
GEN_CASE(D3DFVF_TEX5);
GEN_CASE(D3DFVF_TEX6);
GEN_CASE(D3DFVF_TEX7);
GEN_CASE(D3DFVF_TEX8);
}
#undef GEN_CASE
for (i = 0; i < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); i++) {
DPRINTF(" T%d-s%ld", i + 1, GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, i));
}
DPRINTF("\n");
}
void
convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided, DWORD dwStartVertex)
{
int current_offset = 0;
unsigned int tex_index;
int size = get_flexible_vertex_size(d3dvtVertexType);
lpvVertices = ((BYTE *) lpvVertices) + (size * dwStartVertex);
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
strided->position.lpvData = lpvVertices;
current_offset += 3 * sizeof(D3DVALUE);
} else {
strided->position.lpvData = lpvVertices;
current_offset += 4 * sizeof(D3DVALUE);
}
if (d3dvtVertexType & D3DFVF_RESERVED1) {
current_offset += sizeof(DWORD);
}
if (d3dvtVertexType & D3DFVF_NORMAL) {
strided->normal.lpvData = ((char *) lpvVertices) + current_offset;
current_offset += 3 * sizeof(D3DVALUE);
}
if (d3dvtVertexType & D3DFVF_DIFFUSE) {
strided->diffuse.lpvData = ((char *) lpvVertices) + current_offset;
current_offset += sizeof(DWORD);
}
if (d3dvtVertexType & D3DFVF_SPECULAR) {
strided->specular.lpvData = ((char *) lpvVertices) + current_offset;
current_offset += sizeof(DWORD);
}
for (tex_index = 0; tex_index < GET_TEXCOUNT_FROM_FVF(d3dvtVertexType); tex_index++) {
strided->textureCoords[tex_index].lpvData = ((char *) lpvVertices) + current_offset;
current_offset += GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_index) * sizeof(D3DVALUE);
}
strided->position.dwStride = current_offset;
strided->normal.dwStride = current_offset;
strided->diffuse.dwStride = current_offset;
strided->specular.dwStride = current_offset;
for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++)
strided->textureCoords[tex_index].dwStride = current_offset;
}
void
dump_D3DVOP(DWORD dwVertexOp)
{
static const flag_info flags[] =
{
FE(D3DVOP_LIGHT),
FE(D3DVOP_CLIP),
FE(D3DVOP_EXTENTS),
FE(D3DVOP_TRANSFORM)
};
DDRAW_dump_flags(dwVertexOp, flags, sizeof(flags)/sizeof(flags[0]));
}
void
dump_D3DPV(DWORD dwFlags)
{
if (dwFlags == D3DPV_DONOTCOPYDATA) DPRINTF("D3DPV_DONOTCOPYDATA\n");
else if (dwFlags != 0) DPRINTF("Unknown !!!\n");
else DPRINTF("\n");
}
void multiply_matrix(LPD3DMATRIX dest, LPD3DMATRIX src1, LPD3DMATRIX src2)
{
D3DMATRIX temp;
/* Now do the multiplication 'by hand'.
I know that all this could be optimised, but this will be done later :-) */
temp._11 = (src1->_11 * src2->_11) + (src1->_21 * src2->_12) + (src1->_31 * src2->_13) + (src1->_41 * src2->_14);
temp._21 = (src1->_11 * src2->_21) + (src1->_21 * src2->_22) + (src1->_31 * src2->_23) + (src1->_41 * src2->_24);
temp._31 = (src1->_11 * src2->_31) + (src1->_21 * src2->_32) + (src1->_31 * src2->_33) + (src1->_41 * src2->_34);
temp._41 = (src1->_11 * src2->_41) + (src1->_21 * src2->_42) + (src1->_31 * src2->_43) + (src1->_41 * src2->_44);
temp._12 = (src1->_12 * src2->_11) + (src1->_22 * src2->_12) + (src1->_32 * src2->_13) + (src1->_42 * src2->_14);
temp._22 = (src1->_12 * src2->_21) + (src1->_22 * src2->_22) + (src1->_32 * src2->_23) + (src1->_42 * src2->_24);
temp._32 = (src1->_12 * src2->_31) + (src1->_22 * src2->_32) + (src1->_32 * src2->_33) + (src1->_42 * src2->_34);
temp._42 = (src1->_12 * src2->_41) + (src1->_22 * src2->_42) + (src1->_32 * src2->_43) + (src1->_42 * src2->_44);
temp._13 = (src1->_13 * src2->_11) + (src1->_23 * src2->_12) + (src1->_33 * src2->_13) + (src1->_43 * src2->_14);
temp._23 = (src1->_13 * src2->_21) + (src1->_23 * src2->_22) + (src1->_33 * src2->_23) + (src1->_43 * src2->_24);
temp._33 = (src1->_13 * src2->_31) + (src1->_23 * src2->_32) + (src1->_33 * src2->_33) + (src1->_43 * src2->_34);
temp._43 = (src1->_13 * src2->_41) + (src1->_23 * src2->_42) + (src1->_33 * src2->_43) + (src1->_43 * src2->_44);
temp._14 = (src1->_14 * src2->_11) + (src1->_24 * src2->_12) + (src1->_34 * src2->_13) + (src1->_44 * src2->_14);
temp._24 = (src1->_14 * src2->_21) + (src1->_24 * src2->_22) + (src1->_34 * src2->_23) + (src1->_44 * src2->_24);
temp._34 = (src1->_14 * src2->_31) + (src1->_24 * src2->_32) + (src1->_34 * src2->_33) + (src1->_44 * src2->_34);
temp._44 = (src1->_14 * src2->_41) + (src1->_24 * src2->_42) + (src1->_34 * src2->_43) + (src1->_44 * src2->_44);
/* And copy the new matrix in the good storage.. */
memcpy(dest, &temp, 16 * sizeof(D3DVALUE));
}

3046
dlls/ddraw/ddraw.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,8 @@
@ stdcall DirectDrawCreateEx(ptr ptr ptr ptr)
@ stdcall DirectDrawEnumerateA(ptr ptr)
@ stdcall DirectDrawEnumerateExA(ptr ptr long)
@ stdcall DirectDrawEnumerateExW(ptr ptr long)
@ stdcall DirectDrawEnumerateW(ptr ptr)
@ stub DirectDrawEnumerateExW
@ stub DirectDrawEnumerateW
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()

View File

@ -1,578 +0,0 @@
/* DirectDraw HAL driver
*
* Copyright 2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdarg.h>
#include <stdlib.h>
#include "wine/debug.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "ddraw.h"
#include "ddrawi.h"
#include "d3dhal.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const IDirectDraw7Vtbl HAL_DirectDraw_VTable;
static DDVERSIONDATA hal_version;
static DD32BITDRIVERDATA hal_driverdata;
static HINSTANCE hal_instance;
static const DDDEVICEIDENTIFIER2 hal_device =
{
"display",
"DirectDraw HAL",
{ { 0x00010001, 0x00010001 } },
0, 0, 0, 0,
/* 40c1b248-9d7d-4a29-b7d7-4cd8109f3d5d */
{0x40c1b248,0x9d7d,0x4a29,{0xd7,0xb7,0x4c,0xd8,0x10,0x9f,0x3d,0x5d}},
0
};
HRESULT HAL_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex);
HRESULT HAL_DirectDraw_Initialize(IDirectDrawImpl*, const GUID*);
static const ddraw_driver hal_driver =
{
&hal_device,
100, /* we prefer the HAL */
HAL_DirectDraw_Create,
HAL_DirectDraw_Initialize
};
static DDHAL_CALLBACKS dd_cbs;
static DDRAWI_DIRECTDRAW_GBL dd_gbl;
static D3DHAL_GLOBALDRIVERDATA d3d_hal_data;
static D3DHAL_D3DEXTENDEDCAPS d3d_hal_extcaps;
static D3DHAL_CALLBACKS d3d_hal_cbs1;
static D3DHAL_CALLBACKS2 d3d_hal_cbs2;
/* in real windoze, these entry points are 16-bit, but we can work in 32-bit */
static BOOL WINAPI set_hal_info(LPDDHALINFO lpDDHalInfo, BOOL reset)
{
dd_cbs.HALDD = *lpDDHalInfo->lpDDCallbacks;
dd_cbs.HALDDSurface = *lpDDHalInfo->lpDDSurfaceCallbacks;
dd_cbs.HALDDPalette = *lpDDHalInfo->lpDDPaletteCallbacks;
if (lpDDHalInfo->lpDDExeBufCallbacks)
dd_cbs.HALDDExeBuf = *lpDDHalInfo->lpDDExeBufCallbacks;
dd_gbl.lpDDCBtmp = &dd_cbs;
dd_gbl.ddCaps = lpDDHalInfo->ddCaps;
dd_gbl.dwMonitorFrequency = lpDDHalInfo->dwMonitorFrequency;
dd_gbl.vmiData = lpDDHalInfo->vmiData;
dd_gbl.dwModeIndex = lpDDHalInfo->dwModeIndex;
dd_gbl.dwNumFourCC = lpDDHalInfo->ddCaps.dwNumFourCCCodes;
dd_gbl.lpdwFourCC = lpDDHalInfo->lpdwFourCC;
dd_gbl.dwNumModes = lpDDHalInfo->dwNumModes;
dd_gbl.lpModeInfo = lpDDHalInfo->lpModeInfo;
/* FIXME: dwFlags */
dd_gbl.dwPDevice = (DWORD)lpDDHalInfo->lpPDevice;
dd_gbl.hInstance = lpDDHalInfo->hInstance;
/* DirectX 2 */
if (lpDDHalInfo->lpD3DGlobalDriverData)
memcpy(&d3d_hal_data, (LPVOID)lpDDHalInfo->lpD3DGlobalDriverData, sizeof(D3DDEVICEDESC_V1));
else
memset(&d3d_hal_data, 0, sizeof(D3DDEVICEDESC_V1));
dd_gbl.lpD3DGlobalDriverData = (ULONG_PTR)&d3d_hal_data;
if (lpDDHalInfo->lpD3DHALCallbacks)
memcpy(&d3d_hal_cbs1, (LPVOID)lpDDHalInfo->lpD3DHALCallbacks, sizeof(D3DHAL_CALLBACKS));
else
memset(&d3d_hal_cbs1, 0, sizeof(D3DHAL_CALLBACKS));
dd_gbl.lpD3DHALCallbacks = (ULONG_PTR)&d3d_hal_cbs1;
if (lpDDHalInfo->dwFlags & DDHALINFO_GETDRIVERINFOSET) {
DDHAL_GETDRIVERINFODATA data;
data.dwSize = sizeof(DDHAL_GETDRIVERINFODATA);
data.dwFlags = 0; /* ? */
data.dwContext = hal_driverdata.dwContext; /* ? */
data.guidInfo = GUID_D3DExtendedCaps;
data.dwExpectedSize = sizeof(D3DHAL_D3DEXTENDEDCAPS);
data.lpvData = &d3d_hal_extcaps;
data.dwActualSize = 0;
data.ddRVal = 0;
lpDDHalInfo->GetDriverInfo(&data);
d3d_hal_extcaps.dwSize = data.dwActualSize;
dd_gbl.lpD3DExtendedCaps = (ULONG_PTR)&d3d_hal_extcaps;
data.guidInfo = GUID_D3DCallbacks2;
data.dwExpectedSize = sizeof(D3DHAL_CALLBACKS2);
data.lpvData = &d3d_hal_cbs2;
data.dwActualSize = 0;
data.ddRVal = 0;
lpDDHalInfo->GetDriverInfo(&data);
d3d_hal_cbs2.dwSize = data.dwActualSize;
dd_gbl.lpD3DHALCallbacks2 = (ULONG_PTR)&d3d_hal_cbs2;
}
if( opengl_initialized &&
(d3d_hal_data.hwCaps.dwFlags & D3DDD_WINE_OPENGL_DEVICE) ) {
/*GL_DirectDraw_Init(&dd_gbl);*/
}
return FALSE;
}
static DDHALDDRAWFNS hal_funcs = {
sizeof(DDHALDDRAWFNS),
set_hal_info,
NULL, /* VidMemAlloc */
NULL /* VidMemFree */
};
/* Called from DllInit, which is synchronised so there are no threading
* concerns. */
static BOOL initialize(void)
{
DCICMD cmd;
INT ncmd = DCICOMMAND;
BOOL ret;
HDC dc = CreateDCA("DISPLAY", NULL, NULL, NULL);
INT ver = Escape(dc, QUERYESCSUPPORT, sizeof(ncmd), (LPVOID)&ncmd, NULL);
if (ver != DD_HAL_VERSION) {
DeleteDC(dc);
TRACE("DirectDraw HAL not available\n");
return FALSE;
}
cmd.dwVersion = DD_VERSION;
cmd.dwReserved = 0;
/* the DDNEWCALLBACKFNS is supposed to give the 16-bit driver entry points
* in ddraw16.dll, but since Wine doesn't have or use 16-bit display drivers,
* we'll just work in 32-bit, who'll notice... */
cmd.dwCommand = DDNEWCALLBACKFNS;
cmd.dwParam1 = (DWORD)&hal_funcs;
ExtEscape(dc, DCICOMMAND, sizeof(cmd), (LPVOID)&cmd, 0, NULL);
/* next, exchange version information */
cmd.dwCommand = DDVERSIONINFO;
cmd.dwParam1 = DD_RUNTIME_VERSION; /* not sure what should *really* go here */
ExtEscape(dc, DCICOMMAND, sizeof(cmd), (LPVOID)&cmd, sizeof(hal_version), (LPVOID)&hal_version);
/* get 32-bit driver data (dll name and entry point) */
cmd.dwCommand = DDGET32BITDRIVERNAME;
ExtEscape(dc, DCICOMMAND, sizeof(cmd), (LPVOID)&cmd, sizeof(hal_driverdata), (LPVOID)&hal_driverdata);
/* we're supposed to load the DLL in hal_driverdata.szName, then GetProcAddress
* the hal_driverdata.szEntryPoint, and call it with hal_driverdata.dwContext
* as a parameter... but since this is only more remains from the 16-bit world,
* we'll ignore it */
/* finally, initialize the driver object */
cmd.dwCommand = DDCREATEDRIVEROBJECT;
ret = ExtEscape(dc, DCICOMMAND, sizeof(cmd), (LPVOID)&cmd, sizeof(hal_instance), (LPVOID)&hal_instance);
if (ret) {
/* the driver should have called our set_hal_info now */
if (!dd_gbl.lpDDCBtmp) ret = FALSE;
}
/* init done */
DeleteDC(dc);
TRACE("%s DirectDraw HAL\n", ret ? "enabling" : "disabling");
return ret;
}
static void cleanup(void)
{
DDHAL_DESTROYDRIVERDATA data;
if (!dd_cbs.HALDD.DestroyDriver) return;
data.lpDD = NULL;
data.ddRVal = 0;
data.DestroyDriver = dd_cbs.HALDD.DestroyDriver;
data.DestroyDriver(&data);
}
static DWORD choose_mode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags)
{
int best = -1;
unsigned int i;
if (!dd_gbl.dwNumModes) return 0;
/* let's support HALs that cannot switch depths (XVidMode),
* these should return dwBPP == 0 for all their resolutions */
#define BPP_MATCH(dd, bpp) ((!(dd)) || ((dd) == bpp))
/* FIXME: we should try to match the refresh rate too */
/* Choose the smallest mode that is large enough. */
for (i=0; i < dd_gbl.dwNumModes; i++)
{
if (dd_gbl.lpModeInfo[i].dwWidth >= dwWidth &&
dd_gbl.lpModeInfo[i].dwHeight >= dwHeight &&
BPP_MATCH(dd_gbl.lpModeInfo[i].dwBPP, dwBPP))
{
if (best == -1) best = i;
else
{
if (dd_gbl.lpModeInfo[i].dwWidth < dd_gbl.lpModeInfo[best].dwWidth ||
dd_gbl.lpModeInfo[i].dwHeight < dd_gbl.lpModeInfo[best].dwHeight)
best = i;
}
}
}
if (best == -1)
{
TRACE("all modes too small\n");
/* ok, let's use the largest */
for (i=0; i < dd_gbl.dwNumModes; i++)
{
if (BPP_MATCH(dd_gbl.lpModeInfo[i].dwBPP, dwBPP))
{
if (best == -1) best = i;
else
{
if (dd_gbl.lpModeInfo[i].dwWidth > dd_gbl.lpModeInfo[best].dwWidth ||
dd_gbl.lpModeInfo[i].dwHeight > dd_gbl.lpModeInfo[best].dwHeight)
best = i;
}
}
}
}
#undef BPP_MATCH
if (best == -1)
{
ERR("requested color depth (%ld) not available, try reconfiguring X server\n", dwBPP);
return dd_gbl.dwModeIndex;
}
TRACE("using mode %d\n", best);
return best;
}
static HRESULT set_mode(IDirectDrawImpl *This, DWORD dwMode)
{
HRESULT hr = DD_OK;
if (dwMode != dd_gbl.dwModeIndex)
{
DDHAL_SETMODEDATA data;
data.lpDD = &dd_gbl;
data.dwModeIndex = dwMode;
data.ddRVal = 0;
data.SetMode = dd_cbs.HALDD.SetMode;
data.inexcl = 0;
data.useRefreshRate = FALSE;
if (data.SetMode)
data.SetMode(&data);
hr = data.ddRVal;
if (SUCCEEDED(hr))
dd_gbl.dwModeIndex = dwMode;
}
return hr;
}
static HRESULT set_exclusive_mode(IDirectDrawImpl *This, DWORD dwEnterExcl)
{
DDHAL_SETEXCLUSIVEMODEDATA data;
data.lpDD = &dd_gbl;
data.dwEnterExcl = dwEnterExcl;
data.dwReserved = 0;
data.ddRVal = 0;
data.SetExclusiveMode = dd_cbs.HALDD.SetExclusiveMode;
if (data.SetExclusiveMode)
data.SetExclusiveMode(&data);
return data.ddRVal;
}
BOOL DDRAW_HAL_Init(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
if (initialize())
DDRAW_register_driver(&hal_driver);
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
cleanup();
}
return TRUE;
}
/* Not called from the vtable. */
HRESULT HAL_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex)
{
HRESULT hr;
TRACE("(%p,%d)\n", This, ex);
hr = User_DirectDraw_Construct(This, ex);
if (FAILED(hr)) return hr;
This->local.lpGbl = &dd_gbl;
This->final_release = HAL_DirectDraw_final_release;
This->set_exclusive_mode = set_exclusive_mode;
This->create_palette = HAL_DirectDrawPalette_Create;
This->create_primary = HAL_DirectDraw_create_primary;
This->create_backbuffer = HAL_DirectDraw_create_backbuffer;
This->create_texture = HAL_DirectDraw_create_texture;
ICOM_INIT_INTERFACE(This, IDirectDraw7, HAL_DirectDraw_VTable);
/* merge HAL caps */
This->caps.dwCaps |= dd_gbl.ddCaps.dwCaps;
This->caps.dwCaps2 |= dd_gbl.ddCaps.dwCaps2;
This->caps.dwCKeyCaps |= dd_gbl.ddCaps.dwCKeyCaps;
This->caps.dwFXCaps |= dd_gbl.ddCaps.dwFXCaps;
This->caps.dwPalCaps |= dd_gbl.ddCaps.dwPalCaps;
/* FIXME: merge more caps */
This->caps.ddsCaps.dwCaps |= dd_gbl.ddCaps.ddsCaps.dwCaps;
This->caps.ddsCaps.dwCaps2 |= dd_gbl.ddsCapsMore.dwCaps2;
This->caps.ddsCaps.dwCaps3 |= dd_gbl.ddsCapsMore.dwCaps3;
This->caps.ddsCaps.dwCaps4 |= dd_gbl.ddsCapsMore.dwCaps4;
This->caps.ddsOldCaps.dwCaps = This->caps.ddsCaps.dwCaps;
return S_OK;
}
/* This function is called from DirectDrawCreate(Ex) on the most-derived
* class to start construction.
* Not called from the vtable. */
HRESULT HAL_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex)
{
HRESULT hr;
IDirectDrawImpl* This;
TRACE("\n");
assert(pUnkOuter == NULL);
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawImpl)
+ sizeof(HAL_DirectDrawImpl));
if (This == NULL) return E_OUTOFMEMORY;
/* Note that this relation does *not* hold true if the DD object was
* CoCreateInstanced then Initialized. */
This->private = (HAL_DirectDrawImpl *)(This+1);
/* Initialize the DDCAPS structure */
This->caps.dwSize = sizeof(This->caps);
hr = HAL_DirectDraw_Construct(This, ex);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*pIface = ICOM_INTERFACE(This, IDirectDraw7);
return hr;
}
/* This function is called from Uninit_DirectDraw_Initialize on the
* most-derived-class to start initialization.
* Not called from the vtable. */
HRESULT HAL_DirectDraw_Initialize(IDirectDrawImpl *This, const GUID* guid)
{
HRESULT hr;
TRACE("\n");
This->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(HAL_DirectDrawImpl));
if (This->private == NULL) return E_OUTOFMEMORY;
/* Initialize the DDCAPS structure */
This->caps.dwSize = sizeof(This->caps);
hr = HAL_DirectDraw_Construct(This, TRUE); /* XXX ex? */
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, This->private);
return hr;
}
return DD_OK;
}
/* Called from an internal function pointer. */
void HAL_DirectDraw_final_release(IDirectDrawImpl *This)
{
if (dd_gbl.dwFlags & DDRAWI_MODECHANGED) set_mode(This, dd_gbl.dwModeIndexOrig);
User_DirectDraw_final_release(This);
}
HRESULT HAL_DirectDraw_create_primary(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter)
{
if (This->cooperative_level & DDSCL_EXCLUSIVE)
return HAL_DirectDrawSurface_Create(This, pDDSD, ppSurf, pUnkOuter);
else
return User_DirectDrawSurface_Create(This, pDDSD, ppSurf, pUnkOuter);
}
HRESULT HAL_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter,
IDirectDrawSurfaceImpl* primary)
{
if (This->cooperative_level & DDSCL_EXCLUSIVE)
return HAL_DirectDrawSurface_Create(This, pDDSD, ppSurf, pUnkOuter);
else
return User_DirectDrawSurface_Create(This, pDDSD, ppSurf, pUnkOuter);
}
HRESULT HAL_DirectDraw_create_texture(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
LPUNKNOWN pOuter,
DWORD dwMipMapLevel)
{
return HAL_DirectDrawSurface_Create(This, pDDSD, ppSurf, pOuter);
}
HRESULT WINAPI
HAL_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI,
DWORD dwFlags)
{
*pDDDI = hal_device;
return DD_OK;
}
HRESULT WINAPI
HAL_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
HRESULT hr;
TRACE("(%p)\n", iface);
if (!(dd_gbl.dwFlags & DDRAWI_MODECHANGED)) return DD_OK;
hr = Main_DirectDraw_RestoreDisplayMode(iface);
if (SUCCEEDED(hr)) {
hr = set_mode(This, dd_gbl.dwModeIndexOrig);
if (SUCCEEDED(hr)) dd_gbl.dwFlags &= ~DDRAWI_MODECHANGED;
}
return hr;
}
HRESULT WINAPI
HAL_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
HRESULT hr;
TRACE("(%p)->(%ldx%ldx%ld,%ld Hz,%08lx)\n",This,dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags);
hr = User_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, dwBPP,
dwRefreshRate, dwFlags);
if (SUCCEEDED(hr)) {
if (!(dd_gbl.dwFlags & DDRAWI_MODECHANGED)) dd_gbl.dwModeIndexOrig = dd_gbl.dwModeIndex;
hr = set_mode(This, choose_mode(dwWidth, dwHeight, dwBPP, dwRefreshRate, dwFlags));
if (SUCCEEDED(hr)) dd_gbl.dwFlags |= DDRAWI_MODECHANGED;
}
return hr;
}
HRESULT WINAPI
HAL_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes,
LPDWORD pCodes)
{
unsigned int i;
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
if (*pNumCodes)
*pNumCodes=dd_gbl.dwNumFourCC;
if (pCodes && dd_gbl.dwNumFourCC)
memcpy(pCodes,dd_gbl.lpdwFourCC,sizeof(pCodes[0])*dd_gbl.dwNumFourCC);
FIXME("(%p,%p,%p)\n",This,pNumCodes,pCodes);
if (dd_gbl.dwNumFourCC) {
if (pCodes && FIXME_ON(ddraw)) {
FIXME("returning: ");
for (i=0;i<dd_gbl.dwNumFourCC;i++) {
MESSAGE("%c%c%c%c,",
((LPBYTE)(pCodes+i))[0],
((LPBYTE)(pCodes+i))[1],
((LPBYTE)(pCodes+i))[2],
((LPBYTE)(pCodes+i))[3]
);
}
MESSAGE("\n");
}
}
return DD_OK;
}
static const IDirectDraw7Vtbl HAL_DirectDraw_VTable =
{
Main_DirectDraw_QueryInterface,
Main_DirectDraw_AddRef,
Main_DirectDraw_Release,
Main_DirectDraw_Compact,
Main_DirectDraw_CreateClipper,
Main_DirectDraw_CreatePalette,
Main_DirectDraw_CreateSurface,
Main_DirectDraw_DuplicateSurface,
User_DirectDraw_EnumDisplayModes,
Main_DirectDraw_EnumSurfaces,
Main_DirectDraw_FlipToGDISurface,
Main_DirectDraw_GetCaps,
Main_DirectDraw_GetDisplayMode,
HAL_DirectDraw_GetFourCCCodes,
Main_DirectDraw_GetGDISurface,
Main_DirectDraw_GetMonitorFrequency,
Main_DirectDraw_GetScanLine,
Main_DirectDraw_GetVerticalBlankStatus,
Main_DirectDraw_Initialize,
HAL_DirectDraw_RestoreDisplayMode,
Main_DirectDraw_SetCooperativeLevel,
HAL_DirectDraw_SetDisplayMode,
Main_DirectDraw_WaitForVerticalBlank,
Main_DirectDraw_GetAvailableVidMem,
Main_DirectDraw_GetSurfaceFromDC,
Main_DirectDraw_RestoreAllSurfaces,
Main_DirectDraw_TestCooperativeLevel,
HAL_DirectDraw_GetDeviceIdentifier,
Main_DirectDraw_StartModeTest,
Main_DirectDraw_EvaluateMode
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include "windef.h"
@ -205,6 +208,7 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
IUnknown *pUnkOuter)
{
LPDIRECTDRAWSURFACE7 pSurface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
/* the LPDDSURFACEDESC -> LPDDSURFACEDESC2 conversion should be ok,
@ -221,6 +225,12 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
if(impl)
{
impl->version = 1;
}
return hr;
}
@ -230,6 +240,7 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IUnknown *pUnkOuter)
{
LPDIRECTDRAWSURFACE7 pSurface7;
IDirectDrawSurfaceImpl *impl;
HRESULT hr;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
@ -244,6 +255,12 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IDirectDrawSurface7, IDirectDrawSurface3,
pSurface7);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, pSurface7);
if(impl)
{
impl->version = 2;
}
return hr;
}
@ -252,13 +269,22 @@ IDirectDraw4Impl_CreateSurface(LPDIRECTDRAW4 This, LPDDSURFACEDESC2 pSDesc,
LPDIRECTDRAWSURFACE4 *ppSurface,
IUnknown *pUnkOuter)
{
return IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
HRESULT hr;
IDirectDrawSurfaceImpl *impl;
hr = IDirectDraw7_CreateSurface(COM_INTERFACE_CAST(IDirectDrawImpl,
IDirectDraw4,
IDirectDraw7,
This),
pSDesc,
(LPDIRECTDRAWSURFACE7 *)ppSurface,
pUnkOuter);
impl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, *ppSurface);
if(impl)
{
impl->version = 4;
}
return hr;
}
static HRESULT WINAPI
@ -710,9 +736,6 @@ IDirectDrawImpl_Initialize(LPDIRECTDRAW iface, LPGUID pGUID)
ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID);
/* Overwrite the falsely set 'DIRECTDRAW7' flag */
This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7;
return ret_value;
}
@ -724,9 +747,6 @@ IDirectDraw2Impl_Initialize(LPDIRECTDRAW2 iface, LPGUID pGUID)
ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID);
/* Overwrite the falsely set 'DIRECTDRAW7' flag */
This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7;
return ret_value;
}
@ -738,9 +758,6 @@ IDirectDraw4Impl_Initialize(LPDIRECTDRAW4 iface, LPGUID pGUID)
ret_value = IDirectDraw7_Initialize(ICOM_INTERFACE(This, IDirectDraw7), pGUID);
/* Overwrite the falsely set 'DIRECTDRAW7' flag */
This->local.dwLocalFlags &= ~DDRAWILCL_DIRECTDRAW7;
return ret_value;
}
@ -942,7 +959,7 @@ IDirectDraw4Impl_GetDeviceIdentifier(LPDIRECTDRAW4 This,
return hr;
}
const IDirectDrawVtbl DDRAW_IDirectDraw_VTable =
const IDirectDrawVtbl IDirectDraw1_Vtbl =
{
IDirectDrawImpl_QueryInterface,
IDirectDrawImpl_AddRef,
@ -969,7 +986,7 @@ const IDirectDrawVtbl DDRAW_IDirectDraw_VTable =
IDirectDrawImpl_WaitForVerticalBlank,
};
const IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable =
const IDirectDraw2Vtbl IDirectDraw2_Vtbl =
{
IDirectDraw2Impl_QueryInterface,
IDirectDraw2Impl_AddRef,
@ -997,7 +1014,7 @@ const IDirectDraw2Vtbl DDRAW_IDirectDraw2_VTable =
IDirectDraw2Impl_GetAvailableVidMem
};
const IDirectDraw4Vtbl DDRAW_IDirectDraw4_VTable =
const IDirectDraw4Vtbl IDirectDraw4_Vtbl =
{
IDirectDraw4Impl_QueryInterface,
IDirectDraw4Impl_AddRef,

View File

@ -1,575 +0,0 @@
/* DirectDraw driver for User-based primary surfaces
*
* Copyright 2000-2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "ddraw.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const IDirectDraw7Vtbl User_DirectDraw_VTable;
static const DDDEVICEIDENTIFIER2 user_device =
{
"display",
"User (and GDI)",
{ { 0x00010001, 0x00010001 } },
0, 0, 0, 0,
/* fe38440c-8969-4283-bc73-749e7bc3c2eb */
{0xfe38440c,0x8969,0x428e, {0x73,0xbc,0x74,0x9e,0x7b,0xc3,0xc2,0xeb}},
0
};
static const DDPIXELFORMAT pixelformats[] =
{
/* 8bpp paletted */
{ sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED8, 0, { 8 } },
/* 15bpp 5/5/5 */
{ sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 16 }, { 0x7C00 }, { 0x3E0 },
{ 0x1F } },
/* 16bpp 5/6/5 */
{ sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 16 }, { 0xF800 }, { 0x7E0 },
{ 0x1F } },
/* 24bpp 8/8/8 */
{ sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 24 }, { 0xFF0000 },
{ 0x00FF00 }, { 0x0000FF } },
/* 32bpp 8/8/8 */
{ sizeof(DDPIXELFORMAT), DDPF_RGB, 0, { 32 }, { 0xFF0000 },
{ 0x00FF00 }, { 0x0000FF } }
};
HRESULT User_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex);
HRESULT User_DirectDraw_Initialize(IDirectDrawImpl*, const GUID*);
static const ddraw_driver user_driver =
{
&user_device,
10,
User_DirectDraw_Create,
User_DirectDraw_Initialize
};
BOOL DDRAW_User_Init(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
if (fdwReason == DLL_PROCESS_ATTACH)
DDRAW_register_driver(&user_driver);
return TRUE;
}
static const DDPIXELFORMAT* pixelformat_for_depth(DWORD depth)
{
switch (depth)
{
case 8: return pixelformats + 0;
case 15: return pixelformats + 1;
case 16: return pixelformats + 2;
case 24: return pixelformats + 3;
case 32: return pixelformats + 4;
default: return NULL;
}
}
/* Not called from the vtable. */
HRESULT User_DirectDraw_Construct(IDirectDrawImpl *This, BOOL ex)
{
HRESULT hr;
DWORD depth;
HDC hDC;
TRACE("(%p,%d)\n",This,ex);
hr = Main_DirectDraw_Construct(This, ex);
if (FAILED(hr)) return hr;
This->final_release = User_DirectDraw_final_release;
This->create_primary = User_DirectDraw_create_primary;
This->create_backbuffer = User_DirectDraw_create_backbuffer;
hDC = CreateDCA("DISPLAY", NULL, NULL, NULL);
depth = GetDeviceCaps(hDC, BITSPIXEL) * GetDeviceCaps(hDC, PLANES);
DeleteDC(hDC);
This->width = GetSystemMetrics(SM_CXSCREEN);
This->height = GetSystemMetrics(SM_CYSCREEN);
This->pitch = DDRAW_width_bpp_to_pitch(This->width, depth);
This->pixelformat = *pixelformat_for_depth(depth);
This->orig_width = This->width;
This->orig_height = This->height;
This->orig_pitch = This->pitch;
This->orig_pixelformat = This->pixelformat;
ICOM_INIT_INTERFACE(This, IDirectDraw7, User_DirectDraw_VTable);
/* capabilities */
#define BLIT_CAPS (DDCAPS_BLT | DDCAPS_BLTCOLORFILL | DDCAPS_BLTDEPTHFILL \
| DDCAPS_BLTSTRETCH | DDCAPS_CANBLTSYSMEM | DDCAPS_CANCLIP \
| DDCAPS_CANCLIPSTRETCHED | DDCAPS_COLORKEY \
| DDCAPS_COLORKEYHWASSIST | DDCAPS_OVERLAY | DDCAPS_OVERLAYSTRETCH)
#define CKEY_CAPS (DDCKEYCAPS_DESTBLT | DDCKEYCAPS_SRCBLT)
#define FX_CAPS (DDFXCAPS_BLTALPHA | DDFXCAPS_BLTMIRRORLEFTRIGHT \
| DDFXCAPS_BLTMIRRORUPDOWN | DDFXCAPS_BLTROTATION90 \
| DDFXCAPS_BLTSHRINKX | DDFXCAPS_BLTSHRINKXN \
| DDFXCAPS_BLTSHRINKY | DDFXCAPS_BLTSHRINKXN \
| DDFXCAPS_BLTSTRETCHX | DDFXCAPS_BLTSTRETCHXN \
| DDFXCAPS_BLTSTRETCHY | DDFXCAPS_BLTSTRETCHYN)
This->caps.dwCaps |= DDCAPS_GDI | DDCAPS_PALETTE | BLIT_CAPS;
if( opengl_initialized )
{
/* Hack for D3D code */
This->caps.dwCaps |= DDCAPS_3D;
}
This->caps.dwCaps2 |= DDCAPS2_CERTIFIED | DDCAPS2_NOPAGELOCKREQUIRED |
DDCAPS2_PRIMARYGAMMA | DDCAPS2_WIDESURFACES;
This->caps.dwCKeyCaps |= CKEY_CAPS;
This->caps.dwFXCaps |= FX_CAPS;
This->caps.dwPalCaps |= DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE;
This->caps.dwVidMemTotal = 16*1024*1024;
This->caps.dwVidMemFree = 16*1024*1024;
This->caps.dwSVBCaps |= BLIT_CAPS;
This->caps.dwSVBCKeyCaps |= CKEY_CAPS;
This->caps.dwSVBFXCaps |= FX_CAPS;
This->caps.dwVSBCaps |= BLIT_CAPS;
This->caps.dwVSBCKeyCaps |= CKEY_CAPS;
This->caps.dwVSBFXCaps |= FX_CAPS;
This->caps.dwSSBCaps |= BLIT_CAPS;
This->caps.dwSSBCKeyCaps |= CKEY_CAPS;
This->caps.dwSSBFXCaps |= FX_CAPS;
This->caps.ddsCaps.dwCaps |= DDSCAPS_ALPHA | DDSCAPS_BACKBUFFER |
DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER |
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
DDSCAPS_PRIMARYSURFACE | DDSCAPS_SYSTEMMEMORY |
DDSCAPS_VIDEOMEMORY | DDSCAPS_VISIBLE;
if( opengl_initialized )
{
/* Hacks for D3D code */
This->caps.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE | DDSCAPS_MIPMAP | DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER;
}
This->caps.ddsOldCaps.dwCaps = This->caps.ddsCaps.dwCaps;
#undef BLIT_CAPS
#undef CKEY_CAPS
#undef FX_CAPS
return S_OK;
}
/* This function is called from DirectDrawCreate(Ex) on the most-derived
* class to start construction.
* Not called from the vtable. */
HRESULT User_DirectDraw_Create(const GUID* pGUID, LPDIRECTDRAW7* pIface,
IUnknown* pUnkOuter, BOOL ex)
{
HRESULT hr;
IDirectDrawImpl* This;
assert(pUnkOuter == NULL);
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawImpl) + sizeof(User_DirectDrawImpl));
if (This == NULL) return E_OUTOFMEMORY;
/* Note that this relation does *not* hold true if the DD object was
* CoCreateInstanced then Initialized. */
This->private = (User_DirectDrawImpl *)(This+1);
/* Initialize the DDCAPS structure */
This->caps.dwSize = sizeof(This->caps);
hr = User_DirectDraw_Construct(This, ex);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*pIface = ICOM_INTERFACE(This, IDirectDraw7);
return hr;
}
/* This function is called from Uninit_DirectDraw_Initialize on the
* most-derived-class to start initialization.
* Not called from the vtable. */
HRESULT User_DirectDraw_Initialize(IDirectDrawImpl *This, const GUID* guid)
{
HRESULT hr;
This->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(User_DirectDrawImpl));
if (This->private == NULL) return E_OUTOFMEMORY;
/* Initialize the DDCAPS structure */
This->caps.dwSize = sizeof(This->caps);
hr = User_DirectDraw_Construct(This, TRUE); /* XXX ex? */
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, This->private);
return hr;
}
return DD_OK;
}
/* Called from an internal function pointer. */
void User_DirectDraw_final_release(IDirectDrawImpl *This)
{
Main_DirectDraw_final_release(This);
}
/* Compact: generic */
/* CreateClipper: generic */
/* CreatePalette: generic (with callback) */
/* CreateSurface: generic (with callbacks) */
HRESULT
User_DirectDraw_create_primary(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter)
{
return User_DirectDrawSurface_Create(This, pDDSD, ppSurf, pUnkOuter);
}
HRESULT
User_DirectDraw_create_backbuffer(IDirectDrawImpl* This,
const DDSURFACEDESC2* pDDSD,
LPDIRECTDRAWSURFACE7* ppSurf,
IUnknown* pUnkOuter,
IDirectDrawSurfaceImpl* primary)
{
return User_DirectDrawSurface_Create(This, pDDSD, ppSurf, pUnkOuter);
}
/* DuplicateSurface: generic */
/* Originally derived from Xlib_IDirectDraw2Impl_EnumDisplayModes.
*
* The depths are whatever DIBsections support on the client side.
* Should they be limited by screen depth?
*/
HRESULT WINAPI
User_DirectDraw_EnumDisplayModes(LPDIRECTDRAW7 iface, DWORD dwFlags,
LPDDSURFACEDESC2 pDDSD, LPVOID context,
LPDDENUMMODESCALLBACK2 callback)
{
DDSURFACEDESC2 callback_sd;
DEVMODEW DevModeW;
const DDPIXELFORMAT* pixelformat;
int i;
TRACE("(%p)->(0x%08lx,%p,%p,%p)\n",iface,dwFlags,pDDSD,context,callback);
if (pDDSD && TRACE_ON(ddraw))
{
TRACE("Enumerate modes matching:\n");
DDRAW_dump_surface_desc(pDDSD);
}
ZeroMemory(&callback_sd, sizeof(callback_sd));
callback_sd.dwSize = sizeof(callback_sd);
callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_CAPS
| DDSD_PITCH;
if (dwFlags & DDEDM_REFRESHRATES)
callback_sd.dwFlags |= DDSD_REFRESHRATE;
callback_sd.u2.dwRefreshRate = 60.0;
for (i = 0; EnumDisplaySettingsExW(NULL, i, &DevModeW, 0); i++)
{
if (pDDSD)
{
if ((pDDSD->dwFlags & DDSD_WIDTH) && (pDDSD->dwWidth != DevModeW.dmPelsWidth))
continue;
if ((pDDSD->dwFlags & DDSD_HEIGHT) && (pDDSD->dwHeight != DevModeW.dmPelsHeight))
continue;
if ((pDDSD->dwFlags & DDSD_PIXELFORMAT) && (pDDSD->u4.ddpfPixelFormat.dwFlags & DDPF_RGB) &&
(pDDSD->u4.ddpfPixelFormat.u1.dwRGBBitCount != DevModeW.dmBitsPerPel))
continue;
}
callback_sd.dwHeight = DevModeW.dmPelsHeight;
callback_sd.dwWidth = DevModeW.dmPelsWidth;
if (DevModeW.dmFields & DM_DISPLAYFREQUENCY)
{
callback_sd.u2.dwRefreshRate = DevModeW.dmDisplayFrequency;
}
TRACE("- mode: %ldx%ld\n", callback_sd.dwWidth, callback_sd.dwHeight);
pixelformat = pixelformat_for_depth(DevModeW.dmBitsPerPel);
callback_sd.u1.lPitch
= DDRAW_width_bpp_to_pitch(DevModeW.dmPelsWidth,
pixelformat->u1.dwRGBBitCount);
callback_sd.u4.ddpfPixelFormat = *pixelformat;
callback_sd.ddsCaps.dwCaps = 0;
if (pixelformat->dwFlags & DDPF_PALETTEINDEXED8) /* ick */
callback_sd.ddsCaps.dwCaps |= DDSCAPS_PALETTE;
TRACE(" - %2ld bpp, R=%08lx G=%08lx B=%08lx\n",
callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount,
callback_sd.u4.ddpfPixelFormat.u2.dwRBitMask,
callback_sd.u4.ddpfPixelFormat.u3.dwGBitMask,
callback_sd.u4.ddpfPixelFormat.u4.dwBBitMask);
if (callback(&callback_sd, context) == DDENUMRET_CANCEL)
return DD_OK;
}
return DD_OK;
}
/* EnumSurfaces: generic */
/* FlipToGDISurface: ??? */
#if 0
HRESULT WINAPI
User_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
LPDDCAPS pHELCaps)
{
/* Based on my guesses for what is appropriate with some clues from the
* NVidia driver. Not everything is actually implemented yet.
* NV has but we don't: Overlays, Video Ports, DDCAPS_READSCANLINE,
* DDCAPS2_CERTIFIED (heh), DDSCAPS2_NONLOCALVIDMEM, DDSCAPS2_COPYFOURCC.
* It actually has no FX alpha caps.
* Oddly, it doesn't list DDPCAPS_PRIMARYSURFACE.
* And the HEL caps make little sense.
*/
#define BLIT_CAPS (DDCAPS_BLT | DDCAPS_BLTCOLORFILL | DDCAPS_BLTDEPTHFILL \
| DDCAPS_BLTSTRETCH | DDCAPS_CANBLTSYSMEM | DDCAPS_CANCLIP \
| DDCAPS_CANCLIPSTRETCHED | DDCAPS_COLORKEY \
| DDCAPS_COLORKEYHWASSIST | DDCAPS_OVERLAY | DDCAPS_OVERLAYSTRETCH)
#define CKEY_CAPS (DDCKEYCAPS_DESTBLT | DDCKEYCAPS_SRCBLT)
#define FX_CAPS (DDFXCAPS_BLTALPHA | DDFXCAPS_BLTMIRRORLEFTRIGHT \
| DDFXCAPS_BLTMIRRORUPDOWN | DDFXCAPS_BLTROTATION90 \
| DDFXCAPS_BLTSHRINKX | DDFXCAPS_BLTSHRINKXN \
| DDFXCAPS_BLTSHRINKY | DDFXCAPS_BLTSHRINKXN \
| DDFXCAPS_BLTSTRETCHX | DDFXCAPS_BLTSTRETCHXN \
| DDFXCAPS_BLTSTRETCHY | DDFXCAPS_BLTSTRETCHYN)
#if 0
#define ROPS { SRCCOPY, SRCPAINT, SRCAND, SRCINVERT, SRCERASE, NOTSRCCOPY, \
NOTSRCERASE, MERGEPAINT, BLACKNESS, WHITENESS, }
#else
#define ROPS { 0, }
#endif
static const DDCAPS caps =
{ sizeof(DDCAPS),
DDCAPS_3D | DDCAPS_GDI | DDCAPS_PALETTE | BLIT_CAPS,
DDCAPS2_CANMANAGETEXTURE | DDCAPS2_CANRENDERWINDOWED | DDCAPS2_CERTIFIED
| DDCAPS2_NOPAGELOCKREQUIRED | DDCAPS2_PRIMARYGAMMA
| DDCAPS2_WIDESURFACES,
CKEY_CAPS,
FX_CAPS,
0, /* dwFXAlphaCaps */
DDPCAPS_8BIT | DDPCAPS_PRIMARYSURFACE,
0, /* dwSVCaps */
0, /* ? dwAlphaBitConstBitDepths */
0, /* ? dwAlphaBitPixelPitDepths */
0, /* ? dwAlphaBltSurfaceBitDepths */
0, /* ? dwAlphaOverlayConstBitDepths */
0, /* ? dwAlphaOverlayPixelBitDepths */
0, /* ? dwAlphaOverlaySurfaceBitDepths */
DDBD_16, /* ? dwZBufferBitDepths */
16*1024*1024, /* dwVidMemTotal */
16*1024*1024, /* dwVidMemFree */
0, /* dwMaxVisibleOverlays */
0, /* dwCurrVisibleOverlays */
0, /* dwNumFourCCCodes */
0, /* dwAlignBoundarySrc */
0, /* dwAlignSizeSrc */
0, /* dwAlignBoundaryDest */
0, /* dwAlignSizeDest */
0, /* dwAlignStrideAlign */
ROPS, /* XXX dwRops[DD_ROP_SPACE] */
{ 0, }, /* XXX ddsOldCaps */
1000, /* dwMinOverlayStretch */
1000, /* dwMaxOverlayStretch */
1000, /* dwMinLiveVideoStretch */
1000, /* dwMaxLiveVideoStretch */
1000, /* dwMinHwCodecStretch */
1000, /* dwMaxHwCodecStretch */
0, 0, 0, /* dwReserved1, 2, 3 */
BLIT_CAPS, /* dwSVBCaps */
CKEY_CAPS, /* dwSVBCKeyCaps */
FX_CAPS, /* dwSVBFXCaps */
ROPS, /* dwSVBRops */
BLIT_CAPS, /* dwVSBCaps */
CKEY_CAPS, /* dwVSBCKeyCaps */
FX_CAPS, /* dwVSBFXCaps */
ROPS, /* dwVSBRops */
BLIT_CAPS, /* dwSSBCaps */
CKEY_CAPS, /* dwSSBCKeyCaps */
FX_CAPS, /* dwSSBFXCaps */
ROPS, /* dwSSBRops */
0, /* dwMaxVideoPorts */
0, /* dwCurrVideoPorts */
0, /* ? dwSVBCaps2 */
BLIT_CAPS, /* ? dwNLVBCaps */
0, /* ? dwNLVBCaps2 */
CKEY_CAPS, /* dwNLVBCKeyCaps */
FX_CAPS, /* dwNLVBFXCaps */
ROPS, /* dwNLVBRops */
{ /* ddsCaps */
DDSCAPS_3DDEVICE | DDSCAPS_ALPHA | DDSCAPS_BACKBUFFER | DDSCAPS_FLIP
| DDSCAPS_FRONTBUFFER | DDSCAPS_MIPMAP | DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_PALETTE | DDSCAPS_PRIMARYSURFACE | DDSCAPS_SYSTEMMEMORY
| DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_VISIBLE
| DDSCAPS_ZBUFFER,
DDSCAPS2_CUBEMAP,
0,
0
}
};
#undef BLIT_CAPS
#undef CKEY_CAPS
#undef FX_CAPS
#undef ROPS
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
TRACE("(%p)->(%p,%p)\n",This,pDriverCaps,pHELCaps);
if (pDriverCaps != NULL)
DD_STRUCT_COPY_BYSIZE(pDriverCaps,&caps);
if (pHELCaps != NULL)
DD_STRUCT_COPY_BYSIZE(pHELCaps,&caps);
return DD_OK;
}
#endif
HRESULT WINAPI
User_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7 iface,
LPDDDEVICEIDENTIFIER2 pDDDI,
DWORD dwFlags)
{
TRACE("(%p)->(%p,%08lx)\n",iface,pDDDI,dwFlags);
*pDDDI = user_device;
return DD_OK;
}
/* GetDisplayMode: generic */
/* GetFourCCCodes: generic */
/* GetGDISurface: ??? */
/* GetMonitorFrequency: generic */
/* GetScanLine: generic */
/* GetSurfaceFromDC: generic */
/* GetVerticalBlankStatus: generic */
/* Initialize: generic */
/* RestoreAllSurfaces: generic */
/* RestoreDisplayMode: generic */
/* SetCooperativeLevel: ??? */
HRESULT WINAPI
User_DirectDraw_SetDisplayMode(LPDIRECTDRAW7 iface, DWORD dwWidth,
DWORD dwHeight, DWORD dwBPP,
DWORD dwRefreshRate, DWORD dwFlags)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
const DDPIXELFORMAT* pixelformat;
DEVMODEW devmode;
LONG pitch;
TRACE("(%p)->(%ldx%ldx%ld,%ld Hz,%08lx)\n",This,dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags);
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
devmode.dmBitsPerPel = dwBPP;
devmode.dmPelsWidth = dwWidth;
devmode.dmPelsHeight = dwHeight;
/* '0' means default frequency */
if (dwRefreshRate != 0)
{
devmode.dmFields |= DM_DISPLAYFREQUENCY;
devmode.dmDisplayFrequency = dwRefreshRate;
}
if (ChangeDisplaySettingsExW(NULL, &devmode, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
return DDERR_INVALIDMODE;
pixelformat = pixelformat_for_depth(dwBPP);
if (pixelformat == NULL)
{
assert(0);
return DDERR_GENERIC;
}
pitch = DDRAW_width_bpp_to_pitch(dwWidth, dwBPP);
return Main_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, pitch,
dwRefreshRate, dwFlags, pixelformat);
}
/* StartModeTest: ??? */
/* TestCooperativeLevel: generic? */
/* WaitForVerticalBlank: ??? */
static const IDirectDraw7Vtbl User_DirectDraw_VTable =
{
Main_DirectDraw_QueryInterface,
Main_DirectDraw_AddRef,
Main_DirectDraw_Release,
Main_DirectDraw_Compact,
Main_DirectDraw_CreateClipper,
Main_DirectDraw_CreatePalette,
Main_DirectDraw_CreateSurface,
Main_DirectDraw_DuplicateSurface,
User_DirectDraw_EnumDisplayModes,
Main_DirectDraw_EnumSurfaces,
Main_DirectDraw_FlipToGDISurface,
Main_DirectDraw_GetCaps,
Main_DirectDraw_GetDisplayMode,
Main_DirectDraw_GetFourCCCodes,
Main_DirectDraw_GetGDISurface,
Main_DirectDraw_GetMonitorFrequency,
Main_DirectDraw_GetScanLine,
Main_DirectDraw_GetVerticalBlankStatus,
Main_DirectDraw_Initialize,
Main_DirectDraw_RestoreDisplayMode,
Main_DirectDraw_SetCooperativeLevel,
User_DirectDraw_SetDisplayMode,
Main_DirectDraw_WaitForVerticalBlank,
Main_DirectDraw_GetAvailableVidMem,
Main_DirectDraw_GetSurfaceFromDC,
Main_DirectDraw_RestoreAllSurfaces,
Main_DirectDraw_TestCooperativeLevel,
User_DirectDraw_GetDeviceIdentifier,
Main_DirectDraw_StartModeTest,
Main_DirectDraw_EvaluateMode
};

View File

@ -1,951 +0,0 @@
/*
* DirectDraw helper functions
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
* Copyright 2000 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "wine/debug.h"
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "ddraw.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* *************************************
16 / 15 bpp to palettized 8 bpp
************************************* */
static void pixel_convert_16_to_8(void *src, void *dst, DWORD width, DWORD height, LONG pitch, IDirectDrawPaletteImpl* palette) {
unsigned char *c_src = (unsigned char *) src;
unsigned short *c_dst = (unsigned short *) dst;
int y;
if (palette != NULL) {
const unsigned int * pal = (unsigned int *) palette->screen_palents;
for (y = height; y--; ) {
#if defined(__i386__) && defined(__GNUC__)
/* gcc generates slightly inefficient code for the the copy/lookup,
* it generates one excess memory access (to pal) per pixel. Since
* we know that pal is not modified by the memory write we can
* put it into a register and reduce the number of memory accesses
* from 4 to 3 pp. There are two xor eax,eax to avoid pipeline
* stalls. (This is not guaranteed to be the fastest method.)
*/
__asm__ __volatile__(
"xor %%eax,%%eax\n"
"1:\n"
" lodsb\n"
" movw (%%edx,%%eax,4),%%ax\n"
" stosw\n"
" xor %%eax,%%eax\n"
" loop 1b\n"
: "=S" (c_src), "=D" (c_dst)
: "S" (c_src), "D" (c_dst) , "c" (width), "d" (pal)
: "eax", "cc", "memory"
);
c_src+=(pitch-width);
#else
unsigned char * srclineend = c_src+width;
while (c_src < srclineend)
*c_dst++ = pal[*c_src++];
c_src+=(pitch-width);
#endif
}
} else {
FIXME("No palette set...\n");
memset(dst, 0, width * height * 2);
}
}
static void palette_convert_16_to_8(
LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count
) {
unsigned int i;
unsigned int *pal = (unsigned int *) screen_palette;
for (i = 0; i < count; i++)
pal[start + i] = (((((unsigned short) palent[i].peRed) & 0xF8) << 8) |
((((unsigned short) palent[i].peBlue) & 0xF8) >> 3) |
((((unsigned short) palent[i].peGreen) & 0xFC) << 3));
}
static void palette_convert_15_to_8(
LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count
) {
unsigned int i;
unsigned int *pal = (unsigned int *) screen_palette;
for (i = 0; i < count; i++)
pal[start + i] = (((((unsigned short) palent[i].peRed) & 0xF8) << 7) |
((((unsigned short) palent[i].peBlue) & 0xF8) >> 3) |
((((unsigned short) palent[i].peGreen) & 0xF8) << 2));
}
/* *************************************
24 to palettized 8 bpp
************************************* */
static void pixel_convert_24_to_8(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned char *c_src = (unsigned char *) src;
unsigned char *c_dst = (unsigned char *) dst;
int y;
if (palette != NULL) {
const unsigned int *pal = (unsigned int *) palette->screen_palents;
for (y = height; y--; ) {
unsigned char * srclineend = c_src+width;
while (c_src < srclineend ) {
register long pixel = pal[*c_src++];
*c_dst++ = pixel;
*c_dst++ = pixel>>8;
*c_dst++ = pixel>>16;
}
c_src+=(pitch-width);
}
} else {
FIXME("No palette set...\n");
memset(dst, 0, width * height * 3);
}
}
/* *************************************
32 bpp to palettized 8 bpp
************************************* */
static void pixel_convert_32_to_8(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned char *c_src = (unsigned char *) src;
unsigned int *c_dst = (unsigned int *) dst;
int y;
if (palette != NULL) {
const unsigned int *pal = (unsigned int *) palette->screen_palents;
for (y = height; y--; ) {
#if defined(__i386__) && defined(__GNUC__)
/* See comment in pixel_convert_16_to_8 */
__asm__ __volatile__(
"xor %%eax,%%eax\n"
"1:\n"
" lodsb\n"
" movl (%%edx,%%eax,4),%%eax\n"
" stosl\n"
" xor %%eax,%%eax\n"
" loop 1b\n"
: "=S" (c_src), "=D" (c_dst)
: "S" (c_src), "D" (c_dst) , "c" (width), "d" (pal)
: "eax", "cc", "memory"
);
c_src+=(pitch-width);
#else
unsigned char * srclineend = c_src+width;
while (c_src < srclineend )
*c_dst++ = pal[*c_src++];
c_src+=(pitch-width);
#endif
}
} else {
FIXME("No palette set...\n");
memset(dst, 0, width * height * 4);
}
}
static void palette_convert_24_to_8(
LPPALETTEENTRY palent, void *screen_palette, DWORD start, DWORD count
) {
unsigned int i;
unsigned int *pal = (unsigned int *) screen_palette;
for (i = 0; i < count; i++)
pal[start + i] = ((((unsigned int) palent[i].peRed) << 16) |
(((unsigned int) palent[i].peGreen) << 8) |
((unsigned int) palent[i].peBlue));
}
/* *************************************
16 bpp to 15 bpp
************************************* */
static void pixel_convert_15_to_16(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned short *c_src = (unsigned short *) src;
unsigned short *c_dst = (unsigned short *) dst;
int y;
for (y = height; y--; ) {
unsigned short * srclineend = c_src+width;
while (c_src < srclineend ) {
unsigned short val = *c_src++;
*c_dst++=((val&0xFFC0)>>1)|(val&0x001f);
}
c_src+=((pitch/2)-width);
}
}
/* *************************************
32 bpp to 16 bpp
************************************* */
static void pixel_convert_32_to_16(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned short *c_src = (unsigned short *) src;
unsigned int *c_dst = (unsigned int *) dst;
int y;
for (y = height; y--; ) {
unsigned short * srclineend = c_src+width;
while (c_src < srclineend ) {
*c_dst++ = (((*c_src & 0xF800) << 8) |
((*c_src & 0x07E0) << 5) |
((*c_src & 0x001F) << 3));
c_src++;
}
c_src+=((pitch/2)-width);
}
}
/* *************************************
32 bpp to 24 bpp
************************************* */
static void pixel_convert_32_to_24(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned char *c_src = (unsigned char *) src;
unsigned int *c_dst = (unsigned int *) dst;
int y;
for (y = height; y--; ) {
unsigned char * srclineend = c_src+width*3;
while (c_src < srclineend ) {
/* FIXME: wrong for big endian */
memcpy(c_dst,c_src,3);
c_src+=3;
c_dst++;
}
c_src+=pitch-width*3;
}
}
/* *************************************
16 bpp to 32 bpp
************************************* */
static void pixel_convert_16_to_32(
void *src, void *dst, DWORD width, DWORD height, LONG pitch,
IDirectDrawPaletteImpl* palette
) {
unsigned int *c_src = (unsigned int *) src;
unsigned short *c_dst = (unsigned short *) dst;
int y;
for (y = height; y--; ) {
unsigned int * srclineend = c_src+width;
while (c_src < srclineend ) {
*c_dst++ = (((*c_src & 0xF80000) >> 8) |
((*c_src & 0x00FC00) >> 5) |
((*c_src & 0x0000F8) >> 3));
c_src++;
}
c_src+=((pitch/4)-width);
}
}
Convert ModeEmulations[8] = {
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { pixel_convert_32_to_24, NULL } },
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 16, 16, 0xF800, 0x07E0, 0x001F }, { pixel_convert_32_to_16, NULL } },
{ { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_32_to_8, palette_convert_24_to_8 } },
{ { 24, 24, 0xFF0000, 0x00FF00, 0x0000FF }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_24_to_8, palette_convert_24_to_8 } },
{ { 16, 15, 0x7C00, 0x03E0, 0x001F }, { 16,16, 0xf800, 0x07e0, 0x001f }, { pixel_convert_15_to_16, NULL } },
{ { 16, 16, 0xF800, 0x07E0, 0x001F }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_16_to_8, palette_convert_16_to_8 } },
{ { 16, 15, 0x7C00, 0x03E0, 0x001F }, { 8, 8, 0x00, 0x00, 0x00 }, { pixel_convert_16_to_8, palette_convert_15_to_8 } },
{ { 16, 16, 0xF800, 0x07E0, 0x001F }, { 32, 24, 0x00FF0000, 0x0000FF00, 0x000000FF }, { pixel_convert_16_to_32, NULL } }
};
void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, DDSCAPS2* pOut)
{
/* 2 adds three additional caps fields to the end. Both versions
* are unversioned. */
pOut->dwCaps = pIn->dwCaps;
pOut->dwCaps2 = 0;
pOut->dwCaps3 = 0;
pOut->dwCaps4 = 0;
}
void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
DDDEVICEIDENTIFIER* pOut)
{
/* 2 adds a dwWHQLLevel field to the end. Both structures are
* unversioned. */
memcpy(pOut, pIn, sizeof(*pOut));
}
/******************************************************************************
* debug output functions
*/
void DDRAW_dump_flags_(DWORD flags, const flag_info* names,
size_t num_names, int newline)
{
unsigned int i;
for (i=0; i < num_names; i++)
if ((flags & names[i].val) || /* standard flag value */
((!flags) && (!names[i].val))) /* zero value only */
DPRINTF("%s ", names[i].name);
if (newline)
DPRINTF("\n");
}
void DDRAW_dump_members(DWORD flags, const void* data,
const member_info* mems, size_t num_mems)
{
unsigned int i;
for (i=0; i < num_mems; i++)
{
if (mems[i].val & flags)
{
DPRINTF(" - %s : ", mems[i].name);
mems[i].func((const char *)data + mems[i].offset);
DPRINTF("\n");
}
}
}
void DDRAW_dump_DDBLTFX(DWORD flagmask)
{
static const flag_info flags[] =
{
FE(DDBLTFX_ARITHSTRETCHY),
FE(DDBLTFX_MIRRORLEFTRIGHT),
FE(DDBLTFX_MIRRORUPDOWN),
FE(DDBLTFX_NOTEARING),
FE(DDBLTFX_ROTATE180),
FE(DDBLTFX_ROTATE270),
FE(DDBLTFX_ROTATE90),
FE(DDBLTFX_ZBUFFERRANGE),
FE(DDBLTFX_ZBUFFERBASEDEST)
};
DDRAW_dump_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
void DDRAW_dump_DDBLTFAST(DWORD flagmask)
{
static const flag_info flags[] =
{
FE(DDBLTFAST_NOCOLORKEY),
FE(DDBLTFAST_SRCCOLORKEY),
FE(DDBLTFAST_DESTCOLORKEY),
FE(DDBLTFAST_WAIT)
};
DDRAW_dump_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
void DDRAW_dump_DDBLT(DWORD flagmask)
{
static const flag_info flags[] =
{
FE(DDBLT_ALPHADEST),
FE(DDBLT_ALPHADESTCONSTOVERRIDE),
FE(DDBLT_ALPHADESTNEG),
FE(DDBLT_ALPHADESTSURFACEOVERRIDE),
FE(DDBLT_ALPHAEDGEBLEND),
FE(DDBLT_ALPHASRC),
FE(DDBLT_ALPHASRCCONSTOVERRIDE),
FE(DDBLT_ALPHASRCNEG),
FE(DDBLT_ALPHASRCSURFACEOVERRIDE),
FE(DDBLT_ASYNC),
FE(DDBLT_COLORFILL),
FE(DDBLT_DDFX),
FE(DDBLT_DDROPS),
FE(DDBLT_KEYDEST),
FE(DDBLT_KEYDESTOVERRIDE),
FE(DDBLT_KEYSRC),
FE(DDBLT_KEYSRCOVERRIDE),
FE(DDBLT_ROP),
FE(DDBLT_ROTATIONANGLE),
FE(DDBLT_ZBUFFER),
FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE),
FE(DDBLT_ZBUFFERDESTOVERRIDE),
FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE),
FE(DDBLT_ZBUFFERSRCOVERRIDE),
FE(DDBLT_WAIT),
FE(DDBLT_DEPTHFILL),
FE(DDBLT_DONOTWAIT)
};
DDRAW_dump_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in)
{
static const flag_info flags[] = {
FE(DDSCAPS_RESERVED1),
FE(DDSCAPS_ALPHA),
FE(DDSCAPS_BACKBUFFER),
FE(DDSCAPS_COMPLEX),
FE(DDSCAPS_FLIP),
FE(DDSCAPS_FRONTBUFFER),
FE(DDSCAPS_OFFSCREENPLAIN),
FE(DDSCAPS_OVERLAY),
FE(DDSCAPS_PALETTE),
FE(DDSCAPS_PRIMARYSURFACE),
FE(DDSCAPS_PRIMARYSURFACELEFT),
FE(DDSCAPS_SYSTEMMEMORY),
FE(DDSCAPS_TEXTURE),
FE(DDSCAPS_3DDEVICE),
FE(DDSCAPS_VIDEOMEMORY),
FE(DDSCAPS_VISIBLE),
FE(DDSCAPS_WRITEONLY),
FE(DDSCAPS_ZBUFFER),
FE(DDSCAPS_OWNDC),
FE(DDSCAPS_LIVEVIDEO),
FE(DDSCAPS_HWCODEC),
FE(DDSCAPS_MODEX),
FE(DDSCAPS_MIPMAP),
FE(DDSCAPS_RESERVED2),
FE(DDSCAPS_ALLOCONLOAD),
FE(DDSCAPS_VIDEOPORT),
FE(DDSCAPS_LOCALVIDMEM),
FE(DDSCAPS_NONLOCALVIDMEM),
FE(DDSCAPS_STANDARDVGAMODE),
FE(DDSCAPS_OPTIMIZED)
};
static const flag_info flags2[] = {
FE(DDSCAPS2_HARDWAREDEINTERLACE),
FE(DDSCAPS2_HINTDYNAMIC),
FE(DDSCAPS2_HINTSTATIC),
FE(DDSCAPS2_TEXTUREMANAGE),
FE(DDSCAPS2_RESERVED1),
FE(DDSCAPS2_RESERVED2),
FE(DDSCAPS2_OPAQUE),
FE(DDSCAPS2_HINTANTIALIASING),
FE(DDSCAPS2_CUBEMAP),
FE(DDSCAPS2_CUBEMAP_POSITIVEX),
FE(DDSCAPS2_CUBEMAP_NEGATIVEX),
FE(DDSCAPS2_CUBEMAP_POSITIVEY),
FE(DDSCAPS2_CUBEMAP_NEGATIVEY),
FE(DDSCAPS2_CUBEMAP_POSITIVEZ),
FE(DDSCAPS2_CUBEMAP_NEGATIVEZ),
FE(DDSCAPS2_MIPMAPSUBLEVEL),
FE(DDSCAPS2_D3DTEXTUREMANAGE),
FE(DDSCAPS2_DONOTPERSIST),
FE(DDSCAPS2_STEREOSURFACELEFT)
};
DDRAW_dump_flags_(in->dwCaps, flags, sizeof(flags)/sizeof(flags[0]), 0);
DDRAW_dump_flags_(in->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]), 0);
}
void DDRAW_dump_DDSCAPS(const DDSCAPS *in) {
DDSCAPS2 in_bis;
in_bis.dwCaps = in->dwCaps;
in_bis.dwCaps2 = 0;
in_bis.dwCaps3 = 0;
in_bis.dwCaps4 = 0;
DDRAW_dump_DDSCAPS2(&in_bis);
}
void DDRAW_dump_pixelformat_flag(DWORD flagmask)
{
static const flag_info flags[] =
{
FE(DDPF_ALPHAPIXELS),
FE(DDPF_ALPHA),
FE(DDPF_FOURCC),
FE(DDPF_PALETTEINDEXED4),
FE(DDPF_PALETTEINDEXEDTO8),
FE(DDPF_PALETTEINDEXED8),
FE(DDPF_RGB),
FE(DDPF_COMPRESSED),
FE(DDPF_RGBTOYUV),
FE(DDPF_YUV),
FE(DDPF_ZBUFFER),
FE(DDPF_PALETTEINDEXED1),
FE(DDPF_PALETTEINDEXED2),
FE(DDPF_ZPIXELS)
};
DDRAW_dump_flags_(flagmask, flags, sizeof(flags)/sizeof(flags[0]), 0);
}
void DDRAW_dump_paletteformat(DWORD dwFlags)
{
static const flag_info flags[] =
{
FE(DDPCAPS_4BIT),
FE(DDPCAPS_8BITENTRIES),
FE(DDPCAPS_8BIT),
FE(DDPCAPS_INITIALIZE),
FE(DDPCAPS_PRIMARYSURFACE),
FE(DDPCAPS_PRIMARYSURFACELEFT),
FE(DDPCAPS_ALLOW256),
FE(DDPCAPS_VSYNC),
FE(DDPCAPS_1BIT),
FE(DDPCAPS_2BIT),
FE(DDPCAPS_ALPHA)
};
DDRAW_dump_flags(dwFlags, flags, sizeof(flags)/sizeof(flags[0]));
}
void DDRAW_dump_pixelformat(const DDPIXELFORMAT *pf) {
DPRINTF("( ");
DDRAW_dump_pixelformat_flag(pf->dwFlags);
if (pf->dwFlags & DDPF_FOURCC) {
DPRINTF(", dwFourCC code '%c%c%c%c' (0x%08lx) - %ld bits per pixel",
(unsigned char)( pf->dwFourCC &0xff),
(unsigned char)((pf->dwFourCC>> 8)&0xff),
(unsigned char)((pf->dwFourCC>>16)&0xff),
(unsigned char)((pf->dwFourCC>>24)&0xff),
pf->dwFourCC,
pf->u1.dwYUVBitCount
);
}
if (pf->dwFlags & DDPF_RGB) {
const char *cmd;
DPRINTF(", RGB bits: %ld, ", pf->u1.dwRGBBitCount);
switch (pf->u1.dwRGBBitCount) {
case 4: cmd = "%1lx"; break;
case 8: cmd = "%02lx"; break;
case 16: cmd = "%04lx"; break;
case 24: cmd = "%06lx"; break;
case 32: cmd = "%08lx"; break;
default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
}
DPRINTF(" R "); DPRINTF(cmd, pf->u2.dwRBitMask);
DPRINTF(" G "); DPRINTF(cmd, pf->u3.dwGBitMask);
DPRINTF(" B "); DPRINTF(cmd, pf->u4.dwBBitMask);
if (pf->dwFlags & DDPF_ALPHAPIXELS) {
DPRINTF(" A "); DPRINTF(cmd, pf->u5.dwRGBAlphaBitMask);
}
if (pf->dwFlags & DDPF_ZPIXELS) {
DPRINTF(" Z "); DPRINTF(cmd, pf->u5.dwRGBZBitMask);
}
}
if (pf->dwFlags & DDPF_ZBUFFER) {
DPRINTF(", Z bits : %ld", pf->u1.dwZBufferBitDepth);
}
if (pf->dwFlags & DDPF_ALPHA) {
DPRINTF(", Alpha bits : %ld", pf->u1.dwAlphaBitDepth);
}
DPRINTF(")");
}
void DDRAW_dump_colorkeyflag(DWORD ck)
{
static const flag_info flags[] =
{
FE(DDCKEY_COLORSPACE),
FE(DDCKEY_DESTBLT),
FE(DDCKEY_DESTOVERLAY),
FE(DDCKEY_SRCBLT),
FE(DDCKEY_SRCOVERLAY)
};
DDRAW_dump_flags(ck, flags, sizeof(flags)/sizeof(flags[0]));
}
void DDRAW_dump_lockflag(DWORD lockflag)
{
static const flag_info flags[] =
{
FE(DDLOCK_SURFACEMEMORYPTR),
FE(DDLOCK_WAIT),
FE(DDLOCK_EVENT),
FE(DDLOCK_READONLY),
FE(DDLOCK_WRITEONLY),
FE(DDLOCK_NOSYSLOCK),
FE(DDLOCK_DISCARDCONTENTS),
FE(DDLOCK_NOOVERWRITE)
};
DDRAW_dump_flags(lockflag, flags, sizeof(flags)/sizeof(flags[0]));
}
static void DDRAW_dump_DWORD(const void *in) {
DPRINTF("%ld", *((const DWORD *) in));
}
static void DDRAW_dump_PTR(const void *in) {
DPRINTF("%p", *((const void * const*) in));
}
void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY *ddck) {
DPRINTF(" Low : %ld - High : %ld", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
}
void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd)
{
#define STRUCT DDSURFACEDESC2
static const member_info members[] =
{
ME(DDSD_HEIGHT, DDRAW_dump_DWORD, dwHeight),
ME(DDSD_WIDTH, DDRAW_dump_DWORD, dwWidth),
ME(DDSD_PITCH, DDRAW_dump_DWORD, u1.lPitch),
ME(DDSD_LINEARSIZE, DDRAW_dump_DWORD, u1.dwLinearSize),
ME(DDSD_BACKBUFFERCOUNT, DDRAW_dump_DWORD, dwBackBufferCount),
ME(DDSD_MIPMAPCOUNT, DDRAW_dump_DWORD, u2.dwMipMapCount),
ME(DDSD_ZBUFFERBITDEPTH, DDRAW_dump_DWORD, u2.dwMipMapCount), /* This is for 'old-style' D3D */
ME(DDSD_REFRESHRATE, DDRAW_dump_DWORD, u2.dwRefreshRate),
ME(DDSD_ALPHABITDEPTH, DDRAW_dump_DWORD, dwAlphaBitDepth),
ME(DDSD_LPSURFACE, DDRAW_dump_PTR, lpSurface),
ME(DDSD_CKDESTOVERLAY, DDRAW_dump_DDCOLORKEY, u3.ddckCKDestOverlay),
ME(DDSD_CKDESTBLT, DDRAW_dump_DDCOLORKEY, ddckCKDestBlt),
ME(DDSD_CKSRCOVERLAY, DDRAW_dump_DDCOLORKEY, ddckCKSrcOverlay),
ME(DDSD_CKSRCBLT, DDRAW_dump_DDCOLORKEY, ddckCKSrcBlt),
ME(DDSD_PIXELFORMAT, DDRAW_dump_pixelformat, u4.ddpfPixelFormat)
};
static const member_info members_caps[] =
{
ME(DDSD_CAPS, DDRAW_dump_DDSCAPS, ddsCaps)
};
static const member_info members_caps2[] =
{
ME(DDSD_CAPS, DDRAW_dump_DDSCAPS2, ddsCaps)
};
#undef STRUCT
if (NULL == lpddsd) {
DPRINTF("(null)\n");
} else {
if (lpddsd->dwSize >= sizeof(DDSURFACEDESC2)) {
DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps2, 1);
} else {
DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members_caps, 1);
}
DDRAW_dump_members(lpddsd->dwFlags, lpddsd, members,
sizeof(members)/sizeof(members[0]));
}
}
void DDRAW_dump_cooperativelevel(DWORD cooplevel)
{
static const flag_info flags[] =
{
FE(DDSCL_FULLSCREEN),
FE(DDSCL_ALLOWREBOOT),
FE(DDSCL_NOWINDOWCHANGES),
FE(DDSCL_NORMAL),
FE(DDSCL_ALLOWMODEX),
FE(DDSCL_EXCLUSIVE),
FE(DDSCL_SETFOCUSWINDOW),
FE(DDSCL_SETDEVICEWINDOW),
FE(DDSCL_CREATEDEVICEWINDOW)
};
if (TRACE_ON(ddraw))
{
DPRINTF(" - ");
DDRAW_dump_flags(cooplevel, flags, sizeof(flags)/sizeof(flags[0]));
}
}
void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) {
static const flag_info flags1[] = {
FE(DDCAPS_3D),
FE(DDCAPS_ALIGNBOUNDARYDEST),
FE(DDCAPS_ALIGNSIZEDEST),
FE(DDCAPS_ALIGNBOUNDARYSRC),
FE(DDCAPS_ALIGNSIZESRC),
FE(DDCAPS_ALIGNSTRIDE),
FE(DDCAPS_BLT),
FE(DDCAPS_BLTQUEUE),
FE(DDCAPS_BLTFOURCC),
FE(DDCAPS_BLTSTRETCH),
FE(DDCAPS_GDI),
FE(DDCAPS_OVERLAY),
FE(DDCAPS_OVERLAYCANTCLIP),
FE(DDCAPS_OVERLAYFOURCC),
FE(DDCAPS_OVERLAYSTRETCH),
FE(DDCAPS_PALETTE),
FE(DDCAPS_PALETTEVSYNC),
FE(DDCAPS_READSCANLINE),
FE(DDCAPS_STEREOVIEW),
FE(DDCAPS_VBI),
FE(DDCAPS_ZBLTS),
FE(DDCAPS_ZOVERLAYS),
FE(DDCAPS_COLORKEY),
FE(DDCAPS_ALPHA),
FE(DDCAPS_COLORKEYHWASSIST),
FE(DDCAPS_NOHARDWARE),
FE(DDCAPS_BLTCOLORFILL),
FE(DDCAPS_BANKSWITCHED),
FE(DDCAPS_BLTDEPTHFILL),
FE(DDCAPS_CANCLIP),
FE(DDCAPS_CANCLIPSTRETCHED),
FE(DDCAPS_CANBLTSYSMEM)
};
static const flag_info flags2[] = {
FE(DDCAPS2_CERTIFIED),
FE(DDCAPS2_NO2DDURING3DSCENE),
FE(DDCAPS2_VIDEOPORT),
FE(DDCAPS2_AUTOFLIPOVERLAY),
FE(DDCAPS2_CANBOBINTERLEAVED),
FE(DDCAPS2_CANBOBNONINTERLEAVED),
FE(DDCAPS2_COLORCONTROLOVERLAY),
FE(DDCAPS2_COLORCONTROLPRIMARY),
FE(DDCAPS2_CANDROPZ16BIT),
FE(DDCAPS2_NONLOCALVIDMEM),
FE(DDCAPS2_NONLOCALVIDMEMCAPS),
FE(DDCAPS2_NOPAGELOCKREQUIRED),
FE(DDCAPS2_WIDESURFACES),
FE(DDCAPS2_CANFLIPODDEVEN),
FE(DDCAPS2_CANBOBHARDWARE),
FE(DDCAPS2_COPYFOURCC),
FE(DDCAPS2_PRIMARYGAMMA),
FE(DDCAPS2_CANRENDERWINDOWED),
FE(DDCAPS2_CANCALIBRATEGAMMA),
FE(DDCAPS2_FLIPINTERVAL),
FE(DDCAPS2_FLIPNOVSYNC),
FE(DDCAPS2_CANMANAGETEXTURE),
FE(DDCAPS2_TEXMANINNONLOCALVIDMEM),
FE(DDCAPS2_STEREO),
FE(DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL)
};
static const flag_info flags3[] = {
FE(DDCKEYCAPS_DESTBLT),
FE(DDCKEYCAPS_DESTBLTCLRSPACE),
FE(DDCKEYCAPS_DESTBLTCLRSPACEYUV),
FE(DDCKEYCAPS_DESTBLTYUV),
FE(DDCKEYCAPS_DESTOVERLAY),
FE(DDCKEYCAPS_DESTOVERLAYCLRSPACE),
FE(DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV),
FE(DDCKEYCAPS_DESTOVERLAYONEACTIVE),
FE(DDCKEYCAPS_DESTOVERLAYYUV),
FE(DDCKEYCAPS_SRCBLT),
FE(DDCKEYCAPS_SRCBLTCLRSPACE),
FE(DDCKEYCAPS_SRCBLTCLRSPACEYUV),
FE(DDCKEYCAPS_SRCBLTYUV),
FE(DDCKEYCAPS_SRCOVERLAY),
FE(DDCKEYCAPS_SRCOVERLAYCLRSPACE),
FE(DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV),
FE(DDCKEYCAPS_SRCOVERLAYONEACTIVE),
FE(DDCKEYCAPS_SRCOVERLAYYUV),
FE(DDCKEYCAPS_NOCOSTOVERLAY)
};
static const flag_info flags4[] = {
FE(DDFXCAPS_BLTALPHA),
FE(DDFXCAPS_OVERLAYALPHA),
FE(DDFXCAPS_BLTARITHSTRETCHYN),
FE(DDFXCAPS_BLTARITHSTRETCHY),
FE(DDFXCAPS_BLTMIRRORLEFTRIGHT),
FE(DDFXCAPS_BLTMIRRORUPDOWN),
FE(DDFXCAPS_BLTROTATION),
FE(DDFXCAPS_BLTROTATION90),
FE(DDFXCAPS_BLTSHRINKX),
FE(DDFXCAPS_BLTSHRINKXN),
FE(DDFXCAPS_BLTSHRINKY),
FE(DDFXCAPS_BLTSHRINKYN),
FE(DDFXCAPS_BLTSTRETCHX),
FE(DDFXCAPS_BLTSTRETCHXN),
FE(DDFXCAPS_BLTSTRETCHY),
FE(DDFXCAPS_BLTSTRETCHYN),
FE(DDFXCAPS_OVERLAYARITHSTRETCHY),
FE(DDFXCAPS_OVERLAYARITHSTRETCHYN),
FE(DDFXCAPS_OVERLAYSHRINKX),
FE(DDFXCAPS_OVERLAYSHRINKXN),
FE(DDFXCAPS_OVERLAYSHRINKY),
FE(DDFXCAPS_OVERLAYSHRINKYN),
FE(DDFXCAPS_OVERLAYSTRETCHX),
FE(DDFXCAPS_OVERLAYSTRETCHXN),
FE(DDFXCAPS_OVERLAYSTRETCHY),
FE(DDFXCAPS_OVERLAYSTRETCHYN),
FE(DDFXCAPS_OVERLAYMIRRORLEFTRIGHT),
FE(DDFXCAPS_OVERLAYMIRRORUPDOWN)
};
static const flag_info flags5[] = {
FE(DDFXALPHACAPS_BLTALPHAEDGEBLEND),
FE(DDFXALPHACAPS_BLTALPHAPIXELS),
FE(DDFXALPHACAPS_BLTALPHAPIXELSNEG),
FE(DDFXALPHACAPS_BLTALPHASURFACES),
FE(DDFXALPHACAPS_BLTALPHASURFACESNEG),
FE(DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND),
FE(DDFXALPHACAPS_OVERLAYALPHAPIXELS),
FE(DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG),
FE(DDFXALPHACAPS_OVERLAYALPHASURFACES),
FE(DDFXALPHACAPS_OVERLAYALPHASURFACESNEG)
};
static const flag_info flags6[] = {
FE(DDPCAPS_4BIT),
FE(DDPCAPS_8BITENTRIES),
FE(DDPCAPS_8BIT),
FE(DDPCAPS_INITIALIZE),
FE(DDPCAPS_PRIMARYSURFACE),
FE(DDPCAPS_PRIMARYSURFACELEFT),
FE(DDPCAPS_ALLOW256),
FE(DDPCAPS_VSYNC),
FE(DDPCAPS_1BIT),
FE(DDPCAPS_2BIT),
FE(DDPCAPS_ALPHA),
};
static const flag_info flags7[] = {
FE(DDSVCAPS_RESERVED1),
FE(DDSVCAPS_RESERVED2),
FE(DDSVCAPS_RESERVED3),
FE(DDSVCAPS_RESERVED4),
FE(DDSVCAPS_STEREOSEQUENTIAL),
};
DPRINTF(" - dwSize : %ld\n", lpcaps->dwSize);
DPRINTF(" - dwCaps : "); DDRAW_dump_flags(lpcaps->dwCaps, flags1, sizeof(flags1)/sizeof(flags1[0]));
DPRINTF(" - dwCaps2 : "); DDRAW_dump_flags(lpcaps->dwCaps2, flags2, sizeof(flags2)/sizeof(flags2[0]));
DPRINTF(" - dwCKeyCaps : "); DDRAW_dump_flags(lpcaps->dwCKeyCaps, flags3, sizeof(flags3)/sizeof(flags3[0]));
DPRINTF(" - dwFXCaps : "); DDRAW_dump_flags(lpcaps->dwFXCaps, flags4, sizeof(flags4)/sizeof(flags4[0]));
DPRINTF(" - dwFXAlphaCaps : "); DDRAW_dump_flags(lpcaps->dwFXAlphaCaps, flags5, sizeof(flags5)/sizeof(flags5[0]));
DPRINTF(" - dwPalCaps : "); DDRAW_dump_flags(lpcaps->dwPalCaps, flags6, sizeof(flags6)/sizeof(flags6[0]));
DPRINTF(" - dwSVCaps : "); DDRAW_dump_flags(lpcaps->dwSVCaps, flags7, sizeof(flags7)/sizeof(flags7[0]));
DPRINTF("...\n");
DPRINTF(" - dwNumFourCCCodes : %ld\n", lpcaps->dwNumFourCCCodes);
DPRINTF(" - dwCurrVisibleOverlays : %ld\n", lpcaps->dwCurrVisibleOverlays);
DPRINTF(" - dwMinOverlayStretch : %ld\n", lpcaps->dwMinOverlayStretch);
DPRINTF(" - dwMaxOverlayStretch : %ld\n", lpcaps->dwMaxOverlayStretch);
DPRINTF("...\n");
DPRINTF(" - ddsCaps : "); DDRAW_dump_DDSCAPS2(&lpcaps->ddsCaps); DPRINTF("\n");
}
void DDRAW_dump_DDENUMSURFACES(DWORD flagmask)
{
static const flag_info flags[] =
{
FE(DDENUMSURFACES_ALL),
FE(DDENUMSURFACES_MATCH),
FE(DDENUMSURFACES_NOMATCH),
FE(DDENUMSURFACES_CANBECREATED),
FE(DDENUMSURFACES_DOESEXIST)
};
DDRAW_dump_flags(flagmask, flags, sizeof(flags)/sizeof(flags[0]));
}
/* Debug function that can be helpful to debug various surface-related problems */
static int get_shift(DWORD color_mask) {
int shift = 0;
while (color_mask > 0xFF) {
color_mask >>= 1;
shift += 1;
}
while ((color_mask & 0x80) == 0) {
color_mask <<= 1;
shift -= 1;
}
return shift;
}
void DDRAW_dump_surface_to_disk(IDirectDrawSurfaceImpl *surface, FILE *f, int scale)
{
int rwidth, rheight, x, y;
static char *output = NULL;
static int size = 0;
rwidth = (surface->surface_desc.dwWidth + scale - 1) / scale;
rheight = (surface->surface_desc.dwHeight + scale - 1) / scale;
if (rwidth > size) {
output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, rwidth * 3);
size = rwidth;
}
fprintf(f, "P6\n%d %d\n255\n", rwidth, rheight);
if (surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) {
unsigned char table[256][3];
int i;
if (surface->palette == NULL) {
fclose(f);
return;
}
for (i = 0; i < 256; i++) {
table[i][0] = surface->palette->palents[i].peRed;
table[i][1] = surface->palette->palents[i].peGreen;
table[i][2] = surface->palette->palents[i].peBlue;
}
for (y = 0; y < rheight; y++) {
unsigned char *src = (unsigned char *) surface->surface_desc.lpSurface + (y * scale * surface->surface_desc.u1.lPitch);
for (x = 0; x < rwidth; x++) {
unsigned char color = *src;
src += scale;
output[3 * x + 0] = table[color][0];
output[3 * x + 1] = table[color][1];
output[3 * x + 2] = table[color][2];
}
fwrite(output, 3 * rwidth, 1, f);
}
} else if (surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_RGB) {
int red_shift, green_shift, blue_shift, pix_width;
if (surface->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 8) {
pix_width = 1;
} else if (surface->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) {
pix_width = 2;
} else if (surface->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) {
pix_width = 4;
} else {
pix_width = 3;
}
red_shift = get_shift(surface->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask);
green_shift = get_shift(surface->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask);
blue_shift = get_shift(surface->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask);
for (y = 0; y < rheight; y++) {
unsigned char *src = (unsigned char *) surface->surface_desc.lpSurface + (y * scale * surface->surface_desc.u1.lPitch);
for (x = 0; x < rwidth; x++) {
unsigned int color;
unsigned int comp;
int i;
color = 0;
for (i = 0; i < pix_width; i++) {
color |= src[i] << (8 * i);
}
src += scale * pix_width;
comp = color & surface->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask;
output[3 * x + 0] = red_shift > 0 ? comp >> red_shift : comp << -red_shift;
comp = color & surface->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask;
output[3 * x + 1] = green_shift > 0 ? comp >> green_shift : comp << -green_shift;
comp = color & surface->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask;
output[3 * x + 2] = blue_shift > 0 ? comp >> blue_shift : comp << -blue_shift;
}
fwrite(output, 3 * rwidth, 1, f);
}
}
fclose(f);
}

4574
dlls/ddraw/device.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1394
dlls/ddraw/direct3d.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,439 +0,0 @@
/*
* Copyright 2000 Marcus Meissner
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "ddraw.h"
#include "d3d.h"
#include "wine/debug.h"
#include "d3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
HRESULT WINAPI
Main_IDirect3DImpl_1_Initialize(LPDIRECT3D iface,
REFIID riid)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
TRACE("(%p/%p)->(%s) no-op...\n", This, iface, debugstr_guid(riid));
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface,
LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
LPVOID lpUserArg)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface,
LPDIRECT3DLIGHT* lplpDirect3DLight,
IUnknown* pUnkOuter)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DLight, pUnkOuter);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface,
LPDIRECT3DMATERIAL3* lplpDirect3DMaterial3,
IUnknown* pUnkOuter)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DMaterial3, pUnkOuter);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface,
LPDIRECT3DVIEWPORT3* lplpD3DViewport3,
IUnknown* pUnkOuter)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpD3DViewport3, pUnkOuter);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface,
LPD3DFINDDEVICESEARCH lpD3DDFS,
LPD3DFINDDEVICERESULT lpD3DFDR)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface,
REFCLSID rclsid,
LPDIRECTDRAWSURFACE lpDDS,
LPDIRECT3DDEVICE2* lplpD3DDevice2)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice2);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface,
REFCLSID rclsid,
LPDIRECTDRAWSURFACE4 lpDDS,
LPDIRECT3DDEVICE3* lplpD3DDevice3,
LPUNKNOWN lpUnk)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
FIXME("(%p/%p)->(%s,%p,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice3, lpUnk);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface,
REFCLSID riidDevice,
LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
LPVOID lpContext)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_7_3T_EvictManagedTextures(LPDIRECT3D7 iface)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
FIXME("(%p/%p)->(): stub!\n", This, iface);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface,
LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback,
LPVOID lpUserArg)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface,
REFCLSID rclsid,
LPDIRECTDRAWSURFACE7 lpDDS,
LPDIRECT3DDEVICE7* lplpD3DDevice)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface,
LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags);
return D3D_OK;
}
HRESULT WINAPI
Thunk_IDirect3DImpl_7_QueryInterface(LPDIRECT3D7 iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface),
riid,
obp);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_3_QueryInterface(LPDIRECT3D3 iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface),
riid,
obp);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_2_QueryInterface(LPDIRECT3D2 iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface),
riid,
obp);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_1_QueryInterface(LPDIRECT3D iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface),
riid,
obp);
}
ULONG WINAPI
Thunk_IDirect3DImpl_7_AddRef(LPDIRECT3D7 iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_3_AddRef(LPDIRECT3D3 iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_2_AddRef(LPDIRECT3D2 iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_1_AddRef(LPDIRECT3D iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_7_Release(LPDIRECT3D7 iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_3_Release(LPDIRECT3D3 iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_2_Release(LPDIRECT3D2 iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface));
}
ULONG WINAPI
Thunk_IDirect3DImpl_1_Release(LPDIRECT3D iface)
{
TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface));
}
HRESULT WINAPI
Thunk_IDirect3DImpl_3_EnumZBufferFormats(LPDIRECT3D3 iface,
REFCLSID riidDevice,
LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
LPVOID lpContext)
{
TRACE("(%p)->(%s,%p,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
return IDirect3D7_EnumZBufferFormats(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface),
riidDevice,
lpEnumCallback,
lpContext);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_3_EvictManagedTextures(LPDIRECT3D3 iface)
{
TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
return IDirect3D7_EvictManagedTextures(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface));
}
HRESULT WINAPI
Thunk_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface,
LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
LPVOID lpUserArg)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpEnumDevicesCallback, lpUserArg);
return IDirect3D3_EnumDevices(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
lpEnumDevicesCallback,
lpUserArg);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_2_CreateLight(LPDIRECT3D2 iface,
LPDIRECT3DLIGHT* lplpDirect3DLight,
IUnknown* pUnkOuter)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter);
return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
lplpDirect3DLight,
pUnkOuter);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_1_CreateLight(LPDIRECT3D iface,
LPDIRECT3DLIGHT* lplpDirect3DLight,
IUnknown* pUnkOuter)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter);
return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
lplpDirect3DLight,
pUnkOuter);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_1_CreateMaterial(LPDIRECT3D iface,
LPDIRECT3DMATERIAL* lplpDirect3DMaterial,
IUnknown* pUnkOuter)
{
HRESULT ret;
LPDIRECT3DMATERIAL3 ret_val;
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial, pUnkOuter);
ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
&ret_val,
pUnkOuter);
*lplpDirect3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, ret_val);
TRACE(" returning interface %p.\n", *lplpDirect3DMaterial);
return ret;
}
HRESULT WINAPI
Thunk_IDirect3DImpl_1_CreateViewport(LPDIRECT3D iface,
LPDIRECT3DVIEWPORT* lplpD3DViewport,
IUnknown* pUnkOuter)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport, pUnkOuter);
return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
(LPDIRECT3DVIEWPORT3 *) lplpD3DViewport /* No need to cast here */,
pUnkOuter);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_2_CreateMaterial(LPDIRECT3D2 iface,
LPDIRECT3DMATERIAL2* lplpDirect3DMaterial2,
IUnknown* pUnkOuter)
{
HRESULT ret;
LPDIRECT3DMATERIAL3 ret_val;
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial2, pUnkOuter);
ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
&ret_val,
pUnkOuter);
*lplpDirect3DMaterial2 = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, ret_val);
TRACE(" returning interface %p.\n", *lplpDirect3DMaterial2);
return ret;
}
HRESULT WINAPI
Thunk_IDirect3DImpl_2_CreateViewport(LPDIRECT3D2 iface,
LPDIRECT3DVIEWPORT2* lplpD3DViewport2,
IUnknown* pUnkOuter)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport2, pUnkOuter);
return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
(LPDIRECT3DVIEWPORT3 *) lplpD3DViewport2 /* No need to cast here */,
pUnkOuter);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_3_CreateVertexBuffer(LPDIRECT3D3 iface,
LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
LPDIRECT3DVERTEXBUFFER* lplpD3DVertBuf,
DWORD dwFlags,
LPUNKNOWN lpUnk)
{
HRESULT ret;
LPDIRECT3DVERTEXBUFFER7 ret_val;
TRACE("(%p)->(%p,%p,%08lx,%p) thunking to IDirect3D7 interface.\n", iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags, lpUnk);
/* dwFlags is not used in the D3D7 interface, use the vertex buffer description instead */
if (dwFlags & D3DDP_DONOTCLIP) lpD3DVertBufDesc->dwCaps |= D3DVBCAPS_DONOTCLIP;
ret = IDirect3D7_CreateVertexBuffer(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface),
lpD3DVertBufDesc,
&ret_val,
dwFlags);
*lplpD3DVertBuf = COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, IDirect3DVertexBuffer, ret_val);
TRACE(" returning interface %p.\n", *lplpD3DVertBuf);
return ret;
}
HRESULT WINAPI
Thunk_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
LPD3DFINDDEVICESEARCH lpD3DDFS,
LPD3DFINDDEVICERESULT lplpD3DDevice)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lplpD3DDevice);
return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
lpD3DDFS,
lplpD3DDevice);
}
HRESULT WINAPI
Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
LPD3DFINDDEVICESEARCH lpD3DDFS,
LPD3DFINDDEVICERESULT lpD3DFDR)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lpD3DFDR);
return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
lpD3DDFS,
lpD3DFDR);
}

View File

@ -1,445 +0,0 @@
/*
* Copyright 2000 Marcus Meissner
* Copyright 2000 Peter Hunnisett
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <fcntl.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "d3d.h"
#include "ddraw.h"
#include "winerror.h"
#include "ddraw_private.h"
#include "d3d_private.h"
#include "opengl_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
HRESULT WINAPI
GL_IDirect3DImpl_1_EnumDevices(LPDIRECT3D iface,
LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
LPVOID lpUserArg)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
/* Call functions defined in d3ddevices.c */
if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 1) != D3DENUMRET_OK)
return D3D_OK;
return D3D_OK;
}
HRESULT WINAPI
GL_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface,
LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
LPVOID lpUserArg)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
/* Call functions defined in d3ddevices.c */
if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 2) != D3DENUMRET_OK)
return D3D_OK;
return D3D_OK;
}
HRESULT WINAPI
GL_IDirect3DImpl_3_EnumDevices(LPDIRECT3D3 iface,
LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
LPVOID lpUserArg)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
/* Call functions defined in d3ddevices.c */
if (d3ddevice_enumerate(lpEnumDevicesCallback, lpUserArg, 3) != D3DENUMRET_OK)
return D3D_OK;
return D3D_OK;
}
HRESULT WINAPI
GL_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface,
LPDIRECT3DLIGHT* lplpDirect3DLight,
IUnknown* pUnkOuter)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
IDirect3DLightImpl *d3dlimpl;
HRESULT ret_value;
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lplpDirect3DLight, pUnkOuter);
ret_value = d3dlight_create(&d3dlimpl, This);
*lplpDirect3DLight = ICOM_INTERFACE(d3dlimpl, IDirect3DLight);
return ret_value;
}
HRESULT WINAPI
GL_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface,
LPDIRECT3DMATERIAL3* lplpDirect3DMaterial3,
IUnknown* pUnkOuter)
{
IDirect3DMaterialImpl *D3Dmat_impl;
HRESULT ret_value;
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lplpDirect3DMaterial3, pUnkOuter);
ret_value = d3dmaterial_create(&D3Dmat_impl, This);
*lplpDirect3DMaterial3 = ICOM_INTERFACE(D3Dmat_impl, IDirect3DMaterial3);
return ret_value;
}
HRESULT WINAPI
GL_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface,
LPDIRECT3DVIEWPORT3* lplpD3DViewport3,
IUnknown* pUnkOuter)
{
IDirect3DViewportImpl *D3Dvp_impl;
HRESULT ret_value;
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lplpD3DViewport3, pUnkOuter);
ret_value = d3dviewport_create(&D3Dvp_impl, This);
*lplpD3DViewport3 = ICOM_INTERFACE(D3Dvp_impl, IDirect3DViewport3);
return ret_value;
}
static HRESULT
create_device_helper(IDirectDrawImpl *This,
REFCLSID iid,
IDirectDrawSurfaceImpl *lpDDS,
void **obj,
int version) {
IDirect3DDeviceImpl *lpd3ddev;
HRESULT ret_value;
ret_value = d3ddevice_create(&lpd3ddev, This, lpDDS, version);
if (FAILED(ret_value)) return ret_value;
if ((iid == NULL) ||
(IsEqualGUID(&IID_D3DDEVICE_OpenGL, iid)) ||
(IsEqualGUID(&IID_IDirect3DHALDevice, iid)) ||
(IsEqualGUID(&IID_IDirect3DTnLHalDevice, iid)) ||
(IsEqualGUID(&IID_IDirect3DRGBDevice, iid)) ||
(IsEqualGUID(&IID_IDirect3DRefDevice, iid))) {
switch (version) {
case 1:
*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice);
TRACE(" returning OpenGL D3DDevice %p.\n", *obj);
return D3D_OK;
case 2:
*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice2);
TRACE(" returning OpenGL D3DDevice2 %p.\n", *obj);
return D3D_OK;
case 3:
*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice3);
TRACE(" returning OpenGL D3DDevice3 %p.\n", *obj);
return D3D_OK;
case 7:
*obj = ICOM_INTERFACE(lpd3ddev, IDirect3DDevice7);
TRACE(" returning OpenGL D3DDevice7 %p.\n", *obj);
return D3D_OK;
}
}
*obj = NULL;
ERR(" Interface unknown when creating D3DDevice (%s)\n", debugstr_guid(iid));
IDirect3DDevice7_Release(ICOM_INTERFACE(lpd3ddev, IDirect3DDevice7));
return DDERR_INVALIDPARAMS;
}
HRESULT WINAPI
GL_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface,
REFCLSID rclsid,
LPDIRECTDRAWSURFACE lpDDS,
LPDIRECT3DDEVICE2* lplpD3DDevice2)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
IDirectDrawSurfaceImpl *ddsurfaceimpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface3, lpDDS);
TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice2);
return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice2, 2);
}
HRESULT WINAPI
GL_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface,
REFCLSID rclsid,
LPDIRECTDRAWSURFACE4 lpDDS,
LPDIRECT3DDEVICE3* lplpD3DDevice3,
LPUNKNOWN lpUnk)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
IDirectDrawSurfaceImpl *ddsurfaceimpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpDDS);
TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice3);
return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice3, 3);
}
HRESULT WINAPI
GL_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface,
LPD3DFINDDEVICESEARCH lpD3DDFS,
LPD3DFINDDEVICERESULT lpD3DFDR)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DDFS, lpD3DFDR);
return d3ddevice_find(This, lpD3DDFS, lpD3DFDR);
}
HRESULT WINAPI
GL_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface,
REFCLSID riidDevice,
LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
LPVOID lpContext)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
DDPIXELFORMAT pformat;
TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
memset(&pformat, 0, sizeof(pformat));
pformat.dwSize = sizeof(DDPIXELFORMAT);
pformat.dwFourCC = 0;
TRACE("Enumerating dummy ZBuffer format (16 bits)\n");
pformat.dwFlags = DDPF_ZBUFFER;
pformat.u1.dwZBufferBitDepth = 16;
pformat.u3.dwZBitMask = 0x0000FFFF;
pformat.u5.dwRGBZBitMask = 0x0000FFFF;
/* Whatever the return value, stop here.. */
lpEnumCallback(&pformat, lpContext);
return D3D_OK;
}
HRESULT WINAPI
GL_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface,
LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback,
LPVOID lpUserArg)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpEnumDevicesCallback, lpUserArg);
if (d3ddevice_enumerate7(lpEnumDevicesCallback, lpUserArg) != D3DENUMRET_OK)
return D3D_OK;
return D3D_OK;
}
HRESULT WINAPI
GL_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface,
REFCLSID rclsid,
LPDIRECTDRAWSURFACE7 lpDDS,
LPDIRECT3DDEVICE7* lplpD3DDevice)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
IDirectDrawSurfaceImpl *ddsurfaceimpl = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, lpDDS);
TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice);
return create_device_helper(This, rclsid, ddsurfaceimpl, (void **) lplpD3DDevice, 7);
}
HRESULT WINAPI
GL_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface,
LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
IDirect3DVertexBufferImpl *vbimpl;
HRESULT res;
TRACE("(%p/%p)->(%p,%p,%08lx)\n", This, iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags);
res = d3dvertexbuffer_create(&vbimpl, This, lpD3DVertBufDesc, dwFlags);
*lplpD3DVertBuf = ICOM_INTERFACE(vbimpl, IDirect3DVertexBuffer7);
return res;
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3D7.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3D7Vtbl VTABLE_IDirect3D7 =
{
XCAST(QueryInterface) Thunk_IDirect3DImpl_7_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DImpl_7_AddRef,
XCAST(Release) Thunk_IDirect3DImpl_7_Release,
XCAST(EnumDevices) GL_IDirect3DImpl_7_EnumDevices,
XCAST(CreateDevice) GL_IDirect3DImpl_7_CreateDevice,
XCAST(CreateVertexBuffer) GL_IDirect3DImpl_7_3T_CreateVertexBuffer,
XCAST(EnumZBufferFormats) GL_IDirect3DImpl_7_3T_EnumZBufferFormats,
XCAST(EvictManagedTextures) Main_IDirect3DImpl_7_3T_EvictManagedTextures,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3D3.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3D3Vtbl VTABLE_IDirect3D3 =
{
XCAST(QueryInterface) Thunk_IDirect3DImpl_3_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DImpl_3_AddRef,
XCAST(Release) Thunk_IDirect3DImpl_3_Release,
XCAST(EnumDevices) GL_IDirect3DImpl_3_EnumDevices,
XCAST(CreateLight) GL_IDirect3DImpl_3_2T_1T_CreateLight,
XCAST(CreateMaterial) GL_IDirect3DImpl_3_2T_1T_CreateMaterial,
XCAST(CreateViewport) GL_IDirect3DImpl_3_2T_1T_CreateViewport,
XCAST(FindDevice) GL_IDirect3DImpl_3_2T_1T_FindDevice,
XCAST(CreateDevice) GL_IDirect3DImpl_3_CreateDevice,
XCAST(CreateVertexBuffer) Thunk_IDirect3DImpl_3_CreateVertexBuffer,
XCAST(EnumZBufferFormats) Thunk_IDirect3DImpl_3_EnumZBufferFormats,
XCAST(EvictManagedTextures) Thunk_IDirect3DImpl_3_EvictManagedTextures,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3D2.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3D2Vtbl VTABLE_IDirect3D2 =
{
XCAST(QueryInterface) Thunk_IDirect3DImpl_2_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DImpl_2_AddRef,
XCAST(Release) Thunk_IDirect3DImpl_2_Release,
XCAST(EnumDevices) GL_IDirect3DImpl_2_EnumDevices,
XCAST(CreateLight) Thunk_IDirect3DImpl_2_CreateLight,
XCAST(CreateMaterial) Thunk_IDirect3DImpl_2_CreateMaterial,
XCAST(CreateViewport) Thunk_IDirect3DImpl_2_CreateViewport,
XCAST(FindDevice) Thunk_IDirect3DImpl_2_FindDevice,
XCAST(CreateDevice) GL_IDirect3DImpl_2_CreateDevice,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3D.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DVtbl VTABLE_IDirect3D =
{
XCAST(QueryInterface) Thunk_IDirect3DImpl_1_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DImpl_1_AddRef,
XCAST(Release) Thunk_IDirect3DImpl_1_Release,
XCAST(Initialize) Main_IDirect3DImpl_1_Initialize,
XCAST(EnumDevices) GL_IDirect3DImpl_1_EnumDevices,
XCAST(CreateLight) Thunk_IDirect3DImpl_1_CreateLight,
XCAST(CreateMaterial) Thunk_IDirect3DImpl_1_CreateMaterial,
XCAST(CreateViewport) Thunk_IDirect3DImpl_1_CreateViewport,
XCAST(FindDevice) Thunk_IDirect3DImpl_1_FindDevice,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
static HRESULT d3d_add_device(IDirectDrawImpl *This, IDirect3DDeviceImpl *device)
{
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.. */
IDirectDrawSurfaceImpl *surf = This->surfaces;
while (surf != NULL) {
if (surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) {
/* Found a texture.. Now create the OpenGL part */
d3dtexture_create(This, surf, FALSE, surf->mip_main);
}
surf = surf->next_ddraw;
}
}
/* For the moment, only one device 'supported'... */
This->current_device = device;
return DD_OK;
}
static HRESULT d3d_remove_device(IDirectDrawImpl *This, IDirect3DDeviceImpl *device)
{
This->current_device = NULL;
return DD_OK;
}
HRESULT direct3d_create(IDirectDrawImpl *This)
{
IDirect3DGLImpl *globject;
globject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DGLImpl));
if (globject == NULL) return DDERR_OUTOFMEMORY;
This->d3d_create_texture = d3dtexture_create;
This->d3d_added_device = d3d_add_device;
This->d3d_removed_device = d3d_remove_device;
ICOM_INIT_INTERFACE(This, IDirect3D, VTABLE_IDirect3D);
ICOM_INIT_INTERFACE(This, IDirect3D2, VTABLE_IDirect3D2);
ICOM_INIT_INTERFACE(This, IDirect3D3, VTABLE_IDirect3D3);
ICOM_INIT_INTERFACE(This, IDirect3D7, VTABLE_IDirect3D7);
This->d3d_private = globject;
TRACE(" creating OpenGL private storage at %p.\n", globject);
return D3D_OK;
}

View File

@ -1,8 +1,9 @@
/* Direct3D ExecuteBuffer
* Copyright (c) 1998-2004 Lionel ULMER
* Copyright (c) 2002-2004 Christian Costa
* Copyright (c) 2006 Stefan Dösinger
*
* This file contains the implementation of Direct3DExecuteBuffer.
* This file contains the implementation of IDirect3DExecuteBuffer.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,38 +21,45 @@
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "objbase.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
#include "d3d_private.h"
#include "opengl_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_geom);
static void _dump_d3dstatus(LPD3DSTATUS lpStatus) {
}
/*****************************************************************************
* _dump_executedata
* _dump_D3DEXECUTEBUFFERDESC
*
* Debug functions which write the executebuffer data to the console
*
*****************************************************************************/
static void _dump_executedata(LPD3DEXECUTEDATA lpData) {
DPRINTF("dwSize : %ld\n", lpData->dwSize);
DPRINTF("Vertex Offset : %ld Count : %ld\n", lpData->dwVertexOffset, lpData->dwVertexCount);
DPRINTF("Instruction Offset : %ld Length : %ld\n", lpData->dwInstructionOffset, lpData->dwInstructionLength);
DPRINTF("HVertex Offset : %ld\n", lpData->dwHVertexOffset);
_dump_d3dstatus(&(lpData->dsStatus));
}
static void _dump_D3DEXECUTEBUFFERDESC(LPD3DEXECUTEBUFFERDESC lpDesc) {
@ -62,7 +70,26 @@ static void _dump_D3DEXECUTEBUFFERDESC(LPD3DEXECUTEBUFFERDESC lpDesc) {
DPRINTF("lpData : %p\n", lpDesc->lpData);
}
static void execute(IDirect3DExecuteBufferImpl *This,
/*****************************************************************************
* IDirect3DExecuteBufferImpl_Execute
*
* The main functionality of the execute buffer
* It transforms the vertices if necessary, and calls IDirect3DDevice7
* for drawing the vertices. It is called from
* IDirect3DDevice::Execute
*
* TODO: Perhaps some comments about the varios opcodes wouldn't hurt
*
* Don't declare this static, as it's called from device.c,
* IDirect3DDevice::Execute
*
* Params:
* Device: 3D Device associated to use for drawing
* Viewport: Viewport for this operation
*
*****************************************************************************/
void
IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice,
IDirect3DViewportImpl *lpViewport)
{
@ -81,7 +108,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
lpViewport->activate(lpViewport);
TRACE("ExecuteData :\n");
if (TRACE_ON(ddraw))
if (TRACE_ON(d3d7))
_dump_executedata(&(This->data));
while (1) {
@ -117,32 +144,39 @@ static void execute(IDirect3DExecuteBufferImpl *This,
for (i = 0; i < count; i++) {
LPD3DTRIANGLE ci = (LPD3DTRIANGLE) instr;
TRACE_(ddraw_geom)(" v1: %d v2: %d v3: %d\n",ci->u1.v1, ci->u2.v2, ci->u3.v3);
TRACE_(ddraw_geom)(" Flags : ");
if (TRACE_ON(ddraw)) {
TRACE_(d3d7)(" v1: %d v2: %d v3: %d\n",ci->u1.v1, ci->u2.v2, ci->u3.v3);
TRACE_(d3d7)(" Flags : ");
if (TRACE_ON(d3d7)) {
/* Wireframe */
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1)
TRACE_(ddraw_geom)("EDGEENABLE1 ");
TRACE_(d3d7)("EDGEENABLE1 ");
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE2)
TRACE_(ddraw_geom)("EDGEENABLE2 ");
TRACE_(d3d7)("EDGEENABLE2 ");
if (ci->wFlags & D3DTRIFLAG_EDGEENABLE1)
TRACE_(ddraw_geom)("EDGEENABLE3 ");
TRACE_(d3d7)("EDGEENABLE3 ");
/* Strips / Fans */
if (ci->wFlags == D3DTRIFLAG_EVEN)
TRACE_(ddraw_geom)("EVEN ");
TRACE_(d3d7)("EVEN ");
if (ci->wFlags == D3DTRIFLAG_ODD)
TRACE_(ddraw_geom)("ODD ");
TRACE_(d3d7)("ODD ");
if (ci->wFlags == D3DTRIFLAG_START)
TRACE_(ddraw_geom)("START ");
TRACE_(d3d7)("START ");
if ((ci->wFlags > 0) && (ci->wFlags < 30))
TRACE_(ddraw_geom)("STARTFLAT(%d) ", ci->wFlags);
TRACE_(ddraw_geom)("\n");
TRACE_(d3d7)("STARTFLAT(%d) ", ci->wFlags);
TRACE_(d3d7)("\n");
}
This->indices[(i * 3) ] = ci->u1.v1;
This->indices[(i * 3) + 1] = ci->u2.v2;
This->indices[(i * 3) + 2] = ci->u3.v3;
instr += size;
}
/* IDirect3DDevices have color keying always enabled -
* enable it before drawing. This overwrites any ALPHA*
* render state
*/
IWineD3DDevice_SetRenderState(lpDevice->wineD3DDevice,
WINED3DRS_COLORKEYENABLE,
1);
IDirect3DDevice7_DrawIndexedPrimitive(ICOM_INTERFACE(lpDevice,IDirect3DDevice7),
D3DPT_TRIANGLELIST,D3DFVF_TLVERTEX,tl_vx,0,This->indices,count*3,0);
} break;
@ -264,17 +298,35 @@ static void execute(IDirect3DExecuteBufferImpl *This,
}
} break;
case D3DOP_PROCESSVERTICES: {
case D3DOP_PROCESSVERTICES:
{
/* TODO: Share code with IDirect3DVertexBuffer::ProcessVertices and / or
* IWineD3DDevice::ProcessVertices
*/
int i;
D3DMATRIX view_mat, world_mat, proj_mat;
TRACE("PROCESSVERTICES (%d)\n", count);
/* Get the transform and world matrix */
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_VIEW,
&view_mat);
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_PROJECTION,
&proj_mat);
IWineD3DDevice_GetTransform(lpDevice->wineD3DDevice,
D3DTRANSFORMSTATE_WORLD,
&world_mat);
for (i = 0; i < count; i++) {
LPD3DPROCESSVERTICES ci = (LPD3DPROCESSVERTICES) instr;
TRACE(" Start : %d Dest : %d Count : %ld\n",
ci->wStart, ci->wDest, ci->dwCount);
TRACE(" Flags : ");
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
if (ci->dwFlags & D3DPROCESSVERTICES_COPY)
TRACE("COPY ");
if (ci->dwFlags & D3DPROCESSVERTICES_NOCOLOR)
@ -321,22 +373,22 @@ static void execute(IDirect3DExecuteBufferImpl *This,
unsigned int nb;
D3DVERTEX *src = ((LPD3DVERTEX) ((char *)This->desc.lpData + vs)) + ci->wStart;
D3DTLVERTEX *dst = ((LPD3DTLVERTEX) (This->vertex_data)) + ci->wDest;
D3DMATRIX *mat2 = lpDevice->world_mat;
D3DMATRIX *mat2 = &world_mat;
D3DMATRIX mat;
D3DVALUE nx,ny,nz;
D3DVIEWPORT* Viewport = &lpViewport->viewports.vp1;
if (TRACE_ON(ddraw)) {
TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat);
dump_D3DMATRIX(lpDevice->proj_mat);
TRACE(" View Matrix : (%p)\n", lpDevice->view_mat);
dump_D3DMATRIX(lpDevice->view_mat);
TRACE(" World Matrix : (%p)\n", lpDevice->world_mat);
dump_D3DMATRIX(lpDevice->world_mat);
if (TRACE_ON(d3d7)) {
TRACE(" Projection Matrix : (%p)\n", &proj_mat);
dump_D3DMATRIX(&proj_mat);
TRACE(" View Matrix : (%p)\n", &view_mat);
dump_D3DMATRIX(&view_mat);
TRACE(" World Matrix : (%p)\n", &world_mat);
dump_D3DMATRIX(&world_mat);
}
multiply_matrix(&mat,lpDevice->view_mat,lpDevice->world_mat);
multiply_matrix(&mat,lpDevice->proj_mat,&mat);
multiply_matrix(&mat,&view_mat,&world_mat);
multiply_matrix(&mat,&proj_mat,&mat);
for (nb = 0; nb < ci->dwCount; nb++) {
/* Normals transformation */
@ -375,17 +427,17 @@ static void execute(IDirect3DExecuteBufferImpl *This,
D3DMATRIX mat;
D3DVIEWPORT* Viewport = &lpViewport->viewports.vp1;
if (TRACE_ON(ddraw)) {
TRACE(" Projection Matrix : (%p)\n", lpDevice->proj_mat);
dump_D3DMATRIX(lpDevice->proj_mat);
TRACE(" View Matrix : (%p)\n", lpDevice->view_mat);
dump_D3DMATRIX(lpDevice->view_mat);
if (TRACE_ON(d3d7)) {
TRACE(" Projection Matrix : (%p)\n", &proj_mat);
dump_D3DMATRIX(&proj_mat);
TRACE(" View Matrix : (%p)\n",&view_mat);
dump_D3DMATRIX(&view_mat);
TRACE(" World Matrix : (%p)\n", &mat);
dump_D3DMATRIX(&mat);
}
multiply_matrix(&mat,lpDevice->view_mat,lpDevice->world_mat);
multiply_matrix(&mat,lpDevice->proj_mat,&mat);
multiply_matrix(&mat,&view_mat,&world_mat);
multiply_matrix(&mat,&proj_mat,&mat);
for (nb = 0; nb < ci->dwCount; nb++) {
dst->u5.color = src->u4.color;
@ -490,50 +542,85 @@ end_of_buffer:
;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_QueryInterface(LPDIRECT3DEXECUTEBUFFER iface,
/*****************************************************************************
* IDirect3DExecuteBuffer::QueryInterface
*
* Well, a usual QueryInterface function. Don't know fur sure which
* interfaces it can Query.
*
* Params:
* riid: The interface ID queried for
* obj: Address to return the interface pointer at
*
* Returns:
* D3D_OK in case of a success (S_OK? Think it's the same)
* OLE_E_ENUM_NOMORE if the interface wasn't found.
* (E_NOINTERFACE?? Don't know what I really need)
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_QueryInterface(IDirect3DExecuteBuffer *iface,
REFIID riid,
LPVOID* obp)
void **obj)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obj);
*obp = NULL;
*obj = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ) {
IDirect3DExecuteBuffer_AddRef(ICOM_INTERFACE(This, IDirect3DExecuteBuffer));
*obp = iface;
TRACE(" Creating IUnknown interface at %p.\n", *obp);
*obj = iface;
TRACE(" Creating IUnknown interface at %p.\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DMaterial, riid ) ) {
IDirect3DExecuteBuffer_AddRef(ICOM_INTERFACE(This, IDirect3DExecuteBuffer));
*obp = ICOM_INTERFACE(This, IDirect3DExecuteBuffer);
TRACE(" Creating IDirect3DExecuteBuffer interface %p\n", *obp);
*obj = ICOM_INTERFACE(This, IDirect3DExecuteBuffer);
TRACE(" Creating IDirect3DExecuteBuffer interface %p\n", *obj);
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return OLE_E_ENUM_NOMORE;
return E_NOINTERFACE;
}
ULONG WINAPI
Main_IDirect3DExecuteBufferImpl_1_AddRef(LPDIRECT3DEXECUTEBUFFER iface)
/*****************************************************************************
* IDirect3DExecuteBuffer::AddRef
*
* A normal AddRef method, nothing special
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DExecuteBufferImpl_AddRef(IDirect3DExecuteBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
ULONG ref = InterlockedIncrement(&This->ref);
FIXME("(%p/%p)->()incrementing from %lu.\n", This, iface, ref - 1);
FIXME("(%p)->()incrementing from %lu.\n", This, ref - 1);
return ref;
}
ULONG WINAPI
Main_IDirect3DExecuteBufferImpl_1_Release(LPDIRECT3DEXECUTEBUFFER iface)
/*****************************************************************************
* IDirect3DExecuteBuffer::Release
*
* A normal Release method, nothing special
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DExecuteBufferImpl_Release(IDirect3DExecuteBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->()decrementing from %lu.\n", This, iface, ref + 1);
TRACE("(%p)->()decrementing from %lu.\n", This, ref + 1);
if (!ref) {
if (This->need_free)
@ -547,50 +634,96 @@ Main_IDirect3DExecuteBufferImpl_1_Release(LPDIRECT3DEXECUTEBUFFER iface)
return ref;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_Initialize(LPDIRECT3DEXECUTEBUFFER iface,
LPDIRECT3DDEVICE lpDirect3DDevice,
LPD3DEXECUTEBUFFERDESC lpDesc)
/*****************************************************************************
* IDirect3DExecuteBuffer::Initialize
*
* Initializes the Execute Buffer. This method exists for COM compliance
* Nothing to do here.
*
* Returns:
* D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Initialize(IDirect3DExecuteBuffer *iface,
IDirect3DDevice *lpDirect3DDevice,
D3DEXECUTEBUFFERDESC *lpDesc)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p/%p)->(%p,%p) no-op....\n", This, iface, lpDirect3DDevice, lpDesc);
return DD_OK;
TRACE("(%p)->(%p,%p) no-op....\n", This, lpDirect3DDevice, lpDesc);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_Lock(LPDIRECT3DEXECUTEBUFFER iface,
LPD3DEXECUTEBUFFERDESC lpDesc)
/*****************************************************************************
* IDirect3DExecuteBuffer::Lock
*
* Locks the buffer, so the app can write into it.
*
* Params:
* Desc: Pointer to return the buffer description. This Description contains
* a pointer to the buffer data.
*
* Returns:
* This implementation always returns D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Lock(IDirect3DExecuteBuffer *iface,
D3DEXECUTEBUFFERDESC *lpDesc)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
DWORD dwSize;
TRACE("(%p/%p)->(%p)\n", This, iface, lpDesc);
TRACE("(%p)->(%p)\n", This, lpDesc);
dwSize = lpDesc->dwSize;
memset(lpDesc, 0, dwSize);
memcpy(lpDesc, &This->desc, dwSize);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE(" Returning description :\n");
_dump_D3DEXECUTEBUFFERDESC(lpDesc);
}
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_Unlock(LPDIRECT3DEXECUTEBUFFER iface)
/*****************************************************************************
* IDirect3DExecuteBuffer::Unlock
*
* Unlocks the buffer. We don't have anything to do here
*
* Returns:
* This implementation always returns D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Unlock(IDirect3DExecuteBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p/%p)->() no-op...\n", This, iface);
return DD_OK;
TRACE("(%p)->() no-op...\n", This);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_SetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
LPD3DEXECUTEDATA lpData)
/*****************************************************************************
* IDirect3DExecuteBuffer::SetExecuteData
*
* Sets the execute data. This data is used to describe the buffer's content
*
* Params:
* Data: Pointer to a D3DEXECUTEDATA structure containing the data to
* assign
*
* Returns:
* D3D_OK on success
* DDERR_OUTOFMEMORY if the vertex buffer allocation failed
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_SetExecuteData(IDirect3DExecuteBuffer *iface,
D3DEXECUTEDATA *lpData)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
DWORD nbvert;
TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
TRACE("(%p)->(%p)\n", This, lpData);
memcpy(&This->data, lpData, lpData->dwSize);
@ -601,26 +734,38 @@ Main_IDirect3DExecuteBufferImpl_1_SetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
HeapFree(GetProcessHeap(), 0, This->vertex_data);
This->vertex_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nbvert * sizeof(D3DTLVERTEX));
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
_dump_executedata(lpData);
}
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_GetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
LPD3DEXECUTEDATA lpData)
/*****************************************************************************
* IDirect3DExecuteBuffer::GetExecuteData
*
* Returns the data in the execute buffer
*
* Params:
* Data: Pointer to a D3DEXECUTEDATA structure used to return data
*
* Returns:
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_GetExecuteData(IDirect3DExecuteBuffer *iface,
D3DEXECUTEDATA *lpData)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
DWORD dwSize;
TRACE("(%p/%p)->(%p): stub!\n", This, iface, lpData);
TRACE("(%p)->(%p): stub!\n", This, lpData);
dwSize = lpData->dwSize;
memset(lpData, 0, dwSize);
memcpy(lpData, &This->data, dwSize);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE("Returning data :\n");
_dump_executedata(lpData);
}
@ -628,96 +773,63 @@ Main_IDirect3DExecuteBufferImpl_1_GetExecuteData(LPDIRECT3DEXECUTEBUFFER iface,
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_Validate(LPDIRECT3DEXECUTEBUFFER iface,
LPDWORD lpdwOffset,
LPD3DVALIDATECALLBACK lpFunc,
LPVOID lpUserArg,
DWORD dwReserved)
/*****************************************************************************
* IDirect3DExecuteBuffer::Validate
*
* DirectX 5 SDK: "The IDirect3DExecuteBuffer::Validate method is not
* currently implemented"
*
* Params:
* ?
*
* Returns:
* DDERR_UNSUPPORTED, because it's not implemented in Windows.
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Validate(IDirect3DExecuteBuffer *iface,
DWORD *Offset,
LPD3DVALIDATECALLBACK Func,
void *UserArg,
DWORD Reserved)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
FIXME("(%p/%p)->(%p,%p,%p,%08lx): stub!\n", This, iface, lpdwOffset, lpFunc, lpUserArg, dwReserved);
return DD_OK;
TRACE("(%p)->(%p,%p,%p,%08lx): Unimplemented!\n", This, Offset, Func, UserArg, Reserved);
return DDERR_UNSUPPORTED; /* Unchecked */
}
HRESULT WINAPI
Main_IDirect3DExecuteBufferImpl_1_Optimize(LPDIRECT3DEXECUTEBUFFER iface,
DWORD dwDummy)
/*****************************************************************************
* IDirect3DExecuteBuffer::Optimize
*
* DirectX5 SDK: "The IDirect3DExecuteBuffer::Optimize method is not
* currently supported"
*
* Params:
* Dummy: Seems to be an unused dummy ;)
*
* Returns:
* DDERR_UNSUPPORTED, because it's not implemented in Windows.
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DExecuteBufferImpl_Optimize(IDirect3DExecuteBuffer *iface,
DWORD Dummy)
{
ICOM_THIS_FROM(IDirect3DExecuteBufferImpl, IDirect3DExecuteBuffer, iface);
TRACE("(%p/%p)->(%08lx) no-op...\n", This, iface, dwDummy);
return DD_OK;
TRACE("(%p)->(%08lx): Unimplemented\n", This, Dummy);
return DDERR_UNSUPPORTED; /* Unchecked */
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DExecuteBuffer.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DExecuteBufferVtbl VTABLE_IDirect3DExecuteBuffer =
const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl =
{
XCAST(QueryInterface) Main_IDirect3DExecuteBufferImpl_1_QueryInterface,
XCAST(AddRef) Main_IDirect3DExecuteBufferImpl_1_AddRef,
XCAST(Release) Main_IDirect3DExecuteBufferImpl_1_Release,
XCAST(Initialize) Main_IDirect3DExecuteBufferImpl_1_Initialize,
XCAST(Lock) Main_IDirect3DExecuteBufferImpl_1_Lock,
XCAST(Unlock) Main_IDirect3DExecuteBufferImpl_1_Unlock,
XCAST(SetExecuteData) Main_IDirect3DExecuteBufferImpl_1_SetExecuteData,
XCAST(GetExecuteData) Main_IDirect3DExecuteBufferImpl_1_GetExecuteData,
XCAST(Validate) Main_IDirect3DExecuteBufferImpl_1_Validate,
XCAST(Optimize) Main_IDirect3DExecuteBufferImpl_1_Optimize,
IDirect3DExecuteBufferImpl_QueryInterface,
IDirect3DExecuteBufferImpl_AddRef,
IDirect3DExecuteBufferImpl_Release,
IDirect3DExecuteBufferImpl_Initialize,
IDirect3DExecuteBufferImpl_Lock,
IDirect3DExecuteBufferImpl_Unlock,
IDirect3DExecuteBufferImpl_SetExecuteData,
IDirect3DExecuteBufferImpl_GetExecuteData,
IDirect3DExecuteBufferImpl_Validate,
IDirect3DExecuteBufferImpl_Optimize,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc)
{
IDirect3DExecuteBufferImpl* object;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DExecuteBufferImpl));
ICOM_INIT_INTERFACE(object, IDirect3DExecuteBuffer, VTABLE_IDirect3DExecuteBuffer);
object->ref = 1;
object->d3d = d3d;
object->d3ddev = d3ddev;
/* Initializes memory */
memcpy(&object->desc, lpDesc, lpDesc->dwSize);
/* No buffer given */
if ((object->desc.dwFlags & D3DDEB_LPDATA) == 0)
object->desc.lpData = NULL;
/* No buffer size given */
if ((lpDesc->dwFlags & D3DDEB_BUFSIZE) == 0)
object->desc.dwBufferSize = 0;
/* Create buffer if asked */
if ((object->desc.lpData == NULL) && (object->desc.dwBufferSize > 0)) {
object->need_free = TRUE;
object->desc.lpData = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,object->desc.dwBufferSize);
} else {
object->need_free = FALSE;
}
/* No vertices for the moment */
object->vertex_data = NULL;
object->desc.dwFlags |= D3DDEB_LPDATA;
object->execute = execute;
object->indices = NULL;
object->nb_indices = 0;
*obj = object;
TRACE(" creating implementation at %p.\n", *obj);
return DD_OK;
}

213
dlls/ddraw/gamma.c Normal file
View File

@ -0,0 +1,213 @@
/* DirectDrawGammaControl implementation
*
* Copyright 2001 TransGaming Technologies Inc.
* Copyright 2006 Stefan Dösinger
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
/**********************************************************
* IUnkown parts follow
**********************************************************/
/**********************************************************
* IDirectDrawGammaControl::QueryInterface
*
* QueryInterface, thunks to IDirectDrawSurface
*
* Params:
* riid: Interface id queried for
* obj: Returns the interface pointer
*
* Returns:
* S_OK or E_NOINTERFACE: See IDirectDrawSurface7::QueryInterface
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_QueryInterface(IDirectDrawGammaControl *iface, REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->(%s,%p): Thunking to IDirectDrawSurface7\n", This, debugstr_guid(riid), obj);
return IDirectDrawSurface7_QueryInterface(ICOM_INTERFACE(This, IDirectDrawSurface7),
riid,
obj);
}
/**********************************************************
* IDirectDrawGammaControl::AddRef
*
* Addref, thunks to IDirectDrawSurface
*
* Returns:
* The new refcount
*
**********************************************************/
static ULONG WINAPI
IDirectDrawGammaControlImpl_AddRef(IDirectDrawGammaControl *iface)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->() Thunking to IDirectDrawSurface7\n", This);
return IDirectDrawSurface7_AddRef(ICOM_INTERFACE(This, IDirectDrawSurface7));
}
/**********************************************************
* IDirectDrawGammaControl::Release
*
* Release, thunks to IDirectDrawSurface
*
* Returns:
* The new refcount
*
**********************************************************/
static ULONG WINAPI
IDirectDrawGammaControlImpl_Release(IDirectDrawGammaControl *iface)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE_(ddraw_thunk)("(%p)->() Thunking to IDirectDrawSurface7\n", This);
return IDirectDrawSurface7_Release(ICOM_INTERFACE(This, IDirectDrawSurface7));
}
/**********************************************************
* IDirectDrawGammaControl
**********************************************************/
/**********************************************************
* IDirectDrawGammaControl::GetGammaRamp
*
* Returns the current gamma ramp for a surface
*
* Params:
* Flags: Ignored
* GammaRamp: Address to write the ramp to
*
* Returns:
* DD_OK on success
* DDERR_INVALIDPARAMS if GammaRamp is NULL
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_GetGammaRamp(IDirectDrawGammaControl *iface,
DWORD Flags,
DDGAMMARAMP *GammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", This,Flags,GammaRamp);
/* This looks sane */
if(!GammaRamp)
{
ERR("(%p) GammaRamp is NULL, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* This returns a void */
IWineD3DDevice_GetGammaRamp(This->ddraw->wineD3DDevice,
0 /* Swapchain */,
(WINED3DGAMMARAMP *) GammaRamp);
}
else
{
ERR("(%p) Unimplemented for non-primary surfaces\n", This);
}
return DD_OK;
}
/**********************************************************
* IDirectDrawGammaControl::SetGammaRamp
*
* Sets the red, green and blue gamma ramps for
*
* Params:
* Flags: Can be DDSGR_CALIBRATE to request calibration
* GammaRamp: Structure containing the new gamma ramp
*
* Returns:
* DD_OK on success
* DDERR_INVALIDPARAMS if GammaRamp is NULL
*
**********************************************************/
static HRESULT WINAPI
IDirectDrawGammaControlImpl_SetGammaRamp(IDirectDrawGammaControl *iface,
DWORD Flags,
DDGAMMARAMP *GammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", This,Flags,GammaRamp);
/* This looks sane */
if(!GammaRamp)
{
ERR("(%p) GammaRamp is NULL, returning DDERR_INVALIDPARAMS\n", This);
return DDERR_INVALIDPARAMS;
}
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
/* This returns a void */
IWineD3DDevice_SetGammaRamp(This->ddraw->wineD3DDevice,
0 /* Swapchain */,
Flags,
(WINED3DGAMMARAMP *) GammaRamp);
}
else
{
ERR("(%p) Unimplemented for non-primary surfaces\n", This);
}
return DD_OK;
}
const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl =
{
IDirectDrawGammaControlImpl_QueryInterface,
IDirectDrawGammaControlImpl_AddRef,
IDirectDrawGammaControlImpl_Release,
IDirectDrawGammaControlImpl_GetGammaRamp,
IDirectDrawGammaControlImpl_SetGammaRamp
};

View File

@ -1,125 +0,0 @@
/* GL API list
* Copyright (c) 2003 Lionel Ulmer / Mike McCormack
*
* This file contains all structures that are not exported
* through d3d.h and all common macros.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Note : this file is NOT protected against double-inclusion for pretty good
reasons :-) */
#ifndef GL_API_FUNCTION
#error "This file should be included with GL_API_FUNCTION defined !"
#endif
GL_API_FUNCTION(glAlphaFunc)
GL_API_FUNCTION(glBegin)
GL_API_FUNCTION(glBindTexture)
GL_API_FUNCTION(glBlendFunc)
GL_API_FUNCTION(glClear)
GL_API_FUNCTION(glClearColor)
GL_API_FUNCTION(glClearDepth)
GL_API_FUNCTION(glClearStencil)
GL_API_FUNCTION(glClipPlane)
GL_API_FUNCTION(glColor3f)
GL_API_FUNCTION(glColor3ub)
GL_API_FUNCTION(glColor4ub)
GL_API_FUNCTION(glColorMask)
GL_API_FUNCTION(glColorMaterial)
GL_API_FUNCTION(glColorPointer)
GL_API_FUNCTION(glCopyPixels)
GL_API_FUNCTION(glCopyTexSubImage2D)
GL_API_FUNCTION(glCullFace)
GL_API_FUNCTION(glDeleteTextures)
GL_API_FUNCTION(glDepthFunc)
GL_API_FUNCTION(glDepthMask)
GL_API_FUNCTION(glDepthRange)
GL_API_FUNCTION(glDisable)
GL_API_FUNCTION(glDisableClientState)
GL_API_FUNCTION(glDrawArrays)
GL_API_FUNCTION(glDrawBuffer)
GL_API_FUNCTION(glDrawElements)
GL_API_FUNCTION(glDrawPixels)
GL_API_FUNCTION(glEnable)
GL_API_FUNCTION(glEnableClientState)
GL_API_FUNCTION(glEnd)
GL_API_FUNCTION(glFlush)
GL_API_FUNCTION(glFogf)
GL_API_FUNCTION(glFogfv)
GL_API_FUNCTION(glFogi)
GL_API_FUNCTION(glFrontFace)
GL_API_FUNCTION(glGenTextures)
GL_API_FUNCTION(glGetBooleanv)
GL_API_FUNCTION(glGetError)
GL_API_FUNCTION(glGetFloatv)
GL_API_FUNCTION(glGetIntegerv)
GL_API_FUNCTION(glGetString)
GL_API_FUNCTION(glGetTexEnviv)
GL_API_FUNCTION(glGetTexParameteriv)
GL_API_FUNCTION(glHint)
GL_API_FUNCTION(glLightModelfv)
GL_API_FUNCTION(glLightModeli)
GL_API_FUNCTION(glLightfv)
GL_API_FUNCTION(glLoadIdentity)
GL_API_FUNCTION(glLoadMatrixf)
GL_API_FUNCTION(glMaterialf)
GL_API_FUNCTION(glMaterialfv)
GL_API_FUNCTION(glMatrixMode)
GL_API_FUNCTION(glMultMatrixf)
GL_API_FUNCTION(glNormal3f)
GL_API_FUNCTION(glNormal3fv)
GL_API_FUNCTION(glNormalPointer)
GL_API_FUNCTION(glOrtho)
GL_API_FUNCTION(glPixelStorei)
GL_API_FUNCTION(glPolygonMode)
GL_API_FUNCTION(glPolygonOffset)
GL_API_FUNCTION(glPopMatrix)
GL_API_FUNCTION(glPushMatrix)
GL_API_FUNCTION(glRasterPos2i)
GL_API_FUNCTION(glRasterPos3d)
GL_API_FUNCTION(glReadBuffer)
GL_API_FUNCTION(glReadPixels)
GL_API_FUNCTION(glScissor)
GL_API_FUNCTION(glShadeModel)
GL_API_FUNCTION(glStencilFunc)
GL_API_FUNCTION(glStencilMask)
GL_API_FUNCTION(glStencilOp)
GL_API_FUNCTION(glTexCoord1fv)
GL_API_FUNCTION(glTexCoord2f)
GL_API_FUNCTION(glTexCoord2fv)
GL_API_FUNCTION(glTexCoord3fv)
GL_API_FUNCTION(glTexCoord4fv)
GL_API_FUNCTION(glTexCoordPointer)
GL_API_FUNCTION(glTexEnvf)
GL_API_FUNCTION(glTexEnvfv)
GL_API_FUNCTION(glTexEnvi)
GL_API_FUNCTION(glTexImage2D)
GL_API_FUNCTION(glTexParameteri)
GL_API_FUNCTION(glTexParameterfv)
GL_API_FUNCTION(glTexSubImage2D)
GL_API_FUNCTION(glTranslatef)
GL_API_FUNCTION(glVertex3d)
GL_API_FUNCTION(glVertex3f)
GL_API_FUNCTION(glVertex3fv)
GL_API_FUNCTION(glVertex4f)
GL_API_FUNCTION(glVertexPointer)
GL_API_FUNCTION(glViewport)
GL_API_FUNCTION(glXCreateContext)
GL_API_FUNCTION(glXDestroyContext)
GL_API_FUNCTION(glXMakeCurrent)
GL_API_FUNCTION(glXQueryExtensionsString)
GL_API_FUNCTION(glXSwapBuffers)

View File

@ -1,174 +0,0 @@
/* GL 'hack' private include file
* Copyright (c) 2003 Lionel Ulmer / Mike McCormack
*
* This file contains all structures that are not exported
* through d3d.h and all common macros.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __GRAPHICS_WINE_GL_PRIVATE_H
#define __GRAPHICS_WINE_GL_PRIVATE_H
#ifdef HAVE_OPENGL
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
#include <GL/gl.h>
#include <GL/glx.h>
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#undef XMD_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
#define GL_API_FUNCTION(f) extern typeof(f) * p##f;
#include "gl_api.h"
#undef GL_API_FUNCTION
/* This is also where I store our private extension defines...
I know that Raphael won't like it, but well, I prefer doing that than battling 10 different headers :-)
Note: this is perfectly 'legal' as the three variants of the enum have exactly the same value
*/
#define GL_MIRRORED_REPEAT_WINE 0x8370
#define GL_TEXTURE_FILTER_CONTROL_WINE 0x8500
#define GL_TEXTURE_LOD_BIAS_WINE 0x8501
#define GL_TEXTURE0_WINE 0x84C0
#define GL_TEXTURE1_WINE 0x84C1
#define GL_TEXTURE2_WINE 0x84C2
#define GL_TEXTURE3_WINE 0x84C3
#define GL_TEXTURE4_WINE 0x84C4
#define GL_TEXTURE5_WINE 0x84C5
#define GL_TEXTURE6_WINE 0x84C6
#define GL_TEXTURE7_WINE 0x84C7
#define GL_MAX_TEXTURE_UNITS_WINE 0x84E2
#ifndef GLPRIVATE_NO_REDEFINE
#define glAlphaFunc pglAlphaFunc
#define glBegin pglBegin
#define glBindTexture pglBindTexture
#define glBlendFunc pglBlendFunc
#define glClear pglClear
#define glClearColor pglClearColor
#define glClearDepth pglClearDepth
#define glClearStencil pglClearStencil
#define glClipPlane pglClipPlane
#define glColor3f pglColor3f
#define glColor3ub pglColor3ub
#define glColor4ub pglColor4ub
#define glColorMask pglColorMask
#define glColorPointer pglColorPointer
#define glCopyPixels pglCopyPixels
#define glCopyTexSubImage2D pglCopyTexSubImage2D
#define glColorMaterial pglColorMaterial
#define glCullFace pglCullFace
#define glDeleteTextures pglDeleteTextures
#define glDepthFunc pglDepthFunc
#define glDepthMask pglDepthMask
#define glDepthRange pglDepthRange
#define glDisable pglDisable
#define glDisableClientState pglDisableClientState
#define glDrawArrays pglDrawArrays
#define glDrawBuffer pglDrawBuffer
#define glDrawElements pglDrawElements
#define glDrawPixels pglDrawPixels
#define glEnable pglEnable
#define glEnableClientState pglEnableClientState
#define glEnd pglEnd
#define glFlush pglFlush
#define glFogf pglFogf
#define glFogfv pglFogfv
#define glFogi pglFogi
#define glFrontFace pglFrontFace
#define glGenTextures pglGenTextures
#define glGetBooleanv pglGetBooleanv
#define glGetError pglGetError
#define glGetFloatv pglGetFloatv
#define glGetIntegerv pglGetIntegerv
#define glGetString pglGetString
#define glGetTexEnviv pglGetTexEnviv
#define glGetTexParameteriv pglGetTexParameteriv
#define glHint pglHint
#define glLightModelfv pglLightModelfv
#define glLightModeli pglLightModeli
#define glLightfv pglLightfv
#define glLoadIdentity pglLoadIdentity
#define glLoadMatrixf pglLoadMatrixf
#define glMaterialf pglMaterialf
#define glMaterialfv pglMaterialfv
#define glMatrixMode pglMatrixMode
#define glMultMatrixf pglMultMatrixf
#define glNormal3f pglNormal3f
#define glNormal3fv pglNormal3fv
#define glNormalPointer pglNormalPointer
#define glOrtho pglOrtho
#define glPixelStorei pglPixelStorei
#define glPolygonMode pglPolygonMode
#define glPolygonOffset pglPolygonOffset
#define glPopMatrix pglPopMatrix
#define glPushMatrix pglPushMatrix
#define glRasterPos2i pglRasterPos2i
#define glRasterPos3d pglRasterPos3d
#define glReadBuffer pglReadBuffer
#define glReadPixels pglReadPixels
#define glScissor pglScissor
#define glShadeModel pglShadeModel
#define glStencilFunc pglStencilFunc
#define glStencilMask pglStencilMask
#define glStencilOp pglStencilOp
#define glTexCoord1fv pglTexCoord1fv
#define glTexCoord2f pglTexCoord2f
#define glTexCoord2fv pglTexCoord2fv
#define glTexCoord3fv pglTexCoord3fv
#define glTexCoord4fv pglTexCoord4fv
#define glTexCoordPointer pglTexCoordPointer
#define glTexEnvf pglTexEnvf
#define glTexEnvfv pglTexEnvfv
#define glTexEnvi pglTexEnvi
#define glTexImage2D pglTexImage2D
#define glTexParameteri pglTexParameteri
#define glTexParameterfv pglTexParameterfv
#define glTexSubImage2D pglTexSubImage2D
#define glTranslatef pglTranslatef
#define glVertex3d pglVertex3d
#define glVertex3f pglVertex3f
#define glVertex3fv pglVertex3fv
#define glVertex4f pglVertex4f
#define glVertexPointer pglVertexPointer
#define glViewport pglViewport
#define glXCreateContext pglXCreateContext
#define glXDestroyContext pglXDestroyContext
#define glXMakeCurrent pglXMakeCurrent
#define glXQueryExtensionsString pglXQueryExtensionsString
#define glXSwapBuffers pglXSwapBuffers
#endif /* GLPRIVATE_NO_REDEFINE */
#endif /* HAVE_OPENGL */
#endif /* __GRAPHICS_WINE_GL_PRIVATE_H */

View File

@ -1,5 +1,6 @@
/* Direct3D Light
* Copyright (c) 1998 / 2002 Lionel ULMER
* Copyright (c) 2006 Stefan DÖSINGER
*
* This file contains the implementation of Direct3DLight.
*
@ -19,55 +20,96 @@
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "objbase.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "wine/debug.h"
#include "d3d_private.h"
#include "opengl_private.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
/* First, the 'main' interface... */
HRESULT WINAPI
Main_IDirect3DLightImpl_1_QueryInterface(LPDIRECT3DLIGHT iface,
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DLight::QueryInterface
*
* Queries the object for different interfaces. Unimplemented for this
* object at the moment
*
* Params:
* riid: Interface id asked for
* obj: Address to return the resulting pointer at.
*
* Returns:
* E_NOINTERFACE, because it's a stub
*****************************************************************************/
static HRESULT WINAPI
IDirect3DLightImpl_QueryInterface(IDirect3DLight *iface,
REFIID riid,
LPVOID* obp)
void **obp)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
FIXME("(%p/%p)->(%s,%p): stub!\n", This, iface, debugstr_guid(riid), obp);
return DD_OK;
FIXME("(%p)->(%s,%p): stub!\n", This, debugstr_guid(riid), obp);
*obp = NULL;
return E_NOINTERFACE;
}
ULONG WINAPI
Main_IDirect3DLightImpl_1_AddRef(LPDIRECT3DLIGHT iface)
/*****************************************************************************
* IDirect3DLight::AddRef
*
* Increases the refcount by 1
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DLightImpl_AddRef(IDirect3DLight *iface)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)->() incrementing from %lu.\n", This, iface, ref - 1);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
ULONG WINAPI
Main_IDirect3DLightImpl_1_Release(LPDIRECT3DLIGHT iface)
/*****************************************************************************
* IDirect3DLight::Release
*
* Reduces the refcount by one. If the refcount falls to 0, the object
* is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DLightImpl_Release(IDirect3DLight *iface)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
@ -76,16 +118,46 @@ Main_IDirect3DLightImpl_1_Release(LPDIRECT3DLIGHT iface)
return ref;
}
HRESULT WINAPI
Main_IDirect3DLightImpl_1_Initialize(LPDIRECT3DLIGHT iface,
LPDIRECT3D lpDirect3D)
/*****************************************************************************
* IDirect3DLight Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DLight::Initialize
*
* Initializes the interface. This implementation is a no-op, because
* initialization takes place at creation time
*
* Params:
* Direct3D: Pointer to an IDirect3D interface.
*
* Returns:
* D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DLightImpl_Initialize(IDirect3DLight *iface,
IDirect3D *lpDirect3D)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
TRACE("(%p/%p)->(%p) no-op...\n", This, iface, lpDirect3D);
return DD_OK;
IDirectDrawImpl *d3d = ICOM_OBJECT(IDirectDrawImpl, IDirect3D, lpDirect3D);
TRACE("(%p)->(%p) no-op...\n", This, d3d);
return D3D_OK;
}
/*** IDirect3DLight methods ***/
/*****************************************************************************
* IDirect3DLight::SetLight
*
* Assigns a lighting value to this object
*
* Params:
* Light: Lighting parametes to set
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Light is NULL
*
*****************************************************************************/
static void dump_light(LPD3DLIGHT2 light)
{
DPRINTF(" - dwSize : %ld\n", light->dwSize);
@ -95,14 +167,14 @@ static const float zero_value[] = {
0.0, 0.0, 0.0, 0.0
};
HRESULT WINAPI
Main_IDirect3DLightImpl_1_SetLight(LPDIRECT3DLIGHT iface,
LPD3DLIGHT lpLight)
static HRESULT WINAPI
IDirect3DLightImpl_SetLight(IDirect3DLight *iface,
D3DLIGHT *lpLight)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
LPD3DLIGHT7 light7 = &(This->light7);
TRACE("(%p/%p)->(%p)\n", This, iface, lpLight);
if (TRACE_ON(ddraw)) {
TRACE("(%p)->(%p)\n", This, lpLight);
if (TRACE_ON(d3d7)) {
TRACE(" Light definition :\n");
dump_light((LPD3DLIGHT2) lpLight);
}
@ -135,16 +207,28 @@ Main_IDirect3DLightImpl_1_SetLight(LPDIRECT3DLIGHT iface,
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
This->update(This);
}
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DLightImpl_1_GetLight(LPDIRECT3DLIGHT iface,
LPD3DLIGHT lpLight)
/*****************************************************************************
* IDirect3DLight::GetLight
*
* Returns the parameters currently assigned to the IDirect3DLight object
*
* Params:
* Light: Pointer to an D3DLIGHT structure to store the parameters
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Light is NULL
*****************************************************************************/
static HRESULT WINAPI
IDirect3DLightImpl_GetLight(IDirect3DLight *iface,
D3DLIGHT *lpLight)
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
TRACE("(%p/%p)->(%p)\n", This, iface, lpLight);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE(" Returning light definition :\n");
dump_light(&This->light);
}
@ -152,11 +236,13 @@ Main_IDirect3DLightImpl_1_GetLight(LPDIRECT3DLIGHT iface,
return DD_OK;
}
/*******************************************************************************
* Light static functions
*/
static void update(IDirect3DLightImpl* This)
/*****************************************************************************
* light_update
*
* Updates the Direct3DDevice7 lighting parameters
*
*****************************************************************************/
void light_update(IDirect3DLightImpl* This)
{
IDirect3DDeviceImpl* device;
@ -169,7 +255,13 @@ static void update(IDirect3DLightImpl* This)
IDirect3DDevice7_SetLight(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, &(This->light7));
}
static void activate(IDirect3DLightImpl* This)
/*****************************************************************************
* light_activate
*
* Uses the Direct3DDevice7::LightEnable method to active the light
*
*****************************************************************************/
void light_activate(IDirect3DLightImpl* This)
{
IDirect3DDeviceImpl* device;
@ -179,7 +271,7 @@ static void activate(IDirect3DLightImpl* This)
return;
device = This->active_viewport->active_device;
update(This);
light_update(This);
/* If was not active, activate it */
if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) {
IDirect3DDevice7_LightEnable(ICOM_INTERFACE(device,IDirect3DDevice7), This->dwLightIndex, TRUE);
@ -187,7 +279,14 @@ static void activate(IDirect3DLightImpl* This)
}
}
static void desactivate(IDirect3DLightImpl* This)
/*****************************************************************************
*
* light_desactivate
*
* Uses the Direct3DDevice7::LightEnable method to deactivate the light
*
*****************************************************************************/
void light_desactivate(IDirect3DLightImpl* This)
{
IDirect3DDeviceImpl* device;
@ -204,64 +303,14 @@ static void desactivate(IDirect3DLightImpl* This)
}
}
ULONG WINAPI
GL_IDirect3DLightImpl_1_Release(LPDIRECT3DLIGHT iface)
const IDirect3DLightVtbl IDirect3DLight_Vtbl =
{
ICOM_THIS_FROM(IDirect3DLightImpl, IDirect3DLight, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
return ref;
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DLight.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DLightVtbl VTABLE_IDirect3DLight =
{
XCAST(QueryInterface) Main_IDirect3DLightImpl_1_QueryInterface,
XCAST(AddRef) Main_IDirect3DLightImpl_1_AddRef,
XCAST(Release) GL_IDirect3DLightImpl_1_Release,
XCAST(Initialize) Main_IDirect3DLightImpl_1_Initialize,
XCAST(SetLight) Main_IDirect3DLightImpl_1_SetLight,
XCAST(GetLight) Main_IDirect3DLightImpl_1_GetLight,
/*** IUnknown Methods ***/
IDirect3DLightImpl_QueryInterface,
IDirect3DLightImpl_AddRef,
IDirect3DLightImpl_Release,
/*** IDirect3DLight Methods ***/
IDirect3DLightImpl_Initialize,
IDirect3DLightImpl_SetLight,
IDirect3DLightImpl_GetLight
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d)
{
IDirect3DLightImpl *object;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DLightImpl));
if (object == NULL) return DDERR_OUTOFMEMORY;
object->ref = 1;
object->d3d = d3d;
object->next = NULL;
object->activate = activate;
object->desactivate = desactivate;
object->update = update;
object->active_viewport = NULL;
ICOM_INIT_INTERFACE(object, IDirect3DLight, VTABLE_IDirect3DLight);
*obj = object;
TRACE(" creating implementation at %p.\n", *obj);
return D3D_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
/* Direct3D Material
* Copyright (c) 2002 Lionel ULMER
* Copyright (c) 2006 Stefan DÖSINGER
*
* This file contains the implementation of Direct3DMaterial.
*
@ -19,38 +20,64 @@
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "objbase.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
#include "d3d_private.h"
#include "opengl_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
static void dump_material(LPD3DMATERIAL mat)
{
DPRINTF(" dwSize : %ld\n", mat->dwSize);
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_3_2T_1T_QueryInterface(LPDIRECT3DMATERIAL3 iface,
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DMaterial3::QueryInterface
*
* QueryInterface for IDirect3DMaterial. Can query all IDirect3DMaterial
* versions.
*
* Params:
* riid: Interface id queried for
* obj: Address to pass the interface pointer back
*
* Returns:
* S_OK on success
* E_NOINTERFACE if the requested interface wasn't found
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_QueryInterface(IDirect3DMaterial3 *iface,
REFIID riid,
LPVOID* obp)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obp);
*obp = NULL;
@ -79,27 +106,46 @@ Main_IDirect3DMaterialImpl_3_2T_1T_QueryInterface(LPDIRECT3DMATERIAL3 iface,
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return OLE_E_ENUM_NOMORE;
return E_NOINTERFACE;
}
ULONG WINAPI
Main_IDirect3DMaterialImpl_3_2T_1T_AddRef(LPDIRECT3DMATERIAL3 iface)
/*****************************************************************************
* IDirect3DMaterial3::AddRef
*
* Increases the refcount.
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DMaterialImpl_AddRef(IDirect3DMaterial3 *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)->() incrementing from %lu.\n", This, iface, ref - 1);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
ULONG WINAPI
Main_IDirect3DMaterialImpl_3_2T_1T_Release(LPDIRECT3DMATERIAL3 iface)
/*****************************************************************************
* IDirect3DMaterial3::Release
*
* Reduces the refcount by one. If the refcount falls to 0, the object
* is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DMaterialImpl_Release(IDirect3DMaterial3 *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
@ -108,38 +154,90 @@ Main_IDirect3DMaterialImpl_3_2T_1T_Release(LPDIRECT3DMATERIAL3 iface)
return ref;
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_1_Initialize(LPDIRECT3DMATERIAL iface,
LPDIRECT3D lpDirect3D)
/*****************************************************************************
* IDirect3DMaterial Methods
*****************************************************************************/
/*****************************************************************************
* IDirect3DMaterial::Initialize
*
* A no-op initialization
*
* Params:
* Direct3D: Pointer to a Direct3D interface
*
* Returns:
* D3D_OK
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_Initialize(IDirect3DMaterial *iface,
IDirect3D *Direct3D)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial, iface);
TRACE("(%p/%p)->(%p) no-op...!\n", This, iface, lpDirect3D);
return DD_OK;
TRACE("(%p)->(%p) no-op...!\n", This, Direct3D);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_1_Reserve(LPDIRECT3DMATERIAL iface)
/*****************************************************************************
* IDirect3DMaterial::Reserve
*
* DirectX 5 sdk: "The IDirect3DMaterial2::Reserve method is not implemented"
* Odd. They seem to have mixed their interfaces.
*
* Returns:
* DDERR_UNSUPPORTED
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_Reserve(IDirect3DMaterial *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial, iface);
TRACE("(%p/%p)->() not implemented.\n", This, iface);
return DD_OK;
TRACE("(%p)->() not implemented\n", This);
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_1_Unreserve(LPDIRECT3DMATERIAL iface)
/*****************************************************************************
* IDirect3DMaterial::Unreserve
*
* Not supported too
*
* Returns:
* DDERR_UNSUPPORTED
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_Unreserve(IDirect3DMaterial *iface)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial, iface);
FIXME("(%p/%p)->() not implemented.\n", This, iface);
return DD_OK;
TRACE("(%p)->() not implemented.\n", This);
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_3_2T_1T_SetMaterial(LPDIRECT3DMATERIAL3 iface,
LPD3DMATERIAL lpMat)
/*****************************************************************************
* IDirect3DMaterial3::SetMaterial
*
* Sets the material description
*
* Params:
* Mat: Material to set
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Mat is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_SetMaterial(IDirect3DMaterial3 *iface,
D3DMATERIAL *lpMat)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
TRACE("(%p/%p)->(%p)\n", This, iface, lpMat);
if (TRACE_ON(ddraw))
TRACE("(%p)->(%p)\n", This, lpMat);
if (TRACE_ON(d3d7))
dump_material(lpMat);
/* Stores the material */
@ -149,14 +247,27 @@ Main_IDirect3DMaterialImpl_3_2T_1T_SetMaterial(LPDIRECT3DMATERIAL3 iface,
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_3_2T_1T_GetMaterial(LPDIRECT3DMATERIAL3 iface,
LPD3DMATERIAL lpMat)
/*****************************************************************************
* IDirect3DMaterial3::GetMaterial
*
* Returns the material assigned to this interface
*
* Params:
* Mat: Pointer to a D3DMATERIAL structure to store the material description
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Mat is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_GetMaterial(IDirect3DMaterial3 *iface,
D3DMATERIAL *lpMat)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
DWORD dwSize;
TRACE("(%p/%p)->(%p)\n", This, iface, lpMat);
if (TRACE_ON(ddraw)) {
TRACE("(%p)->(%p)\n", This, lpMat);
if (TRACE_ON(d3d7)) {
TRACE(" Returning material : ");
dump_material(&This->mat);
}
@ -169,10 +280,25 @@ Main_IDirect3DMaterialImpl_3_2T_1T_GetMaterial(LPDIRECT3DMATERIAL3 iface,
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DMaterialImpl_3_2T_1T_GetHandle(LPDIRECT3DMATERIAL3 iface,
LPDIRECT3DDEVICE3 lpDirect3DDevice3,
LPD3DMATERIALHANDLE lpHandle)
/*****************************************************************************
* IDirect3DMaterial3::GetHandle
*
* Returns a handle for the material interface. The handle is simply a
* pointer to the material implementation
*
* Params:
* Direct3DDevice3: The device this handle is assigned to
* Handle: Address to write the handle to
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Handle is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
IDirect3DDevice3 *lpDirect3DDevice3,
D3DMATERIALHANDLE *lpHandle)
{
ICOM_THIS_FROM(IDirect3DMaterialImpl, IDirect3DMaterial3, iface);
TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpDirect3DDevice3, lpHandle);
@ -191,7 +317,7 @@ Thunk_IDirect3DMaterialImpl_2_GetHandle(LPDIRECT3DMATERIAL2 iface,
LPDIRECT3DDEVICE2 lpDirect3DDevice2,
LPD3DMATERIALHANDLE lpHandle)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice2, lpHandle);
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice2, lpHandle);
return IDirect3DMaterial3_GetHandle(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice2, IDirect3DDevice3, lpDirect3DDevice2),
lpHandle);
@ -202,7 +328,7 @@ Thunk_IDirect3DMaterialImpl_1_GetHandle(LPDIRECT3DMATERIAL iface,
LPDIRECT3DDEVICE lpDirect3DDevice,
LPD3DMATERIALHANDLE lpHandle)
{
TRACE("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice, lpHandle);
TRACE_(ddraw_thunk)("(%p)->(%p,%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpDirect3DDevice, lpHandle);
return IDirect3DMaterial3_GetHandle(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice, IDirect3DDevice3, lpDirect3DDevice),
lpHandle);
@ -213,7 +339,7 @@ Thunk_IDirect3DMaterialImpl_2_QueryInterface(LPDIRECT3DMATERIAL2 iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
riid,
obp);
@ -224,195 +350,136 @@ Thunk_IDirect3DMaterialImpl_1_QueryInterface(LPDIRECT3DMATERIAL iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DMaterial3 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DMaterial3_QueryInterface(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
riid,
obp);
}
ULONG WINAPI
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_AddRef(LPDIRECT3DMATERIAL2 iface)
{
TRACE("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_AddRef(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface));
}
ULONG WINAPI
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_AddRef(LPDIRECT3DMATERIAL iface)
{
TRACE("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_AddRef(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface));
}
ULONG WINAPI
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_2_Release(LPDIRECT3DMATERIAL2 iface)
{
TRACE("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_Release(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface));
}
ULONG WINAPI
static ULONG WINAPI
Thunk_IDirect3DMaterialImpl_1_Release(LPDIRECT3DMATERIAL iface)
{
TRACE("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DMaterial3 interface.\n", iface);
return IDirect3DMaterial3_Release(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface));
}
HRESULT WINAPI
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_SetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
lpMat);
}
HRESULT WINAPI
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_SetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_SetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
lpMat);
}
HRESULT WINAPI
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_2_GetMaterial(LPDIRECT3DMATERIAL2 iface,
LPD3DMATERIAL lpMat)
{
TRACE("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial2, IDirect3DMaterial3, iface),
lpMat);
}
HRESULT WINAPI
static HRESULT WINAPI
Thunk_IDirect3DMaterialImpl_1_GetMaterial(LPDIRECT3DMATERIAL iface,
LPD3DMATERIAL lpMat)
{
TRACE("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DMaterial3 interface.\n", iface, lpMat);
return IDirect3DMaterial3_GetMaterial(COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial, IDirect3DMaterial3, iface),
lpMat);
}
/*******************************************************************************
* Matrial2 static functions
*/
static void activate(IDirect3DMaterialImpl* This) {
/*****************************************************************************
* material_activate
*
* Uses IDirect3DDevice7::SetMaterial to activate the material
*
* Params:
* This: Pointer to the material implementation to activate
*
*****************************************************************************/
void material_activate(IDirect3DMaterialImpl* This)
{
D3DMATERIAL7 d3d7mat;
TRACE("Activating material %p\n", This);
d3d7mat.u.diffuse = This->mat.u.diffuse;
d3d7mat.u1.ambient = This->mat.u1.ambient;
d3d7mat.u2.specular = This->mat.u2.specular;
d3d7mat.u3.emissive = This->mat.u3.emissive;
d3d7mat.u4.power = This->mat.u4.power;
/* Set the current Material */
ENTER_GL();
glMaterialfv(GL_FRONT_AND_BACK,
GL_DIFFUSE,
(float *) &(This->mat.u.diffuse));
glMaterialfv(GL_FRONT_AND_BACK,
GL_AMBIENT,
(float *) &(This->mat.u1.ambient));
glMaterialfv(GL_FRONT_AND_BACK,
GL_SPECULAR,
(float *) &(This->mat.u2.specular));
glMaterialfv(GL_FRONT_AND_BACK,
GL_EMISSION,
(float *) &(This->mat.u3.emissive));
LEAVE_GL();
if (TRACE_ON(ddraw)) {
DPRINTF(" - size : %ld\n", This->mat.dwSize);
DPRINTF(" - diffuse : "); dump_D3DCOLORVALUE(&(This->mat.u.diffuse)); DPRINTF("\n");
DPRINTF(" - ambient : "); dump_D3DCOLORVALUE(&(This->mat.u1.ambient)); DPRINTF("\n");
DPRINTF(" - specular: "); dump_D3DCOLORVALUE(&(This->mat.u2.specular)); DPRINTF("\n");
DPRINTF(" - emissive: "); dump_D3DCOLORVALUE(&(This->mat.u3.emissive)); DPRINTF("\n");
DPRINTF(" - power : %f\n", This->mat.u4.power);
DPRINTF(" - texture handle : %08lx\n", (DWORD)This->mat.hTexture);
}
IDirect3DDevice7_SetMaterial(ICOM_INTERFACE(This->active_device, IDirect3DDevice7),
&d3d7mat);
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DMaterial3.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DMaterial3Vtbl VTABLE_IDirect3DMaterial3 =
const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl =
{
XCAST(QueryInterface) Main_IDirect3DMaterialImpl_3_2T_1T_QueryInterface,
XCAST(AddRef) Main_IDirect3DMaterialImpl_3_2T_1T_AddRef,
XCAST(Release) Main_IDirect3DMaterialImpl_3_2T_1T_Release,
XCAST(SetMaterial) Main_IDirect3DMaterialImpl_3_2T_1T_SetMaterial,
XCAST(GetMaterial) Main_IDirect3DMaterialImpl_3_2T_1T_GetMaterial,
XCAST(GetHandle) Main_IDirect3DMaterialImpl_3_2T_1T_GetHandle,
/*** IUnknown Methods ***/
IDirect3DMaterialImpl_QueryInterface,
IDirect3DMaterialImpl_AddRef,
IDirect3DMaterialImpl_Release,
/*** IDirect3DMaterial3 Methods ***/
IDirect3DMaterialImpl_SetMaterial,
IDirect3DMaterialImpl_GetMaterial,
IDirect3DMaterialImpl_GetHandle,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DMaterial2.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DMaterial2Vtbl VTABLE_IDirect3DMaterial2 =
const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl =
{
XCAST(QueryInterface) Thunk_IDirect3DMaterialImpl_2_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DMaterialImpl_2_AddRef,
XCAST(Release) Thunk_IDirect3DMaterialImpl_2_Release,
XCAST(SetMaterial) Thunk_IDirect3DMaterialImpl_2_SetMaterial,
XCAST(GetMaterial) Thunk_IDirect3DMaterialImpl_2_GetMaterial,
XCAST(GetHandle) Thunk_IDirect3DMaterialImpl_2_GetHandle,
/*** IUnknown Methods ***/
Thunk_IDirect3DMaterialImpl_2_QueryInterface,
Thunk_IDirect3DMaterialImpl_2_AddRef,
Thunk_IDirect3DMaterialImpl_2_Release,
/*** IDirect3DMaterial2 Methods ***/
Thunk_IDirect3DMaterialImpl_2_SetMaterial,
Thunk_IDirect3DMaterialImpl_2_GetMaterial,
Thunk_IDirect3DMaterialImpl_2_GetHandle,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DMaterial.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DMaterialVtbl VTABLE_IDirect3DMaterial =
const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl =
{
XCAST(QueryInterface) Thunk_IDirect3DMaterialImpl_1_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DMaterialImpl_1_AddRef,
XCAST(Release) Thunk_IDirect3DMaterialImpl_1_Release,
XCAST(Initialize) Main_IDirect3DMaterialImpl_1_Initialize,
XCAST(SetMaterial) Thunk_IDirect3DMaterialImpl_1_SetMaterial,
XCAST(GetMaterial) Thunk_IDirect3DMaterialImpl_1_GetMaterial,
XCAST(GetHandle) Thunk_IDirect3DMaterialImpl_1_GetHandle,
XCAST(Reserve) Main_IDirect3DMaterialImpl_1_Reserve,
XCAST(Unreserve) Main_IDirect3DMaterialImpl_1_Unreserve,
/*** IUnknown Methods ***/
Thunk_IDirect3DMaterialImpl_1_QueryInterface,
Thunk_IDirect3DMaterialImpl_1_AddRef,
Thunk_IDirect3DMaterialImpl_1_Release,
/*** IDirect3DMaterial1 Methods ***/
IDirect3DMaterialImpl_Initialize,
Thunk_IDirect3DMaterialImpl_1_SetMaterial,
Thunk_IDirect3DMaterialImpl_1_GetMaterial,
Thunk_IDirect3DMaterialImpl_1_GetHandle,
IDirect3DMaterialImpl_Reserve,
IDirect3DMaterialImpl_Unreserve
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d)
{
IDirect3DMaterialImpl *object;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DMaterialImpl));
if (object == NULL) return DDERR_OUTOFMEMORY;
object->ref = 1;
object->d3d = d3d;
object->activate = activate;
ICOM_INIT_INTERFACE(object, IDirect3DMaterial, VTABLE_IDirect3DMaterial);
ICOM_INIT_INTERFACE(object, IDirect3DMaterial2, VTABLE_IDirect3DMaterial2);
ICOM_INIT_INTERFACE(object, IDirect3DMaterial3, VTABLE_IDirect3DMaterial3);
*obj = object;
TRACE(" creating implementation at %p.\n", *obj);
return D3D_OK;
}

View File

@ -1,222 +0,0 @@
/* MESA private include file
* Copyright (c) 1998 Lionel ULMER
*
* This file contains all structures that are not exported
* through d3d.h and all common macros.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __GRAPHICS_WINE_MESA_PRIVATE_H
#define __GRAPHICS_WINE_MESA_PRIVATE_H
#include "d3d_private.h"
#ifdef HAVE_OPENGL
#include "gl_private.h"
/* X11 locking */
extern void (*wine_tsx11_lock_ptr)(void);
extern void (*wine_tsx11_unlock_ptr)(void);
/* As GLX relies on X, this is needed */
#define ENTER_GL() wine_tsx11_lock_ptr()
#define LEAVE_GL() wine_tsx11_unlock_ptr()
extern const GUID IID_D3DDEVICE_OpenGL;
typedef enum {
SURFACE_GL,
SURFACE_MEMORY,
SURFACE_MEMORY_DIRTY
} SURFACE_STATE;
/* This structure is used for the 'd3d_private' field of the IDirectDraw structure */
typedef struct IDirect3DGLImpl
{
int dummy; /* Empty for the moment */
} IDirect3DGLImpl;
/* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
typedef struct IDirect3DTextureGLImpl
{
GLuint tex_name;
BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
IDirectDrawSurfaceImpl *main; /* Pointer to the 'main' surface of the mip-map set */
/* Texture upload management */
BOOLEAN initial_upload_done;
SURFACE_STATE dirty_flag;
/* This is used to optimize dirty checking in case of mipmapping.
Note that a bitmap could have been used but it was not worth the pain as it will be very rare
to have only one mipmap level change...
The __global_dirty_flag will only be set for the main mipmap level.
*/
SURFACE_STATE __global_dirty_flag;
SURFACE_STATE *global_dirty_flag;
/* This is to optimize the 'per-texture' parameters. */
DWORD *tex_parameters;
/* Surface optimization */
void *surface_ptr;
/* Used to detect a change in internal format when going from non-CK texture to CK-ed texture */
GLenum current_internal_format;
/* This is for now used to override 'standard' surface stuff to be as transparent as possible */
void (*final_release)(struct IDirectDrawSurfaceImpl *This);
void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
} IDirect3DTextureGLImpl;
typedef enum {
GL_TRANSFORM_NONE = 0,
GL_TRANSFORM_ORTHO,
GL_TRANSFORM_NORMAL,
GL_TRANSFORM_VERTEXBUFFER
} GL_TRANSFORM_STATE;
typedef enum {
WINE_GL_BUFFER_BACK = 0,
WINE_GL_BUFFER_FRONT
} WINE_GL_BUFFER_TYPE;
typedef struct IDirect3DDeviceGLImpl
{
struct IDirect3DDeviceImpl parent;
GLXContext gl_context;
/* This stores the textures which are actually bound to the GL context */
IDirectDrawSurfaceImpl *current_bound_texture[MAX_TEXTURES];
/* The last type of vertex drawn */
GL_TRANSFORM_STATE transform_state;
/* Used to handle fogging faster... */
BYTE fog_table[3 * 0x10000]; /* 3 is for R, G and B
0x10000 is 0xFF for the vertex color and
0xFF for the fog intensity */
Display *display;
Drawable drawable;
/* Variables used for the flush to frame-buffer code using the texturing code */
GLuint unlock_tex;
void *surface_ptr;
GLenum current_internal_format;
/* 0 is back-buffer, 1 is front-buffer */
SURFACE_STATE state[2];
IDirectDrawSurfaceImpl *lock_surf[2];
RECT lock_rect[2];
/* This is just here to print-out a nice warning if we have two successive locks */
BOOLEAN lock_rect_valid[2];
/* This is used to optimize some stuff */
DWORD prev_clear_color;
DWORD prev_clear_stencil;
D3DVALUE prev_clear_Z;
BOOLEAN depth_mask, depth_test, alpha_test, stencil_test, cull_face, lighting, blending, fogging;
GLenum current_alpha_test_func;
GLclampf current_alpha_test_ref;
GLenum current_tex_env;
GLenum current_active_tex_unit;
} IDirect3DDeviceGLImpl;
/* This is for the OpenGL additions... */
typedef struct {
struct IDirect3DVertexBufferImpl parent;
DWORD dwVertexTypeDesc;
D3DMATRIX world_mat, view_mat, proj_mat;
LPVOID vertices;
} IDirect3DVertexBufferGLImpl;
/* This is for GL extension support.
This can contain either only a boolean if no function pointer exists or a set
of function pointers.
*/
typedef struct {
/* Mirrored Repeat */
BOOLEAN mirrored_repeat;
/* Mipmap lod-bias */
BOOLEAN mipmap_lodbias;
/* Multi-texturing */
GLint max_texture_units;
void (*glActiveTexture)(GLenum texture);
void (*glMultiTexCoord[4])(GLenum target, const GLfloat *v);
void (*glClientActiveTexture)(GLenum texture);
/* S3TC/DXTN compressed texture */
BOOLEAN s3tc_compressed_texture;
void (*glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
void (*glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLsizei imageSize, const GLvoid *data);
} GL_EXTENSIONS_LIST;
extern GL_EXTENSIONS_LIST GL_extensions;
/* All non-static functions 'exported' by various sub-objects */
extern HRESULT direct3d_create(IDirectDrawImpl *This);
extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d);
extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d);
extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d);
extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface, int version);
/* Used for Direct3D to request the device to enumerate itself */
extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ;
extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
/* Used by the DLL init routine to set-up the GL context and stuff properly */
extern BOOL d3ddevice_init_at_startup(void *gl_handle);
/* Used to upload the texture */
extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage) ;
/* Used to get the texture name */
extern GLuint gltex_get_tex_name(IDirectDrawSurfaceImpl *This) ;
/* Used to set-up our orthographic projection */
extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
/* Rendering state management functions */
extern void set_render_state(IDirect3DDeviceImpl* This, D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock);
extern void store_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState, STATEBLOCK* lpStateBlock);
extern void get_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState, STATEBLOCK* lpStateBlock);
extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlock);
/* Memory to texture conversion code. Split in three functions to do some optimizations. */
extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface, GLuint level, GLenum *prev_internal_format,
BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height);
extern HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer);
extern HRESULT upload_surface_to_tex_memory_release(void);
/* Some utilities functions needed to be shared.. */
extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState) ;
#endif /* HAVE_OPENGL */
#endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */

File diff suppressed because it is too large Load Diff

240
dlls/ddraw/palette.c Normal file
View File

@ -0,0 +1,240 @@
/* DirectDraw - IDirectPalette base interface
*
* Copyright 2006 Stefan Dösinger
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*****************************************************************************
* IDirectDrawPalette::QueryInterface
*
* A usual QueryInterface implementation. Can only Query IUnknown and
* IDirectDrawPalette
*
* Params:
* refiid: The interface id queried for
* obj: Address to return the interface pointer at
*
* Returns:
* S_OK on success
* E_NOINTERFACE if the requested interface wasn't found
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_QueryInterface(IDirectDrawPalette *iface,
REFIID refiid,
void **obj)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
*obj = iface;
IDirectDrawPalette_AddRef(iface);
return S_OK;
}
else
{
*obj = NULL;
return E_NOINTERFACE;
}
}
/*****************************************************************************
* IDirectDrawPaletteImpl::AddRef
*
* Increases the refcount.
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirectDrawPaletteImpl_AddRef(IDirectDrawPalette *iface)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IDirectDrawPaletteImpl::Release
*
* Reduces the refcount. If the refcount falls to 0, the object is destroyed
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (ref == 0)
{
IWineD3DPalette_Release(This->wineD3DPalette);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/*****************************************************************************
* IDirectDrawPalette::Initialize
*
* Initializes the palette. As we start initialized, return
* DDERR_ALREADYINITIALIZED
*
* Params:
* DD: DirectDraw interface this palette is asigned to
* Flags: Some flags, as usual
* ColorTable: The startup color table
*
* Returns:
* DDERR_ALREADYINITIALIZED
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_Initialize(IDirectDrawPalette *iface,
IDirectDraw *DD,
DWORD Flags,
PALETTEENTRY *ColorTable)
{
TRACE("(%p)->(%p,%lx,%p)\n", iface, DD, Flags, ColorTable);
return DDERR_ALREADYINITIALIZED;
}
/*****************************************************************************
* IDirectDrawPalette::GetCaps
*
* Returns the palette description
*
* Params:
* Caps: Address to store the caps at
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Caps is NULL
* For more details, see IWineD3DPalette::GetCaps
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
DWORD *Caps)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%p): Relay\n", This, Caps);
return IWineD3DPalette_GetCaps(This->wineD3DPalette, Caps);
}
/*****************************************************************************
* IDirectDrawPalette::SetEntries
*
* Sets the palette entries from a PALETTEENTRY structure. WineD3D takes
* care for updating the surface.
*
* Params:
* Flags: Flags, as usual
* Start: First palette entry to set
* Count: Number of entries to set
* PalEnt: Source entries
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if PalEnt is NULL
* For details, see IWineD3DDevice::SetEntries
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
DWORD Flags,
DWORD Start,
DWORD Count,
PALETTEENTRY *PalEnt)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%lx,%ld,%ld,%p): Relay\n", This, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return IWineD3DPalette_SetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
}
/*****************************************************************************
* IDirectDrawPalette::GetEntries
*
* Returns the entries stored in this interface.
*
* Params:
* Flags: Flags :)
* Start: First entry to return
* Count: The number of entries to return
* PalEnt: PALETTEENTRY structure to write the entries to
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if PalEnt is NULL
* For details, see IWineD3DDevice::SetEntries
*
*****************************************************************************/
static HRESULT WINAPI
IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
DWORD Flags,
DWORD Start,
DWORD Count,
PALETTEENTRY *PalEnt)
{
ICOM_THIS_FROM(IDirectDrawPaletteImpl, IDirectDrawPalette, iface);
TRACE("(%p)->(%lx,%ld,%ld,%p): Relay\n", This, Flags, Start, Count, PalEnt);
if(!PalEnt)
return DDERR_INVALIDPARAMS;
return IWineD3DPalette_GetEntries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
}
const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl =
{
/*** IUnknown ***/
IDirectDrawPaletteImpl_QueryInterface,
IDirectDrawPaletteImpl_AddRef,
IDirectDrawPaletteImpl_Release,
/*** IDirectDrawPalette ***/
IDirectDrawPaletteImpl_GetCaps,
IDirectDrawPaletteImpl_GetEntries,
IDirectDrawPaletteImpl_Initialize,
IDirectDrawPaletteImpl_SetEntries
};

View File

@ -1,134 +0,0 @@
/* DirectDrawPalette HAL driver
*
* Copyright 2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable;
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
IDirectDrawImpl* pDD, DWORD dwFlags)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
DDHAL_CREATEPALETTEDATA data;
HRESULT hr;
hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr)) return hr;
This->final_release = HAL_DirectDrawPalette_final_release;
ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_HAL_Palette_VTable);
/* initialize HAL palette */
data.lpDD = dd_gbl;
data.lpDDPalette = &This->global;
data.lpColorTable = NULL;
data.ddRVal = 0;
data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
if (data.CreatePalette)
data.CreatePalette(&data);
return DD_OK;
}
HRESULT
HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter)
{
IDirectDrawPaletteImpl* This;
HRESULT hr;
if (pUnkOuter != NULL)
return CLASS_E_NOAGGREGATION; /* unchecked */
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
if (This == NULL) return E_OUTOFMEMORY;
hr = HAL_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
return hr;
}
HRESULT WINAPI
HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
DDHAL_SETENTRIESDATA data;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
data.lpDD = dd_gbl;
data.lpDDPalette = &This->global;
data.dwBase = dwStart;
data.dwNumEntries = dwCount;
data.lpEntries = palent;
data.ddRVal = 0;
data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.SetEntries;
if (data.SetEntries)
data.SetEntries(&data);
return Main_DirectDrawPalette_SetEntries(iface, dwFlags, dwStart, dwCount, palent);
}
void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
DDHAL_DESTROYPALETTEDATA data;
/* destroy HAL palette */
data.lpDD = dd_gbl;
data.lpDDPalette = &This->global;
data.ddRVal = 0;
data.DestroyPalette = dd_gbl->lpDDCBtmp->HALDDPalette.DestroyPalette;
if (data.DestroyPalette)
data.DestroyPalette(&data);
Main_DirectDrawPalette_final_release(This);
}
static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable =
{
Main_DirectDrawPalette_QueryInterface,
Main_DirectDrawPalette_AddRef,
Main_DirectDrawPalette_Release,
Main_DirectDrawPalette_GetCaps,
Main_DirectDrawPalette_GetEntries,
Main_DirectDrawPalette_Initialize,
HAL_DirectDrawPalette_SetEntries
};

View File

@ -1,281 +0,0 @@
/* DirectDraw - IDirectPalette base interface
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 2000-2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include "wine/debug.h"
#include <assert.h>
#include <string.h>
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
#define SIZE_BITS (DDPCAPS_1BIT | DDPCAPS_2BIT | DDPCAPS_4BIT | DDPCAPS_8BIT)
/* For unsigned x. 0 is not a power of 2. */
#define IS_POW_2(x) (((x) & ((x) - 1)) == 0)
static const IDirectDrawPaletteVtbl DDRAW_Main_Palette_VTable;
/******************************************************************************
* IDirectDrawPalette
*/
HRESULT Main_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
IDirectDrawImpl* pDD, DWORD dwFlags)
{
if (!IS_POW_2(dwFlags & SIZE_BITS)) return DDERR_INVALIDPARAMS;
if (dwFlags & DDPCAPS_8BITENTRIES)
WARN("creating palette with 8 bit entries\n");
This->palNumEntries = Main_DirectDrawPalette_Size(dwFlags);
This->ref = 1;
This->local.lpGbl = &This->global;
This->local.lpDD_lcl = &pDD->local;
This->global.lpDD_lcl = &pDD->local;
This->global.dwProcessId = GetCurrentProcessId();
This->global.dwFlags = dwFlags;
This->final_release = Main_DirectDrawPalette_final_release;
ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_Main_Palette_VTable);
/* we could defer hpal creation until we need it,
* but does anyone have a case where it would be useful? */
This->hpal = CreatePalette((const LOGPALETTE*)&(This->palVersion));
Main_DirectDraw_AddPalette(pDD, This);
return DD_OK;
}
HRESULT
Main_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
LPDIRECTDRAWPALETTE* ppPalette,
LPUNKNOWN pUnkOuter)
{
IDirectDrawPaletteImpl* This;
HRESULT hr;
if (pUnkOuter != NULL)
return CLASS_E_NOAGGREGATION; /* unchecked */
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
if (This == NULL) return E_OUTOFMEMORY;
hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
return hr;
}
DWORD Main_DirectDrawPalette_Size(DWORD dwFlags)
{
switch (dwFlags & SIZE_BITS)
{
case DDPCAPS_1BIT: return 2;
case DDPCAPS_2BIT: return 4;
case DDPCAPS_4BIT: return 16;
case DDPCAPS_8BIT: return 256;
default: assert(0); return 256;
}
}
HRESULT WINAPI
Main_DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->GetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
if (dwFlags != 0) return DDERR_INVALIDPARAMS; /* unchecked */
if (dwStart + dwCount > Main_DirectDrawPalette_Size(This->global.dwFlags))
return DDERR_INVALIDPARAMS;
if (This->global.dwFlags & DDPCAPS_8BITENTRIES)
{
unsigned int i;
LPBYTE entry = (LPBYTE)palent;
for (i=dwStart; i < dwCount+dwStart; i++)
*entry++ = This->palents[i].peRed;
}
else
memcpy(palent, This->palents+dwStart, dwCount * sizeof(PALETTEENTRY));
return DD_OK;
}
HRESULT WINAPI
Main_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
palent);
if (This->global.dwFlags & DDPCAPS_8BITENTRIES)
{
unsigned int i;
const BYTE* entry = (const BYTE*)palent;
for (i=dwStart; i < dwCount+dwStart; i++)
This->palents[i].peRed = *entry++;
}
else {
memcpy(This->palents+dwStart, palent, dwCount * sizeof(PALETTEENTRY));
if (This->hpal)
SetPaletteEntries(This->hpal, dwStart, dwCount, This->palents+dwStart);
if (This->global.dwFlags & DDPCAPS_PRIMARYSURFACE) {
/* update physical palette */
LPDIRECTDRAWSURFACE7 psurf = NULL;
IDirectDraw7_GetGDISurface(ICOM_INTERFACE(This->ddraw_owner,IDirectDraw7), &psurf);
if (psurf) {
IDirectDrawSurfaceImpl *surf = ICOM_OBJECT(IDirectDrawSurfaceImpl,
IDirectDrawSurface7, psurf);
surf->update_palette(surf, This, dwStart, dwCount, palent);
IDirectDrawSurface7_Release(psurf);
}
else ERR("can't find GDI surface!!\n");
}
}
#if 0
/* Now, if we are in 'depth conversion mode', update the screen palette */
/* FIXME: we need to update the image or we won't get palette fading. */
if (This->ddraw->d->palette_convert != NULL)
This->ddraw->d->palette_convert(palent,This->screen_palents,start,count);
#endif
return DD_OK;
}
void Main_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
{
Main_DirectDraw_RemovePalette(This->ddraw_owner, This);
if (This->hpal) DeleteObject(This->hpal);
}
static void Main_DirectDrawPalette_Destroy(IDirectDrawPaletteImpl* This)
{
This->final_release(This);
if (This->private != This+1)
HeapFree(GetProcessHeap(), 0, This->private);
HeapFree(GetProcessHeap(),0,This);
}
void Main_DirectDrawPalette_ForceDestroy(IDirectDrawPaletteImpl* This)
{
WARN("deleting palette %p with refcnt %lu\n", This, This->ref);
Main_DirectDrawPalette_Destroy(This);
}
ULONG WINAPI
Main_DirectDrawPalette_Release(LPDIRECTDRAWPALETTE iface)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (!ref)
{
Main_DirectDrawPalette_Destroy(This);
return 0;
}
return ref;
}
ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface) {
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
HRESULT WINAPI
Main_DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface,
LPDIRECTDRAW ddraw, DWORD dwFlags,
LPPALETTEENTRY palent)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->(%p,%ld,%p)\n", This, ddraw, dwFlags, palent);
return DDERR_ALREADYINITIALIZED;
}
HRESULT WINAPI
Main_DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->(%p)\n",This,lpdwCaps);
*lpdwCaps = This->global.dwFlags;
return DD_OK;
}
HRESULT WINAPI
Main_DirectDrawPalette_QueryInterface(LPDIRECTDRAWPALETTE iface,
REFIID refiid, LPVOID *obj)
{
IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if (IsEqualGUID(refiid, &IID_IUnknown)
|| IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
*obj = iface;
IDirectDrawPalette_AddRef(iface);
return S_OK;
}
else
{
return E_NOINTERFACE;
}
}
static const IDirectDrawPaletteVtbl DDRAW_Main_Palette_VTable =
{
Main_DirectDrawPalette_QueryInterface,
Main_DirectDrawPalette_AddRef,
Main_DirectDrawPalette_Release,
Main_DirectDrawPalette_GetCaps,
Main_DirectDrawPalette_GetEntries,
Main_DirectDrawPalette_Initialize,
Main_DirectDrawPalette_SetEntries
};

152
dlls/ddraw/parent.c Normal file
View File

@ -0,0 +1,152 @@
/*
* IParent implementation
*
* Copyright (c) 2006 Stefan Dösinger
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* A universal parent interface for everything in WineD3D that doesn't have
* a DDraw counterpart
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
const GUID IID_IParent = {0xc20e4c88, 0x74e7, 0x4940, {0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81}};
/*****************************************************************************
* IUnknown methods
*****************************************************************************/
/*****************************************************************************
* IParent::Queryinterface
*
* It can't query any interfaces, and it's not used for anything. So
* it just returns E_NOINTERFACE
*
* Params:
* riid: guid of queried interface
* obj: returns a pointer to the interface
*
* Return values
* This implementation always returns E_NOINTERFACE and NULL
*
*****************************************************************************/
static HRESULT WINAPI
IParentImpl_QueryInterface(IParent *iface,
REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
*obj = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ||
IsEqualGUID( &IID_IParent, riid ) )
{
*obj = ICOM_INTERFACE(This, IParent);
IParent_AddRef(ICOM_INTERFACE(This, IParent));
return DD_OK;
}
return E_NOINTERFACE;
}
/*****************************************************************************
* IParent::AddRef
*
* Increases the refcount
*
* Params:
*
* Return values
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_AddRef(IParent *iface)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
return ref;
}
/*****************************************************************************
* IParent::Release
*
* Releases the refcount, and destroys the object if the refcount falls to 0
* Also releases the child object, if destroyed. That's almost the whole sense
* of this interface.
*
* Params:
*
* Return values
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IParentImpl_Release(IParent *iface)
{
ICOM_THIS_FROM(IParentImpl, IParent, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
if (ref == 0)
{
TRACE("(%p) Releasing child at %p\n", This, This->child);
if(This->child)
IUnknown_Release(This->child);
HeapFree(GetProcessHeap(), 0, This);
TRACE("Released\n");
}
return ref;
}
/*****************************************************************************
* The VTable
*****************************************************************************/
const IParentVtbl IParent_Vtbl =
{
IParentImpl_QueryInterface,
IParentImpl_AddRef,
IParentImpl_Release,
};

2091
dlls/ddraw/surface.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,312 +0,0 @@
/* 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.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include <assert.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "ddraw.h"
#include "d3d.h"
#include "wine/debug.h"
#include "ddcomimpl.h"
#include "ddraw_private.h"
#include "d3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const IDirectDrawSurface7Vtbl FakeZBuffer_IDirectDrawSurface7_VTable;
#ifdef HAVE_OPENGL
static void zbuffer_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags)
{
/* Note that this does not do anything for now... At least it's not needed for Grim Fandango :-) */
}
static void zbuffer_unlock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
{
((FakeZBuffer_DirectDrawSurfaceImpl *) This->private)->in_memory = TRUE;
}
static BOOLEAN zbuffer_get_dirty_status(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
{
if (((FakeZBuffer_DirectDrawSurfaceImpl *) This->private)->in_memory) {
((FakeZBuffer_DirectDrawSurfaceImpl *) This->private)->in_memory = FALSE;
return TRUE;
}
return FALSE;
}
#endif
HRESULT FakeZBuffer_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl *This,
IDirectDrawImpl *pDD,
const DDSURFACEDESC2 *pDDSD)
{
HRESULT hr;
BYTE zdepth = 16; /* Default value.. Should use the one from GL */
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;
#ifdef HAVE_OPENGL
if (opengl_initialized) {
This->lock_update = zbuffer_lock_update;
This->unlock_update = zbuffer_unlock_update;
This->get_dirty_status = zbuffer_get_dirty_status;
}
#endif
/* Beginning of some D3D hacks :-) */
if (This->surface_desc.dwFlags & DDSD_ZBUFFERBITDEPTH) {
zdepth = This->surface_desc.u2.dwMipMapCount; /* This is where the Z buffer depth is stored in 'old' versions */
}
if ((This->surface_desc.dwFlags & DDSD_PIXELFORMAT) == 0) {
This->surface_desc.dwFlags |= DDSD_PIXELFORMAT;
This->surface_desc.u4.ddpfPixelFormat.dwSize = sizeof(This->surface_desc.u4.ddpfPixelFormat);
This->surface_desc.u4.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
This->surface_desc.u4.ddpfPixelFormat.u1.dwZBufferBitDepth = zdepth;
}
if ((This->surface_desc.dwFlags & DDSD_PITCH) == 0) {
This->surface_desc.dwFlags |= DDSD_PITCH;
This->surface_desc.u1.lPitch = ((zdepth + 7) / 8) * This->surface_desc.dwWidth;
}
This->surface_desc.lpSurface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
This->surface_desc.u1.lPitch * This->surface_desc.dwHeight);
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)
{
Main_DirectDrawSurface_final_release(This);
}
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)
{
IDirectDrawSurfaceImpl *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 :%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);
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 ((dwFlags & DDBLT_DEPTHFILL) && (This->ddraw_owner->d3d_private != NULL)) {
if (This->ddraw_owner->current_device != NULL) {
D3DRECT rect;
if (rdst) {
rect.u1.x1 = rdst->left;
rect.u2.y1 = rdst->top;
rect.u3.x2 = rdst->right;
rect.u4.y2 = rdst->bottom;
}
This->ddraw_owner->current_device->clear(This->ddraw_owner->current_device,
(rdst == NULL ? 0 : 1), &rect,
D3DCLEAR_ZBUFFER,
0x00000000,
((double) lpbltfx->u5.dwFillDepth) / 4294967295.0,
0x00000000);
return DD_OK;
}
}
return cant_do_that("blt to a");
}
HRESULT WINAPI
FakeZBuffer_DirectDrawSurface_BltFast(LPDIRECTDRAWSURFACE7 iface, DWORD dstx,
DWORD dsty, LPDIRECTDRAWSURFACE7 src,
LPRECT rsrc, DWORD trans)
{
IDirectDrawSurfaceImpl *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: %ldx%ld-%ldx%ld\n",rsrc->left,rsrc->top,rsrc->right,rsrc->bottom);
else
FIXME(" srcrect: NULL\n");
}
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 const IDirectDrawSurface7Vtbl FakeZBuffer_IDirectDrawSurface7_VTable=
{
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
};

View File

@ -1,79 +0,0 @@
/* DirectDrawGammaControl implementation
*
* Copyright 2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "winerror.h"
#include <assert.h>
#include <stdlib.h>
#include "wine/debug.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
#define CONVERT(pddgc) COM_INTERFACE_CAST(IDirectDrawSurfaceImpl, \
IDirectDrawGammaControl, \
IDirectDrawSurface7, \
(pddgc))
static HRESULT WINAPI
DirectDrawGammaControl_QueryInterface(LPDIRECTDRAWGAMMACONTROL iface, REFIID riid,
LPVOID *ppObj)
{
TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ppObj);
return E_NOINTERFACE;
}
static ULONG WINAPI
DirectDrawGammaControl_AddRef(LPDIRECTDRAWGAMMACONTROL iface)
{
return IDirectDrawSurface7_AddRef(CONVERT(iface));
}
static ULONG WINAPI
DirectDrawGammaControl_Release(LPDIRECTDRAWGAMMACONTROL iface)
{
return IDirectDrawSurface7_Release(CONVERT(iface));
}
static HRESULT WINAPI
DirectDrawGammaControl_GetGammaRamp(LPDIRECTDRAWGAMMACONTROL iface, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", iface,dwFlags,lpGammaRamp);
return This->get_gamma_ramp(This, dwFlags, lpGammaRamp);
}
static HRESULT WINAPI
DirectDrawGammaControl_SetGammaRamp(LPDIRECTDRAWGAMMACONTROL iface, DWORD dwFlags, LPDDGAMMARAMP lpGammaRamp)
{
ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawGammaControl, iface);
TRACE("(%p)->(%08lx,%p)\n", iface,dwFlags,lpGammaRamp);
return This->set_gamma_ramp(This, dwFlags, lpGammaRamp);
}
const IDirectDrawGammaControlVtbl DDRAW_IDDGC_VTable =
{
DirectDrawGammaControl_QueryInterface,
DirectDrawGammaControl_AddRef,
DirectDrawGammaControl_Release,
DirectDrawGammaControl_GetGammaRamp,
DirectDrawGammaControl_SetGammaRamp
};

View File

@ -1,411 +0,0 @@
/* DirectDrawSurface HAL driver
*
* Copyright 2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "wine/debug.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static const IDirectDrawSurface7Vtbl HAL_IDirectDrawSurface7_VTable;
static HRESULT HAL_DirectDrawSurface_create_surface(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD)
{
HAL_PRIV_VAR(priv, This);
HAL_DDRAW_PRIV_VAR(ddpriv, pDD);
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
LPDDRAWI_DDRAWSURFACE_LCL local = &This->local;
DDHAL_CREATESURFACEDATA data;
HRESULT hr;
data.lpDD = dd_gbl;
data.lpDDSurfaceDesc = (LPDDSURFACEDESC)&This->surface_desc;
data.lplpSList = &local;
data.dwSCnt = 1;
data.ddRVal = 0;
data.CreateSurface = dd_gbl->lpDDCBtmp->HALDD.CreateSurface;
hr = data.CreateSurface(&data);
if (hr == DDHAL_DRIVER_HANDLED) {
if (This->global.fpVidMem < 4) {
/* grab framebuffer data from current_mode */
priv->hal.fb_pitch = dd_gbl->vmiData.lDisplayPitch;
priv->hal.fb_vofs = ddpriv->hal.next_vofs;
priv->hal.fb_addr = ((LPBYTE)dd_gbl->vmiData.fpPrimary) +
dd_gbl->vmiData.lDisplayPitch * priv->hal.fb_vofs;
TRACE("vofs=%ld, addr=%p\n", priv->hal.fb_vofs, priv->hal.fb_addr);
ddpriv->hal.next_vofs += This->surface_desc.dwHeight;
This->global.fpVidMem = (FLATPTR)priv->hal.fb_addr;
This->global.u4.lPitch = priv->hal.fb_pitch;
}
This->surface_desc.lpSurface = (LPVOID)This->global.fpVidMem;
This->surface_desc.dwFlags |= DDSD_LPSURFACE;
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_EXECUTEBUFFER) {
This->surface_desc.u1.dwLinearSize = This->global.u4.dwLinearSize;
This->surface_desc.dwFlags |= DDSD_LINEARSIZE;
} else {
This->surface_desc.u1.lPitch = This->global.u4.lPitch;
This->surface_desc.dwFlags |= DDSD_PITCH;
}
}
else priv->hal.need_late = TRUE;
return data.ddRVal;
}
static inline BOOL HAL_IsUser(IDirectDrawSurfaceImpl* This)
{
HAL_PRIV_VAR(priv, This);
if (This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_EXECUTEBUFFER))
return FALSE;
if (priv->hal.fb_addr)
return FALSE;
return TRUE;
}
HRESULT
HAL_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD)
{
HAL_PRIV_VAR(priv, This);
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
HRESULT hr;
TRACE("(%p,%p,%p)\n",This,pDD,pDDSD);
/* copy surface_desc, we may want to modify it before DIB construction */
This->surface_desc = *pDDSD;
/* the driver may want to dereference these pointers */
This->local.lpSurfMore = &This->more;
This->local.lpGbl = &This->global;
This->gmore = &This->global_more;
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) {
hr = HAL_DirectDrawSurface_create_surface(This, pDD);
if (FAILED(hr)) return hr;
hr = DIB_DirectDrawSurface_Construct(This, pDD, &This->surface_desc);
if (FAILED(hr)) return hr;
}
else if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_EXECUTEBUFFER) {
FIXME("create execute buffer\n");
return DDERR_GENERIC;
}
else {
if (!(dd_gbl->dwFlags & DDRAWI_MODECHANGED)) {
/* force a mode set (HALs like DGA may need it) */
hr = HAL_DirectDraw_SetDisplayMode(ICOM_INTERFACE(pDD, IDirectDraw7),
pDD->width, pDD->height,
pDD->pixelformat.u1.dwRGBBitCount,
0, 0);
if (FAILED(hr)) return hr;
}
if (dd_gbl->vmiData.fpPrimary) {
hr = HAL_DirectDrawSurface_create_surface(This, pDD);
if (FAILED(hr)) return hr;
if (priv->hal.need_late) {
/* this doesn't make sense... driver error? */
ERR("driver failed to create framebuffer surface\n");
return DDERR_GENERIC;
}
hr = DIB_DirectDrawSurface_Construct(This, pDD, &This->surface_desc);
if (FAILED(hr)) return hr;
} else {
/* no framebuffer, construct User-based primary */
hr = User_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr)) return hr;
/* must notify HAL *after* creating User-based primary */
/* (or use CreateSurfaceEx, which we don't yet) */
hr = HAL_DirectDrawSurface_create_surface(This, pDD);
if (FAILED(hr)) return hr;
priv->hal.need_late = FALSE;
}
}
ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
HAL_IDirectDrawSurface7_VTable);
This->final_release = HAL_DirectDrawSurface_final_release;
This->late_allocate = HAL_DirectDrawSurface_late_allocate;
This->duplicate_surface = HAL_DirectDrawSurface_duplicate_surface;
This->flip_data = HAL_DirectDrawSurface_flip_data;
This->flip_update = HAL_DirectDrawSurface_flip_update;
This->set_palette = HAL_DirectDrawSurface_set_palette;
This->get_display_window = HAL_DirectDrawSurface_get_display_window;
return DD_OK;
}
HRESULT
HAL_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(HAL_DirectDrawSurfaceImpl));
if (This == NULL) return E_OUTOFMEMORY;
This->private = (HAL_DirectDrawSurfaceImpl*)(This+1);
hr = HAL_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
return hr;
}
void HAL_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->more.lpDD_lcl->lpGbl;
DDHAL_DESTROYSURFACEDATA data;
/* destroy HAL surface */
data.lpDD = dd_gbl;
data.lpDDSurface = &This->local;
data.ddRVal = 0;
data.DestroySurface = dd_gbl->lpDDCBtmp->HALDDSurface.DestroySurface;
data.DestroySurface(&data);
if (HAL_IsUser(This)) {
User_DirectDrawSurface_final_release(This);
} else {
DIB_DirectDrawSurface_final_release(This);
}
}
HRESULT HAL_DirectDrawSurface_late_allocate(IDirectDrawSurfaceImpl* This)
{
HAL_PRIV_VAR(priv, This);
if (priv->hal.need_late) {
priv->hal.need_late = FALSE;
return HAL_DirectDrawSurface_create_surface(This, This->ddraw_owner);
}
return DD_OK;
}
void HAL_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->more.lpDD_lcl->lpGbl;
DDHAL_SETPALETTEDATA data;
DIB_DirectDrawSurface_set_palette(This, pal);
data.lpDD = dd_gbl;
data.lpDDSurface = &This->local;
data.lpDDPalette = (pal != NULL ? &pal->global : NULL);
data.ddRVal = 0;
data.Attach = TRUE; /* what's this? */
data.SetPalette = dd_gbl->lpDDCBtmp->HALDDSurface.SetPalette;
if (data.SetPalette)
data.SetPalette(&data);
}
HRESULT HAL_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup)
{
return HAL_DirectDrawSurface_Create(This->ddraw_owner,
&This->surface_desc, ppDup, NULL);
}
void HAL_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect, DWORD dwFlags)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->more.lpDD_lcl->lpGbl;
DDHAL_LOCKDATA data;
data.lpDD = dd_gbl;
data.lpDDSurface = &This->local;
data.ddRVal = 0;
data.lpSurfData = This->surface_desc.lpSurface; /* FIXME: correct? */
if (pRect) {
data.rArea.top = pRect->top;
data.rArea.bottom = pRect->bottom;
data.rArea.left = pRect->left;
data.rArea.right = pRect->right;
data.bHasRect = TRUE;
} else {
data.bHasRect = FALSE;
}
data.dwFlags = dwFlags;
data.Lock = dd_gbl->lpDDCBtmp->HALDDSurface.Lock;
if (data.Lock && (data.Lock(&data) == DDHAL_DRIVER_HANDLED))
return;
if (HAL_IsUser(This)) {
User_DirectDrawSurface_lock_update(This, pRect, dwFlags);
} else {
Main_DirectDrawSurface_lock_update(This, pRect, dwFlags);
}
}
void HAL_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect)
{
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->more.lpDD_lcl->lpGbl;
DDHAL_UNLOCKDATA data;
data.lpDD = dd_gbl;
data.lpDDSurface = &This->local;
data.ddRVal = 0;
data.Unlock = dd_gbl->lpDDCBtmp->HALDDSurface.Unlock;
if (data.Unlock && (data.Unlock(&data) == DDHAL_DRIVER_HANDLED))
return;
if (HAL_IsUser(This)) {
User_DirectDrawSurface_unlock_update(This, pRect);
} else {
Main_DirectDrawSurface_unlock_update(This, pRect);
}
}
BOOL HAL_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back,
DWORD dwFlags)
{
HAL_PRIV_VAR(front_priv, front);
HAL_PRIV_VAR(back_priv, back);
LPDDRAWI_DIRECTDRAW_GBL dd_gbl = front->more.lpDD_lcl->lpGbl;
DDHAL_FLIPDATA data;
BOOL ret;
{
DWORD tmp;
tmp = front_priv->hal.fb_vofs;
front_priv->hal.fb_vofs = back_priv->hal.fb_vofs;
back_priv->hal.fb_vofs = tmp;
}
{
LPVOID tmp;
tmp = front_priv->hal.fb_addr;
front_priv->hal.fb_addr = back_priv->hal.fb_addr;
back_priv->hal.fb_addr = tmp;
}
if (HAL_IsUser(front)) {
ret = User_DirectDrawSurface_flip_data(front, back, dwFlags);
} else {
ret = DIB_DirectDrawSurface_flip_data(front, back, dwFlags);
}
TRACE("(%p,%p)\n",front,back);
data.lpDD = dd_gbl;
data.lpSurfCurr = &front->local;
data.lpSurfTarg = &back->local;
data.lpSurfCurrLeft = NULL;
data.lpSurfTargLeft = NULL;
data.dwFlags = dwFlags;
data.ddRVal = 0;
data.Flip = dd_gbl->lpDDCBtmp->HALDDSurface.Flip;
if (data.Flip)
if (data.Flip(&data) == DDHAL_DRIVER_HANDLED) ret = FALSE;
return ret;
}
void HAL_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This, DWORD dwFlags)
{
if (HAL_IsUser(This)) {
User_DirectDrawSurface_flip_update(This, dwFlags);
}
}
HWND HAL_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This)
{
return 0;
}
static const IDirectDrawSurface7Vtbl HAL_IDirectDrawSurface7_VTable =
{
Main_DirectDrawSurface_QueryInterface,
Main_DirectDrawSurface_AddRef,
Main_DirectDrawSurface_Release,
Main_DirectDrawSurface_AddAttachedSurface,
Main_DirectDrawSurface_AddOverlayDirtyRect,
DIB_DirectDrawSurface_Blt,
Main_DirectDrawSurface_BltBatch,
DIB_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,
Main_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,
Main_DirectDrawSurface_ReleaseDC,
DIB_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,
DIB_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
};

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,8 @@
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
@ -38,6 +40,8 @@
IDirectDrawSurface3, \
(pdds))
WINE_DEFAULT_DEBUG_CHANNEL(ddraw_thunk);
static HRESULT WINAPI
IDirectDrawSurface3Impl_QueryInterface(LPDIRECTDRAWSURFACE3 This, REFIID iid,
LPVOID *ppObj)
@ -52,9 +56,11 @@ IDirectDrawSurface3Impl_AddRef(LPDIRECTDRAWSURFACE3 This)
}
static ULONG WINAPI
IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 This)
IDirectDrawSurface3Impl_Release(LPDIRECTDRAWSURFACE3 iface)
{
return IDirectDrawSurface7_Release(CONVERT(This));
ICOM_THIS_FROM( IDirectDrawSurfaceImpl, IDirectDrawSurface3, iface);
TRACE("(%p)\n", This);
return IDirectDrawSurface7_Release(CONVERT(iface));
}
static HRESULT WINAPI
@ -389,7 +395,7 @@ IDirectDrawSurface3Impl_SetSurfaceDesc(LPDIRECTDRAWSURFACE3 This,
dwFlags);
}
const IDirectDrawSurface3Vtbl DDRAW_IDDS3_Thunk_VTable =
const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl =
{
IDirectDrawSurface3Impl_QueryInterface,
IDirectDrawSurface3Impl_AddRef,

View File

@ -1,675 +0,0 @@
/* User-based primary surface driver
*
* Copyright 2000-2001 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "winerror.h"
#include "wine/debug.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* if you use OWN_WINDOW, don't use SYNC_UPDATE, or you may get trouble */
/* #define SYNC_UPDATE */
/*
* FIXME: This does not work any more because the created window has its own
* thread queue that cannot be manipulated by application threads.
* #define OWN_WINDOW
*/
#ifdef OWN_WINDOW
static void User_create_own_window(IDirectDrawSurfaceImpl* This);
static void User_destroy_own_window(IDirectDrawSurfaceImpl* This);
#endif
#ifndef SYNC_UPDATE
static DWORD CALLBACK User_update_thread(LPVOID);
#endif
static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc);
static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt);
static const IDirectDrawSurface7Vtbl User_IDirectDrawSurface7_VTable;
HRESULT
User_DirectDrawSurface_Construct(IDirectDrawSurfaceImpl* This,
IDirectDrawImpl* pDD,
const DDSURFACEDESC2* pDDSD)
{
USER_PRIV_VAR(priv, This);
HRESULT hr;
TRACE("(%p,%p,%p)\n",This,pDD,pDDSD);
hr = DIB_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr)) return hr;
ICOM_INIT_INTERFACE(This, IDirectDrawSurface7,
User_IDirectDrawSurface7_VTable);
This->final_release = User_DirectDrawSurface_final_release;
This->duplicate_surface = User_DirectDrawSurface_duplicate_surface;
This->lock_update = User_DirectDrawSurface_lock_update;
This->unlock_update = User_DirectDrawSurface_unlock_update;
This->flip_data = User_DirectDrawSurface_flip_data;
This->flip_update = User_DirectDrawSurface_flip_update;
This->get_dc = User_DirectDrawSurface_get_dc;
This->release_dc = User_DirectDrawSurface_release_dc;
This->set_palette = User_DirectDrawSurface_set_palette;
This->update_palette = User_DirectDrawSurface_update_palette;
This->get_gamma_ramp = User_DirectDrawSurface_get_gamma_ramp;
This->set_gamma_ramp = User_DirectDrawSurface_set_gamma_ramp;
This->get_display_window = User_DirectDrawSurface_get_display_window;
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
#ifdef OWN_WINDOW
DirectDrawSurface_RegisterClass();
#endif
#ifndef SYNC_UPDATE
InitializeCriticalSection(&priv->user.crit);
priv->user.refresh_event = CreateEventW(NULL, TRUE, FALSE, NULL);
priv->user.update_event = CreateEventW(NULL, FALSE, FALSE, NULL);
priv->user.update_thread = CreateThread(NULL, 0, User_update_thread, This, 0, NULL);
#ifdef OWN_WINDOW
if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN) {
/* wait for window creation (or update thread destruction) */
while (WaitForMultipleObjects(1, &priv->user.update_thread, FALSE, 100) == WAIT_TIMEOUT)
if (This->more.lpDDRAWReserved) break;
if (!This->more.lpDDRAWReserved) {
ERR("window creation failed\n");
}
}
#endif
#else
#ifdef OWN_WINDOW
User_create_own_window(This);
#endif
#endif
if (!This->more.lpDDRAWReserved)
This->more.lpDDRAWReserved = (LPVOID)pDD->window;
}
return DIB_DirectDrawSurface_alloc_dc(This, &priv->user.cached_dc);
}
HRESULT
User_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(User_DirectDrawSurfaceImpl));
if (This == NULL) return E_OUTOFMEMORY;
This->private = (User_DirectDrawSurfaceImpl*)(This+1);
hr = User_DirectDrawSurface_Construct(This, pDD, pDDSD);
if (FAILED(hr))
HeapFree(GetProcessHeap(), 0, This);
else
*ppSurf = ICOM_INTERFACE(This, IDirectDrawSurface7);
return hr;
}
void User_DirectDrawSurface_final_release(IDirectDrawSurfaceImpl* This)
{
USER_PRIV_VAR(priv, This);
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
#ifndef SYNC_UPDATE
HANDLE event = priv->user.update_event;
priv->user.update_event = 0;
SetEvent(event);
TRACE("waiting for update thread to terminate...\n");
#ifdef OWN_WINDOW
/* dispatch any waiting sendmessages */
{
MSG msg;
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
}
/* to avoid deadlocks, allow SendMessages from update thread
* through while we wait for it */
while (MsgWaitForMultipleObjects(1, &priv->user.update_thread, FALSE,
INFINITE, QS_SENDMESSAGE) == WAIT_OBJECT_0+1)
{
MSG msg;
PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE);
}
#else
WaitForSingleObject(priv->user.update_thread,INFINITE);
#endif
TRACE("update thread terminated\n");
CloseHandle(event);
CloseHandle(priv->user.update_thread);
CloseHandle(priv->user.refresh_event);
DeleteCriticalSection(&priv->user.crit);
#else
#ifdef OWN_WINDOW
User_destroy_own_window(This);
#endif
#endif
This->more.lpDDRAWReserved = 0;
#ifdef OWN_WINDOW
DirectDrawSurface_UnregisterClass();
#endif
}
DIB_DirectDrawSurface_free_dc(This, priv->user.cached_dc);
DIB_DirectDrawSurface_final_release(This);
}
static int User_DirectDrawSurface_init_wait(IDirectDrawSurfaceImpl* This)
{
USER_PRIV_VAR(priv, This);
int need_wait;
EnterCriticalSection(&priv->user.crit);
priv->user.wait_count++;
need_wait = priv->user.in_refresh;
LeaveCriticalSection(&priv->user.crit);
return need_wait;
}
static void User_DirectDrawSurface_end_wait(IDirectDrawSurfaceImpl* This)
{
USER_PRIV_VAR(priv, This);
EnterCriticalSection(&priv->user.crit);
if (!--priv->user.wait_count)
ResetEvent(priv->user.refresh_event);
LeaveCriticalSection(&priv->user.crit);
}
static void User_DirectDrawSurface_wait_update(IDirectDrawSurfaceImpl* This)
{
USER_PRIV_VAR(priv, This);
if (priv->user.in_refresh) {
if (User_DirectDrawSurface_init_wait(This))
WaitForSingleObject(priv->user.refresh_event, 2);
User_DirectDrawSurface_end_wait(This);
}
}
void User_DirectDrawSurface_lock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect, DWORD dwFlags)
{
#if 0
if (!(dwFlags & DDLOCK_WRITEONLY))
User_copy_from_screen(This, pRect);
#endif
if (dwFlags & DDLOCK_WAIT) User_DirectDrawSurface_wait_update(This);
if (pRect) {
This->lastlockrect = *pRect;
} else {
This->lastlockrect.left = This->lastlockrect.right = 0;
}
}
void User_DirectDrawSurface_unlock_update(IDirectDrawSurfaceImpl* This,
LPCRECT pRect)
{
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
#ifdef SYNC_UPDATE
User_copy_to_screen(This, pRect);
#else
USER_PRIV_VAR(priv, This);
SetEvent(priv->user.update_event);
#endif
}
}
void User_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal)
{
USER_PRIV_VAR(priv, This);
if (!pal) {
FIXME("selecting null palette\n");
/* I don't think selecting GDI object 0 will work, we should select
* the original palette, returned by the first SelectPalette */
SelectPalette(priv->user.cached_dc, 0, FALSE);
return;
}
SelectPalette(priv->user.cached_dc, pal->hpal, FALSE);
DIB_DirectDrawSurface_set_palette(This, pal);
}
void User_DirectDrawSurface_update_palette(IDirectDrawSurfaceImpl* This,
IDirectDrawPaletteImpl* pal,
DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent)
{
#ifndef SYNC_UPDATE
USER_PRIV_VAR(priv, This);
#endif
DIB_DirectDrawSurface_update_palette(This, pal, dwStart, dwCount, palent);
/* FIXME: realize palette on display window */
#ifndef SYNC_UPDATE
/* with async updates, it's probably cool to force an update */
SetEvent(priv->user.update_event);
#endif
}
HRESULT User_DirectDrawSurface_duplicate_surface(IDirectDrawSurfaceImpl* This,
LPDIRECTDRAWSURFACE7* ppDup)
{
return User_DirectDrawSurface_Create(This->ddraw_owner,
&This->surface_desc, ppDup, NULL);
}
BOOL User_DirectDrawSurface_flip_data(IDirectDrawSurfaceImpl* front,
IDirectDrawSurfaceImpl* back,
DWORD dwFlags)
{
USER_PRIV_VAR(front_priv, front);
USER_PRIV_VAR(back_priv, back);
{
HDC tmp;
tmp = front_priv->user.cached_dc;
front_priv->user.cached_dc = back_priv->user.cached_dc;
back_priv->user.cached_dc = tmp;
}
return DIB_DirectDrawSurface_flip_data(front, back, dwFlags);
}
void User_DirectDrawSurface_flip_update(IDirectDrawSurfaceImpl* This, DWORD dwFlags)
{
#ifdef SYNC_UPDATE
This->lastlockrect.left = This->lastlockrect.right = 0;
assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
User_copy_to_screen(This,NULL);
#else
USER_PRIV_VAR(priv, This);
assert(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE);
if (dwFlags & DDFLIP_WAIT) User_DirectDrawSurface_wait_update(This);
This->lastlockrect.left = This->lastlockrect.right = 0;
SetEvent(priv->user.update_event);
#endif
}
HRESULT User_DirectDrawSurface_get_dc(IDirectDrawSurfaceImpl* This, HDC* phDC)
{
USER_PRIV_VAR(priv, This);
*phDC = priv->user.cached_dc;
return S_OK;
}
HRESULT User_DirectDrawSurface_release_dc(IDirectDrawSurfaceImpl* This,
HDC hDC)
{
return S_OK;
}
HRESULT User_DirectDrawSurface_get_gamma_ramp(IDirectDrawSurfaceImpl* This,
DWORD dwFlags,
LPDDGAMMARAMP lpGammaRamp)
{
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
POINT offset;
HWND hDisplayWnd;
HDC hDisplayDC;
HRESULT hr;
hDisplayWnd = get_display_window(This, &offset);
hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
hr = GetDeviceGammaRamp(hDisplayDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
ReleaseDC(hDisplayWnd, hDisplayDC);
return hr;
}
return Main_DirectDrawSurface_get_gamma_ramp(This, dwFlags, lpGammaRamp);
}
HRESULT User_DirectDrawSurface_set_gamma_ramp(IDirectDrawSurfaceImpl* This,
DWORD dwFlags,
LPDDGAMMARAMP lpGammaRamp)
{
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
POINT offset;
HWND hDisplayWnd;
HDC hDisplayDC;
HRESULT hr;
hDisplayWnd = get_display_window(This, &offset);
hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
hr = SetDeviceGammaRamp(hDisplayDC, lpGammaRamp) ? DD_OK : DDERR_UNSUPPORTED;
ReleaseDC(hDisplayWnd, hDisplayDC);
return hr;
}
return Main_DirectDrawSurface_set_gamma_ramp(This, dwFlags, lpGammaRamp);
}
/* Returns the window that hosts the display.
* *pt is set to the upper left position of the window relative to the
* upper left corner of the surface. */
static HWND get_display_window(IDirectDrawSurfaceImpl* This, LPPOINT pt)
{
memset(pt, 0, sizeof(*pt));
if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN)
{
#ifdef OWN_WINDOW
USER_PRIV_VAR(priv, This);
#if 1
SetWindowPos(priv->user.window, HWND_TOP, 0, 0, 0, 0,
SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|
SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE);
#endif
return priv->user.window;
#else
return This->ddraw_owner->window;
#endif
}
else
{
if (This->clipper != NULL)
{
/* looks silly, but since we don't have the clipper locked */
HWND hWnd = This->clipper->hWnd;
if (hWnd != 0)
{
ClientToScreen(hWnd, pt);
return hWnd;
}
else
{
static BOOL warn = 0;
if (!warn++) FIXME("clipper clip lists not supported\n");
return GetDesktopWindow();
}
}
else
{
static BOOL warn = 0;
if (!warn++) WARN("hosting on root\n");
return GetDesktopWindow();
}
}
}
HWND User_DirectDrawSurface_get_display_window(IDirectDrawSurfaceImpl* This)
{
POINT offset;
return get_display_window(This, &offset);
}
#ifdef OWN_WINDOW
static void User_create_own_window(IDirectDrawSurfaceImpl* This)
{
USER_PRIV_VAR(priv, This);
if (This->ddraw_owner->cooperative_level & DDSCL_FULLSCREEN)
{
priv->user.window = CreateWindowExA(WS_EX_TOPMOST |
WS_EX_LAYERED |
WS_EX_TRANSPARENT,
"WINE_DDRAW", "DirectDraw",
WS_POPUP,
0, 0,
This->surface_desc.dwWidth,
This->surface_desc.dwHeight,
GetDesktopWindow(),
0, 0, This);
This->more.lpDDRAWReserved = (LPVOID)priv->user.window;
SetWindowPos(priv->user.window, HWND_TOP, 0, 0, 0, 0,
SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|
SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_SHOWWINDOW);
UpdateWindow(priv->user.window);
}
}
static void User_destroy_own_window(IDirectDrawSurfaceImpl* This)
{
USER_PRIV_VAR(priv, This);
if (priv->user.window)
{
SetWindowPos(priv->user.window, 0, 0, 0, 0, 0,
SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOZORDER|
SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_HIDEWINDOW);
This->more.lpDDRAWReserved = NULL;
DestroyWindow(priv->user.window);
priv->user.window = 0;
}
}
#endif
#ifndef SYNC_UPDATE
static DWORD CALLBACK User_update_thread(LPVOID arg)
{
IDirectDrawSurfaceImpl *This = (IDirectDrawSurfaceImpl *)arg;
USER_PRIV_VAR(priv, This);
volatile HANDLE *pActive = (volatile HANDLE *)&priv->user.update_event;
HANDLE event = *pActive;
#ifdef OWN_WINDOW
User_create_own_window(This);
#endif
/* the point of this is that many games lock the primary surface
* multiple times per frame; this thread will then simply copy as
* often as it can without keeping the main thread waiting for
* each unlock, thus keeping the frame rate high */
do {
#ifdef OWN_WINDOW
DWORD ret = MsgWaitForMultipleObjects(1, &event, FALSE, INFINITE, QS_ALLINPUT);
MSG msg;
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
{
switch (msg.message) {
case WM_PAINT:
DispatchMessageA(&msg);
break;
default:
/* since we risk getting keyboard messages posted to us,
* repost posted messages to cooperative window */
PostMessageA(This->ddraw_owner->window, msg.message, msg.wParam, msg.lParam);
}
}
#else
DWORD ret = WaitForSingleObject(event, INFINITE);
#endif
if (ret == WAIT_OBJECT_0)
{
if (*pActive) {
priv->user.in_refresh = TRUE;
User_copy_to_screen(This, NULL);
EnterCriticalSection(&priv->user.crit);
priv->user.in_refresh = FALSE;
if (priv->user.wait_count)
SetEvent(priv->user.refresh_event);
LeaveCriticalSection(&priv->user.crit);
} else
break;
}
else if (ret != WAIT_OBJECT_0+1) break;
} while (TRUE);
SetEvent(priv->user.refresh_event);
#ifdef OWN_WINDOW
User_destroy_own_window(This);
#endif
return 0;
}
#endif
static void User_copy_to_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
{
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
POINT offset;
HWND hDisplayWnd;
HDC hDisplayDC;
HDC hSurfaceDC;
RECT drawrect;
if (FAILED(This->get_dc(This, &hSurfaceDC)))
return;
hDisplayWnd = get_display_window(This, &offset);
hDisplayDC = GetDCEx(hDisplayWnd, 0, DCX_CLIPSIBLINGS|DCX_CACHE);
#if 0
/* FIXME: this doesn't work... if users really want to run
* X in 8bpp, then we need to call directly into display.drv
* (or Wine's equivalent), and force a private colormap
* without default entries. */
if (This->palette) {
SelectPalette(hDisplayDC, This->palette->hpal, FALSE);
RealizePalette(hDisplayDC); /* sends messages => deadlocks */
}
#endif
drawrect.left = 0;
drawrect.right = This->surface_desc.dwWidth;
drawrect.top = 0;
drawrect.bottom = This->surface_desc.dwHeight;
if (This->clipper) {
RECT xrc;
HWND hwnd = This->clipper->hWnd;
if (hwnd && GetClientRect(hwnd,&xrc)) {
OffsetRect(&xrc,offset.x,offset.y);
IntersectRect(&drawrect,&drawrect,&xrc);
}
}
if (rc)
IntersectRect(&drawrect,&drawrect,rc);
else {
/* Only use this if the caller did not pass a rectangle, since
* due to double locking this could be the wrong one ... */
if (This->lastlockrect.left != This->lastlockrect.right)
IntersectRect(&drawrect,&drawrect,&This->lastlockrect);
}
BitBlt(hDisplayDC,
drawrect.left-offset.x, drawrect.top-offset.y,
drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
hSurfaceDC,
drawrect.left, drawrect.top,
SRCCOPY
);
ReleaseDC(hDisplayWnd, hDisplayDC);
}
}
#if 0
static void User_copy_from_screen(IDirectDrawSurfaceImpl* This, LPCRECT rc)
{
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
POINT offset;
HWND hDisplayWnd = get_display_window(This, &offset);
HDC hDisplayDC = GetDC(hDisplayWnd);
RECT drawrect;
drawrect.left = 0;
drawrect.right = This->surface_desc.dwWidth;
drawrect.top = 0;
drawrect.bottom = This->surface_desc.dwHeight;
if (rc)
IntersectRect(&drawrect,&drawrect,rc);
BitBlt(This->hDC,
drawrect.left, drawrect.top,
drawrect.right-drawrect.left, drawrect.bottom-drawrect.top,
hDisplayDC,
drawrect.left+offset.x, drawrect.top+offset.y,
SRCCOPY
);
ReleaseDC(hDisplayWnd, hDisplayDC);
}
}
#endif
static const IDirectDrawSurface7Vtbl User_IDirectDrawSurface7_VTable =
{
Main_DirectDrawSurface_QueryInterface,
Main_DirectDrawSurface_AddRef,
Main_DirectDrawSurface_Release,
Main_DirectDrawSurface_AddAttachedSurface,
Main_DirectDrawSurface_AddOverlayDirtyRect,
DIB_DirectDrawSurface_Blt,
Main_DirectDrawSurface_BltBatch,
DIB_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,
Main_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,
Main_DirectDrawSurface_ReleaseDC,
DIB_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,
DIB_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
};

View File

@ -1,104 +0,0 @@
/* User-based primary surface driver
*
* Copyright 2000 TransGaming Technologies Inc.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "winerror.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void DirectDrawSurface_RegisterClass(void)
{
WNDCLASSA wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = DirectDrawSurface_WndProc;
wc.cbWndExtra = sizeof(IDirectDrawSurfaceImpl*);
wc.hCursor = (HCURSOR)IDC_ARROW;
wc.lpszClassName = "WINE_DDRAW";
RegisterClassA(&wc);
}
void DirectDrawSurface_UnregisterClass(void)
{
UnregisterClassA("WINE_DDRAW", 0);
}
static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
IDirectDrawSurfaceImpl *This;
LRESULT ret;
This = (IDirectDrawSurfaceImpl *)GetWindowLongPtrA(hwnd, 0);
if (This) {
HWND window = This->ddraw_owner->window;
switch (msg) {
case WM_DESTROY:
case WM_NCDESTROY:
case WM_SHOWWINDOW:
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
case WM_SIZE:
case WM_MOVE:
case WM_ERASEBKGND:
case WM_SYNCPAINT:
/* since we're pretending fullscreen,
* let's not pass these on to the app */
ret = DefWindowProcA(hwnd, msg, wParam, lParam);
break;
case WM_NCHITTEST:
ret = HTCLIENT;
break;
case WM_MOUSEACTIVATE:
ret = MA_NOACTIVATE;
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC dc;
dc = BeginPaint(hwnd, &ps);
/* call User_copy_to_screen? */
EndPaint(hwnd, &ps);
ret = 0;
}
break;
default:
ret = window ? SendMessageA(window, msg, wParam, lParam)
: DefWindowProcA(hwnd, msg, wParam, lParam);
}
} else {
if (msg == WM_CREATE) {
CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
This = (IDirectDrawSurfaceImpl *)cs->lpCreateParams;
SetWindowLongPtrA(hwnd, 0, (LONG_PTR)This);
}
ret = DefWindowProcA(hwnd, msg, wParam, lParam);
}
return ret;
}

View File

@ -320,53 +320,29 @@ static void ProcessVerticesTest()
if(!out) goto out;
/* Check the results */
if( !comparefloat(out[0].x, 128.0 ) ||
!comparefloat(out[0].y, 128.0 ) ||
!comparefloat(out[0].z, 0.0 ) ||
!comparefloat(out[0].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
}
else
{
todo_wine ok(TRUE, "Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
}
ok( comparefloat(out[0].x, 128.0 ) &&
comparefloat(out[0].y, 128.0 ) &&
comparefloat(out[0].z, 0.0 ) &&
comparefloat(out[0].rhw, 1.0 ),
"Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
if( !comparefloat(out[1].x, 256.0 ) ||
!comparefloat(out[1].y, 0.0 ) ||
!comparefloat(out[1].z, 1.0 ) ||
!comparefloat(out[1].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
else
{
todo_wine ok(TRUE, "Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
ok( comparefloat(out[1].x, 256.0 ) &&
comparefloat(out[1].y, 0.0 ) &&
comparefloat(out[1].z, 1.0 ) &&
comparefloat(out[1].rhw, 1.0 ),
"Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
if( !comparefloat(out[2].x, 0.0 ) ||
!comparefloat(out[2].y, 256.0 ) ||
!comparefloat(out[2].z, 0.5 ) ||
!comparefloat(out[2].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
}
else
{
todo_wine ok(TRUE, "Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
}
ok( comparefloat(out[2].x, 0.0 ) &&
comparefloat(out[2].y, 256.0 ) &&
comparefloat(out[2].z, 0.5 ) &&
comparefloat(out[2].rhw, 1.0 ),
"Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
if( !comparefloat(out[3].x, 192.0 ) ||
!comparefloat(out[3].y, 192.0 ) ||
!comparefloat(out[3].z, 0.25 ) ||
!comparefloat(out[3].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
}
else
{
todo_wine ok(TRUE, "Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
}
ok( comparefloat(out[3].x, 192.0 ) &&
comparefloat(out[3].y, 192.0 ) &&
comparefloat(out[3].z, 0.25 ) &&
comparefloat(out[3].rhw, 1.0 ),
"Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest1);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %lx\n", rc);
@ -379,16 +355,10 @@ static void ProcessVerticesTest()
* so let's check for it: If the output vertex buffer has to RHW value,
* The RHW value of the last vertex is written into the next vertex
*/
if( !comparefloat(out2[4].x, 1.0 ) ||
!comparefloat(out2[4].y, 0.0 ) ||
!comparefloat(out2[4].z, 0.0 ) )
{
todo_wine ok(FALSE, "Output 4 vertex is (%f , %f , %f)\n", out2[4].x, out2[4].y, out2[4].z);
}
else
{
todo_wine ok(TRUE, "Output 4 vertex is (%f , %f , %f)\n", out2[4].x, out2[4].y, out2[4].z);
}
ok( comparefloat(out2[4].x, 1.0 ) &&
comparefloat(out2[4].y, 0.0 ) &&
comparefloat(out2[4].z, 0.0 ),
"Output 4 vertex is (%f , %f , %f)\n", out2[4].x, out2[4].y, out2[4].z);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest2);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %lx\n", rc);
@ -414,53 +384,29 @@ static void ProcessVerticesTest()
if(!out) goto out;
/* Check the results */
if( !comparefloat(out[0].x, 133.0 ) ||
!comparefloat(out[0].y, 70.0 ) ||
!comparefloat(out[0].z, -2.0 ) ||
!comparefloat(out[0].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
}
else
{
todo_wine ok(TRUE, "Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
}
ok( comparefloat(out[0].x, 133.0 ) &&
comparefloat(out[0].y, 70.0 ) &&
comparefloat(out[0].z, -2.0 ) &&
comparefloat(out[0].rhw, 1.0 ),
"Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
if( !comparefloat(out[1].x, 256.0 ) ||
!comparefloat(out[1].y, 5.0 ) ||
!comparefloat(out[1].z, 4.0 ) ||
!comparefloat(out[1].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
else
{
todo_wine ok(TRUE, "Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
ok( comparefloat(out[1].x, 256.0 ) &&
comparefloat(out[1].y, 5.0 ) &&
comparefloat(out[1].z, 4.0 ) &&
comparefloat(out[1].rhw, 1.0 ),
"Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
if( !comparefloat(out[2].x, 10.0 ) ||
!comparefloat(out[2].y, 135.0 ) ||
!comparefloat(out[2].z, 1.0 ) ||
!comparefloat(out[2].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 2 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
else
{
todo_wine ok(TRUE, "Output 2 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
ok( comparefloat(out[2].x, 10.0 ) &&
comparefloat(out[2].y, 135.0 ) &&
comparefloat(out[2].z, 1.0 ) &&
comparefloat(out[2].rhw, 1.0 ),
"Output 2 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
if( !comparefloat(out[3].x, 194.5 ) ||
!comparefloat(out[3].y, 102.5 ) ||
!comparefloat(out[3].z, -0.5 ) ||
!comparefloat(out[3].rhw, 1.0 ))
{
todo_wine ok(FALSE, "Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
}
else
{
todo_wine ok(TRUE, "Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
}
ok( comparefloat(out[3].x, 194.5 ) &&
comparefloat(out[3].y, 102.5 ) &&
comparefloat(out[3].z, -0.5 ) &&
comparefloat(out[3].rhw, 1.0 ),
"Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest1);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %lx\n", rc);
@ -495,53 +441,29 @@ static void ProcessVerticesTest()
ok(rc==D3D_OK, "IDirect3DDevice7_SetViewport failed\n");
/* Check the results */
if( !comparefloat(out[0].x, 256.0 ) || /* X coordinate is cut at the surface edges */
!comparefloat(out[0].y, 70.0 ) ||
!comparefloat(out[0].z, -2.0 ) ||
!comparefloat(out[0].rhw, (1.0 / 3.0)))
{
todo_wine ok(FALSE, "Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
}
else
{
todo_wine ok(TRUE, "Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
}
ok( comparefloat(out[0].x, 256.0 ) && /* X coordinate is cut at the surface edges */
comparefloat(out[0].y, 70.0 ) &&
comparefloat(out[0].z, -2.0 ) &&
comparefloat(out[0].rhw, (1.0 / 3.0)),
"Output 0 vertex is (%f , %f , %f , %f)\n", out[0].x, out[0].y, out[0].z, out[0].rhw);
if( !comparefloat(out[1].x, 256.0 ) ||
!comparefloat(out[1].y, 78.125000 ) ||
!comparefloat(out[1].z, -2.750000 ) ||
!comparefloat(out[1].rhw, 0.125000 ))
{
todo_wine ok(FALSE, "Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
else
{
todo_wine ok(TRUE, "Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
}
ok( comparefloat(out[1].x, 256.0 ) &&
comparefloat(out[1].y, 78.125000 ) &&
comparefloat(out[1].z, -2.750000 ) &&
comparefloat(out[1].rhw, 0.125000 ),
"Output 1 vertex is (%f , %f , %f , %f)\n", out[1].x, out[1].y, out[1].z, out[1].rhw);
if( !comparefloat(out[2].x, 256.0 ) ||
!comparefloat(out[2].y, 44.000000 ) ||
!comparefloat(out[2].z, 0.400000 ) ||
!comparefloat(out[2].rhw, 0.400000 ))
{
todo_wine ok(FALSE, "Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
}
else
{
todo_wine ok(TRUE, "Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
}
ok( comparefloat(out[2].x, 256.0 ) &&
comparefloat(out[2].y, 44.000000 ) &&
comparefloat(out[2].z, 0.400000 ) &&
comparefloat(out[2].rhw, 0.400000 ),
"Output 2 vertex is (%f , %f , %f , %f)\n", out[2].x, out[2].y, out[2].z, out[2].rhw);
if( !comparefloat(out[3].x, 256.0 ) ||
!comparefloat(out[3].y, 81.818184 ) ||
!comparefloat(out[3].z, -3.090909 ) ||
!comparefloat(out[3].rhw, 0.363636 ))
{
todo_wine ok(FALSE, "Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
}
else
{
todo_wine ok(TRUE, "Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
}
ok( comparefloat(out[3].x, 256.0 ) &&
comparefloat(out[3].y, 81.818184 ) &&
comparefloat(out[3].z, -3.090909 ) &&
comparefloat(out[3].rhw, 0.363636 ),
"Output 3 vertex is (%f , %f , %f , %f)\n", out[3].x, out[3].y, out[3].z, out[3].rhw);
rc = IDirect3DVertexBuffer7_Unlock(lpVBufDest1);
ok(rc==D3D_OK , "IDirect3DVertexBuffer::Unlock returned: %lx\n", rc);

File diff suppressed because it is too large Load Diff

1171
dlls/ddraw/utils.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
/* Direct3D Viewport
/* Direct3D Vertex Buffer
* Copyright (c) 2002 Lionel ULMER
* Copyright (c) 2006 Stefan DÖSINGER
*
* This file contains the implementation of Direct3DVertexBuffer COM object
*
@ -19,58 +20,112 @@
*/
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "objbase.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "wine/debug.h"
#include "d3d_private.h"
#include "opengl_private.h"
#include "ddraw_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_geom);
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_thunk);
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_QueryInterface(LPDIRECT3DVERTEXBUFFER7 iface,
/*****************************************************************************
* IUnknown Methods
*****************************************************************************/
/*****************************************************************************
* IDirect3DVertexBuffer7::QueryInterface
*
* The QueryInterface Method for Vertex Buffers
* For a link to QueryInterface rules, see IDirectDraw7::QueryInterface
*
* Params
* riid: Queryied Interface id
* obj: Address to return the interface pointer
*
* Returns:
* S_OK on success
* E_NOINTERFACE if the interface wasn't found
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_QueryInterface(IDirect3DVertexBuffer7 *iface,
REFIID riid,
LPVOID* obp)
void **obj)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
/* By default, set the object pointer to NULL */
*obp = NULL;
*obj = NULL;
if ( IsEqualGUID( &IID_IUnknown, riid ) ) {
if ( IsEqualGUID( &IID_IUnknown, riid ) )
{
IDirect3DVertexBuffer7_AddRef(ICOM_INTERFACE(This,IDirect3DVertexBuffer7));
*obp = iface;
TRACE(" Creating IUnknown interface at %p.\n", *obp);
*obj = iface;
TRACE(" Creating IUnknown interface at %p.\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DVertexBuffer, riid ) ) {
if ( IsEqualGUID( &IID_IDirect3DVertexBuffer, riid ) )
{
IDirect3DVertexBuffer7_AddRef(ICOM_INTERFACE(This,IDirect3DVertexBuffer7));
*obp = ICOM_INTERFACE(This, IDirect3DVertexBuffer);
TRACE(" Creating IDirect3DVertexBuffer interface %p\n", *obp);
*obj = ICOM_INTERFACE(This, IDirect3DVertexBuffer);
TRACE(" Creating IDirect3DVertexBuffer interface %p\n", *obj);
return S_OK;
}
if ( IsEqualGUID( &IID_IDirect3DVertexBuffer7, riid ) ) {
if ( IsEqualGUID( &IID_IDirect3DVertexBuffer7, riid ) )
{
IDirect3DVertexBuffer7_AddRef(ICOM_INTERFACE(This,IDirect3DVertexBuffer7));
*obp = ICOM_INTERFACE(This, IDirect3DVertexBuffer7);
TRACE(" Creating IDirect3DVertexBuffer7 interface %p\n", *obp);
*obj = ICOM_INTERFACE(This, IDirect3DVertexBuffer7);
TRACE(" Creating IDirect3DVertexBuffer7 interface %p\n", *obj);
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return OLE_E_ENUM_NOMORE;
return E_NOINTERFACE;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_QueryInterface(IDirect3DVertexBuffer *iface,
REFIID riid,
void **obj)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
TRACE_(ddraw_thunk)("(%p)->(%s,%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, debugstr_guid(riid), obj);
return IDirect3DVertexBuffer7_QueryInterface(ICOM_INTERFACE(This, IDirect3DVertexBuffer7),
riid,
obj);
}
/*****************************************************************************
* IDirect3DVertexBuffer7::AddRef
*
* AddRef for Vertex Buffers
*
* Returns:
* The new refcount
*
*****************************************************************************/
ULONG WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_AddRef(LPDIRECT3DVERTEXBUFFER7 iface)
IDirect3DVertexBufferImpl_AddRef(IDirect3DVertexBuffer7 *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
ULONG ref = InterlockedIncrement(&This->ref);
@ -81,477 +136,426 @@ Main_IDirect3DVertexBufferImpl_7_1T_AddRef(LPDIRECT3DVERTEXBUFFER7 iface)
}
ULONG WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_Release(LPDIRECT3DVERTEXBUFFER7 iface)
Thunk_IDirect3DVertexBufferImpl_1_AddRef(IDirect3DVertexBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
return IDirect3DVertexBuffer7_AddRef(ICOM_INTERFACE(This, IDirect3DVertexBuffer7));
}
/*****************************************************************************
* IDirect3DVertexBuffer7::Release
*
* Release for Vertex Buffers
*
* Returns:
* The new refcount
*
*****************************************************************************/
ULONG WINAPI
IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->vertices);
if (ref == 0)
{
IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
return ref;
}
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_Lock(LPDIRECT3DVERTEXBUFFER7 iface,
DWORD dwFlags,
LPVOID* lplpData,
LPDWORD lpdwSize)
ULONG WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Release(IDirect3DVertexBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
return IDirect3DVertexBuffer7_Release(ICOM_INTERFACE(This, IDirect3DVertexBuffer7));
}
/*****************************************************************************
* IDirect3DVertexBuffer Methods
*****************************************************************************/
/*****************************************************************************
* IDirect3DVertexBuffer7::Lock
*
* Locks the vertex buffer and returns a pointer to the vertex data
* Locking vertex buffers is simmilar to locking surfaces, because Windows
* uses surfaces to store vertex data internally(According to the DX sdk)
*
* Params:
* Flags: Locking flags. Relevant here are DDLOCK_READONLY, DDLOCK_WRITEONLY,
* DDLOCK_DISCARDCONTENTS and DDLOCK_NOOVERWRITE.
* Data: Returns a pointer to the vertex data
* Size: Returns the size of the buffer if not NULL
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Data is NULL
* D3DERR_VERTEXBUFFEROPTIMIZED if called on an optimized buffer(WineD3D)
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
DWORD Flags,
void **Data,
DWORD *Size)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
TRACE("(%p/%p)->(%08lx,%p,%p)\n", This, iface, dwFlags, lplpData, lpdwSize);
WINED3DVERTEXBUFFER_DESC Desc;
HRESULT hr;
TRACE("(%p)->(%08lx,%p,%p)\n", This, Flags, Data, Size);
if (TRACE_ON(ddraw)) {
TRACE(" lock flags : ");
DDRAW_dump_lockflag(dwFlags);
/* Get the size, for returning it, and for locking */
hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer,
&Desc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08lx\n", This, hr);
return hr;
}
if (This->processed) {
WARN(" application does a Lock on a vertex buffer resulting from a ProcessVertices call. Expect problems !\n");
}
if(Size) *Size = Desc.Size;
if (This->desc.dwCaps & D3DVBCAPS_OPTIMIZED) return D3DERR_VERTEXBUFFEROPTIMIZED;
if (lpdwSize != NULL) *lpdwSize = This->vertex_buffer_size;
*lplpData = This->vertices;
return DD_OK;
return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer,
0 /* OffsetToLock */,
Desc.Size,
(BYTE **) Data,
Flags);
}
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_Unlock(LPDIRECT3DVERTEXBUFFER7 iface)
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Lock(IDirect3DVertexBuffer *iface,
DWORD Flags,
void **Data,
DWORD *Size)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
TRACE_(ddraw_thunk)("(%p)->(%08lx,%p,%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, Flags, Data, Size);
return IDirect3DVertexBuffer7_Lock(ICOM_INTERFACE(This, IDirect3DVertexBuffer7),
Flags,
Data,
Size);
}
/*****************************************************************************
* IDirect3DVertexBuffer7::Unlock
*
* Unlocks a vertex Buffer
*
* Returns:
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
TRACE("(%p/%p)->()\n", This, iface);
/* Nothing to do here for now. Maybe some optimizations if ever we want to do some :-) */
return DD_OK;
TRACE("(%p)->()\n", This);
/* This is easy :) */
return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
}
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_ProcessVertices(LPDIRECT3DVERTEXBUFFER7 iface,
DWORD dwVertexOp,
DWORD dwDestIndex,
DWORD dwCount,
LPDIRECT3DVERTEXBUFFER7 lpSrcBuffer,
DWORD dwSrcIndex,
LPDIRECT3DDEVICE7 lpD3DDevice,
DWORD dwFlags)
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Unlock(IDirect3DVertexBuffer *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
TRACE_(ddraw_thunk)("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", This);
return IDirect3DVertexBuffer7_Unlock(ICOM_INTERFACE(This, IDirect3DVertexBuffer7));
}
/*****************************************************************************
* IDirect3DVertexBuffer7::ProcessVertices
*
* Processes untransformed Vertices into a transformed or optimized vertex
* buffer. It can also perform other operations, such as lighting or clipping
*
* Params
* VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM
* DestIndex: Index in the destination buffer(This), where the vertices are
* placed
* Count: Number of Vertices in the Source buffer to process
* SrcBuffer: Source vertex buffer
* SrcIndex: Index of the first vertex in the src buffer to process
* D3DDevice: Device to use for transformation
* Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying
* unchaned vertices
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
DWORD VertexOp,
DWORD DestIndex,
DWORD Count,
IDirect3DVertexBuffer7 *SrcBuffer,
DWORD SrcIndex,
IDirect3DDevice7 *D3DDevice,
DWORD Flags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
FIXME("(%p/%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx): stub!\n", This, iface, dwVertexOp, dwDestIndex, dwCount, lpSrcBuffer, dwSrcIndex, lpD3DDevice, dwFlags);
return DD_OK;
}
IDirect3DVertexBufferImpl *Src = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, SrcBuffer);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice);
BOOL oldClip, doClip;
HRESULT hr;
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_GetVertexBufferDesc(LPDIRECT3DVERTEXBUFFER7 iface,
LPD3DVERTEXBUFFERDESC lpD3DVertexBufferDesc)
{
DWORD size;
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
TRACE("(%p)->(%08lx,%ld,%ld,%p,%ld,%p,%08lx)\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
TRACE("(%p/%p)->(%p)\n", This, iface, lpD3DVertexBufferDesc);
size = lpD3DVertexBufferDesc->dwSize;
memset(lpD3DVertexBufferDesc, 0, size);
memcpy(lpD3DVertexBufferDesc, &This->desc,
(size < This->desc.dwSize) ? size : This->desc.dwSize);
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_Optimize(LPDIRECT3DVERTEXBUFFER7 iface,
LPDIRECT3DDEVICE7 lpD3DDevice,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
FIXME("(%p/%p)->(%p,%08lx): stub!\n", This, iface, lpD3DDevice, dwFlags);
This->desc.dwCaps |= D3DVBCAPS_OPTIMIZED;
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_ProcessVerticesStrided(LPDIRECT3DVERTEXBUFFER7 iface,
DWORD dwVertexOp,
DWORD dwDestIndex,
DWORD dwCount,
LPD3DDRAWPRIMITIVESTRIDEDDATA lpStrideData,
DWORD dwVertexTypeDesc,
LPDIRECT3DDEVICE7 lpD3DDevice,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
FIXME("(%p/%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx): stub!\n", This, iface, dwVertexOp, dwDestIndex, dwCount, lpStrideData, dwVertexTypeDesc, lpD3DDevice, dwFlags);
return DD_OK;
}
HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices(LPDIRECT3DVERTEXBUFFER iface,
DWORD dwVertexOp,
DWORD dwDestIndex,
DWORD dwCount,
LPDIRECT3DVERTEXBUFFER lpSrcBuffer,
DWORD dwSrcIndex,
LPDIRECT3DDEVICE3 lpD3DDevice,
DWORD dwFlags)
{
TRACE("(%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx) thunking to IDirect3DVertexBuffer7 interface.\n", iface,
dwVertexOp, dwDestIndex, dwCount, lpSrcBuffer, dwSrcIndex, lpD3DDevice, dwFlags);
return IDirect3DVertexBuffer7_ProcessVertices(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface),
dwVertexOp,
dwDestIndex,
dwCount,
COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, lpSrcBuffer),
dwSrcIndex,
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, lpD3DDevice),
dwFlags);
}
HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Optimize(LPDIRECT3DVERTEXBUFFER iface,
LPDIRECT3DDEVICE3 lpD3DDevice,
DWORD dwFlags)
{
TRACE("(%p)->(%p,%08lx) thunking to IDirect3DVertexBuffer7 interface.\n", iface, lpD3DDevice, dwFlags);
return IDirect3DVertexBuffer7_Optimize(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface),
COM_INTERFACE_CAST(IDirect3DDeviceImpl, IDirect3DDevice3, IDirect3DDevice7, lpD3DDevice),
dwFlags);
}
HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_QueryInterface(LPDIRECT3DVERTEXBUFFER iface,
REFIID riid,
LPVOID* obp)
{
TRACE("(%p)->(%s,%p) thunking to IDirect3DVertexBuffer7 interface.\n", iface, debugstr_guid(riid), obp);
return IDirect3DVertexBuffer7_QueryInterface(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface),
riid,
obp);
}
ULONG WINAPI
Thunk_IDirect3DVertexBufferImpl_1_AddRef(LPDIRECT3DVERTEXBUFFER iface)
{
TRACE("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", iface);
return IDirect3DVertexBuffer7_AddRef(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface));
}
ULONG WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Release(LPDIRECT3DVERTEXBUFFER iface)
{
TRACE("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", iface);
return IDirect3DVertexBuffer7_Release(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface));
}
HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Lock(LPDIRECT3DVERTEXBUFFER iface,
DWORD dwFlags,
LPVOID* lplpData,
LPDWORD lpdwSize)
{
TRACE("(%p)->(%08lx,%p,%p) thunking to IDirect3DVertexBuffer7 interface.\n", iface, dwFlags, lplpData, lpdwSize);
return IDirect3DVertexBuffer7_Lock(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface),
dwFlags,
lplpData,
lpdwSize);
}
HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Unlock(LPDIRECT3DVERTEXBUFFER iface)
{
TRACE("(%p)->() thunking to IDirect3DVertexBuffer7 interface.\n", iface);
return IDirect3DVertexBuffer7_Unlock(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface));
}
HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(LPDIRECT3DVERTEXBUFFER iface,
LPD3DVERTEXBUFFERDESC lpD3DVertexBufferDesc)
{
TRACE("(%p)->(%p) thunking to IDirect3DVertexBuffer7 interface.\n", iface, lpD3DVertexBufferDesc);
return IDirect3DVertexBuffer7_GetVertexBufferDesc(COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, IDirect3DVertexBuffer7, iface),
lpD3DVertexBufferDesc);
}
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
static HRESULT
process_vertices_strided(IDirect3DVertexBufferImpl *This,
DWORD dwVertexOp,
DWORD dwDestIndex,
DWORD dwCount,
LPD3DDRAWPRIMITIVESTRIDEDDATA lpStrideData,
DWORD dwVertexTypeDesc,
IDirect3DDeviceImpl *device_impl,
DWORD dwFlags)
{
IDirect3DVertexBufferGLImpl *glThis = (IDirect3DVertexBufferGLImpl *) This;
DWORD size = get_flexible_vertex_size(dwVertexTypeDesc);
char *dest_ptr;
unsigned int i;
This->processed = TRUE;
/* For the moment, the trick is to save the transform and lighting state at process
time to restore them at drawing time.
The BIG problem with this method is nothing prevents D3D to do dirty tricks like
processing two different sets of vertices with two different rendering parameters
and then to display them using the same DrawPrimitive call.
It would be nice to check for such code here (but well, even this is not trivial
to do).
This is exactly what the TWIST.EXE demo does but using the same kind of ugly stuff
in the D3DExecuteBuffer code. I really wonder why Microsoft went back in time when
implementing this mostly useless (IMHO) API.
/* Vertex operations:
* D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information
* in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP)
* D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices
* D3DVOP_LIGHT: Lights the vertices
* D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary
*
* WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT
* are not implemented. Clipping is disabled ATM, because of unsure conditions.
*/
glThis->dwVertexTypeDesc = dwVertexTypeDesc;
if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS;
if (dwVertexTypeDesc & D3DFVF_NORMAL) {
WARN(" lighting state not saved yet... Some strange stuff may happen !\n");
/* WineD3D doesn't know d3d7 vertex operation, it uses
* render states instead. Set the render states according to
* the vertex ops
*/
doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE;
IWineD3DDevice_GetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
(DWORD *) &oldClip);
if(doClip != oldClip)
{
IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
doClip);
}
if (glThis->vertices == NULL) {
glThis->vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size * This->desc.dwNumVertices);
}
dest_ptr = ((char *) glThis->vertices) + dwDestIndex * size;
memcpy(&(glThis->world_mat), device_impl->world_mat, sizeof(D3DMATRIX));
memcpy(&(glThis->view_mat), device_impl->view_mat, sizeof(D3DMATRIX));
memcpy(&(glThis->proj_mat), device_impl->proj_mat, sizeof(D3DMATRIX));
hr = IWineD3DDevice_ProcessVertices(D3D->wineD3DDevice,
SrcIndex,
DestIndex,
Count,
This->wineD3DVertexBuffer,
Src->wineD3DVertexBuffer,
Flags);
for (i = 0; i < dwCount; i++) {
unsigned int tex_index;
if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
D3DVALUE *position =
(D3DVALUE *) (((char *) lpStrideData->position.lpvData) + i * lpStrideData->position.dwStride);
copy_and_next(dest_ptr, position, 3 * sizeof(D3DVALUE));
} else if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
D3DVALUE *position =
(D3DVALUE *) (((char *) lpStrideData->position.lpvData) + i * lpStrideData->position.dwStride);
copy_and_next(dest_ptr, position, 4 * sizeof(D3DVALUE));
}
if (dwVertexTypeDesc & D3DFVF_RESERVED1) {
dest_ptr += sizeof(DWORD);
}
if (dwVertexTypeDesc & D3DFVF_NORMAL) {
D3DVALUE *normal =
(D3DVALUE *) (((char *) lpStrideData->normal.lpvData) + i * lpStrideData->normal.dwStride);
copy_and_next(dest_ptr, normal, 3 * sizeof(D3DVALUE));
}
if (dwVertexTypeDesc & D3DFVF_DIFFUSE) {
DWORD *color_d =
(DWORD *) (((char *) lpStrideData->diffuse.lpvData) + i * lpStrideData->diffuse.dwStride);
copy_and_next(dest_ptr, color_d, sizeof(DWORD));
}
if (dwVertexTypeDesc & D3DFVF_SPECULAR) {
DWORD *color_s =
(DWORD *) (((char *) lpStrideData->specular.lpvData) + i * lpStrideData->specular.dwStride);
copy_and_next(dest_ptr, color_s, sizeof(DWORD));
}
for (tex_index = 0; tex_index < GET_TEXCOUNT_FROM_FVF(dwVertexTypeDesc); tex_index++) {
D3DVALUE *tex_coord =
(D3DVALUE *) (((char *) lpStrideData->textureCoords[tex_index].lpvData) +
i * lpStrideData->textureCoords[tex_index].dwStride);
copy_and_next(dest_ptr, tex_coord, GET_TEXCOORD_SIZE_FROM_FVF(dwVertexTypeDesc, tex_index) * sizeof(D3DVALUE));
}
if (TRACE_ON(ddraw_geom)) {
if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
D3DVALUE *position =
(D3DVALUE *) (((char *) lpStrideData->position.lpvData) + i * lpStrideData->position.dwStride);
TRACE_(ddraw_geom)(" %f %f %f", position[0], position[1], position[2]);
} else if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
D3DVALUE *position =
(D3DVALUE *) (((char *) lpStrideData->position.lpvData) + i * lpStrideData->position.dwStride);
TRACE_(ddraw_geom)(" %f %f %f %f", position[0], position[1], position[2], position[3]);
}
if (dwVertexTypeDesc & D3DFVF_NORMAL) {
D3DVALUE *normal =
(D3DVALUE *) (((char *) lpStrideData->normal.lpvData) + i * lpStrideData->normal.dwStride);
TRACE_(ddraw_geom)(" / %f %f %f", normal[0], normal[1], normal[2]);
}
if (dwVertexTypeDesc & D3DFVF_DIFFUSE) {
DWORD *color_d =
(DWORD *) (((char *) lpStrideData->diffuse.lpvData) + i * lpStrideData->diffuse.dwStride);
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
(*color_d >> 16) & 0xFF,
(*color_d >> 8) & 0xFF,
(*color_d >> 0) & 0xFF,
(*color_d >> 24) & 0xFF);
}
if (dwVertexTypeDesc & D3DFVF_SPECULAR) {
DWORD *color_s =
(DWORD *) (((char *) lpStrideData->specular.lpvData) + i * lpStrideData->specular.dwStride);
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
(*color_s >> 16) & 0xFF,
(*color_s >> 8) & 0xFF,
(*color_s >> 0) & 0xFF,
(*color_s >> 24) & 0xFF);
}
for (tex_index = 0; tex_index < GET_TEXCOUNT_FROM_FVF(dwVertexTypeDesc); tex_index++) {
D3DVALUE *tex_coord =
(D3DVALUE *) (((char *) lpStrideData->textureCoords[tex_index].lpvData) +
i * lpStrideData->textureCoords[tex_index].dwStride);
switch (GET_TEXCOORD_SIZE_FROM_FVF(dwVertexTypeDesc, tex_index)) {
case 1: TRACE_(ddraw_geom)(" / %f", tex_coord[0]); break;
case 2: TRACE_(ddraw_geom)(" / %f %f", tex_coord[0], tex_coord[1]); break;
case 3: TRACE_(ddraw_geom)(" / %f %f %f", tex_coord[0], tex_coord[1], tex_coord[2]); break;
case 4: TRACE_(ddraw_geom)(" / %f %f %f %f", tex_coord[0], tex_coord[1], tex_coord[2], tex_coord[3]); break;
default: TRACE_(ddraw_geom)("Invalid texture size (%ld) !!!", GET_TEXCOORD_SIZE_FROM_FVF(dwVertexTypeDesc, tex_index)); break;
}
}
TRACE_(ddraw_geom)("\n");
}
}
return DD_OK;
/* Restore the states if needed */
if(doClip != oldClip)
IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
oldClip);
return hr;
}
#undef copy_and_next
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices(IDirect3DVertexBuffer *iface,
DWORD VertexOp,
DWORD DestIndex,
DWORD Count,
IDirect3DVertexBuffer *SrcBuffer,
DWORD SrcIndex,
IDirect3DDevice3 *D3DDevice,
DWORD Flags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
IDirect3DVertexBufferImpl *Src = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, SrcBuffer);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice3, D3DDevice);
HRESULT WINAPI
GL_IDirect3DVertexBufferImpl_7_1T_ProcessVertices(LPDIRECT3DVERTEXBUFFER7 iface,
DWORD dwVertexOp,
DWORD dwDestIndex,
DWORD dwCount,
LPDIRECT3DVERTEXBUFFER7 lpSrcBuffer,
DWORD dwSrcIndex,
LPDIRECT3DDEVICE7 lpD3DDevice,
DWORD dwFlags)
TRACE_(ddraw_thunk)("(%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx) thunking to IDirect3DVertexBuffer7 interface.\n", This, VertexOp, DestIndex, Count, Src, SrcIndex, D3D, Flags);
return IDirect3DVertexBuffer7_ProcessVertices(ICOM_INTERFACE(This, IDirect3DVertexBuffer7),
VertexOp,
DestIndex,
Count,
ICOM_INTERFACE(Src, IDirect3DVertexBuffer7),
SrcIndex,
ICOM_INTERFACE(D3D, IDirect3DDevice7),
Flags);
}
/*****************************************************************************
* IDirect3DVertexBuffer7::GetVertexBufferDesc
*
* Returns the description of a vertex buffer
*
* Params:
* Desc: Address to write the description to
*
* Returns
* DDERR_INVALIDPARAMS if Desc is NULL
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
D3DVERTEXBUFFERDESC *Desc)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
IDirect3DVertexBufferImpl *src_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpSrcBuffer);
IDirect3DDeviceImpl *device_impl = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, lpD3DDevice);
D3DDRAWPRIMITIVESTRIDEDDATA strided;
WINED3DVERTEXBUFFER_DESC WDesc;
HRESULT hr;
DWORD size;
TRACE("(%p)->(%p)\n", This, Desc);
TRACE("(%p/%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx)\n", This, iface, dwVertexOp, dwDestIndex, dwCount, lpSrcBuffer, dwSrcIndex, lpD3DDevice, dwFlags);
if(!Desc) return DDERR_INVALIDPARAMS;
if (TRACE_ON(ddraw)) {
TRACE(" - vertex operations : "); dump_D3DVOP(dwVertexOp);
TRACE(" - flags : "); dump_D3DPV(dwFlags);
hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer,
&WDesc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08lx\n", This, hr);
return hr;
}
if ((dwVertexOp & D3DVOP_TRANSFORM) == 0) return DDERR_INVALIDPARAMS;
size = get_flexible_vertex_size(src_impl->desc.dwFVF);
convert_FVF_to_strided_data(src_impl->desc.dwFVF, ((char *) src_impl->vertices) + dwSrcIndex * size, &strided, 0);
return process_vertices_strided(This, dwVertexOp, dwDestIndex, dwCount, &strided, src_impl->desc.dwFVF, device_impl, dwFlags);
}
HRESULT WINAPI
GL_IDirect3DVertexBufferImpl_7_ProcessVerticesStrided(LPDIRECT3DVERTEXBUFFER7 iface,
DWORD dwVertexOp,
DWORD dwDestIndex,
DWORD dwCount,
LPD3DDRAWPRIMITIVESTRIDEDDATA lpStrideData,
DWORD dwVertexTypeDesc,
LPDIRECT3DDEVICE7 lpD3DDevice,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
IDirect3DDeviceImpl *device_impl = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, lpD3DDevice);
TRACE("(%p/%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx)\n", This, iface, dwVertexOp, dwDestIndex, dwCount, lpStrideData, dwVertexTypeDesc, lpD3DDevice, dwFlags);
if (TRACE_ON(ddraw)) {
TRACE(" - vertex operations : "); dump_D3DVOP(dwVertexOp);
TRACE(" - flags : "); dump_D3DPV(dwFlags);
TRACE(" - vertex format : "); dump_flexible_vertex(dwVertexTypeDesc);
}
if ((dwVertexOp & D3DVOP_TRANSFORM) == 0) return DDERR_INVALIDPARAMS;
return process_vertices_strided(This, dwVertexOp, dwDestIndex, dwCount, lpStrideData, dwVertexTypeDesc, device_impl, dwFlags);
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DVertexBuffer7.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DVertexBuffer7Vtbl VTABLE_IDirect3DVertexBuffer7 =
{
XCAST(QueryInterface) Main_IDirect3DVertexBufferImpl_7_1T_QueryInterface,
XCAST(AddRef) Main_IDirect3DVertexBufferImpl_7_1T_AddRef,
XCAST(Release) Main_IDirect3DVertexBufferImpl_7_1T_Release,
XCAST(Lock) Main_IDirect3DVertexBufferImpl_7_1T_Lock,
XCAST(Unlock) Main_IDirect3DVertexBufferImpl_7_1T_Unlock,
XCAST(ProcessVertices) GL_IDirect3DVertexBufferImpl_7_1T_ProcessVertices,
XCAST(GetVertexBufferDesc) Main_IDirect3DVertexBufferImpl_7_1T_GetVertexBufferDesc,
XCAST(Optimize) Main_IDirect3DVertexBufferImpl_7_1T_Optimize,
XCAST(ProcessVerticesStrided) GL_IDirect3DVertexBufferImpl_7_ProcessVerticesStrided
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DVertexBuffer.fun))
#else
# define XCAST(fun) (void*)
#endif
static const IDirect3DVertexBufferVtbl VTABLE_IDirect3DVertexBuffer =
{
XCAST(QueryInterface) Thunk_IDirect3DVertexBufferImpl_1_QueryInterface,
XCAST(AddRef) Thunk_IDirect3DVertexBufferImpl_1_AddRef,
XCAST(Release) Thunk_IDirect3DVertexBufferImpl_1_Release,
XCAST(Lock) Thunk_IDirect3DVertexBufferImpl_1_Lock,
XCAST(Unlock) Thunk_IDirect3DVertexBufferImpl_1_Unlock,
XCAST(ProcessVertices) Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices,
XCAST(GetVertexBufferDesc) Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc,
XCAST(Optimize) Thunk_IDirect3DVertexBufferImpl_1_Optimize
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags)
{
IDirect3DVertexBufferImpl *object;
static const flag_info flags[] = {
FE(D3DVBCAPS_DONOTCLIP),
FE(D3DVBCAPS_OPTIMIZED),
FE(D3DVBCAPS_SYSTEMMEMORY),
FE(D3DVBCAPS_WRITEONLY)
};
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBufferGLImpl));
if (object == NULL) return DDERR_OUTOFMEMORY;
object->ref = 1;
object->d3d = d3d;
object->desc = *lpD3DVertBufDesc;
object->vertex_buffer_size = get_flexible_vertex_size(lpD3DVertBufDesc->dwFVF) * lpD3DVertBufDesc->dwNumVertices;
object->vertices = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->vertex_buffer_size);
ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer, VTABLE_IDirect3DVertexBuffer);
ICOM_INIT_INTERFACE(object, IDirect3DVertexBuffer7, VTABLE_IDirect3DVertexBuffer7);
*obj = object;
if (TRACE_ON(ddraw)) {
TRACE(" creating implementation at %p with description :\n", *obj);
TRACE(" flags : "); DDRAW_dump_flags_(lpD3DVertBufDesc->dwCaps, flags, sizeof(flags)/sizeof(flags[0]), TRUE);
TRACE(" vertex type : "); dump_flexible_vertex(lpD3DVertBufDesc->dwFVF);
TRACE(" num vertices : %ld\n", lpD3DVertBufDesc->dwNumVertices);
}
/* Clear the return value of garbage */
size = Desc->dwSize;
memset(Desc, 0, size);
/* Now fill the Desc structure */
Desc->dwSize = size;
Desc->dwCaps = This->Caps;
Desc->dwFVF = WDesc.FVF;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF);
return D3D_OK;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc(IDirect3DVertexBuffer *iface,
D3DVERTEXBUFFERDESC *Desc)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
TRACE_(ddraw_thunk)("(%p)->(%p) thunking to IDirect3DVertexBuffer7 interface.\n", This, Desc);
return IDirect3DVertexBuffer7_GetVertexBufferDesc(ICOM_INTERFACE(This, IDirect3DVertexBuffer7),
Desc);
}
/*****************************************************************************
* IDirect3DVertexBuffer7::Optimize
*
* Converts an unoptimized vertex buffer into an optimized buffer
*
* Params:
* D3DDevice: Device for which this buffer is optimized
* Flags: Not used, should be set to 0
*
* Returns
* D3D_OK, because it's a stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
IDirect3DDevice7 *D3DDevice,
DWORD Flags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice);
FIXME("(%p)->(%p,%08lx): stub!\n", This, D3D, Flags);
/* We could forward this call to WineD3D and take advantage
* of it once we use OpenGL vertex buffers
*/
This->Caps |= D3DVBCAPS_OPTIMIZED;
return DD_OK;
}
static HRESULT WINAPI
Thunk_IDirect3DVertexBufferImpl_1_Optimize(IDirect3DVertexBuffer *iface,
IDirect3DDevice3 *D3DDevice,
DWORD Flags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer, iface);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice3, D3DDevice);
TRACE_(ddraw_thunk)("(%p)->(%p,%08lx) thunking to IDirect3DVertexBuffer7 interface.\n", This, D3D, Flags);
return IDirect3DVertexBuffer7_Optimize(ICOM_INTERFACE(This, IDirect3DVertexBuffer7),
ICOM_INTERFACE(D3D, IDirect3DDevice7),
Flags);
}
/*****************************************************************************
* IDirect3DVertexBuffer7::ProcessVerticesStrided
*
* This method processes untransformed strided vertices into a processed
* or optimized vertex buffer.
*
* For more details on the parameters, see
* IDirect3DVertexBuffer7::ProcessVertices
*
* Params:
* VertexOp: Operations to perform
* DestIndex: Destination index to write the vertices to
* Count: Number of input vertices
* StrideData: Array containing the input vertices
* VertexTypeDesc: Vertex Description or source index?????????
* D3DDevice: IDirect3DDevice7 to use for processing
* Flags: Can be D3DPV_DONOTCOPYDATA to avoid copying unmodified vertices
*
* Returns
* D3D_OK on success, or DDERR_*
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DVertexBufferImpl_ProcessVerticesStrided(IDirect3DVertexBuffer7 *iface,
DWORD VertexOp,
DWORD DestIndex,
DWORD Count,
D3DDRAWPRIMITIVESTRIDEDDATA *StrideData,
DWORD VertexTypeDesc,
IDirect3DDevice7 *D3DDevice,
DWORD Flags)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
IDirect3DDeviceImpl *D3D = ICOM_OBJECT(IDirect3DDeviceImpl, IDirect3DDevice7, D3DDevice);
FIXME("(%p)->(%08lx,%08lx,%08lx,%p,%08lx,%p,%08lx): stub!\n", This, VertexOp, DestIndex, Count, StrideData, VertexTypeDesc, D3D, Flags);
return DD_OK;
}
/*****************************************************************************
* The VTables
*****************************************************************************/
const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl =
{
/*** IUnknown Methods ***/
IDirect3DVertexBufferImpl_QueryInterface,
IDirect3DVertexBufferImpl_AddRef,
IDirect3DVertexBufferImpl_Release,
/*** IDirect3DVertexBuffer Methods ***/
IDirect3DVertexBufferImpl_Lock,
IDirect3DVertexBufferImpl_Unlock,
IDirect3DVertexBufferImpl_ProcessVertices,
IDirect3DVertexBufferImpl_GetVertexBufferDesc,
IDirect3DVertexBufferImpl_Optimize,
/*** IDirect3DVertexBuffer7 Methods ***/
IDirect3DVertexBufferImpl_ProcessVerticesStrided
};
const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl =
{
/*** IUnknown Methods ***/
Thunk_IDirect3DVertexBufferImpl_1_QueryInterface,
Thunk_IDirect3DVertexBufferImpl_1_AddRef,
Thunk_IDirect3DVertexBufferImpl_1_Release,
/*** IDirect3DVertexBuffer Methods ***/
Thunk_IDirect3DVertexBufferImpl_1_Lock,
Thunk_IDirect3DVertexBufferImpl_1_Unlock,
Thunk_IDirect3DVertexBufferImpl_1_ProcessVertices,
Thunk_IDirect3DVertexBufferImpl_1_GetVertexBufferDesc,
Thunk_IDirect3DVertexBufferImpl_1_Optimize
};

View File

@ -1,5 +1,6 @@
/* Direct3D Viewport
* Copyright (c) 1998 Lionel ULMER
* Copyright (c) 2006 Stefan DÖSINGER
*
* This file contains the implementation of Direct3DViewport2.
*
@ -19,26 +20,43 @@
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "objbase.h"
#include "wingdi.h"
#include "wine/exception.h"
#include "excpt.h"
#include "ddraw.h"
#include "d3d.h"
#include "ddraw_private.h"
#include "wine/debug.h"
#include "d3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/*****************************************************************************
* Helper functions
*****************************************************************************/
static void activate(IDirect3DViewportImpl* This) {
/*****************************************************************************
* viewport_activate
*
* activates the viewport using IDirect3DDevice7::SetViewport
*
*****************************************************************************/
void viewport_activate(IDirect3DViewportImpl* This) {
IDirect3DLightImpl* light;
D3DVIEWPORT7 vp;
@ -71,7 +89,12 @@ static void activate(IDirect3DViewportImpl* This) {
IDirect3DDevice7_SetViewport(ICOM_INTERFACE(This->active_device, IDirect3DDevice7), &vp);
}
/*****************************************************************************
* _dump_D3DVIEWPORT, _dump_D3DVIEWPORT2
*
* Writes viewport information to TRACE
*
*****************************************************************************/
static void _dump_D3DVIEWPORT(D3DVIEWPORT *lpvp)
{
TRACE(" - dwSize = %ld dwX = %ld dwY = %ld\n",
@ -100,13 +123,33 @@ static void _dump_D3DVIEWPORT2(D3DVIEWPORT2 *lpvp)
lpvp->dvMinZ, lpvp->dvMaxZ);
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_QueryInterface(LPDIRECT3DVIEWPORT3 iface,
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DViewport3::QueryInterface
*
* A normal QueryInterface. Can query all interface versions and the
* IUnknown interface. The VTables of the different versions
* are equal
*
* Params:
* refiid: Interface id queried for
* obj: Address to write the interface pointer to
*
* Returns:
* S_OK on success.
* E_NOINTERFACE if the requested interface wasn't found
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_QueryInterface(IDirect3DViewport3 *iface,
REFIID riid,
LPVOID* obp)
void **obp)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp);
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obp);
*obp = NULL;
@ -120,27 +163,45 @@ Main_IDirect3DViewportImpl_3_2_1_QueryInterface(LPDIRECT3DVIEWPORT3 iface,
return S_OK;
}
FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
return OLE_E_ENUM_NOMORE;
return E_NOINTERFACE;
}
ULONG WINAPI
Main_IDirect3DViewportImpl_3_2_1_AddRef(LPDIRECT3DVIEWPORT3 iface)
/*****************************************************************************
* IDirect3DViewport3::AddRef
*
* Increases the refcount.
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DViewportImpl_AddRef(IDirect3DViewport3 *iface)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)->() incrementing from %lu.\n", This, iface, ref - 1);
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
return ref;
}
ULONG WINAPI
Main_IDirect3DViewportImpl_3_2_1_Release(LPDIRECT3DVIEWPORT3 iface)
/*****************************************************************************
* IDirect3DViewport3::Release
*
* Reduces the refcount. If it falls to 0, the interface is released
*
* Returns:
* The new refcount
*
*****************************************************************************/
static ULONG WINAPI
IDirect3DViewportImpl_Release(IDirect3DViewport3 *iface)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, ref + 1);
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
@ -149,19 +210,46 @@ Main_IDirect3DViewportImpl_3_2_1_Release(LPDIRECT3DVIEWPORT3 iface)
return ref;
}
/*****************************************************************************
* IDirect3DViewport Methods.
*****************************************************************************/
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_Initialize(LPDIRECT3DVIEWPORT3 iface,
LPDIRECT3D lpDirect3D)
/*****************************************************************************
* IDirect3DViewport3::Initialize
*
* No-op initialization.
*
* Params:
* Direct3D: The direct3D device this viewport is assigned to
*
* Returns:
* DDERR_ALREADYINITIALIZED
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_Initialize(IDirect3DViewport3 *iface,
IDirect3D *Direct3D)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
TRACE("(%p/%p)->(%p) no-op...\n", This, iface, lpDirect3D);
return DD_OK;
TRACE("(%p)->(%p) no-op...\n", iface, Direct3D);
return DDERR_ALREADYINITIALIZED;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_GetViewport(LPDIRECT3DVIEWPORT3 iface,
LPD3DVIEWPORT lpData)
/*****************************************************************************
* IDirect3DViewport3::GetViewport
*
* Returns the viewport data assigned to this viewport interface
*
* Params:
* Data: Address to store the data
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Data is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface,
D3DVIEWPORT *lpData)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
DWORD dwSize;
@ -174,7 +262,7 @@ Main_IDirect3DViewportImpl_3_2_1_GetViewport(LPDIRECT3DVIEWPORT3 iface,
memset(lpData, 0, dwSize);
memcpy(lpData, &(This->viewports.vp1), dwSize);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE(" returning D3DVIEWPORT :\n");
_dump_D3DVIEWPORT(lpData);
}
@ -182,15 +270,28 @@ Main_IDirect3DViewportImpl_3_2_1_GetViewport(LPDIRECT3DVIEWPORT3 iface,
return DD_OK;
}
/*****************************************************************************
* IDirect3DViewport3::SetViewport
*
* Sets the viewport information for this interface
*
* Params:
* lpData: Viewport to set
*
* Returns:
* D3D_OK on succes
* DDERR_INVALIDPARAMS if Data is NULL
*
*****************************************************************************/
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_SetViewport(LPDIRECT3DVIEWPORT3 iface,
LPD3DVIEWPORT lpData)
IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
D3DVIEWPORT *lpData)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
LPDIRECT3DVIEWPORT3 current_viewport;
TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE(" getting D3DVIEWPORT :\n");
_dump_D3DVIEWPORT(lpData);
}
@ -215,36 +316,75 @@ Main_IDirect3DViewportImpl_3_2_1_SetViewport(LPDIRECT3DVIEWPORT3 iface,
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_TransformVertices(LPDIRECT3DVIEWPORT3 iface,
/*****************************************************************************
* IDirect3DViewport3::TransformVertices
*
* Transforms vertices by the transformation matrix.
*
* Params:
* dwVertexCount: The number of vertices to be transformed
* lpData: Pointer to the vertex data
* dwFlags: D3DTRANSFORM_CLIPPED or D3DTRANSFORM_UNCLIPPED
* lpOffScreen: Is set to nonzero if all vertices are off-screen
*
* Returns:
* D3D_OK because it's a stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
DWORD dwVertexCount,
LPD3DTRANSFORMDATA lpData,
D3DTRANSFORMDATA *lpData,
DWORD dwFlags,
LPDWORD lpOffScreen)
DWORD *lpOffScreen)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%08lx,%p,%08lx,%p): stub!\n", This, iface, dwVertexCount, lpData, dwFlags, lpOffScreen);
FIXME("(%p)->(%08lx,%p,%08lx,%p): stub!\n", This, dwVertexCount, lpData, dwFlags, lpOffScreen);
if (lpOffScreen)
*lpOffScreen = 0;
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_LightElements(LPDIRECT3DVIEWPORT3 iface,
/*****************************************************************************
* IDirect3DViewport3::LightElements
*
* The DirectX 5.0 sdk says that it's not implemented
*
* Params:
* ?
*
* Returns:
* DDERR_UNSUPPORTED
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_LightElements(IDirect3DViewport3 *iface,
DWORD dwElementCount,
LPD3DLIGHTDATA lpData)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%08lx,%p): stub!\n", This, iface, dwElementCount, lpData);
return DD_OK;
TRACE("(%p)->(%08lx,%p): Unimplemented!\n", This, dwElementCount, lpData);
return DDERR_UNSUPPORTED;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_SetBackground(LPDIRECT3DVIEWPORT3 iface,
/*****************************************************************************
* IDirect3DViewport3::SetBackground
*
* Sets tje background material
*
* Params:
* hMat: Handle from a IDirect3DMaterial interface
*
* Returns:
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
D3DMATERIALHANDLE hMat)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
TRACE("(%p/%p)->(%08lx)\n", This, iface, (DWORD) hMat);
TRACE("(%p)->(%08lx)\n", This, (DWORD) hMat);
This->background = (IDirect3DMaterialImpl *) hMat;
TRACE(" setting background color : %f %f %f %f\n",
@ -253,42 +393,99 @@ Main_IDirect3DViewportImpl_3_2_1_SetBackground(LPDIRECT3DVIEWPORT3 iface,
This->background->mat.u.diffuse.u3.b,
This->background->mat.u.diffuse.u4.a);
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_GetBackground(LPDIRECT3DVIEWPORT3 iface,
LPD3DMATERIALHANDLE lphMat,
/*****************************************************************************
* IDirect3DViewport3::GetBackground
*
* Returns the material handle assigned to the background of the viewport
*
* Params:
* lphMat: Address to store the handle
* lpValid: is set to FALSE if no background is set, TRUE if one is set
*
* Returns:
* D3D_OK, because it's a stub
* (DDERR_INVALIDPARAMS if Mat or Valid is NULL)
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface,
D3DMATERIALHANDLE *lphMat,
BOOL *lpValid)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p)->(%p,%p): stub!\n", This, lphMat, lpValid);
return D3D_OK;
}
/*****************************************************************************
* IDirect3DViewport3::SetBackgroundDepth
*
* Sets a surface that represents the background depth. It's contents are
* used to set the depth buffer in IDirect3DViewport3::Clear
*
* Params:
* lpDDSurface: Surface to set
*
* Returns: D3D_OK, because it's a stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_SetBackgroundDepth(IDirect3DViewport3 *iface,
IDirectDrawSurface *lpDDSurface)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p)->(%p): stub!\n", This, lpDDSurface);
return D3D_OK;
}
/*****************************************************************************
* IDirect3DViewport3::GetBackgroundDepth
*
* Returns the surface that represents the depth field
*
* Params:
* lplpDDSurface: Address to store the interface pointer
* lpValid: Set to TRUE if a depth is asigned, FALSE otherwise
*
* Returns:
* D3D_OK, because it's a stub
* (DDERR_INVALIDPARAMS if DDSurface of Valid is NULL)
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_GetBackgroundDepth(IDirect3DViewport3 *iface,
IDirectDrawSurface **lplpDDSurface,
LPBOOL lpValid)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lphMat, lpValid);
FIXME("(%p)->(%p,%p): stub!\n", This, lplpDDSurface, lpValid);
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_SetBackgroundDepth(LPDIRECT3DVIEWPORT3 iface,
LPDIRECTDRAWSURFACE lpDDSurface)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpDDSurface);
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_GetBackgroundDepth(LPDIRECT3DVIEWPORT3 iface,
LPDIRECTDRAWSURFACE* lplpDDSurface,
LPBOOL lpValid)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDDSurface, lpValid);
return DD_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_Clear(LPDIRECT3DVIEWPORT3 iface,
/*****************************************************************************
* IDirect3DViewport3::Clear
*
* Clears the render target and / or the z buffer
*
* Params:
* dwCount: The amount of rectangles to clear. If 0, the whole buffer is
* cleared
* lpRects: Pointer to the array of rectangles. If NULL, Count must be 0
* dwFlags: D3DCLEAR_ZBUFFER and / or D3DCLEAR_TARGET
*
* Returns:
* D3D_OK on success
* D3DERR_VIEWPORTHASNODEVICE if there's no active device
* The return value of IDirect3DDevice7::Clear
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
DWORD dwCount,
LPD3DRECT lpRects,
D3DRECT *lpRects,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
@ -310,21 +507,40 @@ Main_IDirect3DViewportImpl_3_2_1_Clear(LPDIRECT3DVIEWPORT3 iface,
((int) ((This->background->mat.u.diffuse.u4.a) * 255) << 24);
}
}
return This->active_device->clear(This->active_device, dwCount, lpRects,
return IDirect3DDevice7_Clear(ICOM_INTERFACE(This->active_device, IDirect3DDevice7),
dwCount,
lpRects,
dwFlags & (D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET),
color, 1.0, 0x00000000);
color,
1.0,
0x00000000);
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_AddLight(LPDIRECT3DVIEWPORT3 iface,
LPDIRECT3DLIGHT lpDirect3DLight)
/*****************************************************************************
* IDirect3DViewport3::AddLight
*
* Adds an light to the viewport
*
* Params:
* lpDirect3DLight: Interface of the light to add
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if Direct3DLight is NULL
* DDERR_INVALIDPARAMS if there are 8 lights or more
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
IDirect3DLightImpl *lpDirect3DLightImpl = ICOM_OBJECT(IDirect3DLightImpl, IDirect3DLight, lpDirect3DLight);
DWORD i = 0;
DWORD map = This->map_lights;
TRACE("(%p/%p)->(%p)\n", This, iface, lpDirect3DLight);
TRACE("(%p)->(%p)\n", This, lpDirect3DLight);
if (This->num_lights >= 8)
return DDERR_INVALIDPARAMS;
@ -350,18 +566,31 @@ Main_IDirect3DViewportImpl_3_2_1_AddLight(LPDIRECT3DVIEWPORT3 iface,
lpDirect3DLightImpl->activate(lpDirect3DLightImpl);
}
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_DeleteLight(LPDIRECT3DVIEWPORT3 iface,
LPDIRECT3DLIGHT lpDirect3DLight)
/*****************************************************************************
* IDirect3DViewport3::DeleteLight
*
* Deletes a light from the viewports' light list
*
* Params:
* lpDirect3DLight: Light to delete
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if the light wasn't found
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
IDirect3DLightImpl *lpDirect3DLightImpl = ICOM_OBJECT(IDirect3DLightImpl, IDirect3DLight, lpDirect3DLight);
IDirect3DLightImpl *cur_light, *prev_light = NULL;
TRACE("(%p/%p)->(%p)\n", This, iface, lpDirect3DLight);
TRACE("(%p)->(%p)\n", This, lpDirect3DLight);
cur_light = This->lights;
while (cur_light != NULL) {
if (cur_light == lpDirect3DLightImpl) {
@ -372,7 +601,7 @@ Main_IDirect3DViewportImpl_3_2_1_DeleteLight(LPDIRECT3DVIEWPORT3 iface,
cur_light->active_viewport = NULL;
This->num_lights--;
This->map_lights &= ~(1<<lpDirect3DLightImpl->dwLightIndex);
return DD_OK;
return D3D_OK;
}
prev_light = cur_light;
cur_light = cur_light->next;
@ -380,24 +609,57 @@ Main_IDirect3DViewportImpl_3_2_1_DeleteLight(LPDIRECT3DVIEWPORT3 iface,
return DDERR_INVALIDPARAMS;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_1_NextLight(LPDIRECT3DVIEWPORT3 iface,
LPDIRECT3DLIGHT lpDirect3DLight,
LPDIRECT3DLIGHT* lplpDirect3DLight,
/*****************************************************************************
* IDirect3DViewport::NextLight
*
* Enumerates the lights associated with the viewport
*
* Params:
* lpDirect3DLight: Light to start with
* lplpDirect3DLight: Address to store the successor to
*
* Returns:
* D3D_OK, because it's a stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
IDirect3DLight *lpDirect3DLight,
IDirect3DLight **lplpDirect3DLight,
DWORD dwFlags)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpDirect3DLight, lplpDirect3DLight, dwFlags);
return DD_OK;
FIXME("(%p)->(%p,%p,%08lx): stub!\n", This, lpDirect3DLight, lplpDirect3DLight, dwFlags);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_GetViewport2(LPDIRECT3DVIEWPORT3 iface,
LPD3DVIEWPORT2 lpData)
/*****************************************************************************
* IDirect3DViewport2 Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DViewport3::GetViewport2
*
* Returns the currently set viewport in a D3DVIEWPORT2 structure.
* Simmilar to IDirect3DViewport3::GetViewport
*
* Params:
* lpData: Pointer to the structure to fill
*
* Returns:
* D3D_OK on success
* DDERR_INVALIDPARAMS if the viewport was set with
* IDirect3DViewport3::SetViewport
* DDERR_INVALIDPARAMS if Data is NULL
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface,
D3DVIEWPORT2 *lpData)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
DWORD dwSize;
TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
TRACE("(%p)->(%p)\n", This, lpData);
if (This->use_vp2 != 1) {
ERR(" Requesting to get a D3DVIEWPORT2 struct where a D3DVIEWPORT was set !\n");
return DDERR_INVALIDPARAMS;
@ -406,23 +668,35 @@ Main_IDirect3DViewportImpl_3_2_GetViewport2(LPDIRECT3DVIEWPORT3 iface,
memset(lpData, 0, dwSize);
memcpy(lpData, &(This->viewports.vp2), dwSize);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE(" returning D3DVIEWPORT2 :\n");
_dump_D3DVIEWPORT2(lpData);
}
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_2_SetViewport2(LPDIRECT3DVIEWPORT3 iface,
LPD3DVIEWPORT2 lpData)
/*****************************************************************************
* IDirect3DViewport3::SetViewport2
*
* Sets the viewport from a D3DVIEWPORT2 structure
*
* Params:
* lpData: Viewport to set
*
* Returns:
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
D3DVIEWPORT2 *lpData)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
LPDIRECT3DVIEWPORT3 current_viewport;
TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
if (TRACE_ON(ddraw)) {
if (TRACE_ON(d3d7)) {
TRACE(" getting D3DVIEWPORT2 :\n");
_dump_D3DVIEWPORT2(lpData);
}
@ -438,30 +712,75 @@ Main_IDirect3DViewportImpl_3_2_SetViewport2(LPDIRECT3DVIEWPORT3 iface,
IDirect3DViewport3_Release(current_viewport);
}
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_SetBackgroundDepth2(LPDIRECT3DVIEWPORT3 iface,
LPDIRECTDRAWSURFACE4 lpDDS)
/*****************************************************************************
* IDirect3DViewport3 Methods.
*****************************************************************************/
/*****************************************************************************
* IDirect3DViewport3::SetBackgroundDepth2
*
* Sets a IDirectDrawSurface4 surface as the background depth surface
*
* Params:
* lpDDS: Surface to set
*
* Returns:
* D3D_OK, because it's stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_SetBackgroundDepth2(IDirect3DViewport3 *iface,
IDirectDrawSurface4 *lpDDS)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpDDS);
return DD_OK;
FIXME("(%p)->(%p): stub!\n", This, lpDDS);
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_GetBackgroundDepth2(LPDIRECT3DVIEWPORT3 iface,
LPDIRECTDRAWSURFACE4* lplpDDS,
LPBOOL lpValid)
/*****************************************************************************
* IDirect3DViewport3::GetBackgroundDepth2
*
* Returns the IDirect3DSurface4 interface to the background depth surface
*
* Params:
* lplpDDS: Address to store the interface pointer at
* lpValid: Set to true if a surface is assigned
*
* Returns:
* D3D_OK because it's a stub
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_GetBackgroundDepth2(IDirect3DViewport3 *iface,
IDirectDrawSurface4 **lplpDDS,
BOOL *lpValid)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDDS, lpValid);
return DD_OK;
return D3D_OK;
}
HRESULT WINAPI
Main_IDirect3DViewportImpl_3_Clear2(LPDIRECT3DVIEWPORT3 iface,
/*****************************************************************************
* IDirect3DViewport3::Clear2
*
* Another clearing method
*
* Params:
* Count: Number of rectangles to clear
* Rects: Rectangle array to clear
* Flags: Some flags :)
* Color: Color to fill the render target with
* Z: Value to fill the depth buffer with
* Stencil: Value to fill the stencil bits with
*
* Returns:
*
*****************************************************************************/
static HRESULT WINAPI
IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
DWORD dwCount,
LPD3DRECT lpRects,
DWORD dwFlags,
@ -470,73 +789,49 @@ Main_IDirect3DViewportImpl_3_Clear2(LPDIRECT3DVIEWPORT3 iface,
DWORD dwStencil)
{
ICOM_THIS_FROM(IDirect3DViewportImpl, IDirect3DViewport3, iface);
TRACE("(%p/%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, iface, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
TRACE("(%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
if (This->active_device == NULL) {
ERR(" Trying to clear a viewport not attached to a device !\n");
return D3DERR_VIEWPORTHASNODEVICE;
}
return This->active_device->clear(This->active_device, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
return IDirect3DDevice7_Clear(ICOM_INTERFACE(This->active_device, IDirect3DDevice7),
dwCount,
lpRects,
dwFlags,
dwColor,
dvZ,
dwStencil);
}
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
# define XCAST(fun) (typeof(VTABLE_IDirect3DViewport3.fun))
#else
# define XCAST(fun) (void*)
#endif
/*****************************************************************************
* The VTable
*****************************************************************************/
static const IDirect3DViewport3Vtbl VTABLE_IDirect3DViewport3 =
const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl =
{
XCAST(QueryInterface) Main_IDirect3DViewportImpl_3_2_1_QueryInterface,
XCAST(AddRef) Main_IDirect3DViewportImpl_3_2_1_AddRef,
XCAST(Release) Main_IDirect3DViewportImpl_3_2_1_Release,
XCAST(Initialize) Main_IDirect3DViewportImpl_3_2_1_Initialize,
XCAST(GetViewport) Main_IDirect3DViewportImpl_3_2_1_GetViewport,
XCAST(SetViewport) Main_IDirect3DViewportImpl_3_2_1_SetViewport,
XCAST(TransformVertices) Main_IDirect3DViewportImpl_3_2_1_TransformVertices,
XCAST(LightElements) Main_IDirect3DViewportImpl_3_2_1_LightElements,
XCAST(SetBackground) Main_IDirect3DViewportImpl_3_2_1_SetBackground,
XCAST(GetBackground) Main_IDirect3DViewportImpl_3_2_1_GetBackground,
XCAST(SetBackgroundDepth) Main_IDirect3DViewportImpl_3_2_1_SetBackgroundDepth,
XCAST(GetBackgroundDepth) Main_IDirect3DViewportImpl_3_2_1_GetBackgroundDepth,
XCAST(Clear) Main_IDirect3DViewportImpl_3_2_1_Clear,
XCAST(AddLight) Main_IDirect3DViewportImpl_3_2_1_AddLight,
XCAST(DeleteLight) Main_IDirect3DViewportImpl_3_2_1_DeleteLight,
XCAST(NextLight) Main_IDirect3DViewportImpl_3_2_1_NextLight,
XCAST(GetViewport2) Main_IDirect3DViewportImpl_3_2_GetViewport2,
XCAST(SetViewport2) Main_IDirect3DViewportImpl_3_2_SetViewport2,
XCAST(SetBackgroundDepth2) Main_IDirect3DViewportImpl_3_SetBackgroundDepth2,
XCAST(GetBackgroundDepth2) Main_IDirect3DViewportImpl_3_GetBackgroundDepth2,
XCAST(Clear2) Main_IDirect3DViewportImpl_3_Clear2,
/*** IUnknown Methods ***/
IDirect3DViewportImpl_QueryInterface,
IDirect3DViewportImpl_AddRef,
IDirect3DViewportImpl_Release,
/*** IDirect3DViewport Methods */
IDirect3DViewportImpl_Initialize,
IDirect3DViewportImpl_GetViewport,
IDirect3DViewportImpl_SetViewport,
IDirect3DViewportImpl_TransformVertices,
IDirect3DViewportImpl_LightElements,
IDirect3DViewportImpl_SetBackground,
IDirect3DViewportImpl_GetBackground,
IDirect3DViewportImpl_SetBackgroundDepth,
IDirect3DViewportImpl_GetBackgroundDepth,
IDirect3DViewportImpl_Clear,
IDirect3DViewportImpl_AddLight,
IDirect3DViewportImpl_DeleteLight,
IDirect3DViewportImpl_NextLight,
/*** IDirect3DViewport2 Methods ***/
IDirect3DViewportImpl_GetViewport2,
IDirect3DViewportImpl_SetViewport2,
/*** IDirect3DViewport3 Methods ***/
IDirect3DViewportImpl_SetBackgroundDepth2,
IDirect3DViewportImpl_GetBackgroundDepth2,
IDirect3DViewportImpl_Clear2,
};
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
#undef XCAST
#endif
HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d)
{
IDirect3DViewportImpl *object;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DViewportImpl));
if (object == NULL) return DDERR_OUTOFMEMORY;
object->ref = 1;
object->d3d = d3d;
object->activate = activate;
object->use_vp2 = 0xFF;
object->next = NULL;
object->lights = NULL;
object->num_lights = 0;
object->map_lights = 0;
ICOM_INIT_INTERFACE(object, IDirect3DViewport3, VTABLE_IDirect3DViewport3);
*obj = object;
TRACE(" creating implementation at %p.\n", *obj);
return D3D_OK;
}