[WINED3D 1] Fix light state bugs
Ivan Gyurdiev
ivg231 at gmail.com
Thu Jul 13 19:17:55 CDT 2006
Fix bugs exposed by light states test for d3d9 [see patch 3]
Bug: Store lightEnabled status into the stateblock in recording mode.
Otherwise the lightEnabled change is always replayed as FALSE when the
stateblock is applied.
Bug: Use status 128 as Enabled, instead of 1.The spec says any nonzero
value will do, but testing shows this one in particular is used.
-------------- next part --------------
---
dlls/wined3d/device.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 082f92b..630d6d4 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2832,6 +2832,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : Idx(%ld), enable? %d\n", This, Index, Enable);
+ /* Tests show true = 128...not clear why */
+
+ Enable = Enable? 128: 0;
+
/* If recording state block, just add to end of lights chain with changedEnable set to true */
if (This->isRecordingState) {
lightInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PLIGHTINFOEL));
@@ -2841,6 +2845,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
lightInfo->OriginalIndex = Index;
lightInfo->glIndex = -1;
lightInfo->enabledChanged = TRUE;
+ lightInfo->lightEnabled = Enable;
/* Add to the END of the chain of lights changes to be replayed */
if (This->updateStateBlock->lights == NULL) {
@@ -2887,7 +2892,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
} else {
TRACE("Nothing to do as light was not enabled\n");
}
- lightInfo->lightEnabled = FALSE;
+ lightInfo->lightEnabled = Enable;
} else {
/* We are enabling it. If it is enabled, it's really simple */
@@ -2898,7 +2903,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
/* If it already has a glIndex, it's still simple */
} else if (lightInfo->glIndex != -1) {
TRACE("Reusing light as already set up at gl idx %ld\n", lightInfo->glIndex);
- lightInfo->lightEnabled = TRUE;
+ lightInfo->lightEnabled = Enable;
ENTER_GL();
glEnable(GL_LIGHT0 + lightInfo->glIndex);
checkGLcall("glEnable GL_LIGHT0+Index already setup");
@@ -2969,7 +2974,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
glIndex = bsf->glIndex;
bsf->glIndex = -1;
lightInfo->glIndex = glIndex;
- lightInfo->lightEnabled = TRUE;
+ lightInfo->lightEnabled = Enable;
/* Finally set up the light in gl itself */
TRACE("Replacing light which was set up at gl idx %ld\n", lightInfo->glIndex);
@@ -2987,7 +2992,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
know the index of the next one! */
glIndex = Index;
lightInfo->glIndex = glIndex;
- lightInfo->lightEnabled = TRUE;
+ lightInfo->lightEnabled = Enable;
/* In an ideal world, it's already in the right place */
if (lightInfo->prev == NULL || lightInfo->prev->glIndex!=-1) {
--
1.4.0
More information about the wine-patches
mailing list