[PATCH 3/5] ddraw: Device2 and Device3 do not have a lighting render state(try 2)
Stefan Dösinger
stefan at codeweavers.com
Thu Jun 20 07:00:02 CDT 2013
try 2: Don't preserve the state set by SetRenderState and just return
0xffffffff from the getter.
Instead, lighting is enabled / disabled with D3DDP_DONOTLIGHT and the
presence or absence of vertex normals.
This fixes bug 29052.
---
dlls/ddraw/device.c | 38 +++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw2.c | 15 ++-------------
2 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index b9058b0..09880dd 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1998-2004 Lionel Ulmer
* Copyright (c) 2002-2005 Christian Costa
- * Copyright (c) 2006-2009, 2011-2012 Stefan Dösinger
+ * Copyright (c) 2006-2009, 2011-2013 Stefan Dösinger
* Copyright (c) 2008 Alexander Dorofeyev
*
* This library is free software; you can redistribute it and/or
@@ -2445,6 +2445,10 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
return D3D_OK;
}
+ case D3DRENDERSTATE_LIGHTING:
+ *value = 0xffffffff;
+ return D3D_OK;
+
default:
return IDirect3DDevice7_GetRenderState(&device->IDirect3DDevice7_iface, state, value);
}
@@ -2800,6 +2804,10 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface,
break;
}
+ case D3DRENDERSTATE_LIGHTING:
+ hr = D3D_OK;
+ break;
+
default:
hr = IDirect3DDevice7_SetRenderState(&device->IDirect3DDevice7_iface, state, value);
break;
@@ -3475,6 +3483,22 @@ static HRESULT WINAPI d3d_device7_DrawPrimitive_FPUPreserve(IDirect3DDevice7 *if
return hr;
}
+static void setup_lighting(const struct d3d_device *device, DWORD fvf, DWORD flags)
+{
+ BOOL enable;
+
+ /* Ignore the D3DFVF_XYZRHW case here, wined3d takes care of that */
+ if (flags & D3DDP_DONOTLIGHT)
+ enable = FALSE;
+ else if (!(fvf & D3DFVF_NORMAL))
+ enable = FALSE;
+ else
+ enable = TRUE;
+
+ wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING, enable);
+}
+
+
static HRESULT WINAPI d3d_device3_DrawPrimitive(IDirect3DDevice3 *iface,
D3DPRIMITIVETYPE primitive_type, DWORD fvf, void *vertices, DWORD vertex_count,
DWORD flags)
@@ -3484,6 +3508,8 @@ static HRESULT WINAPI d3d_device3_DrawPrimitive(IDirect3DDevice3 *iface,
TRACE("iface %p, primitive_type %#x, fvf %#x, vertices %p, vertex_count %u, flags %#x.\n",
iface, primitive_type, fvf, vertices, vertex_count, flags);
+ setup_lighting(device, fvf, flags);
+
return IDirect3DDevice7_DrawPrimitive(&device->IDirect3DDevice7_iface,
primitive_type, fvf, vertices, vertex_count, flags);
}
@@ -3666,6 +3692,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitive(IDirect3DDevice3 *iface,
"indices %p, index_count %u, flags %#x.\n",
iface, primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
+ setup_lighting(device, fvf, flags);
+
return IDirect3DDevice7_DrawIndexedPrimitive(&device->IDirect3DDevice7_iface,
primitive_type, fvf, vertices, vertex_count, indices, index_count, flags);
}
@@ -3972,6 +4000,8 @@ static HRESULT WINAPI d3d_device3_DrawPrimitiveStrided(IDirect3DDevice3 *iface,
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
+ setup_lighting(device, VertexType, Flags);
+
return IDirect3DDevice7_DrawPrimitiveStrided(&device->IDirect3DDevice7_iface,
PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Flags);
}
@@ -4097,6 +4127,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveStrided(IDirect3DDevice3 *
TRACE("iface %p, primitive_type %#x, FVF %#x, strided_data %p, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
+ setup_lighting(device, VertexType, Flags);
+
return IDirect3DDevice7_DrawIndexedPrimitiveStrided(&device->IDirect3DDevice7_iface,
PrimitiveType, VertexType, D3DDrawPrimStrideData, VertexCount, Indices, IndexCount, Flags);
}
@@ -4189,6 +4221,8 @@ static HRESULT WINAPI d3d_device3_DrawPrimitiveVB(IDirect3DDevice3 *iface, D3DPR
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Flags);
+ setup_lighting(device, vb->fvf, Flags);
+
return IDirect3DDevice7_DrawPrimitiveVB(&device->IDirect3DDevice7_iface,
PrimitiveType, &vb->IDirect3DVertexBuffer7_iface, StartVertex, NumVertices, Flags);
}
@@ -4320,6 +4354,8 @@ static HRESULT WINAPI d3d_device3_DrawIndexedPrimitiveVB(IDirect3DDevice3 *iface
TRACE("iface %p, primitive_type %#x, vb %p, indices %p, index_count %u, flags %#x.\n",
iface, PrimitiveType, D3DVertexBuf, Indices, IndexCount, Flags);
+ setup_lighting(device, vb->fvf, Flags);
+
return IDirect3DDevice7_DrawIndexedPrimitiveVB(&device->IDirect3DDevice7_iface, PrimitiveType,
&vb->IDirect3DVertexBuffer7_iface, 0, IndexCount, Indices, IndexCount, Flags);
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 80a2b27..178900f 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -902,13 +902,6 @@ static void test_depth_blit(void)
{0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
{0x0000ff00, 0x0000ff00, 0x0000ff00, 0x0000ff00},
};
- static const BOOL todo[4][4] =
- {
- {FALSE, FALSE, TRUE, TRUE},
- {FALSE, FALSE, TRUE, TRUE},
- {TRUE, TRUE, TRUE, TRUE},
- {TRUE, TRUE, TRUE, TRUE},
- };
DDSURFACEDESC ddsd_new, ddsd_existing;
IDirect3DDevice2 *device;
@@ -1056,12 +1049,8 @@ static void test_depth_blit(void)
unsigned int x = 80 * ((2 * j) + 1);
unsigned int y = 60 * ((2 * i) + 1);
color = get_surface_color(rt, x, y);
- if (todo[i][j])
- todo_wine ok(compare_color(color, expected_colors[i][j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
- else
- ok(compare_color(color, expected_colors[i][j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
+ ok(compare_color(color, expected_colors[i][j], 1),
+ "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected_colors[i][j], x, y, color);
}
}
IDirectDrawSurface_Release(rt);
--
1.8.1.5
More information about the wine-patches
mailing list