Commit b65e790b authored by Antoine Chavasse's avatar Antoine Chavasse Committed by Alexandre Julliard

Rewrote the light management API to allow for an unlimited amount of

lights to be set, and only a subset of them to be enabled.
parent 20806c73
......@@ -225,8 +225,10 @@ struct IDirect3DDeviceImpl
DWORD material;
/* Light parameters */
DWORD active_lights, set_lights;
D3DLIGHT7 light_parameters[MAX_LIGHTS];
DWORD num_set_lights;
DWORD max_active_lights;
LPD3DLIGHT7 light_parameters;
DWORD *active_lights;
/* clipping planes */
DWORD max_clipping_planes;
......
......@@ -642,9 +642,17 @@ Main_IDirect3DDeviceImpl_7_GetLight(LPDIRECT3DDEVICE7 iface,
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwLightIndex, lpLight);
if (dwLightIndex > MAX_LIGHTS) return DDERR_INVALIDPARAMS;
if (dwLightIndex >= This->num_set_lights)
return DDERR_INVALIDPARAMS;
*lpLight = This->light_parameters[dwLightIndex];
/* If dltType is zero, then this light has never been set, either
by calling SetLight or implicitely by calling EnableLight without
calling SetLight first. */
if (lpLight->dltType == 0)
return DDERR_INVALIDPARAMS;
if (TRACE_ON(ddraw)) {
TRACE(" returning light : \n");
dump_D3DLIGHT7(lpLight);
......@@ -950,12 +958,25 @@ Main_IDirect3DDeviceImpl_7_GetLightEnable(LPDIRECT3DDEVICE7 iface,
DWORD dwLightIndex,
BOOL* pbEnable)
{
int i;
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
TRACE("(%p/%p)->(%08lx,%p)\n", This, iface, dwLightIndex, pbEnable);
if (dwLightIndex > MAX_LIGHTS) *pbEnable = 0;
else *pbEnable = ((0x00000001 << dwLightIndex) & This->active_lights) != 0;
*pbEnable = 0;
if (dwLightIndex >= This->num_set_lights)
return DDERR_INVALIDPARAMS;
/* If dltType is zero, then this light has never been set, either
by calling SetLight or implicitely by calling EnableLight without
calling SetLight first. */
if (This->light_parameters[dwLightIndex].dltType == 0)
return DDERR_INVALIDPARAMS;
for (i = 0; i < This->max_active_lights; i++)
if (This->active_lights[i] == dwLightIndex)
*pbEnable = TRUE;
TRACE(" returning %d.\n", *pbEnable);
return DD_OK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment