wined3d: Introduce wined3d_state_set_light() helper.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bc96d2f164
commit
de8eb61d97
|
@ -1573,8 +1573,8 @@ void CDECL wined3d_device_multiply_transform(struct wined3d_device *device,
|
|||
HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
|
||||
UINT light_idx, const struct wined3d_light *light)
|
||||
{
|
||||
UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
|
||||
struct wined3d_light_info *object = NULL;
|
||||
HRESULT hr;
|
||||
float rho;
|
||||
|
||||
TRACE("device %p, light_idx %u, light %p.\n", device, light_idx, light);
|
||||
|
@ -1608,16 +1608,8 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
|
|||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
if (!(object = wined3d_light_state_get_light(&device->update_state->light_state, light_idx)))
|
||||
{
|
||||
TRACE("Adding new light\n");
|
||||
if (!(object = heap_alloc_zero(sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
list_add_head(&device->update_state->light_state.light_map[hash_idx], &object->entry);
|
||||
object->glIndex = -1;
|
||||
object->OriginalIndex = light_idx;
|
||||
}
|
||||
if (FAILED(hr = wined3d_light_state_set_light(&device->update_state->light_state, light_idx, light, &object)))
|
||||
return hr;
|
||||
|
||||
/* Initialize the object. */
|
||||
TRACE("Light %u setting to type %#x, diffuse %s, specular %s, ambient %s, "
|
||||
|
@ -1629,9 +1621,6 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
|
|||
light->direction.x, light->direction.y, light->direction.z,
|
||||
light->range, light->falloff, light->theta, light->phi);
|
||||
|
||||
/* Save away the information. */
|
||||
object->OriginalParms = *light;
|
||||
|
||||
switch (light->type)
|
||||
{
|
||||
case WINED3D_LIGHT_POINT:
|
||||
|
|
|
@ -627,6 +627,33 @@ struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_li
|
|||
return NULL;
|
||||
}
|
||||
|
||||
HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
|
||||
const struct wined3d_light *params, struct wined3d_light_info **light_info)
|
||||
{
|
||||
struct wined3d_light_info *object;
|
||||
unsigned int hash_idx;
|
||||
|
||||
if (!(object = wined3d_light_state_get_light(state, light_idx)))
|
||||
{
|
||||
TRACE("Adding new light.\n");
|
||||
if (!(object = heap_alloc_zero(sizeof(*object))))
|
||||
{
|
||||
ERR("Failed to allocate light info.\n");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
hash_idx = LIGHTMAP_HASHFUNC(light_idx);
|
||||
list_add_head(&state->light_map[hash_idx], &object->entry);
|
||||
object->glIndex = -1;
|
||||
object->OriginalIndex = light_idx;
|
||||
}
|
||||
|
||||
object->OriginalParms = *params;
|
||||
|
||||
*light_info = object;
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
|
||||
struct wined3d_light_info *light_info, BOOL enable)
|
||||
{
|
||||
|
|
|
@ -3639,6 +3639,8 @@ void wined3d_light_state_enable_light(struct wined3d_light_state *state, const s
|
|||
struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
|
||||
struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
|
||||
unsigned int idx) DECLSPEC_HIDDEN;
|
||||
HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
|
||||
const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
|
||||
|
||||
void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
|
||||
void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
|
||||
|
|
Loading…
Reference in New Issue