Commit 47cd5b14 authored by Alexandre Julliard's avatar Alexandre Julliard

d3dx9/tests: Use nameless unions/structs.

parent 8bec6d39
......@@ -49,19 +49,19 @@ static inline void check_mat(D3DXMATRIX got, D3DXMATRIX exp)
int i, j, equal=1;
for (i=0; i<4; i++)
for (j=0; j<4; j++)
if (fabs(U(exp).m[i][j]-U(got).m[i][j]) > admitted_error)
if (fabs(exp.m[i][j]-got.m[i][j]) > admitted_error)
equal=0;
ok(equal, "Got matrix\n\t(%f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f)\n"
"Expected matrix=\n\t(%f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f\n\t %f,%f,%f,%f)\n",
U(got).m[0][0],U(got).m[0][1],U(got).m[0][2],U(got).m[0][3],
U(got).m[1][0],U(got).m[1][1],U(got).m[1][2],U(got).m[1][3],
U(got).m[2][0],U(got).m[2][1],U(got).m[2][2],U(got).m[2][3],
U(got).m[3][0],U(got).m[3][1],U(got).m[3][2],U(got).m[3][3],
U(exp).m[0][0],U(exp).m[0][1],U(exp).m[0][2],U(exp).m[0][3],
U(exp).m[1][0],U(exp).m[1][1],U(exp).m[1][2],U(exp).m[1][3],
U(exp).m[2][0],U(exp).m[2][1],U(exp).m[2][2],U(exp).m[2][3],
U(exp).m[3][0],U(exp).m[3][1],U(exp).m[3][2],U(exp).m[3][3]);
got.m[0][0],got.m[0][1],got.m[0][2],got.m[0][3],
got.m[1][0],got.m[1][1],got.m[1][2],got.m[1][3],
got.m[2][0],got.m[2][1],got.m[2][2],got.m[2][3],
got.m[3][0],got.m[3][1],got.m[3][2],got.m[3][3],
exp.m[0][0],exp.m[0][1],exp.m[0][2],exp.m[0][3],
exp.m[1][0],exp.m[1][1],exp.m[1][2],exp.m[1][3],
exp.m[2][0],exp.m[2][1],exp.m[2][2],exp.m[2][3],
exp.m[3][0],exp.m[3][1],exp.m[3][2],exp.m[3][3]);
}
#define check_rect(rect, left, top, right, bottom) _check_rect(__LINE__, rect, left, top, right, bottom)
......@@ -169,10 +169,10 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device)
/* Test ID3DXSprite_SetTransform */
/* Set a transform and test if it gets returned correctly */
U(mat).m[0][0]=2.1f; U(mat).m[0][1]=6.5f; U(mat).m[0][2]=-9.6f; U(mat).m[0][3]=1.7f;
U(mat).m[1][0]=4.2f; U(mat).m[1][1]=-2.5f; U(mat).m[1][2]=2.1f; U(mat).m[1][3]=5.5f;
U(mat).m[2][0]=-2.6f; U(mat).m[2][1]=0.3f; U(mat).m[2][2]=8.6f; U(mat).m[2][3]=8.4f;
U(mat).m[3][0]=6.7f; U(mat).m[3][1]=-5.1f; U(mat).m[3][2]=6.1f; U(mat).m[3][3]=2.2f;
mat.m[0][0]=2.1f; mat.m[0][1]=6.5f; mat.m[0][2]=-9.6f; mat.m[0][3]=1.7f;
mat.m[1][0]=4.2f; mat.m[1][1]=-2.5f; mat.m[1][2]=2.1f; mat.m[1][3]=5.5f;
mat.m[2][0]=-2.6f; mat.m[2][1]=0.3f; mat.m[2][2]=8.6f; mat.m[2][3]=8.4f;
mat.m[3][0]=6.7f; mat.m[3][1]=-5.1f; mat.m[3][2]=6.1f; mat.m[3][3]=2.2f;
hr = ID3DXSprite_SetTransform(sprite, NULL);
ok (hr == D3DERR_INVALIDCALL, "SetTransform returned %#lx, expected %#lx\n", hr, D3DERR_INVALIDCALL);
......
......@@ -31,7 +31,7 @@ static inline BOOL compare_matrix(const D3DXMATRIX *m1, const D3DXMATRIX *m2)
{
for (j = 0; j < 4; ++j)
{
if (relative_error(U(*m1).m[i][j], U(*m2).m[i][j]) > admitted_error)
if (relative_error(m1->m[i][j], m2->m[i][j]) > admitted_error)
return FALSE;
}
}
......@@ -45,14 +45,14 @@ do { \
const D3DXMATRIX *__m2 = (gotmat); \
ok(compare_matrix(__m1, __m2), "Expected matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n)\n\n" \
"Got matrix=\n(%f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f\n %f,%f,%f,%f)\n", \
U(*__m1).m[0][0], U(*__m1).m[0][1], U(*__m1).m[0][2], U(*__m1).m[0][3], \
U(*__m1).m[1][0], U(*__m1).m[1][1], U(*__m1).m[1][2], U(*__m1).m[1][3], \
U(*__m1).m[2][0], U(*__m1).m[2][1], U(*__m1).m[2][2], U(*__m1).m[2][3], \
U(*__m1).m[3][0], U(*__m1).m[3][1], U(*__m1).m[3][2], U(*__m1).m[3][3], \
U(*__m2).m[0][0], U(*__m2).m[0][1], U(*__m2).m[0][2], U(*__m2).m[0][3], \
U(*__m2).m[1][0], U(*__m2).m[1][1], U(*__m2).m[1][2], U(*__m2).m[1][3], \
U(*__m2).m[2][0], U(*__m2).m[2][1], U(*__m2).m[2][2], U(*__m2).m[2][3], \
U(*__m2).m[3][0], U(*__m2).m[3][1], U(*__m2).m[3][2], U(*__m2).m[3][3]); \
__m1->m[0][0], __m1->m[0][1], __m1->m[0][2], __m1->m[0][3], \
__m1->m[1][0], __m1->m[1][1], __m1->m[1][2], __m1->m[1][3], \
__m1->m[2][0], __m1->m[2][1], __m1->m[2][2], __m1->m[2][3], \
__m1->m[3][0], __m1->m[3][1], __m1->m[3][2], __m1->m[3][3], \
__m2->m[0][0], __m2->m[0][1], __m2->m[0][2], __m2->m[0][3], \
__m2->m[1][0], __m2->m[1][1], __m2->m[1][2], __m2->m[1][3], \
__m2->m[2][0], __m2->m[2][1], __m2->m[2][2], __m2->m[2][3], \
__m2->m[3][0], __m2->m[3][1], __m2->m[3][2], __m2->m[3][3]); \
} while(0)
static void test_create_line(IDirect3DDevice9* device)
......@@ -90,7 +90,7 @@ static void test_create_line(IDirect3DDevice9* device)
D3DXMatrixIdentity(&world);
D3DXMatrixIdentity(&identity);
S(U(world))._11 = r11; S(U(world))._12 = r12; S(U(world))._13 = r13; S(U(world))._14 = r14;
world._11 = r11; world._12 = r12; world._13 = r13; world._14 = r14;
hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &world);
ok(hr == D3D_OK, "Got result %lx, expected %lx (D3D_OK)\n", hr, D3D_OK);
......
......@@ -1658,9 +1658,9 @@ static void check_matrix_(int line, const D3DXMATRIX *got, const D3DXMATRIX *exp
int i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
ok_(__FILE__,line)(compare(U(*expected).m[i][j], U(*got).m[i][j]),
ok_(__FILE__,line)(compare(expected->m[i][j], got->m[i][j]),
"matrix[%u][%u]: expected %g, got %g\n",
i, j, U(*expected).m[i][j], U(*got).m[i][j]);
i, j, expected->m[i][j], got->m[i][j]);
}
}
}
......@@ -1842,8 +1842,8 @@ static HRESULT destroy_mesh_container(LPD3DXMESHCONTAINER mesh_container)
if (!mesh_container)
return D3D_OK;
free(mesh_container->Name);
if (U(mesh_container->MeshData).pMesh)
IUnknown_Release(U(mesh_container->MeshData).pMesh);
if (mesh_container->MeshData.pMesh)
IUnknown_Release(mesh_container->MeshData.pMesh);
if (mesh_container->pMaterials) {
for (i = 0; i < mesh_container->NumMaterials; i++)
free(mesh_container->pMaterials[i].pTextureFilename);
......@@ -1885,7 +1885,7 @@ static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer(ID3DXAllo
int i;
TRACECALLBACK("ID3DXAllocateHierarchyImpl_CreateMeshContainer(%p, '%s', %u, %p, %p, %p, %ld, %p, %p, %p)\n",
iface, name, mesh_data->Type, U(*mesh_data).pMesh, materials, effects,
iface, name, mesh_data->Type, mesh_data->pMesh, materials, effects,
num_materials, adjacency, skin_info, *new_mesh_container);
mesh_container = calloc(1, sizeof(*mesh_container));
......@@ -1952,7 +1952,7 @@ static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer(ID3DXAllo
ok(adjacency != NULL, "Expected non-NULL adjacency, got NULL\n");
if (adjacency) {
if (mesh_data->Type == D3DXMESHTYPE_MESH || mesh_data->Type == D3DXMESHTYPE_PMESH) {
ID3DXBaseMesh *basemesh = (ID3DXBaseMesh*)U(*mesh_data).pMesh;
ID3DXBaseMesh *basemesh = (ID3DXBaseMesh*)mesh_data->pMesh;
DWORD num_faces = basemesh->lpVtbl->GetNumFaces(basemesh);
size_t size = num_faces * sizeof(DWORD) * 3;
mesh_container->pAdjacency = malloc(size);
......@@ -1967,8 +1967,8 @@ static HRESULT CALLBACK ID3DXAllocateHierarchyImpl_CreateMeshContainer(ID3DXAllo
}
memcpy(&mesh_container->MeshData, mesh_data, sizeof(*mesh_data));
if (U(*mesh_data).pMesh)
IUnknown_AddRef(U(*mesh_data).pMesh);
if (mesh_data->pMesh)
IUnknown_AddRef(mesh_data->pMesh);
if (skin_info) {
mesh_container->pSkinInfo = skin_info;
skin_info->lpVtbl->AddRef(skin_info);
......@@ -2428,7 +2428,7 @@ static void D3DXLoadMeshTest(void)
ok(!strcmp(container->Name, ""), "Expected '', got '%s'\n", container->Name);
ok(container->MeshData.Type == D3DXMESHTYPE_MESH, "Expected %d, got %d\n",
D3DXMESHTYPE_MESH, container->MeshData.Type);
mesh = U(container->MeshData).pMesh;
mesh = container->MeshData.pMesh;
check_vertex_buffer(mesh, simple_vertex_buffer, ARRAY_SIZE(simple_vertex_buffer), simple_fvf);
check_index_buffer(mesh, simple_index_buffer, ARRAY_SIZE(simple_index_buffer), sizeof(*simple_index_buffer));
check_materials(container->pMaterials, container->NumMaterials, NULL, 0);
......@@ -2471,7 +2471,7 @@ static void D3DXLoadMeshTest(void)
ok(!strcmp(container->Name, ""), "Expected '', got '%s'\n", container->Name);
ok(container->MeshData.Type == D3DXMESHTYPE_MESH, "Expected %d, got %d\n",
D3DXMESHTYPE_MESH, container->MeshData.Type);
mesh = U(container->MeshData).pMesh;
mesh = container->MeshData.pMesh;
check_vertex_buffer(mesh, box_vertex_buffer, ARRAY_SIZE(box_vertex_buffer), box_fvf);
check_index_buffer(mesh, box_index_buffer, ARRAY_SIZE(box_index_buffer), sizeof(*box_index_buffer));
check_materials(container->pMaterials, container->NumMaterials, box_materials, ARRAY_SIZE(box_materials));
......@@ -2492,14 +2492,14 @@ static void D3DXLoadMeshTest(void)
ok(!strcmp(frame_hier->Name, ""), "Expected '', got '%s'\n", frame_hier->Name);
/* last frame transform replaces the first */
D3DXMatrixIdentity(&transform);
U(transform).m[3][2] = 3.0;
transform.m[3][2] = 3.0;
check_matrix(&frame_hier->TransformationMatrix, &transform);
for (i = 0; i < 3; i++) {
ok(!strcmp(container->Name, ""), "Expected '', got '%s'\n", container->Name);
ok(container->MeshData.Type == D3DXMESHTYPE_MESH, "Expected %d, got %d\n",
D3DXMESHTYPE_MESH, container->MeshData.Type);
mesh = U(container->MeshData).pMesh;
mesh = container->MeshData.pMesh;
check_vertex_buffer(mesh, framed_vertex_buffers[i], ARRAY_SIZE(framed_vertex_buffers[0]), framed_fvf);
check_index_buffer(mesh, framed_index_buffer, ARRAY_SIZE(framed_index_buffer), sizeof(*framed_index_buffer));
check_materials(container->pMaterials, container->NumMaterials, NULL, 0);
......
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