[PATCH 2/2] d3dx9/tests: Add a mesh test for D3DXCreateBox()
Gediminas Jakutis
gediminas at varciai.lt
Thu Feb 27 04:39:00 CST 2014
---
dlls/d3dx9_36/tests/mesh.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/dlls/d3dx9_36/tests/mesh.c b/dlls/d3dx9_36/tests/mesh.c
index d32f159..a34d194 100644
--- a/dlls/d3dx9_36/tests/mesh.c
+++ b/dlls/d3dx9_36/tests/mesh.c
@@ -2424,6 +2424,83 @@ cleanup:
if (wnd) DestroyWindow(wnd);
}
+static BOOL compute_box(struct mesh *mesh, float width, float height, float depth)
+{
+ unsigned int i, face;
+ static const float sign_x[24] = {-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 float sign_y[24] = {-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 float sign_z[24] = {-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 float normal_x[6] = { -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f};
+ static const float normal_y[6] = { 0.0f, 1.0f, 0.0f, -1.0f, 0.0f, 0.0f};
+ static const float normal_z[6] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.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 * sign_x[i];
+ mesh->vertices[i].position.y = height * sign_y[i];
+ mesh->vertices[i].position.z = depth * sign_z[i];
+ mesh->vertices[i].normal.x = normal_x[i / 4];
+ mesh->vertices[i].normal.y = normal_y[i / 4];
+ mesh->vertices[i].normal.z = normal_z[i / 4];
+ }
+
+ 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 +2589,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);
--
1.8.3.2
More information about the wine-patches
mailing list