Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -1467,7 +1467,8 @@ |
1468 | 1468 | default:
|
1469 | 1469 | return DDERR_INVALIDPARAMS;
|
1470 | 1470 | case D3DLIGHTSTATE_MATERIAL:
|
1471 | | - *lpdwLightState = (DWORD)currentmaterial;
|
| 1471 | + if(currentmaterial) *lpdwLightState = currentmaterial->handle;
|
| 1472 | + else *lpdwLightState = 0;
|
1472 | 1473 | return D3D_OK;
|
1473 | 1474 | case D3DLIGHTSTATE_AMBIENT:
|
1474 | 1475 | return GetRenderState(D3DRENDERSTATE_AMBIENT,lpdwLightState);
|
— | — | @@ -1494,15 +1495,15 @@ |
1495 | 1496 | default:
|
1496 | 1497 | return DDERR_INVALIDPARAMS;
|
1497 | 1498 | case D3DLIGHTSTATE_MATERIAL:
|
1498 | | - if(dwLightState == (DWORD)currentmaterial) return D3D_OK;
|
1499 | 1499 | if(!dwLightState) return DDERR_INVALIDPARAMS;
|
1500 | | - for(int i = 0; i < materialcount; i++)
|
| 1500 | + if(dwLightState < materialcount)
|
1501 | 1501 | {
|
1502 | | - if((DWORD)materials[i] == dwLightState)
|
| 1502 | + if(materials[dwLightState] == currentmaterial) return D3D_OK;
|
| 1503 | + if(materials[dwLightState])
|
1503 | 1504 | {
|
1504 | | - if(currentmaterial) currentmaterial->SetCurrent(false);
|
1505 | | - materials[i]->SetCurrent(true);
|
1506 | | - currentmaterial = materials[i];
|
| 1505 | + if(currentmaterial)currentmaterial->SetCurrent(false);
|
| 1506 | + materials[dwLightState]->SetCurrent(true);
|
| 1507 | + currentmaterial = materials[dwLightState];
|
1507 | 1508 | }
|
1508 | 1509 | }
|
1509 | 1510 | return D3D_OK;
|
Index: ddraw/glDirect3DLight.cpp |
— | — | @@ -114,6 +114,7 @@ |
115 | 115 | if(lpLight->dwSize < sizeof(D3DLIGHT)) return DDERR_INVALIDPARAMS;
|
116 | 116 | light.dltType = lpLight->dltType;
|
117 | 117 | light.dcvDiffuse = lpLight->dcvColor;
|
| 118 | + light.dcvAmbient.r = light.dcvAmbient.g = light.dcvAmbient.b = light.dcvAmbient.a = 0;
|
118 | 119 | light.dvPosition = lpLight->dvPosition;
|
119 | 120 | light.dvDirection = lpLight->dvDirection;
|
120 | 121 | light.dvRange = lpLight->dvRange;
|
— | — | @@ -128,7 +129,7 @@ |
129 | 130 | else if(device) enablelight = true;
|
130 | 131 | if(enablelight)
|
131 | 132 | {
|
132 | | - if(((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_ACTIVE)
|
| 133 | + if((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_ACTIVE) || lpLight->dwSize == sizeof(D3DLIGHT))
|
133 | 134 | {
|
134 | 135 | device->SetLight(index,&light);
|
135 | 136 | device->LightEnable(index,TRUE);
|
— | — | @@ -142,4 +143,11 @@ |
143 | 144 | {
|
144 | 145 | this->device = device;
|
145 | 146 | this->index = index;
|
| 147 | +}
|
| 148 | +
|
| 149 | +void glDirect3DLight::Sync()
|
| 150 | +{
|
| 151 | + if(!this) return;
|
| 152 | + device->SetLight(index,&light);
|
| 153 | + device->LightEnable(index,TRUE);
|
146 | 154 | } |
\ No newline at end of file |
Index: ddraw/glDirect3DLight.h |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | HRESULT WINAPI SetLight(LPD3DLIGHT lpLight);
|
37 | 37 | void SetLight7(LPD3DLIGHT7 lpLight7);
|
38 | 38 | void SetDevice(glDirect3DDevice7 *device, int index);
|
| 39 | + void Sync();
|
39 | 40 | D3DLIGHT7 light;
|
40 | 41 | glDirect3DViewport3 *viewport;
|
41 | 42 | private:
|
Index: ddraw/glDirect3DMaterial.cpp |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | glDirect3DMaterial3::glDirect3DMaterial3()
|
25 | 25 | {
|
26 | 26 | device = NULL;
|
| 27 | + current = FALSE;
|
27 | 28 | refcount = 1;
|
28 | 29 | material.dwSize = sizeof(D3DMATERIAL);
|
29 | 30 | const D3DCOLORVALUE defaultcolor = {1.0f,1.0f,1.0f,1.0f};
|
Index: ddraw/glDirect3DMaterial.h |
— | — | @@ -34,11 +34,11 @@ |
35 | 35 | void SetCurrent(bool current);
|
36 | 36 | void unbind();
|
37 | 37 | D3DMATERIAL material;
|
| 38 | + D3DMATERIALHANDLE handle;
|
38 | 39 | private:
|
39 | 40 | ULONG refcount;
|
40 | 41 | bool current;
|
41 | 42 | glDirect3DDevice7 *device;
|
42 | | - D3DMATERIALHANDLE handle;
|
43 | 43 | };
|
44 | 44 |
|
45 | 45 | #endif //__GLDIRECT3DMATERIAL_H |
\ No newline at end of file |
Index: ddraw/glDirect3DViewport.cpp |
— | — | @@ -88,9 +88,12 @@ |
89 | 89 | {
|
90 | 90 | if(!lights[i])
|
91 | 91 | {
|
| 92 | + if(lights[i] == lpDirect3DLight) return D3D_OK;
|
92 | 93 | lights[i] = (glDirect3DLight*)lpDirect3DLight;
|
93 | 94 | lights[i]->AddRef();
|
94 | 95 | lights[i]->viewport = this;
|
| 96 | + if(device) lights[i]->SetDevice(device,i);
|
| 97 | + lights[i]->Sync();
|
95 | 98 | return D3D_OK;
|
96 | 99 | }
|
97 | 100 | }
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -987,7 +987,7 @@ |
988 | 988 | break;
|
989 | 989 | default:
|
990 | 990 | useguid = true;
|
991 | | - FIXME("Display GUIDs not yet supported, using primary.\n");
|
| 991 | + DEBUG("Display GUIDs not yet supported, using primary.\n");
|
992 | 992 | }
|
993 | 993 | directdraw_created = true;
|
994 | 994 | initialized = true;
|