Commit f5973597 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of the WINED3DLIGHT typedef.

parent e2d099a1
......@@ -1343,9 +1343,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetLight(IDirect3DDevice8 *iface, DWO
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
/* Note: D3DLIGHT8 is compatible with struct wined3d_light. */
wined3d_mutex_lock();
hr = wined3d_device_set_light(This->wined3d_device, Index, (const WINED3DLIGHT *)pLight);
hr = wined3d_device_set_light(This->wined3d_device, Index, (const struct wined3d_light *)pLight);
wined3d_mutex_unlock();
return hr;
......@@ -1359,9 +1359,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetLight(IDirect3DDevice8 *iface, DWO
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT8 is compatible with WINED3DLIGHT */
/* Note: D3DLIGHT8 is compatible with struct wined3d_light. */
wined3d_mutex_lock();
hr = wined3d_device_get_light(This->wined3d_device, Index, (WINED3DLIGHT *)pLight);
hr = wined3d_device_get_light(This->wined3d_device, Index, (struct wined3d_light *)pLight);
wined3d_mutex_unlock();
return hr;
......
......@@ -1361,9 +1361,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(IDirect3DDevice9Ex *iface, D
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
/* Note: D3DLIGHT9 is compatible with struct wined3d_light. */
wined3d_mutex_lock();
hr = wined3d_device_set_light(This->wined3d_device, Index, (const WINED3DLIGHT *)pLight);
hr = wined3d_device_set_light(This->wined3d_device, Index, (const struct wined3d_light *)pLight);
wined3d_mutex_unlock();
return hr;
......@@ -1377,9 +1377,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(IDirect3DDevice9Ex *iface, D
TRACE("iface %p, index %u, light %p.\n", iface, Index, pLight);
/* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
/* Note: D3DLIGHT9 is compatible with struct wined3d_light. */
wined3d_mutex_lock();
hr = wined3d_device_get_light(This->wined3d_device, Index, (WINED3DLIGHT *)pLight);
hr = wined3d_device_get_light(This->wined3d_device, Index, (struct wined3d_light *)pLight);
wined3d_mutex_unlock();
return hr;
......
......@@ -5374,8 +5374,8 @@ IDirect3DDeviceImpl_7_SetLight(IDirect3DDevice7 *iface,
TRACE("iface %p, light_idx %u, light %p.\n", iface, LightIndex, Light);
wined3d_mutex_lock();
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
hr = wined3d_device_set_light(This->wined3d_device, LightIndex, (WINED3DLIGHT *)Light);
/* Note: D3DLIGHT7 is compatible with struct wined3d_light. */
hr = wined3d_device_set_light(This->wined3d_device, LightIndex, (struct wined3d_light *)Light);
wined3d_mutex_unlock();
return hr_ddraw_from_wined3d(hr);
......@@ -5429,8 +5429,8 @@ IDirect3DDeviceImpl_7_GetLight(IDirect3DDevice7 *iface,
TRACE("iface %p, light_idx %u, light %p.\n", iface, LightIndex, Light);
wined3d_mutex_lock();
/* Note: D3DLIGHT7 is compatible with WINED3DLIGHT */
rc = wined3d_device_get_light(This->wined3d_device, LightIndex, (WINED3DLIGHT *)Light);
/* Note: D3DLIGHT7 is compatible with struct wined3d_light. */
rc = wined3d_device_get_light(This->wined3d_device, LightIndex, (struct wined3d_light *)Light);
wined3d_mutex_unlock();
/* Translate the result. WineD3D returns other values than D3D7 */
......
......@@ -33,9 +33,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
/* Define the default light parameters as specified by MSDN */
const WINED3DLIGHT WINED3D_default_light = {
/* Define the default light parameters as specified by MSDN. */
const struct wined3d_light WINED3D_default_light =
{
WINED3DLIGHT_DIRECTIONAL, /* Type */
{ 1.0f, 1.0f, 1.0f, 0.0f }, /* Diffuse r,g,b,a */
{ 0.0f, 0.0f, 0.0f, 0.0f }, /* Specular r,g,b,a */
......@@ -1902,7 +1902,8 @@ HRESULT CDECL wined3d_device_multiply_transform(struct wined3d_device *device,
* stateblock problems. When capturing the state block, I duplicate the
* hashmap, but when recording, just build a chain pretty much of commands to
* be replayed. */
HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const WINED3DLIGHT *light)
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;
......@@ -1916,7 +1917,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
if (!light)
return WINED3DERR_INVALIDCALL;
switch (light->Type)
switch (light->type)
{
case WINED3DLIGHT_POINT:
case WINED3DLIGHT_SPOT:
......@@ -1924,7 +1925,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
case WINED3DLIGHT_GLSPOT:
/* Incorrect attenuation values can cause the gl driver to crash.
* Happens with Need for speed most wanted. */
if (light->Attenuation0 < 0.0f || light->Attenuation1 < 0.0f || light->Attenuation2 < 0.0f)
if (light->attenuation0 < 0.0f || light->attenuation1 < 0.0f || light->attenuation2 < 0.0f)
{
WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL.\n");
return WINED3DERR_INVALIDCALL;
......@@ -1964,25 +1965,25 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
/* Initialize the object. */
TRACE("Light %d setting to type %d, Diffuse(%f,%f,%f,%f), Specular(%f,%f,%f,%f), Ambient(%f,%f,%f,%f)\n",
light_idx, light->Type,
light->Diffuse.r, light->Diffuse.g, light->Diffuse.b, light->Diffuse.a,
light->Specular.r, light->Specular.g, light->Specular.b, light->Specular.a,
light->Ambient.r, light->Ambient.g, light->Ambient.b, light->Ambient.a);
TRACE("... Pos(%f,%f,%f), Dir(%f,%f,%f)\n", light->Position.x, light->Position.y, light->Position.z,
light->Direction.x, light->Direction.y, light->Direction.z);
light_idx, light->type,
light->diffuse.r, light->diffuse.g, light->diffuse.b, light->diffuse.a,
light->specular.r, light->specular.g, light->specular.b, light->specular.a,
light->ambient.r, light->ambient.g, light->ambient.b, light->ambient.a);
TRACE("... Pos(%f,%f,%f), Dir(%f,%f,%f)\n", light->position.x, light->position.y, light->position.z,
light->direction.x, light->direction.y, light->direction.z);
TRACE("... Range(%f), Falloff(%f), Theta(%f), Phi(%f)\n",
light->Range, light->Falloff, light->Theta, light->Phi);
light->range, light->falloff, light->theta, light->phi);
/* Save away the information. */
object->OriginalParms = *light;
switch (light->Type)
switch (light->type)
{
case WINED3DLIGHT_POINT:
/* Position */
object->lightPosn[0] = light->Position.x;
object->lightPosn[1] = light->Position.y;
object->lightPosn[2] = light->Position.z;
object->lightPosn[0] = light->position.x;
object->lightPosn[1] = light->position.y;
object->lightPosn[2] = light->position.z;
object->lightPosn[3] = 1.0f;
object->cutoff = 180.0f;
/* FIXME: Range */
......@@ -1990,9 +1991,9 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
case WINED3DLIGHT_DIRECTIONAL:
/* Direction */
object->lightPosn[0] = -light->Direction.x;
object->lightPosn[1] = -light->Direction.y;
object->lightPosn[2] = -light->Direction.z;
object->lightPosn[0] = -light->direction.x;
object->lightPosn[1] = -light->direction.y;
object->lightPosn[2] = -light->direction.z;
object->lightPosn[3] = 0.0f;
object->exponent = 0.0f;
object->cutoff = 180.0f;
......@@ -2000,15 +2001,15 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
case WINED3DLIGHT_SPOT:
/* Position */
object->lightPosn[0] = light->Position.x;
object->lightPosn[1] = light->Position.y;
object->lightPosn[2] = light->Position.z;
object->lightPosn[0] = light->position.x;
object->lightPosn[1] = light->position.y;
object->lightPosn[2] = light->position.z;
object->lightPosn[3] = 1.0f;
/* Direction */
object->lightDirn[0] = light->Direction.x;
object->lightDirn[1] = light->Direction.y;
object->lightDirn[2] = light->Direction.z;
object->lightDirn[0] = light->direction.x;
object->lightDirn[1] = light->direction.y;
object->lightDirn[2] = light->direction.z;
object->lightDirn[3] = 1.0f;
/* opengl-ish and d3d-ish spot lights use too different models
......@@ -2017,7 +2018,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
* roughly. However, spot lights are rather rarely used in games
* (if ever used at all). Furthermore if still used, probably
* nobody pays attention to such details. */
if (!light->Falloff)
if (!light->falloff)
{
/* Falloff = 0 is easy, because d3d's and opengl's spot light
* equations have the falloff resp. exponent parameter as an
......@@ -2028,7 +2029,7 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
}
else
{
rho = light->Theta + (light->Phi - light->Theta) / (2 * light->Falloff);
rho = light->theta + (light->phi - light->theta) / (2 * light->falloff);
if (rho < 0.0001f)
rho = 0.0001f;
object->exponent = -0.3f / logf(cosf(rho / 2));
......@@ -2037,12 +2038,12 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
if (object->exponent > 128.0f)
object->exponent = 128.0f;
object->cutoff = (float)(light->Phi * 90 / M_PI);
object->cutoff = (float)(light->phi * 90 / M_PI);
/* FIXME: Range */
break;
default:
FIXME("Unrecognized light type %#x.\n", light->Type);
FIXME("Unrecognized light type %#x.\n", light->type);
}
/* Update the live definitions if the light is currently assigned a glIndex. */
......@@ -2052,7 +2053,8 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light
return WINED3D_OK;
}
HRESULT CDECL wined3d_device_get_light(const struct wined3d_device *device, UINT light_idx, WINED3DLIGHT *light)
HRESULT CDECL wined3d_device_get_light(const struct wined3d_device *device,
UINT light_idx, struct wined3d_light *light)
{
UINT hash_idx = LIGHTMAP_HASHFUNC(light_idx);
struct wined3d_light_info *light_info = NULL;
......
......@@ -4647,41 +4647,41 @@ static void light(struct wined3d_context *context, const struct wined3d_state *s
glLoadMatrixf(&state->transforms[WINED3DTS_VIEW].u.m[0][0]);
/* Diffuse: */
colRGBA[0] = lightInfo->OriginalParms.Diffuse.r;
colRGBA[1] = lightInfo->OriginalParms.Diffuse.g;
colRGBA[2] = lightInfo->OriginalParms.Diffuse.b;
colRGBA[3] = lightInfo->OriginalParms.Diffuse.a;
colRGBA[0] = lightInfo->OriginalParms.diffuse.r;
colRGBA[1] = lightInfo->OriginalParms.diffuse.g;
colRGBA[2] = lightInfo->OriginalParms.diffuse.b;
colRGBA[3] = lightInfo->OriginalParms.diffuse.a;
glLightfv(GL_LIGHT0 + Index, GL_DIFFUSE, colRGBA);
checkGLcall("glLightfv");
/* Specular */
colRGBA[0] = lightInfo->OriginalParms.Specular.r;
colRGBA[1] = lightInfo->OriginalParms.Specular.g;
colRGBA[2] = lightInfo->OriginalParms.Specular.b;
colRGBA[3] = lightInfo->OriginalParms.Specular.a;
colRGBA[0] = lightInfo->OriginalParms.specular.r;
colRGBA[1] = lightInfo->OriginalParms.specular.g;
colRGBA[2] = lightInfo->OriginalParms.specular.b;
colRGBA[3] = lightInfo->OriginalParms.specular.a;
glLightfv(GL_LIGHT0 + Index, GL_SPECULAR, colRGBA);
checkGLcall("glLightfv");
/* Ambient */
colRGBA[0] = lightInfo->OriginalParms.Ambient.r;
colRGBA[1] = lightInfo->OriginalParms.Ambient.g;
colRGBA[2] = lightInfo->OriginalParms.Ambient.b;
colRGBA[3] = lightInfo->OriginalParms.Ambient.a;
colRGBA[0] = lightInfo->OriginalParms.ambient.r;
colRGBA[1] = lightInfo->OriginalParms.ambient.g;
colRGBA[2] = lightInfo->OriginalParms.ambient.b;
colRGBA[3] = lightInfo->OriginalParms.ambient.a;
glLightfv(GL_LIGHT0 + Index, GL_AMBIENT, colRGBA);
checkGLcall("glLightfv");
if ((lightInfo->OriginalParms.Range *lightInfo->OriginalParms.Range) >= FLT_MIN) {
quad_att = 1.4f/(lightInfo->OriginalParms.Range *lightInfo->OriginalParms.Range);
} else {
if ((lightInfo->OriginalParms.range * lightInfo->OriginalParms.range) >= FLT_MIN)
quad_att = 1.4f / (lightInfo->OriginalParms.range * lightInfo->OriginalParms.range);
else
quad_att = 0.0f; /* 0 or MAX? (0 seems to be ok) */
}
/* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
* but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
* Attenuation0 to NaN and crashes in the gl lib
*/
switch (lightInfo->OriginalParms.Type) {
switch (lightInfo->OriginalParms.type)
{
case WINED3DLIGHT_POINT:
/* Position */
glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->lightPosn[0]);
......@@ -4689,11 +4689,12 @@ static void light(struct wined3d_context *context, const struct wined3d_state *s
glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
checkGLcall("glLightf");
/* Attenuation - Are these right? guessing... */
glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION, lightInfo->OriginalParms.Attenuation0);
glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION, lightInfo->OriginalParms.attenuation0);
checkGLcall("glLightf");
glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION, lightInfo->OriginalParms.Attenuation1);
glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION, lightInfo->OriginalParms.attenuation1);
checkGLcall("glLightf");
if (quad_att < lightInfo->OriginalParms.Attenuation2) quad_att = lightInfo->OriginalParms.Attenuation2;
if (quad_att < lightInfo->OriginalParms.attenuation2)
quad_att = lightInfo->OriginalParms.attenuation2;
glLightf(GL_LIGHT0 + Index, GL_QUADRATIC_ATTENUATION, quad_att);
checkGLcall("glLightf");
/* FIXME: Range */
......@@ -4711,11 +4712,12 @@ static void light(struct wined3d_context *context, const struct wined3d_state *s
glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
checkGLcall("glLightf");
/* Attenuation - Are these right? guessing... */
glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION, lightInfo->OriginalParms.Attenuation0);
glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION, lightInfo->OriginalParms.attenuation0);
checkGLcall("glLightf");
glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION, lightInfo->OriginalParms.Attenuation1);
glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION, lightInfo->OriginalParms.attenuation1);
checkGLcall("glLightf");
if (quad_att < lightInfo->OriginalParms.Attenuation2) quad_att = lightInfo->OriginalParms.Attenuation2;
if (quad_att < lightInfo->OriginalParms.attenuation2)
quad_att = lightInfo->OriginalParms.attenuation2;
glLightf(GL_LIGHT0 + Index, GL_QUADRATIC_ATTENUATION, quad_att);
checkGLcall("glLightf");
/* FIXME: Range */
......@@ -4732,7 +4734,7 @@ static void light(struct wined3d_context *context, const struct wined3d_state *s
break;
default:
FIXME("Unrecognized light type %d\n", lightInfo->OriginalParms.Type);
FIXME("Unrecognized light type %#x.\n", lightInfo->OriginalParms.type);
}
/* Restore the modelview matrix */
......
......@@ -1271,7 +1271,7 @@ void context_surface_update(struct wined3d_context *context, const struct wined3
*/
struct wined3d_light_info
{
WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
DWORD OriginalIndex;
LONG glIndex;
BOOL enabled;
......@@ -1286,7 +1286,7 @@ struct wined3d_light_info
};
/* The default light parameters */
extern const WINED3DLIGHT WINED3D_default_light DECLSPEC_HIDDEN;
extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
struct wined3d_pixel_format
{
......
......@@ -1547,22 +1547,22 @@ struct wined3d_matrix
} DUMMYUNIONNAME;
};
typedef struct _WINED3DLIGHT
{
WINED3DLIGHTTYPE Type;
struct wined3d_color Diffuse;
struct wined3d_color Specular;
struct wined3d_color Ambient;
struct wined3d_vec3 Position;
struct wined3d_vec3 Direction;
float Range;
float Falloff;
float Attenuation0;
float Attenuation1;
float Attenuation2;
float Theta;
float Phi;
} WINED3DLIGHT;
struct wined3d_light
{
WINED3DLIGHTTYPE type;
struct wined3d_color diffuse;
struct wined3d_color specular;
struct wined3d_color ambient;
struct wined3d_vec3 position;
struct wined3d_vec3 direction;
float range;
float falloff;
float attenuation0;
float attenuation1;
float attenuation2;
float theta;
float phi;
};
typedef struct _WINED3DMATERIAL
{
......@@ -2214,7 +2214,8 @@ void __cdecl wined3d_device_get_gamma_ramp(const struct wined3d_device *device,
UINT swapchain_idx, WINED3DGAMMARAMP *ramp);
HRESULT __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device,
struct wined3d_buffer **index_buffer);
HRESULT __cdecl wined3d_device_get_light(const struct wined3d_device *device, UINT light_idx, WINED3DLIGHT *light);
HRESULT __cdecl wined3d_device_get_light(const struct wined3d_device *device,
UINT light_idx, struct wined3d_light *light);
HRESULT __cdecl wined3d_device_get_light_enable(const struct wined3d_device *device, UINT light_idx, BOOL *enable);
HRESULT __cdecl wined3d_device_get_material(const struct wined3d_device *device, WINED3DMATERIAL *material);
float __cdecl wined3d_device_get_npatch_mode(const struct wined3d_device *device);
......@@ -2292,7 +2293,8 @@ void __cdecl wined3d_device_set_gamma_ramp(const struct wined3d_device *device,
UINT swapchain_idx, DWORD flags, const WINED3DGAMMARAMP *ramp);
HRESULT __cdecl wined3d_device_set_index_buffer(struct wined3d_device *device,
struct wined3d_buffer *index_buffer, enum wined3d_format_id format_id);
HRESULT __cdecl wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const WINED3DLIGHT *light);
HRESULT __cdecl wined3d_device_set_light(struct wined3d_device *device,
UINT light_idx, const struct wined3d_light *light);
HRESULT __cdecl wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable);
HRESULT __cdecl wined3d_device_set_material(struct wined3d_device *device, const WINED3DMATERIAL *material);
void __cdecl wined3d_device_set_multithreaded(struct wined3d_device *device);
......
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