From 70bbf734b1f971a65fc13443b02dd4fd05a6c5e1 Mon Sep 17 00:00:00 2001 From: Ivan Gyurdiev Date: Tue, 10 Oct 2006 21:55:47 -0400 Subject: [PATCH] wined3d: Merge LIGHT types into one type in WINED3D namespace. --- dlls/d3d8/device.c | 6 +++-- dlls/d3d9/device.c | 4 +++ dlls/ddraw/device.c | 7 ++++-- dlls/wined3d/device.c | 43 ++++++++++++++++---------------- include/wine/wined3d_interface.h | 3 --- include/wine/wined3d_types.h | 38 ++++++++++++++++++++++++++++ 6 files changed, 72 insertions(+), 29 deletions(-) diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 14678307714..5d841fa2b9e 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -724,14 +724,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetMaterial(LPDIRECT3DDEVICE8 iface, static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(LPDIRECT3DDEVICE8 iface, DWORD Index, CONST D3DLIGHT8* pLight) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; TRACE("(%p) Relay\n" , This); -/* FIXME: Verify that D3DLIGHT8 ~= WINED3DLIGHT */ + + /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */ return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight); } static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(LPDIRECT3DDEVICE8 iface, DWORD Index,D3DLIGHT8* pLight) { IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; TRACE("(%p) Relay\n" , This); -/* FIXME: Verify that D3DLIGHT8 ~= WINED3DLIGHT */ + + /* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */ return IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight); } diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 4ccdabb311a..316d762bd16 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -504,12 +504,16 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9 iface static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, CONST D3DLIGHT9* pLight) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); + + /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */ return IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight); } static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9 iface, DWORD Index, D3DLIGHT9* pLight) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; TRACE("(%p) Relay\n" , This); + + /* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */ return IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight); } diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index a051684e0d3..836168c672b 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -4154,9 +4154,11 @@ IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface, HRESULT hr; TRACE("(%p)->(%08x,%p): Relay!\n", This, LightIndex, Light); + /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */ hr = IWineD3DDevice_SetLight(This->wineD3DDevice, LightIndex, - Light); + (WINED3DLIGHT*) Light); + return hr_ddraw_from_wined3d(hr); } @@ -4183,9 +4185,10 @@ IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface, HRESULT rc; TRACE("(%p)->(%08x,%p): Relay!\n", This, LightIndex, Light); + /* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */ rc = IWineD3DDevice_GetLight(This->wineD3DDevice, LightIndex, - Light); + (WINED3DLIGHT*) Light); /* Translate the result. WineD3D returns other values than D3D7 */ return hr_ddraw_from_wined3d(rc); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index fbe22dc6b3f..40c0d83417a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -38,17 +38,17 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_shader); /* Define the default light parameters as specified by MSDN */ const WINED3DLIGHT WINED3D_default_light = { - D3DLIGHT_DIRECTIONAL, /* Type */ - { 1.0, 1.0, 1.0, 0.0 }, /* Diffuse r,g,b,a */ - { 0.0, 0.0, 0.0, 0.0 }, /* Specular r,g,b,a */ - { 0.0, 0.0, 0.0, 0.0 }, /* Ambient r,g,b,a, */ - { 0.0, 0.0, 0.0 }, /* Position x,y,z */ - { 0.0, 0.0, 1.0 }, /* Direction x,y,z */ - 0.0, /* Range */ - 0.0, /* Falloff */ - 0.0, 0.0, 0.0, /* Attenuation 0,1,2 */ - 0.0, /* Theta */ - 0.0 /* Phi */ + WINED3DLIGHT_DIRECTIONAL, /* Type */ + { 1.0, 1.0, 1.0, 0.0 }, /* Diffuse r,g,b,a */ + { 0.0, 0.0, 0.0, 0.0 }, /* Specular r,g,b,a */ + { 0.0, 0.0, 0.0, 0.0 }, /* Ambient r,g,b,a, */ + { 0.0, 0.0, 0.0 }, /* Position x,y,z */ + { 0.0, 0.0, 1.0 }, /* Direction x,y,z */ + 0.0, /* Range */ + 0.0, /* Falloff */ + 0.0, 0.0, 0.0, /* Attenuation 0,1,2 */ + 0.0, /* Theta */ + 0.0 /* Phi */ }; /* x11drv GDI escapes */ @@ -154,7 +154,7 @@ const float identity[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1}; /* When needed /********************************************************** * Utility functions follow **********************************************************/ -/* Convert the D3DLIGHT properties into equivalent gl lights */ +/* Convert the WINED3DLIGHT properties into equivalent gl lights */ static void setup_light(IWineD3DDevice *iface, LONG Index, PLIGHTINFOEL *lightInfo) { float quad_att; @@ -207,7 +207,7 @@ static void setup_light(IWineD3DDevice *iface, LONG Index, PLIGHTINFOEL *lightIn checkGLcall("glLightf"); switch (lightInfo->OriginalParms.Type) { - case D3DLIGHT_POINT: + case WINED3DLIGHT_POINT: /* Position */ glLightfv(GL_LIGHT0+Index, GL_POSITION, &lightInfo->lightPosn[0]); checkGLcall("glLightfv"); @@ -216,7 +216,7 @@ static void setup_light(IWineD3DDevice *iface, LONG Index, PLIGHTINFOEL *lightIn /* FIXME: Range */ break; - case D3DLIGHT_SPOT: + case WINED3DLIGHT_SPOT: /* Position */ glLightfv(GL_LIGHT0+Index, GL_POSITION, &lightInfo->lightPosn[0]); checkGLcall("glLightfv"); @@ -230,7 +230,7 @@ static void setup_light(IWineD3DDevice *iface, LONG Index, PLIGHTINFOEL *lightIn /* FIXME: Range */ break; - case D3DLIGHT_DIRECTIONAL: + case WINED3DLIGHT_DIRECTIONAL: /* Direction */ glLightfv(GL_LIGHT0+Index, GL_POSITION, &lightInfo->lightPosn[0]); /* Note gl uses w position of 0 for direction! */ checkGLcall("glLightfv"); @@ -2644,7 +2644,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface /***** * Get / Set Light - * WARNING: This code relies on the fact that D3DLIGHT8 == D3DLIGHT9 *****/ /* Note lights are real special cases. Although the device caps state only eg. 8 are supported, you can reference any indexes you want as long as that number max are enabled at any @@ -2665,7 +2664,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I if (NULL == object) { return WINED3DERR_OUTOFVIDEOMEMORY; } - memcpy(&object->OriginalParms, pLight, sizeof(D3DLIGHT9)); + memcpy(&object->OriginalParms, pLight, sizeof(WINED3DLIGHT)); object->OriginalIndex = Index; object->glIndex = -1; object->changed = TRUE; @@ -2733,10 +2732,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n", pLight->Range, pLight->Falloff, pLight->Theta, pLight->Phi); /* Save away the information */ - memcpy(&object->OriginalParms, pLight, sizeof(D3DLIGHT9)); + memcpy(&object->OriginalParms, pLight, sizeof(WINED3DLIGHT)); switch (pLight->Type) { - case D3DLIGHT_POINT: + case WINED3DLIGHT_POINT: /* Position */ object->lightPosn[0] = pLight->Position.x; object->lightPosn[1] = pLight->Position.y; @@ -2746,7 +2745,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I /* FIXME: Range */ break; - case D3DLIGHT_DIRECTIONAL: + case WINED3DLIGHT_DIRECTIONAL: /* Direction */ object->lightPosn[0] = -pLight->Direction.x; object->lightPosn[1] = -pLight->Direction.y; @@ -2756,7 +2755,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD I object->cutoff = 180.0f; break; - case D3DLIGHT_SPOT: + case WINED3DLIGHT_SPOT: /* Position */ object->lightPosn[0] = pLight->Position.x; object->lightPosn[1] = pLight->Position.y; @@ -2816,7 +2815,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD I return WINED3DERR_INVALIDCALL; } - memcpy(pLight, &lightInfo->OriginalParms, sizeof(D3DLIGHT9)); + memcpy(pLight, &lightInfo->OriginalParms, sizeof(WINED3DLIGHT)); return WINED3D_OK; } diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index 516e637ba5c..a5811152909 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -191,21 +191,18 @@ DEFINE_GUID(IID_IWineD3DQuery, /* TODO: remove the d3d8/d3d9 dependencies by making a all inclusive WINED3D version */ #if defined( __WINE_D3D9_H ) /* Identical: */ -# define WINED3DLIGHT D3DLIGHT9 # define WINED3DMATERIAL D3DMATERIAL9 # define WINED3DVIEWPORT D3DVIEWPORT9 # define WINED3DGAMMARAMP D3DGAMMARAMP #elif defined( __WINE_D3D8_H ) /* Identical: */ -# define WINED3DLIGHT D3DLIGHT8 # define WINED3DMATERIAL D3DMATERIAL8 # define WINED3DVIEWPORT D3DVIEWPORT8 # define WINED3DGAMMARAMP D3DGAMMARAMP #else /* defined (__WINE_D3D_H ) */ /* Identical: */ -# define WINED3DLIGHT D3DLIGHT7 # define WINED3DMATERIAL D3DMATERIAL7 # define WINED3DVIEWPORT D3DVIEWPORT7 # define WINED3DGAMMARAMP DDGAMMARAMP diff --git a/include/wine/wined3d_types.h b/include/wine/wined3d_types.h index bfcd4edddc5..814075e3a1f 100644 --- a/include/wine/wined3d_types.h +++ b/include/wine/wined3d_types.h @@ -30,6 +30,44 @@ # error You must include d3d.h, d3d8.h or d3d9.h header to use this header #endif +typedef enum _WINED3DLIGHTTYPE { + WINED3DLIGHT_POINT = 1, + WINED3DLIGHT_SPOT = 2, + WINED3DLIGHT_DIRECTIONAL = 3, + WINED3DLIGHT_PARALLELPOINT = 4, /* D3D7 */ + WINED3DLIGHT_GLSPOT = 5, /* D3D7 */ + WINED3DLIGHT_FORCE_DWORD = 0x7fffffff +} WINED3DLIGHTTYPE; + +typedef struct _WINED3DCOLORVALUE { + float r; + float g; + float b; + float a; +} WINED3DCOLORVALUE; + +typedef struct _WINED3DVECTOR { + float x; + float y; + float z; +} WINED3DVECTOR; + +typedef struct _WINED3DLIGHT { + WINED3DLIGHTTYPE Type; + WINED3DCOLORVALUE Diffuse; + WINED3DCOLORVALUE Specular; + WINED3DCOLORVALUE Ambient; + WINED3DVECTOR Position; + WINED3DVECTOR Direction; + float Range; + float Falloff; + float Attenuation0; + float Attenuation1; + float Attenuation2; + float Theta; + float Phi; +} WINED3DLIGHT; + #define WINED3D_VSHADER_MAX_CONSTANTS 96 #define WINED3D_PSHADER_MAX_CONSTANTS 32