Commit fa568815 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ddraw: Do not set ambient light component for d3d[1-4].

parent a02b23e4
......@@ -182,7 +182,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;
......
......@@ -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);
......
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