[PATCH 07/10] d3dx9: Add tests for D3DXCreateBox index buffer description. (try 2)
Misha Koshelev
misha680 at gmail.com
Sat Jul 17 14:14:11 CDT 2010
---
dlls/d3dx9_36/tests/mesh.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c
index 6db432e..88152c0 100644
--- a/dlls/d3dx9_36/tests/mesh.c
+++ b/dlls/d3dx9_36/tests/mesh.c
@@ -490,11 +490,29 @@ static void D3DXCreateBoxTest(void)
ID3DXMesh* box = NULL;
DWORD number_of_vertices, number_of_faces;
IDirect3DVertexBuffer9* vertex_buffer = NULL;
+ IDirect3DIndexBuffer9* index_buffer = NULL;
D3DVERTEXBUFFER_DESC vertex_buffer_description;
+ D3DINDEXBUFFER_DESC index_buffer_description;
D3DXVECTOR3* vertex_data = NULL;
D3DXVECTOR3 test_vertex_data[48];
+ WORD* index_data = NULL;
int expected, i;
+ static const WORD test_index_data[36] = {
+ 0, 1, 2, /* side 1 */
+ 2, 3, 0,
+ 4, 5, 6, /* side 2 */
+ 6, 7, 4,
+ 8, 9, 10, /* side 3 */
+ 10, 11, 8,
+ 12, 13, 14, /* side 4 */
+ 14, 15, 12,
+ 16, 17, 18, /* side 5 */
+ 18, 19, 16,
+ 20, 21, 22, /* side 6 */
+ 22, 23, 20
+ };
+
hr = D3DXCreateBox(NULL, 0.0f, 0.0f, 0.0f, NULL, NULL);
todo_wine ok( hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n",hr,D3DERR_INVALIDCALL);
@@ -640,6 +658,42 @@ static void D3DXCreateBoxTest(void)
number_of_faces = box->lpVtbl->GetNumFaces(box);
todo_wine ok( number_of_faces == 12, "Got result %u, expected 12\n",number_of_faces);
+ hr = box->lpVtbl->GetIndexBuffer(box, &index_buffer);
+ todo_wine ok( hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n",hr);
+
+ if (index_buffer)
+ {
+ hr = IDirect3DIndexBuffer9_GetDesc(index_buffer, &index_buffer_description);
+ todo_wine ok( hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n",hr);
+
+ if (hr == D3D_OK)
+ {
+ todo_wine ok( index_buffer_description.Format == D3DFMT_INDEX16, "Got result %x, expected %x (D3DFMT_INDEX16)\n",index_buffer_description.Format,D3DFMT_INDEX16);
+ todo_wine ok( index_buffer_description.Type == D3DRTYPE_INDEXBUFFER, "Got result %x, expected %x (D3DRTYPE_INDEXBUFFER)\n",index_buffer_description.Type,D3DRTYPE_INDEXBUFFER);
+ todo_wine ok( index_buffer_description.Usage == 0, "Got result %x, expected %x\n",index_buffer_description.Usage,0);
+ todo_wine ok( index_buffer_description.Pool == D3DPOOL_MANAGED, "Got result %x, expected %x (D3DPOOL_DEFAULT)\n",index_buffer_description.Pool,D3DPOOL_DEFAULT);
+ expected = number_of_faces * 6; /* 3 vertices per triangle, 2 triangles per face */
+ todo_wine ok( index_buffer_description.Size == expected, "Got result %x, expected %x\n",index_buffer_description.Size,expected);
+ }
+
+ /* Specify offset and size to avoid potential overruns */
+ hr = IDirect3DIndexBuffer9_Lock(index_buffer, 0, number_of_faces * 6, (LPVOID *)&index_data, D3DLOCK_DISCARD);
+ todo_wine ok( hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n",hr);
+
+ if (index_data)
+ {
+ /* number_of_faces*3 as we have three vertices for each triangle */
+ for (i=0; i<number_of_faces*3; i++)
+ {
+ todo_wine ok( index_data[i]==test_index_data[i], "Got result %u, expected %u\n",index_data[i],test_index_data[i]);
+ }
+ }
+
+ IDirect3DIndexBuffer9_Unlock(index_buffer);
+
+ IDirect3DIndexBuffer9_Release(index_buffer);
+ }
+
box->lpVtbl->Release(box);
}
--
1.7.1
More information about the wine-patches
mailing list