From 90f5be2bef5c8dd96b02493fd84b491660690db1 Mon Sep 17 00:00:00 2001 From: Ivan Gyurdiev Date: Tue, 10 Oct 2006 21:56:41 -0400 Subject: [PATCH] wined3d: Merge MATERIAL types into one type in WINED3D namespace. --- dlls/d3d8/device.c | 6 ++++-- dlls/d3d9/device.c | 4 ++++ dlls/ddraw/device.c | 8 ++++++-- dlls/wined3d/device.c | 1 - dlls/wined3d/stateblock.c | 4 ++-- include/wine/wined3d_interface.h | 3 --- include/wine/wined3d_types.h | 8 ++++++++ 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 5d841fa2b9e..2a7d730067f 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -710,14 +710,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetViewport(LPDIRECT3DDEVICE8 iface, static HRESULT WINAPI IDirect3DDevice8Impl_SetMaterial(LPDIRECT3DDEVICE8 iface, CONST D3DMATERIAL8* pMaterial) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; TRACE("(%p) Relay\n" , This); -/* FIXME: Verify that D3DMATERIAL8 ~= WINED3DMATERIAL */ + + /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */ return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial); } static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, D3DMATERIAL8* pMaterial) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; TRACE("(%p) Relay\n" , This); -/* FIXME: Verify that D3DMATERIAL8 ~= WINED3DMATERIAL */ + + /* Note: D3DMATERIAL8 is compatible with WINED3DMATERIAL */ return IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial); } diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 316d762bd16..815ea6df0bf 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -492,12 +492,16 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9 iface static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9 iface, CONST D3DMATERIAL9* pMaterial) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); + + /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */ return IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial); } static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface, D3DMATERIAL9* pMaterial) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); + + /* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */ return IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial); } diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 836168c672b..42e469781d1 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -4095,8 +4095,10 @@ IDirect3DDeviceImpl_7_SetMaterial(IDirect3DDevice7 *iface, HRESULT hr; TRACE("(%p)->(%p): Relay!\n", This, Mat); + /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */ hr = IWineD3DDevice_SetMaterial(This->wineD3DDevice, - Mat); + (WINED3DMATERIAL*) Mat); + return hr_ddraw_from_wined3d(hr); } @@ -4124,8 +4126,10 @@ IDirect3DDeviceImpl_7_GetMaterial(IDirect3DDevice7 *iface, HRESULT hr; TRACE("(%p)->(%p): Relay!\n", This, Mat); + /* Note: D3DMATERIAL7 is compatible with WINED3DMATERIAL */ hr = IWineD3DDevice_GetMaterial(This->wineD3DDevice, - Mat); + (WINED3DMATERIAL*) Mat); + return hr_ddraw_from_wined3d(hr); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 40c0d83417a..f0da0cc6e21 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3139,7 +3139,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, /***** * Get / Set Material - * WARNING: This code relies on the fact that D3DMATERIAL8 == D3DMATERIAL9 *****/ static HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONST WINED3DMATERIAL* pMaterial) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 3356a71ca81..841f03c4f21 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -520,9 +520,9 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface) if (This->set.material && memcmp(&targetStateBlock->material, &This->material, - sizeof(D3DMATERIAL9)) != 0) { + sizeof(WINED3DMATERIAL)) != 0) { TRACE("Updating material\n"); - memcpy(&This->material, &targetStateBlock->material, sizeof(D3DMATERIAL9)); + memcpy(&This->material, &targetStateBlock->material, sizeof(WINED3DMATERIAL)); } if (This->set.viewport && memcmp(&targetStateBlock->viewport, diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index a5811152909..7bd64c77da0 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -191,19 +191,16 @@ DEFINE_GUID(IID_IWineD3DQuery, /* TODO: remove the d3d8/d3d9 dependencies by making a all inclusive WINED3D version */ #if defined( __WINE_D3D9_H ) /* Identical: */ -# define WINED3DMATERIAL D3DMATERIAL9 # define WINED3DVIEWPORT D3DVIEWPORT9 # define WINED3DGAMMARAMP D3DGAMMARAMP #elif defined( __WINE_D3D8_H ) /* Identical: */ -# define WINED3DMATERIAL D3DMATERIAL8 # define WINED3DVIEWPORT D3DVIEWPORT8 # define WINED3DGAMMARAMP D3DGAMMARAMP #else /* defined (__WINE_D3D_H ) */ /* Identical: */ -# define WINED3DMATERIAL D3DMATERIAL7 # define WINED3DVIEWPORT D3DVIEWPORT7 # define WINED3DGAMMARAMP DDGAMMARAMP diff --git a/include/wine/wined3d_types.h b/include/wine/wined3d_types.h index 814075e3a1f..b1c3ae1e75d 100644 --- a/include/wine/wined3d_types.h +++ b/include/wine/wined3d_types.h @@ -68,6 +68,14 @@ typedef struct _WINED3DLIGHT { float Phi; } WINED3DLIGHT; +typedef struct _WINED3DMATERIAL { + WINED3DCOLORVALUE Diffuse; + WINED3DCOLORVALUE Ambient; + WINED3DCOLORVALUE Specular; + WINED3DCOLORVALUE Emissive; + float Power; +} WINED3DMATERIAL; + #define WINED3D_VSHADER_MAX_CONSTANTS 96 #define WINED3D_PSHADER_MAX_CONSTANTS 32