Commit 66f751f2 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d9: Retrieve light state from the primary stateblock.

parent 824e2709
...@@ -2232,13 +2232,14 @@ static HRESULT WINAPI d3d9_device_SetLight(IDirect3DDevice9Ex *iface, DWORD inde ...@@ -2232,13 +2232,14 @@ static HRESULT WINAPI d3d9_device_SetLight(IDirect3DDevice9Ex *iface, DWORD inde
static HRESULT WINAPI d3d9_device_GetLight(IDirect3DDevice9Ex *iface, DWORD index, D3DLIGHT9 *light) static HRESULT WINAPI d3d9_device_GetLight(IDirect3DDevice9Ex *iface, DWORD index, D3DLIGHT9 *light)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
BOOL enabled;
HRESULT hr; HRESULT hr;
TRACE("iface %p, index %u, light %p.\n", iface, index, light); TRACE("iface %p, index %u, light %p.\n", iface, index, light);
/* Note: D3DLIGHT9 is compatible with struct wined3d_light. */ /* Note: D3DLIGHT9 is compatible with struct wined3d_light. */
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_get_light(device->wined3d_device, index, (struct wined3d_light *)light); hr = wined3d_stateblock_get_light(device->state, index, (struct wined3d_light *)light, &enabled);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
...@@ -2260,15 +2261,16 @@ static HRESULT WINAPI d3d9_device_LightEnable(IDirect3DDevice9Ex *iface, DWORD i ...@@ -2260,15 +2261,16 @@ static HRESULT WINAPI d3d9_device_LightEnable(IDirect3DDevice9Ex *iface, DWORD i
return hr; return hr;
} }
static HRESULT WINAPI d3d9_device_GetLightEnable(IDirect3DDevice9Ex *iface, DWORD index, BOOL *enable) static HRESULT WINAPI d3d9_device_GetLightEnable(IDirect3DDevice9Ex *iface, DWORD index, BOOL *enabled)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_light light;
HRESULT hr; HRESULT hr;
TRACE("iface %p, index %u, enable %p.\n", iface, index, enable); TRACE("iface %p, index %u, enabled %p.\n", iface, index, enabled);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_get_light_enable(device->wined3d_device, index, enable); hr = wined3d_stateblock_get_light(device->state, index, &light, enabled);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
......
...@@ -1699,6 +1699,21 @@ const struct wined3d_stateblock_state * CDECL wined3d_stateblock_get_state(const ...@@ -1699,6 +1699,21 @@ const struct wined3d_stateblock_state * CDECL wined3d_stateblock_get_state(const
return &stateblock->stateblock_state; return &stateblock->stateblock_state;
} }
HRESULT CDECL wined3d_stateblock_get_light(const struct wined3d_stateblock *stateblock,
UINT light_idx, struct wined3d_light *light, BOOL *enabled)
{
struct wined3d_light_info *light_info;
if (!(light_info = wined3d_light_state_get_light(&stateblock->light_state, light_idx)))
{
TRACE("Light %u is not defined.\n", light_idx);
return WINED3DERR_INVALIDCALL;
}
*light = light_info->OriginalParms;
*enabled = light_info->enabled ? 128 : 0;
return WINED3D_OK;
}
static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info) static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info)
{ {
union union
......
...@@ -260,6 +260,7 @@ ...@@ -260,6 +260,7 @@
@ cdecl wined3d_stateblock_capture(ptr ptr) @ cdecl wined3d_stateblock_capture(ptr ptr)
@ cdecl wined3d_stateblock_create(ptr ptr long ptr) @ cdecl wined3d_stateblock_create(ptr ptr long ptr)
@ cdecl wined3d_stateblock_decref(ptr) @ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_get_light(ptr long ptr ptr)
@ cdecl wined3d_stateblock_get_state(ptr) @ cdecl wined3d_stateblock_get_state(ptr)
@ cdecl wined3d_stateblock_incref(ptr) @ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_stateblock_init_contained_states(ptr) @ cdecl wined3d_stateblock_init_contained_states(ptr)
......
...@@ -2726,6 +2726,8 @@ void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, ...@@ -2726,6 +2726,8 @@ void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state, HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, const struct wined3d_stateblock *device_state,
enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock); enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock); ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_get_light(const struct wined3d_stateblock *stateblock,
UINT light_idx, struct wined3d_light *light, BOOL *enabled);
const struct wined3d_stateblock_state * __cdecl wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock); const struct wined3d_stateblock_state * __cdecl wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock); ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock); void __cdecl wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock);
......
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