wined3d: Fix missing light recording.

Write a light with the default parameters in disabled state if
capturing a missing light.
This commit is contained in:
Ivan Gyurdiev 2006-06-06 23:37:05 -04:00 committed by Alexandre Julliard
parent 5bb0eebc95
commit 4d66615bbb
3 changed files with 35 additions and 45 deletions

View File

@ -32,6 +32,22 @@
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_SetLightEnable(IWineD3DDevice *iface, DWORD In
/* 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;

View File

@ -213,24 +213,23 @@ HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface){
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) {
/* 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 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) {
TRACE("Updating lightEnabled for light %ld\n", src->OriginalIndex);
src->lightEnabled = realLight->lightEnabled;
}
/* 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;

View File

@ -393,6 +393,9 @@ struct PLIGHTINFOEL {
PLIGHTINFOEL *prev;
};
/* The default light parameters */
extern const WINED3DLIGHT WINED3D_default_light;
/*****************************************************************************
* IWineD3D implementation structure
*/