WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
+/*****************************************************************************
+ * light_update
+ *
+ * Updates the Direct3DDevice7 lighting parameters
+ *
+ *****************************************************************************/
+static void light_update(IDirect3DLightImpl *light)
+{
+ IDirect3DDeviceImpl *device;
+
+ TRACE("light %p.\n", light);
+
+ if (!light->active_viewport || !light->active_viewport->active_device) return;
+ device = light->active_viewport->active_device;
+
+ IDirect3DDevice7_SetLight((IDirect3DDevice7 *)device, light->dwLightIndex, &light->light7);
+}
+
+/*****************************************************************************
+ * light_activate
+ *
+ * Uses the Direct3DDevice7::LightEnable method to active the light
+ *
+ *****************************************************************************/
+void light_activate(IDirect3DLightImpl *light)
+{
+ IDirect3DDeviceImpl *device;
+
+ TRACE("light %p.\n", light);
+
+ if (!light->active_viewport || !light->active_viewport->active_device) return;
+ device = light->active_viewport->active_device;
+
+ light_update(light);
+ if (!(light->light.dwFlags & D3DLIGHT_ACTIVE))
+ {
+ IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, light->dwLightIndex, TRUE);
+ light->light.dwFlags |= D3DLIGHT_ACTIVE;
+ }
+}
+
+/*****************************************************************************
+ *
+ * light_deactivate
+ *
+ * Uses the Direct3DDevice7::LightEnable method to deactivate the light
+ *
+ *****************************************************************************/
+void light_deactivate(IDirect3DLightImpl *light)
+{
+ IDirect3DDeviceImpl *device;
+
+ TRACE("light %p.\n", light);
+
+ if (!light->active_viewport || !light->active_viewport->active_device) return;
+ device = light->active_viewport->active_device;
+
+ /* If was not active, activate it */
+ if (light->light.dwFlags & D3DLIGHT_ACTIVE)
+ {
+ IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, light->dwLightIndex, FALSE);
+ light->light.dwFlags &= ~D3DLIGHT_ACTIVE;
+ }
+}
+
/*****************************************************************************
* IUnknown Methods.
*****************************************************************************/
EnterCriticalSection(&ddraw_cs);
memcpy(&This->light, lpLight, lpLight->dwSize);
- if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
- This->update(This);
- }
+ if (This->light.dwFlags & D3DLIGHT_ACTIVE)
+ light_update(This);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
return DD_OK;
}
-/*****************************************************************************
- * light_update
- *
- * Updates the Direct3DDevice7 lighting parameters
- *
- *****************************************************************************/
-void light_update(IDirect3DLightImpl* This)
-{
- IDirect3DDeviceImpl* device;
-
- TRACE("(%p)\n", This);
-
- if (!This->active_viewport || !This->active_viewport->active_device)
- return;
- device = This->active_viewport->active_device;
-
- IDirect3DDevice7_SetLight((IDirect3DDevice7 *)device, This->dwLightIndex, &(This->light7));
-}
-
-/*****************************************************************************
- * light_activate
- *
- * Uses the Direct3DDevice7::LightEnable method to active the light
- *
- *****************************************************************************/
-void light_activate(IDirect3DLightImpl* This)
-{
- IDirect3DDeviceImpl* device;
-
- TRACE("(%p)\n", This);
-
- if (!This->active_viewport || !This->active_viewport->active_device)
- return;
- device = This->active_viewport->active_device;
-
- light_update(This);
- /* If was not active, activate it */
- if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) {
- IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, This->dwLightIndex, TRUE);
- This->light.dwFlags |= D3DLIGHT_ACTIVE;
- }
-}
-
-/*****************************************************************************
- *
- * light_desactivate
- *
- * Uses the Direct3DDevice7::LightEnable method to deactivate the light
- *
- *****************************************************************************/
-void light_desactivate(IDirect3DLightImpl* This)
-{
- IDirect3DDeviceImpl* device;
-
- TRACE("(%p)\n", This);
-
- if (!This->active_viewport || !This->active_viewport->active_device)
- return;
- device = This->active_viewport->active_device;
-
- /* If was not active, activate it */
- if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
- IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, This->dwLightIndex, FALSE);
- This->light.dwFlags &= ~D3DLIGHT_ACTIVE;
- }
-}
-
const IDirect3DLightVtbl IDirect3DLight_Vtbl =
{
/*** IUnknown Methods ***/
/* Activate all the lights associated with this context */
light = This->lights;
- while (light != NULL) {
- light->activate(light);
+ while (light)
+ {
+ light_activate(light);
light = light->next;
}
}
lpDirect3DLightImpl->active_viewport = This;
/* If active, activate the light */
- if (This->active_device != NULL) {
- lpDirect3DLightImpl->activate(lpDirect3DLightImpl);
- }
+ if (This->active_device)
+ light_activate(lpDirect3DLightImpl);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
EnterCriticalSection(&ddraw_cs);
cur_light = This->lights;
while (cur_light != NULL) {
- if (cur_light == lpDirect3DLightImpl) {
- lpDirect3DLightImpl->desactivate(lpDirect3DLightImpl);
+ if (cur_light == lpDirect3DLightImpl)
+ {
+ light_deactivate(lpDirect3DLightImpl);
if (prev_light == NULL) This->lights = cur_light->next;
else prev_light->next = cur_light->next;
/* Detach the light to the viewport */