Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
---
dlls/ddraw/light.c | 2 +-
dlls/ddraw/tests/ddraw4.c | 48 ++++++++++++++++++++++++++++-----------
2 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/dlls/ddraw/light.c b/dlls/ddraw/light.c
index c19e34cb70..c6513ffe8a 100644
--- a/dlls/ddraw/light.c
+++ b/dlls/ddraw/light.c
@@ -180,7 +180,7 @@ static HRESULT WINAPI d3d_light_SetLight(IDirect3DLight *iface, D3DLIGHT *data)
light7->dcvSpecular = zero_value;
else
light7->dcvSpecular = data->dcvColor;
- light7->dcvAmbient = data->dcvColor;
+ light7->dcvAmbient = zero_value;
light7->dvPosition = data->dvPosition;
light7->dvDirection = data->dvDirection;
light7->dvRange = data->dvRange;
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 8403c3d754..e363d88b44 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -492,6 +492,26 @@ static IDirect3DMaterial3 *create_diffuse_material(IDirect3DDevice3 *device, flo
return create_material(device, &mat);
}
+static IDirect3DMaterial3 *create_diffuse_and_ambient_material(IDirect3DDevice3 *device,
+ float r, float g, float b, float a)
+{
+ D3DMATERIAL mat;
+
+ memset(&mat, 0, sizeof(mat));
+ mat.dwSize = sizeof(mat);
+ U1(U(mat).diffuse).r = r;
+ U2(U(mat).diffuse).g = g;
+ U3(U(mat).diffuse).b = b;
+ U4(U(mat).diffuse).a = a;
+
+ U1(U(mat).ambient).r = r;
+ U2(U(mat).ambient).g = g;
+ U3(U(mat).ambient).b = b;
+ U4(U(mat).ambient).a = a;
+
+ return create_material(device, &mat);
+}
+
static IDirect3DMaterial3 *create_specular_material(IDirect3DDevice3 *device,
float r, float g, float b, float a, float power)
{
@@ -4045,10 +4065,10 @@ static void test_lighting(void)
}
tests[] =
{
- {&mat, nquad, 0x000000ff, "Lit quad with light"},
- {&mat_singular, nquad, 0x000000b4, "Lit quad with singular world matrix"},
- {&mat_transf, rotatedquad, 0x000000ff, "Lit quad with transformation matrix"},
- {&mat_nonaffine, translatedquad, 0x000000ff, "Lit quad with non-affine matrix"},
+ {&mat, nquad, 0x000080ff, "Lit quad with light"},
+ {&mat_singular, nquad, 0x000080b4, "Lit quad with singular world matrix"},
+ {&mat_transf, rotatedquad, 0x000080ff, "Lit quad with transformation matrix"},
+ {&mat_nonaffine, translatedquad, 0x000080ff, "Lit quad with non-affine matrix"},
};
DWORD nfvf = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_NORMAL;
@@ -4143,14 +4163,16 @@ static void test_lighting(void)
color = get_surface_color(rt, 480, 120);
ok(color == 0x00ffff00, "Lit quad with normals has color 0x%08x.\n", color);
- material = create_diffuse_material(device, 0.0f, 1.0f, 0.0f, 0.0f);
+ material = create_diffuse_and_ambient_material(device, 0.0f, 1.0f, 1.0f, 0.0f);
hr = IDirect3DMaterial3_GetHandle(material, device, &mat_handle);
- ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_MATERIAL, mat_handle);
- ok(SUCCEEDED(hr), "Failed to set material state, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice3_SetLightState(device, D3DLIGHTSTATE_AMBIENT, 0xff008000);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D3_CreateLight(d3d, &light, NULL);
- ok(SUCCEEDED(hr), "Failed to create a light object, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
memset(&light_desc, 0, sizeof(light_desc));
light_desc.dwSize = sizeof(light_desc);
light_desc.dltType = D3DLIGHT_DIRECTIONAL;
@@ -4172,20 +4194,20 @@ static void test_lighting(void)
IDirect3DViewport3_Release(viewport2);
hr = IDirect3DViewport3_Clear2(viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
- ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device);
- ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, nfvf, nquad,
4, indices, 6, 0);
- ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device);
- ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = get_surface_color(rt, 320, 240);
- ok(color == 0x00000000, "Lit quad with no light has color 0x%08x.\n", color);
+ ok(color == 0x00008000, "Lit quad with no light has color 0x%08x.\n", color);
light_desc.dwFlags = D3DLIGHT_ACTIVE;
hr = IDirect3DLight_SetLight(light, (D3DLIGHT *)&light_desc);
--
2.20.1