Index: ddraw/glDirect3DLight.cpp |
— | — | @@ -16,6 +16,8 @@ |
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
19 | 19 | #include "common.h"
|
| 20 | +#include "glRenderer.h"
|
| 21 | +#include "glDirect3DDevice.h"
|
20 | 22 | #include "glDirect3DViewport.h"
|
21 | 23 | #include "glDirect3DLight.h"
|
22 | 24 | #define _USE_MATH_DEFINES
|
— | — | @@ -27,6 +29,7 @@ |
28 | 30 | {
|
29 | 31 | refcount=1;
|
30 | 32 | viewport = NULL;
|
| 33 | + device = NULL;
|
31 | 34 | ZeroMemory(&light,sizeof(D3DLIGHT7));
|
32 | 35 | light.dltType = D3DLIGHT_DIRECTIONAL;
|
33 | 36 | light.dcvAmbient.r = light.dcvAmbient.g = light.dcvAmbient.b = 1.0f;
|
— | — | @@ -89,12 +92,54 @@ |
90 | 93 | HRESULT WINAPI glDirect3DLight::GetLight(LPD3DLIGHT lpLight)
|
91 | 94 | {
|
92 | 95 | if(!this) return DDERR_INVALIDPARAMS;
|
93 | | - FIXME("glDirect3DLight::GetLight: stub");
|
94 | | - ERR(DDERR_GENERIC);
|
| 96 | + if(!lpLight) return DDERR_INVALIDPARAMS;
|
| 97 | + if(lpLight->dwSize < sizeof(D3DLIGHT)) return DDERR_INVALIDPARAMS;
|
| 98 | + lpLight->dltType = light.dltType;
|
| 99 | + lpLight->dcvColor = light.dcvDiffuse;
|
| 100 | + lpLight->dvPosition = light.dvPosition;
|
| 101 | + lpLight->dvDirection = light.dvDirection;
|
| 102 | + lpLight->dvRange = light.dvRange;
|
| 103 | + lpLight->dvFalloff = light.dvFalloff;
|
| 104 | + lpLight->dvAttenuation0 = light.dvAttenuation0;
|
| 105 | + lpLight->dvAttenuation1 = light.dvAttenuation1;
|
| 106 | + lpLight->dvAttenuation2 = light.dvAttenuation2;
|
| 107 | + lpLight->dvTheta = light.dvTheta;
|
| 108 | + lpLight->dvPhi = light.dvPhi;
|
| 109 | + return D3D_OK;
|
95 | 110 | }
|
96 | 111 | HRESULT WINAPI glDirect3DLight::SetLight(LPD3DLIGHT lpLight)
|
97 | 112 | {
|
98 | 113 | if(!this) return DDERR_INVALIDPARAMS;
|
99 | | - FIXME("glDirect3DLight::SetLight: stub");
|
100 | | - ERR(DDERR_GENERIC);
|
| 114 | + if(!lpLight) return DDERR_INVALIDPARAMS;
|
| 115 | + if(lpLight->dwSize < sizeof(D3DLIGHT)) return DDERR_INVALIDPARAMS;
|
| 116 | + light.dltType = lpLight->dltType;
|
| 117 | + light.dcvDiffuse = lpLight->dcvColor;
|
| 118 | + light.dvPosition = lpLight->dvPosition;
|
| 119 | + light.dvDirection = lpLight->dvDirection;
|
| 120 | + light.dvRange = lpLight->dvRange;
|
| 121 | + light.dvFalloff = lpLight->dvFalloff;
|
| 122 | + light.dvAttenuation0 = lpLight->dvAttenuation0;
|
| 123 | + light.dvAttenuation1 = lpLight->dvAttenuation1;
|
| 124 | + light.dvAttenuation2 = lpLight->dvAttenuation2;
|
| 125 | + light.dvTheta = lpLight->dvTheta;
|
| 126 | + light.dvPhi = lpLight->dvPhi;
|
| 127 | + bool enablelight = false;
|
| 128 | + if(device && (lpLight->dwSize >= sizeof(D3DLIGHT2))) enablelight = true;
|
| 129 | + else if(device) enablelight = true;
|
| 130 | + if(enablelight)
|
| 131 | + {
|
| 132 | + if(((LPD3DLIGHT2)lpLight)->dwFlags & D3DLIGHT_ACTIVE)
|
| 133 | + {
|
| 134 | + device->SetLight(index,&light);
|
| 135 | + device->LightEnable(index,TRUE);
|
| 136 | + }
|
| 137 | + else device->LightEnable(index,FALSE);
|
| 138 | + }
|
| 139 | + return D3D_OK;
|
| 140 | +}
|
| 141 | +
|
| 142 | +void glDirect3DLight::SetDevice(glDirect3DDevice7 *device, int index)
|
| 143 | +{
|
| 144 | + this->device = device;
|
| 145 | + this->index = index;
|
101 | 146 | } |
\ No newline at end of file |
Index: ddraw/glDirect3DLight.h |
— | — | @@ -34,11 +34,14 @@ |
35 | 35 | HRESULT WINAPI Initialize(LPDIRECT3D lpDirect3D);
|
36 | 36 | HRESULT WINAPI SetLight(LPD3DLIGHT lpLight);
|
37 | 37 | void SetLight7(LPD3DLIGHT7 lpLight7);
|
| 38 | + void SetDevice(glDirect3DDevice7 *device, int index);
|
38 | 39 | D3DLIGHT7 light;
|
39 | 40 | glDirect3DViewport3 *viewport;
|
40 | 41 | private:
|
41 | 42 | ULONG refcount;
|
42 | 43 | D3DLIGHT2 convert;
|
| 44 | + glDirect3DDevice7 *device;
|
| 45 | + int index;
|
43 | 46 | };
|
44 | 47 |
|
45 | 48 | #endif //__GLDIRECT3DLIGHT_H |
\ No newline at end of file |
Index: ddraw/glDirect3DViewport.cpp |
— | — | @@ -122,6 +122,7 @@ |
123 | 123 | if(lights[i] == lpDirect3DLight)
|
124 | 124 | {
|
125 | 125 | lights[i]->Release();
|
| 126 | + lights[i]->SetDevice(NULL,0);
|
126 | 127 | lights[i] = NULL;
|
127 | 128 | return D3D_OK;
|
128 | 129 | }
|
— | — | @@ -266,7 +267,11 @@ |
267 | 268 | {
|
268 | 269 | if(this->current && current) return;
|
269 | 270 | this->current = current;
|
270 | | - if(current && device) Sync();
|
| 271 | + if(current && device)
|
| 272 | + {
|
| 273 | + Sync();
|
| 274 | + SyncLights();
|
| 275 | + }
|
271 | 276 | }
|
272 | 277 |
|
273 | 278 | void glDirect3DViewport3::Sync()
|
— | — | @@ -279,4 +284,20 @@ |
280 | 285 | vp7.dvMinZ = viewport.dvMinZ;
|
281 | 286 | vp7.dvMaxZ = viewport.dvMaxZ;
|
282 | 287 | device->SetViewport(&vp7);
|
| 288 | +}
|
| 289 | +
|
| 290 | +void glDirect3DViewport3::SyncLights()
|
| 291 | +{
|
| 292 | + D3DLIGHT7 light;
|
| 293 | + for(int i = 0; i < 8; i++)
|
| 294 | + {
|
| 295 | + if(lights[i])
|
| 296 | + {
|
| 297 | + lights[i]->SetDevice(device,i);
|
| 298 | + lights[i]->GetLight7(&light);
|
| 299 | + device->SetLight(i,&light);
|
| 300 | + device->LightEnable(i,TRUE);
|
| 301 | + }
|
| 302 | + else device->LightEnable(i,FALSE);
|
| 303 | + }
|
283 | 304 | } |
\ No newline at end of file |
Index: ddraw/glDirect3DViewport.h |
— | — | @@ -51,6 +51,7 @@ |
52 | 52 | void SetCurrent(bool current);
|
53 | 53 | void SetDevice(glDirect3DDevice7 *device){this->device = device;};
|
54 | 54 | void Sync();
|
| 55 | + void SyncLights();
|
55 | 56 | private:
|
56 | 57 | ULONG refcount;
|
57 | 58 | glDirect3DLight *lights[8];
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | dds2 = NULL;
|
55 | 55 | dds3 = NULL;
|
56 | 56 | dds4 = NULL;
|
| 57 | + d3dt2 = NULL;
|
57 | 58 | buffer = gdibuffer = NULL;
|
58 | 59 | bigbuffer = NULL;
|
59 | 60 | zbuffer = NULL;
|