From e226e7593abc92603eb27b6ed243271c2c2e3537 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Mon, 27 Apr 2015 17:39:11 +0200 Subject: [PATCH] wined3d: Use struct wined3d_vec4 to store the light position and direction. --- dlls/wined3d/device.c | 32 ++++++++++++++++---------------- dlls/wined3d/glsl_shader.c | 6 +++--- dlls/wined3d/state.c | 14 +++++++------- dlls/wined3d/wined3d_private.h | 8 ++++---- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 0ae29c7b03b..a3fbe2571e7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1521,36 +1521,36 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, { case WINED3D_LIGHT_POINT: /* Position */ - object->lightPosn[0] = light->position.x; - object->lightPosn[1] = light->position.y; - object->lightPosn[2] = light->position.z; - object->lightPosn[3] = 1.0f; + object->position.x = light->position.x; + object->position.y = light->position.y; + object->position.z = light->position.z; + object->position.w = 1.0f; object->cutoff = 180.0f; /* FIXME: Range */ break; case WINED3D_LIGHT_DIRECTIONAL: /* Direction */ - object->lightDirn[0] = -light->direction.x; - object->lightDirn[1] = -light->direction.y; - object->lightDirn[2] = -light->direction.z; - object->lightDirn[3] = 0.0f; + object->direction.x = -light->direction.x; + object->direction.y = -light->direction.y; + object->direction.z = -light->direction.z; + object->direction.w = 0.0f; object->exponent = 0.0f; object->cutoff = 180.0f; break; case WINED3D_LIGHT_SPOT: /* Position */ - object->lightPosn[0] = light->position.x; - object->lightPosn[1] = light->position.y; - object->lightPosn[2] = light->position.z; - object->lightPosn[3] = 1.0f; + object->position.x = light->position.x; + object->position.y = light->position.y; + object->position.z = light->position.z; + object->position.w = 1.0f; /* Direction */ - object->lightDirn[0] = light->direction.x; - object->lightDirn[1] = light->direction.y; - object->lightDirn[2] = light->direction.z; - object->lightDirn[3] = 0.0f; + object->direction.x = light->direction.x; + object->direction.y = light->direction.y; + object->direction.z = light->direction.z; + object->direction.w = 0.0f; /* opengl-ish and d3d-ish spot lights use too different models * for the light "intensity" as a function of the angle towards diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e49aff7f4c6..ae6bbf62673 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -7530,11 +7530,11 @@ static void glsl_vertex_pipe_view(struct wined3d_context *context, const struct if (!(light = state->lights[k])) continue; if (light->OriginalParms.type == WINED3D_LIGHT_DIRECTIONAL) - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightDirn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, &light->direction.x); else - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, &light->position.x); checkGLcall("glLightfv posn"); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, light->lightDirn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, &light->direction.x); checkGLcall("glLightfv dirn"); } diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 92c85472f5d..edaff9542ab 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3974,11 +3974,11 @@ static void transform_view(struct wined3d_context *context, const struct wined3d if (!(light = state->lights[k])) continue; if (light->OriginalParms.type == WINED3D_LIGHT_DIRECTIONAL) - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightDirn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, &light->direction.x); else - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, &light->position.x); checkGLcall("glLightfv posn"); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, light->lightDirn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, &light->direction.x); checkGLcall("glLightfv dirn"); } @@ -4759,7 +4759,7 @@ void light(struct wined3d_context *context, const struct wined3d_state *state, D { case WINED3D_LIGHT_POINT: /* Position */ - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, lightInfo->lightPosn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->position.x); checkGLcall("glLightfv"); gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff); checkGLcall("glLightf"); @@ -4778,10 +4778,10 @@ void light(struct wined3d_context *context, const struct wined3d_state *state, D case WINED3D_LIGHT_SPOT: /* Position */ - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, lightInfo->lightPosn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->position.x); checkGLcall("glLightfv"); /* Direction */ - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_SPOT_DIRECTION, lightInfo->lightDirn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_SPOT_DIRECTION, &lightInfo->direction.x); checkGLcall("glLightfv"); gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_EXPONENT, lightInfo->exponent); checkGLcall("glLightf"); @@ -4803,7 +4803,7 @@ void light(struct wined3d_context *context, const struct wined3d_state *state, D case WINED3D_LIGHT_DIRECTIONAL: /* Direction */ /* Note GL uses w position of 0 for direction! */ - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, lightInfo->lightDirn); + gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->direction.x); checkGLcall("glLightfv"); gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff); checkGLcall("glLightf"); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index eeb752a2fca..2b721c0f30b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1421,10 +1421,10 @@ struct wined3d_light_info BOOL enabled; /* Converted parms to speed up swapping lights */ - float lightPosn[4]; - float lightDirn[4]; - float exponent; - float cutoff; + struct wined3d_vec4 position; + struct wined3d_vec4 direction; + float exponent; + float cutoff; struct list entry; };