Module: wine Branch: refs/heads/master Commit: 4d66615bbb94ebb05802acd3e521ca543b487585 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=4d66615bbb94ebb05802acd3...
Author: Ivan Gyurdiev ivg2@cornell.edu Date: Tue Jun 6 23:37:05 2006 -0400
wined3d: Fix missing light recording.
Write a light with the default parameters in disabled state if capturing a missing light.
---
dlls/wined3d/device.c | 48 +++++++++++++++------------------------- dlls/wined3d/stateblock.c | 31 +++++++++++++------------- dlls/wined3d/wined3d_private.h | 3 +++ 3 files changed, 36 insertions(+), 46 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 27c9dc9..13d497c 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -32,6 +32,22 @@ #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d); #define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
+/* 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 */ +}; + /* x11drv GDI escapes */ #define X11DRV_ESCAPE 6789 enum x11drv_escape_codes @@ -2515,37 +2531,9 @@ HRESULT WINAPI IWineD3DDeviceImpl_SetLig
/* Special case - enabling an undefined light creates one with a strict set of parms! */ if (lightInfo == NULL) { - D3DLIGHT9 lightParms; - /* Warning - untested code :-) Prob safe to change fixme to a trace but - wait until someone confirms it seems to work! */ + TRACE("Light enabled requested but light not defined, so defining one!\n"); - lightParms.Type = D3DLIGHT_DIRECTIONAL; - lightParms.Diffuse.r = 1.0; - lightParms.Diffuse.g = 1.0; - lightParms.Diffuse.b = 1.0; - lightParms.Diffuse.a = 0.0; - lightParms.Specular.r = 0.0; - lightParms.Specular.g = 0.0; - lightParms.Specular.b = 0.0; - lightParms.Specular.a = 0.0; - lightParms.Ambient.r = 0.0; - lightParms.Ambient.g = 0.0; - lightParms.Ambient.b = 0.0; - lightParms.Ambient.a = 0.0; - lightParms.Position.x = 0.0; - lightParms.Position.y = 0.0; - lightParms.Position.z = 0.0; - lightParms.Direction.x = 0.0; - lightParms.Direction.y = 0.0; - lightParms.Direction.z = 1.0; - lightParms.Range = 0.0; - lightParms.Falloff = 0.0; - lightParms.Attenuation0 = 0.0; - lightParms.Attenuation1 = 0.0; - lightParms.Attenuation2 = 0.0; - lightParms.Theta = 0.0; - lightParms.Phi = 0.0; - IWineD3DDeviceImpl_SetLight(iface, Index, &lightParms); + IWineD3DDeviceImpl_SetLight(iface, Index, &WINED3D_default_light);
/* Search for it again! Should be fairly quick as near head of list */ lightInfo = This->stateBlock->lights; diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index c694f44..752773b 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -213,24 +213,23 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Ca realLight = targetStateBlock->lights; while (realLight != NULL && realLight->OriginalIndex != src->OriginalIndex) realLight = realLight->next;
- if (realLight == NULL) { - FIXME("A captured light no longer exists...?\n"); - } else { - - /* If 'changed' then its a SetLight command. Rather than comparing to see - if the OriginalParms have changed and then copy them (twice through - memory) just do the copy */ - if (src->changed) { - TRACE("Updating lights for light %ld\n", src->OriginalIndex); - memcpy(&src->OriginalParms, &realLight->OriginalParms, sizeof(src->OriginalParms)); - } + /* If 'changed' then its a SetLight command. Rather than comparing to see + if the OriginalParms have changed and then copy them (twice through + memory) just do the copy */ + if (src->changed) {
- /* If 'enabledchanged' then its a LightEnable command */ - if (src->enabledChanged) { - TRACE("Updating lightEnabled for light %ld\n", src->OriginalIndex); - src->lightEnabled = realLight->lightEnabled; - } + /* If the light exists, copy its parameters, otherwise copy the default parameters */ + const WINED3DLIGHT* params = realLight? &realLight->OriginalParms: &WINED3D_default_light; + TRACE("Updating lights for light %ld\n", src->OriginalIndex); + memcpy(&src->OriginalParms, params, sizeof(*params)); + } + + /* If 'enabledchanged' then its a LightEnable command */ + if (src->enabledChanged) {
+ /* If the light exists, check if it's enabled, otherwise default is disabled state */ + TRACE("Updating lightEnabled for light %ld\n", src->OriginalIndex); + src->lightEnabled = realLight? realLight->lightEnabled: FALSE; }
src = src->next; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d9c7406..3a42228 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -393,6 +393,9 @@ struct PLIGHTINFOEL { PLIGHTINFOEL *prev; };
+/* The default light parameters */ +extern const WINED3DLIGHT WINED3D_default_light; + /***************************************************************************** * IWineD3D implementation structure */