wined3d: Store the directional light direction in the lightDirn field.

It's only an implementation detail that the direction needs to be passed
to the fixed function GL pipeline as GL_POSITION.
This commit is contained in:
Matteo Bruni 2015-04-27 17:39:10 +02:00 committed by Alexandre Julliard
parent b5affa6d3c
commit 540130bfa9
3 changed files with 13 additions and 7 deletions

View File

@ -1531,10 +1531,10 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
case WINED3D_LIGHT_DIRECTIONAL:
/* Direction */
object->lightPosn[0] = -light->direction.x;
object->lightPosn[1] = -light->direction.y;
object->lightPosn[2] = -light->direction.z;
object->lightPosn[3] = 0.0f;
object->lightDirn[0] = -light->direction.x;
object->lightDirn[1] = -light->direction.y;
object->lightDirn[2] = -light->direction.z;
object->lightDirn[3] = 0.0f;
object->exponent = 0.0f;
object->cutoff = 180.0f;
break;

View File

@ -7529,7 +7529,10 @@ static void glsl_vertex_pipe_view(struct wined3d_context *context, const struct
{
if (!(light = state->lights[k]))
continue;
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
if (light->OriginalParms.type == WINED3D_LIGHT_DIRECTIONAL)
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightDirn);
else
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
checkGLcall("glLightfv posn");
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, light->lightDirn);
checkGLcall("glLightfv dirn");

View File

@ -3973,7 +3973,10 @@ static void transform_view(struct wined3d_context *context, const struct wined3d
{
if (!(light = state->lights[k]))
continue;
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
if (light->OriginalParms.type == WINED3D_LIGHT_DIRECTIONAL)
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightDirn);
else
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
checkGLcall("glLightfv posn");
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, light->lightDirn);
checkGLcall("glLightfv dirn");
@ -4800,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->lightPosn);
gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0 + Index, GL_POSITION, lightInfo->lightDirn);
checkGLcall("glLightfv");
gl_info->gl_ops.gl.p_glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
checkGLcall("glLightf");