Gediminas Jakutis : d3dx9/tests: Add a mesh test for D3DXCreateBox().
Alexandre Julliard
julliard at winehq.org
Mon Mar 3 13:20:10 CST 2014
Module: wine
Branch: master
Commit: 6749bdf66bd83f6e5680d0bc17b6f60468932711
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6749bdf66bd83f6e5680d0bc17b6f60468932711
Author: Gediminas Jakutis <gediminas at varciai.lt>
Date: Thu Feb 27 21:03:03 2014 +0200
d3dx9/tests: Add a mesh test for D3DXCreateBox().
---
dlls/d3dx9_36/tests/mesh.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c
index d32f159..3fd5d9d 100644
--- a/dlls/d3dx9_36/tests/mesh.c
+++ b/dlls/d3dx9_36/tests/mesh.c
@@ -2424,6 +2424,85 @@ cleanup:
if (wnd) DestroyWindow(wnd);
}
+static BOOL compute_box(struct mesh *mesh, float width, float height, float depth)
+{
+ unsigned int i, face;
+ static const D3DXVECTOR3 unit_box[] =
+ {
+ {-1.0f, -1.0f, -1.0f}, {-1.0f, -1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f},
+ {-1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, -1.0f},
+ { 1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, -1.0f},
+ {-1.0f, -1.0f, 1.0f}, {-1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, 1.0f},
+ {-1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f},
+ {-1.0f, -1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}
+ };
+ static const D3DXVECTOR3 normals[] =
+ {
+ {-1.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 1.0f, 0.0f, 0.0f},
+ { 0.0f, -1.0f, 0.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, -1.0f}
+ };
+
+ if (!new_mesh(mesh, 24, 12))
+ {
+ return FALSE;
+ }
+
+ width /= 2.0f;
+ height /= 2.0f;
+ depth /= 2.0f;
+
+ for (i = 0; i < 24; i++)
+ {
+ mesh->vertices[i].position.x = width * unit_box[i].x;
+ mesh->vertices[i].position.y = height * unit_box[i].y;
+ mesh->vertices[i].position.z = depth * unit_box[i].z;
+ mesh->vertices[i].normal.x = normals[i / 4].x;
+ mesh->vertices[i].normal.y = normals[i / 4].y;
+ mesh->vertices[i].normal.z = normals[i / 4].z;
+ }
+
+ face = 0;
+ for (i = 0; i < 12; i++)
+ {
+ mesh->faces[i][0] = face++;
+ mesh->faces[i][1] = face++;
+ mesh->faces[i][2] = (i % 2) ? face - 4 : face;
+ }
+
+ return TRUE;
+}
+
+static void test_box(IDirect3DDevice9 *device, float width, float height, float depth)
+{
+ HRESULT hr;
+ ID3DXMesh *box;
+ struct mesh mesh;
+ char name[256];
+
+ hr = D3DXCreateBox(device, width, height, depth, &box, NULL);
+ ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
+ if (hr != D3D_OK)
+ {
+ skip("Couldn't create box\n");
+ return;
+ }
+
+ if (!compute_box(&mesh, width, height, depth))
+ {
+ skip("Couldn't create mesh\n");
+ box->lpVtbl->Release(box);
+ return;
+ }
+
+ mesh.fvf = D3DFVF_XYZ | D3DFVF_NORMAL;
+
+ sprintf(name, "box (%g, %g, %g)", width, height, depth);
+ compare_mesh(name, box, &mesh);
+
+ free_mesh(&mesh);
+
+ box->lpVtbl->Release(box);
+}
static void D3DXCreateBoxTest(void)
{
HRESULT hr;
@@ -2512,6 +2591,8 @@ static void D3DXCreateBoxTest(void)
box->lpVtbl->Release(box);
+ test_box(device, 10.9f, 20.0f, 4.9f);
+
end:
IDirect3DDevice9_Release(device);
IDirect3D9_Release(d3d);
More information about the wine-cvs
mailing list