ddraw/tests: Test D3DVBCAPS_WRITEONLY.
This commit is contained in:
parent
af733f0475
commit
e7163c802d
|
@ -7438,6 +7438,75 @@ static void test_palette_alpha(void)
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_vb_writeonly(void)
|
||||
{
|
||||
IDirect3DDevice3 *device;
|
||||
IDirect3D3 *d3d;
|
||||
IDirect3DVertexBuffer *buffer;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
D3DVERTEXBUFFERDESC desc;
|
||||
void *ptr;
|
||||
static const struct vec4 quad[] =
|
||||
{
|
||||
{ 0.0f, 480.0f, 0.0f, 1.0f},
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{640.0f, 480.0f, 0.0f, 1.0f},
|
||||
{640.0f, 0.0f, 0.0f, 1.0f},
|
||||
};
|
||||
|
||||
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, 0, 0, 0, 0);
|
||||
|
||||
if (!(device = create_device(window, DDSCL_NORMAL)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
|
||||
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwCaps = D3DVBCAPS_WRITEONLY;
|
||||
desc.dwFVF = D3DFVF_XYZRHW;
|
||||
desc.dwNumVertices = sizeof(quad) / sizeof(*quad);
|
||||
hr = IDirect3D3_CreateVertexBuffer(d3d, &desc, &buffer, 0, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_DISCARDCONTENTS, &ptr, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
|
||||
memcpy(ptr, quad, sizeof(quad));
|
||||
hr = IDirect3DVertexBuffer_Unlock(buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice3_BeginScene(device);
|
||||
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 4, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice3_EndScene(device);
|
||||
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer_Lock(buffer, 0, &ptr, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
|
||||
ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
|
||||
hr = IDirect3DVertexBuffer_Unlock(buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer_Lock(buffer, DDLOCK_READONLY, &ptr, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
|
||||
ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
|
||||
hr = IDirect3DVertexBuffer_Unlock(buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
IDirect3DVertexBuffer_Release(buffer);
|
||||
IDirect3D3_Release(d3d);
|
||||
IDirect3DDevice3_Release(device);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(ddraw4)
|
||||
{
|
||||
IDirectDraw4 *ddraw;
|
||||
|
@ -7500,4 +7569,5 @@ START_TEST(ddraw4)
|
|||
test_material();
|
||||
test_palette_gdi();
|
||||
test_palette_alpha();
|
||||
test_vb_writeonly();
|
||||
}
|
||||
|
|
|
@ -7160,6 +7160,75 @@ static void test_palette_alpha(void)
|
|||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
static void test_vb_writeonly(void)
|
||||
{
|
||||
IDirect3DDevice7 *device;
|
||||
IDirect3D7 *d3d;
|
||||
IDirect3DVertexBuffer7 *buffer;
|
||||
HWND window;
|
||||
HRESULT hr;
|
||||
D3DVERTEXBUFFERDESC desc;
|
||||
void *ptr;
|
||||
static const struct vec4 quad[] =
|
||||
{
|
||||
{ 0.0f, 480.0f, 0.0f, 1.0f},
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{640.0f, 480.0f, 0.0f, 1.0f},
|
||||
{640.0f, 0.0f, 0.0f, 1.0f},
|
||||
};
|
||||
|
||||
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
|
||||
0, 0, 640, 480, 0, 0, 0, 0);
|
||||
|
||||
if (!(device = create_device(window, DDSCL_NORMAL)))
|
||||
{
|
||||
skip("Failed to create a 3D device, skipping test.\n");
|
||||
DestroyWindow(window);
|
||||
return;
|
||||
}
|
||||
|
||||
hr = IDirect3DDevice7_GetDirect3D(device, &d3d);
|
||||
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwCaps = D3DVBCAPS_WRITEONLY;
|
||||
desc.dwFVF = D3DFVF_XYZRHW;
|
||||
desc.dwNumVertices = sizeof(quad) / sizeof(*quad);
|
||||
hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &buffer, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_DISCARDCONTENTS, &ptr, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
|
||||
memcpy(ptr, quad, sizeof(quad));
|
||||
hr = IDirect3DVertexBuffer7_Unlock(buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice7_BeginScene(device);
|
||||
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_DrawPrimitiveVB(device, D3DPT_TRIANGLESTRIP, buffer, 0, 4, 0);
|
||||
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice7_EndScene(device);
|
||||
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer7_Lock(buffer, 0, &ptr, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
|
||||
ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
|
||||
hr = IDirect3DVertexBuffer7_Unlock(buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DVertexBuffer7_Lock(buffer, DDLOCK_READONLY, &ptr, NULL);
|
||||
ok(SUCCEEDED(hr), "Failed to lock vertex buffer, hr %#x.\n", hr);
|
||||
ok (!memcmp(ptr, quad, sizeof(quad)), "Got unexpected vertex buffer data.\n");
|
||||
hr = IDirect3DVertexBuffer7_Unlock(buffer);
|
||||
ok(SUCCEEDED(hr), "Failed to unlock vertex buffer, hr %#x.\n", hr);
|
||||
|
||||
IDirect3DVertexBuffer7_Release(buffer);
|
||||
IDirect3D7_Release(d3d);
|
||||
IDirect3DDevice7_Release(device);
|
||||
DestroyWindow(window);
|
||||
}
|
||||
|
||||
START_TEST(ddraw7)
|
||||
{
|
||||
HMODULE module = GetModuleHandleA("ddraw.dll");
|
||||
|
@ -7229,4 +7298,5 @@ START_TEST(ddraw7)
|
|||
test_material();
|
||||
test_palette_gdi();
|
||||
test_palette_alpha();
|
||||
test_vb_writeonly();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue