wined3d: Use struct wined3d_vec4 to store the light position and direction.
This commit is contained in:
parent
540130bfa9
commit
e226e7593a
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1421,8 +1421,8 @@ struct wined3d_light_info
|
|||
BOOL enabled;
|
||||
|
||||
/* Converted parms to speed up swapping lights */
|
||||
float lightPosn[4];
|
||||
float lightDirn[4];
|
||||
struct wined3d_vec4 position;
|
||||
struct wined3d_vec4 direction;
|
||||
float exponent;
|
||||
float cutoff;
|
||||
|
||||
|
|
Loading…
Reference in New Issue