DXGL r199 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r198‎ | r199 | r200 >
Date:14:04, 5 July 2012
Author:admin
Status:new
Tags:
Comment:
Get D3D6 lights and materials somewhat working
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DLight.cpp (modified) (history)
  • /ddraw/glDirect3DLight.h (modified) (history)
  • /ddraw/glDirect3DMaterial.cpp (modified) (history)
  • /ddraw/glDirect3DMaterial.h (modified) (history)
  • /ddraw/glDirect3DViewport.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -1467,7 +1467,8 @@
14681468 default:
14691469 return DDERR_INVALIDPARAMS;
14701470 case D3DLIGHTSTATE_MATERIAL:
1471 - *lpdwLightState = (DWORD)currentmaterial;
 1471+ if(currentmaterial) *lpdwLightState = currentmaterial->handle;
 1472+ else *lpdwLightState = 0;
14721473 return D3D_OK;
14731474 case D3DLIGHTSTATE_AMBIENT:
14741475 return GetRenderState(D3DRENDERSTATE_AMBIENT,lpdwLightState);
@@ -1494,15 +1495,15 @@
14951496 default:
14961497 return DDERR_INVALIDPARAMS;
14971498 case D3DLIGHTSTATE_MATERIAL:
1498 - if(dwLightState == (DWORD)currentmaterial) return D3D_OK;
14991499 if(!dwLightState) return DDERR_INVALIDPARAMS;
1500 - for(int i = 0; i < materialcount; i++)
 1500+ if(dwLightState < materialcount)
15011501 {
1502 - if((DWORD)materials[i] == dwLightState)
 1502+ if(materials[dwLightState] == currentmaterial) return D3D_OK;
 1503+ if(materials[dwLightState])
15031504 {
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];
15071508 }
15081509 }
15091510 return D3D_OK;
Index: ddraw/glDirect3DLight.cpp
@@ -114,6 +114,7 @@
115115 if(lpLight->dwSize < sizeof(D3DLIGHT)) return DDERR_INVALIDPARAMS;
116116 light.dltType = lpLight->dltType;
117117 light.dcvDiffuse = lpLight->dcvColor;
 118+ light.dcvAmbient.r = light.dcvAmbient.g = light.dcvAmbient.b = light.dcvAmbient.a = 0;
118119 light.dvPosition = lpLight->dvPosition;
119120 light.dvDirection = lpLight->dvDirection;
120121 light.dvRange = lpLight->dvRange;
@@ -128,7 +129,7 @@
129130 else if(device) enablelight = true;
130131 if(enablelight)
131132 {
132 - if(((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_ACTIVE)
 133+ if((((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_ACTIVE) || lpLight->dwSize == sizeof(D3DLIGHT))
133134 {
134135 device->SetLight(index,&light);
135136 device->LightEnable(index,TRUE);
@@ -142,4 +143,11 @@
143144 {
144145 this->device = device;
145146 this->index = index;
 147+}
 148+
 149+void glDirect3DLight::Sync()
 150+{
 151+ if(!this) return;
 152+ device->SetLight(index,&light);
 153+ device->LightEnable(index,TRUE);
146154 }
\ No newline at end of file
Index: ddraw/glDirect3DLight.h
@@ -35,6 +35,7 @@
3636 HRESULT WINAPI SetLight(LPD3DLIGHT lpLight);
3737 void SetLight7(LPD3DLIGHT7 lpLight7);
3838 void SetDevice(glDirect3DDevice7 *device, int index);
 39+ void Sync();
3940 D3DLIGHT7 light;
4041 glDirect3DViewport3 *viewport;
4142 private:
Index: ddraw/glDirect3DMaterial.cpp
@@ -23,6 +23,7 @@
2424 glDirect3DMaterial3::glDirect3DMaterial3()
2525 {
2626 device = NULL;
 27+ current = FALSE;
2728 refcount = 1;
2829 material.dwSize = sizeof(D3DMATERIAL);
2930 const D3DCOLORVALUE defaultcolor = {1.0f,1.0f,1.0f,1.0f};
Index: ddraw/glDirect3DMaterial.h
@@ -34,11 +34,11 @@
3535 void SetCurrent(bool current);
3636 void unbind();
3737 D3DMATERIAL material;
 38+ D3DMATERIALHANDLE handle;
3839 private:
3940 ULONG refcount;
4041 bool current;
4142 glDirect3DDevice7 *device;
42 - D3DMATERIALHANDLE handle;
4343 };
4444
4545 #endif //__GLDIRECT3DMATERIAL_H
\ No newline at end of file
Index: ddraw/glDirect3DViewport.cpp
@@ -88,9 +88,12 @@
8989 {
9090 if(!lights[i])
9191 {
 92+ if(lights[i] == lpDirect3DLight) return D3D_OK;
9293 lights[i] = (glDirect3DLight*)lpDirect3DLight;
9394 lights[i]->AddRef();
9495 lights[i]->viewport = this;
 96+ if(device) lights[i]->SetDevice(device,i);
 97+ lights[i]->Sync();
9598 return D3D_OK;
9699 }
97100 }
Index: ddraw/glDirectDraw.cpp
@@ -987,7 +987,7 @@
988988 break;
989989 default:
990990 useguid = true;
991 - FIXME("Display GUIDs not yet supported, using primary.\n");
 991+ DEBUG("Display GUIDs not yet supported, using primary.\n");
992992 }
993993 directdraw_created = true;
994994 initialized = true;