36 static const unsigned __nan_bytes = 0x7fc00000;
37 return *(
const float *)&__nan_bytes;
39#define NAN __port_nan()
44#define TRACECALLBACK if(winetest_debug > 1) trace
46#define admitted_error 0.0001f
48#define compare_vertex_sizes(type, exp) \
49 got=D3DXGetFVFVertexSize(type); \
50 ok(got==exp, "Expected: %d, Got: %d\n", exp, got);
52#define compare_float(got, exp) \
56 ok(_got == _exp, "Expected: %g, Got: %g\n", _exp, _got); \
74#define check_floats(got, exp, dim) check_floats_(__LINE__, "", got, exp, dim)
78 char exp_buffer[256] =
"";
79 char got_buffer[256] =
"";
80 char *exp_buffer_ptr = exp_buffer;
81 char *got_buffer_ptr = got_buffer;
84 for (
i = 0;
i < dim;
i++) {
86 exp_buffer_ptr +=
sprintf(exp_buffer_ptr,
", ");
87 got_buffer_ptr +=
sprintf(got_buffer_ptr,
", ");
90 exp_buffer_ptr +=
sprintf(exp_buffer_ptr,
"%g", *
exp);
91 got_buffer_ptr +=
sprintf(got_buffer_ptr,
"%g", *got);
94 ok_(__FILE__,
line)(
equal,
"%sExpected (%s), got (%s)",
prefix, exp_buffer, got_buffer);
107 return (
a[0]==
b[0] &&
a[1] ==
b[1] &&
a[2] ==
b[2]);
133 skip(
"Couldn't create application window\n");
140 skip(
"Couldn't create IDirect3D9 object\n");
144 memset(&d3dpp, 0,
sizeof(d3dpp));
151 skip(
"Couldn't create IDirect3DDevice9 object %#x\n",
hr);
158 skip(
"Couldn't allocate memory for test_context\n");
238 DWORD number_of_vertices, number_of_faces;
240 IDirect3DIndexBuffer9 *index_buffer;
247 number_of_vertices = d3dxmesh->lpVtbl->GetNumVertices(d3dxmesh);
251 number_of_faces = d3dxmesh->lpVtbl->GetNumFaces(d3dxmesh);
261 skip(
"Couldn't get vertex buffer\n");
270 skip(
"Couldn't get vertex buffer description\n");
278 ok(vertex_buffer_description.
Usage == 0,
"Test %s, result %x, expected %x\n",
name, vertex_buffer_description.
Usage, 0);
279 ok(vertex_buffer_description.
Pool ==
D3DPOOL_MANAGED,
"Test %s, result %x, expected %x (D3DPOOL_MANAGED)\n",
281 ok(vertex_buffer_description.
FVF ==
mesh->
fvf,
"Test %s, result %x, expected %x\n",
291 ok(vertex_buffer_description.
Size ==
expected,
"Test %s, result %x, expected %x\n",
302 skip(
"Couldn't lock vertex buffer\n");
306 for (
i = 0;
i < number_of_vertices;
i++)
309 "Test %s, vertex position %d, result (%g, %g, %g), expected (%g, %g, %g)\n",
name,
i,
310 vertices[
i].position.x, vertices[
i].position.y, vertices[
i].position.z,
313 "Test %s, vertex normal %d, result (%g, %g, %g), expected (%g, %g, %g)\n",
name,
i,
314 vertices[
i].normal.x, vertices[
i].normal.y, vertices[
i].normal.z,
325 hr = d3dxmesh->lpVtbl->GetIndexBuffer(d3dxmesh, &index_buffer);
330 skip(
"Couldn't get index buffer\n");
339 skip(
"Couldn't get index buffer description\n");
343 ok(index_buffer_description.
Format ==
D3DFMT_INDEX16,
"Test %s, result %x, expected %x (D3DFMT_INDEX16)\n",
347 ok(index_buffer_description.
Usage == 0,
"Test %s, result %#x, expected %#x.\n",
348 name, index_buffer_description.
Usage, 0);
349 ok(index_buffer_description.
Pool ==
D3DPOOL_MANAGED,
"Test %s, result %x, expected %x (D3DPOOL_MANAGED)\n",
352 ok(index_buffer_description.
Size ==
expected,
"Test %s, result %x, expected %x\n",
363 skip(
"Couldn't lock index buffer\n");
367 for (
i = 0;
i < number_of_faces;
i++)
370 "Test %s, face %d, result (%u, %u, %u), expected (%u, %u, %u)\n",
name,
i,
371 faces[
i][0], faces[
i][1], faces[
i][2],
385 D3DXVECTOR3 bottom_point, center, top_point, raydirection, rayposition;
389 bottom_point.
x = -3.0f; bottom_point.
y = -2.0f; bottom_point.
z = -1.0f;
390 top_point.
x = 7.0f; top_point.
y = 8.0f; top_point.
z = 9.0f;
392 raydirection.
x = -4.0f; raydirection.
y = -5.0f; raydirection.
z = -6.0f;
393 rayposition.
x = 5.0f; rayposition.
y = 5.0f; rayposition.
z = 11.0f;
397 raydirection.
x = 4.0f; raydirection.
y = 5.0f; raydirection.
z = 6.0f;
398 rayposition.
x = 5.0f; rayposition.
y = 5.0f; rayposition.
z = 11.0f;
402 rayposition.
x = -4.0f; rayposition.
y = 1.0f; rayposition.
z = -2.0f;
406 bottom_point.
x = 1.0f; bottom_point.
y = 0.0f; bottom_point.
z = 0.0f;
407 top_point.
x = 1.0f; top_point.
y = 0.0f; top_point.
z = 0.0f;
408 rayposition.
x = 0.0f; rayposition.
y = 1.0f; rayposition.
z = 0.0f;
409 raydirection.
x = 0.0f; raydirection.
y = 3.0f; raydirection.
z = 0.0f;
413 bottom_point.
x = 1.0f; bottom_point.
y = 2.0f; bottom_point.
z = 3.0f;
414 top_point.
x = 10.0f; top_point.
y = 15.0f; top_point.
z = 20.0f;
416 raydirection.
x = 7.0f; raydirection.
y = 8.0f; raydirection.
z = 9.0f;
417 rayposition.
x = 3.0f; rayposition.
y = 7.0f; rayposition.
z = -6.0f;
421 bottom_point.
x = 0.0f; bottom_point.
y = 0.0f; bottom_point.
z = 0.0f;
422 top_point.
x = 1.0f; top_point.
y = 1.0f; top_point.
z = 1.0f;
424 raydirection.
x = 0.0f; raydirection.
y = 1.0f; raydirection.
z = .0f;
425 rayposition.
x = -3.0f; rayposition.
y = 0.0f; rayposition.
z = 0.0f;
429 raydirection.
x = 1.0f; raydirection.
y = 0.0f; raydirection.
z = .0f;
430 rayposition.
x = -3.0f; rayposition.
y = 0.0f; rayposition.
z = 0.0f;
435 radius =
sqrt(77.0f);
436 center.
x = 1.0f; center.
y = 2.0f; center.
z = 3.0f;
437 raydirection.
x = 2.0f; raydirection.
y = -4.0f; raydirection.
z = 2.0f;
438 rayposition.
x = 5.0f; rayposition.
y = 5.0f; rayposition.
z = 9.0f;
442 rayposition.
x = 45.0f; rayposition.
y = -75.0f; rayposition.
z = 49.0f;
446 raydirection.
x = -2.0f; raydirection.
y = 4.0f; raydirection.
z = -2.0f;
450 rayposition.
x = 5.0f; rayposition.
y = 11.0f; rayposition.
z = 9.0f;
454 raydirection.
x = 2.0f; raydirection.
y = -4.0f; raydirection.
z = 2.0f;
459 rayposition.
x = 2.0f; rayposition.
y = 2.0f; rayposition.
z = 3.0f;
463 raydirection.
x = 0.0f; raydirection.
y = 0.0f; raydirection.
z = 1.0f;
487 exp_min.
x = 1.0f; exp_min.
y = 1.0f; exp_min.
z = 1.0f;
488 exp_max.
x = 9.0f; exp_max.
y = 9.0f; exp_max.
z = 9.0f;
493 ok(
compare_vec3(exp_min,got_min),
"Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.
x,exp_min.
y,exp_min.
z,got_min.
x,got_min.
y,got_min.
z);
494 ok(
compare_vec3(exp_max,got_max),
"Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.
x,exp_max.
y,exp_max.
z,got_max.
x,got_max.
y,got_max.
z);
504 exp_min.
x = -6.92f; exp_min.
y = -8.1f; exp_min.
z = -3.80f;
505 exp_max.
x = 11.4f; exp_max.
y = 7.90f; exp_max.
z = 11.9f;
510 ok(
compare_vec3(exp_min,got_min),
"Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.
x,exp_min.
y,exp_min.
z,got_min.
x,got_min.
y,got_min.
z);
511 ok(
compare_vec3(exp_max,got_max),
"Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.
x,exp_max.
y,exp_max.
z,got_max.
x,got_max.
y,got_max.
z);
521 exp_min.
x = -6.92f; exp_min.
y = -0.9f; exp_min.
z = -3.8f;
522 exp_max.
x = 7.43f; exp_max.
y = 7.90f; exp_max.
z = 11.9f;
527 ok(
compare_vec3(exp_min,got_min),
"Expected min: (%f, %f, %f), got: (%f, %f, %f)\n", exp_min.
x,exp_min.
y,exp_min.
z,got_min.
x,got_min.
y,got_min.
z);
528 ok(
compare_vec3(exp_max,got_max),
"Expected max: (%f, %f, %f), got: (%f, %f, %f)\n", exp_max.
x,exp_max.
y,exp_max.
z,got_max.
x,got_max.
y,got_max.
z);
546 FLOAT exp_rad, got_rad;
556 exp_cen.
x = 5.0; exp_cen.
y = 5.0; exp_cen.
z = 5.0;
561 ok(
compare(exp_rad, got_rad),
"Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
562 ok(
compare_vec3(exp_cen,got_cen),
"Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen.
x,exp_cen.
y,exp_cen.
z,got_cen.
x,got_cen.
y,got_cen.
z);
572 exp_rad = 13.707883f;
573 exp_cen.
x = 2.408f; exp_cen.
y = 2.22f; exp_cen.
z = 3.76f;
578 ok(
compare(exp_rad, got_rad),
"Expected radius: %f, got radius: %f\n", exp_rad, got_rad);
579 ok(
compare_vec3(exp_cen,got_cen),
"Expected center: (%f, %f, %f), got center: (%f, %f, %f)\n", exp_cen.
x,exp_cen.
y,exp_cen.
z,got_cen.
x,got_cen.
y,got_cen.
z);
603 "[Element %d] Stream = %d, Offset = %d, Type = %d, Method = %d, Usage = %d, UsageIndex = %d\n",
611 unsigned int line,
unsigned int test_id)
622 if (!end1 && !end2)
break;
625 ok(!
status,
"Line %u, test %u: Mismatch in size, test declaration is %s than expected.\n",
626 line, test_id, end1 ?
"shorter" :
"longer");
634 ok(!
status,
"Line %u, test %u: Mismatch in element %u.\n",
line, test_id,
i);
644 HRESULT expected_hr,
unsigned int line,
unsigned int test_id)
650 ok(
hr == expected_hr,
651 "Line %u, test %u: D3DXDeclaratorFromFVF returned %#x, expected %#x.\n",
652 line, test_id,
hr, expected_hr);
657 HRESULT expected_hr,
unsigned int line,
unsigned int test_id)
660 DWORD result_fvf = 0xdeadbeef;
663 ok(
hr == expected_hr,
664 "Line %u, test %u: D3DXFVFFromDeclarator returned %#x, expected %#x.\n",
665 line, test_id,
hr, expected_hr);
668 ok(expected_fvf == result_fvf,
"Line %u, test %u: Got FVF %#x, expected %#x.\n",
669 line, test_id, result_fvf, expected_fvf);
897 decl,
D3D_OK, __LINE__, 0);
1117 BOOL exp_res, got_res;
1119 FLOAT exp_dist, got_dist, exp_u, got_u, exp_v, got_v;
1127 ray.
x = 2.0f; ray.
y = 3.0f; ray.
z = 4.0f;
1129 exp_res =
TRUE; exp_u = 0.5f; exp_v = 0.25f; exp_dist = 8.0f;
1132 ok(got_res == exp_res,
"Expected result %d, got %d.\n", exp_res, got_res);
1133 ok(
compare(exp_u, got_u),
"Expected u %f, got %f.\n", exp_u, got_u);
1134 ok(
compare(exp_v, got_v),
"Expected v %f, got %f.\n", exp_v, got_v);
1135 ok(
compare(exp_dist, got_dist),
"Expected distance %f, got %f.\n", exp_dist, got_dist);
1138 ok(got_res == exp_res,
"Expected result %d, got %d.\n", exp_res, got_res);
1144 got_u = got_v = got_dist = 0.0f;
1146 ok(got_res == exp_res,
"Expected result %d, got %d.\n", exp_res, got_res);
1147 ok(
compare(exp_u, got_u),
"Expected u %f, got %f.\n", exp_u, got_u);
1148 ok(
compare(exp_v, got_v),
"Expected v %f, got %f.\n", exp_v, got_v);
1149 ok(
compare(exp_dist, got_dist),
"Expected distance %f, got %f.\n", exp_dist, got_dist);
1157 got_u = got_v = got_dist = 0.0f;
1159 ok(got_res == exp_res,
"Expected result %d, got %d.\n", exp_res, got_res);
1160 ok(
compare(exp_u, got_u),
"Expected u %f, got %f.\n", exp_u, got_u);
1161 ok(
compare(exp_v, got_v),
"Expected v %f, got %f.\n", exp_v, got_v);
1162 ok(
compare(exp_dist, got_dist),
"Expected distance %f, got %f.\n", exp_dist, got_dist);
1173 ray.
x = 2.0f; ray.
y = 3.0f; ray.
z = 4.0f;
1178 ok( got_res == exp_res,
"Expected result = %d, got %d\n",exp_res,got_res);
1181 ok(got_res == exp_res,
"Expected result = %d, got %d\n", exp_res, got_res);
1191 ray.
x = 1.0f; ray.
y = 0.0f; ray.
z = 0.0f;
1196 ok( got_res == exp_res,
"Expected result = %d, got %d\n",exp_res,got_res);
1199 ok(got_res == exp_res,
"Expected result = %d, got %d\n", exp_res, got_res);
1205 IDirect3DDevice9 *
device, *test_device;
1206 ID3DXMesh *d3dxmesh;
1248 skip(
"Couldn't create test context\n");
1264 d3dxmesh->lpVtbl->Release(d3dxmesh);
1274 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
1279 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh,
NULL);
1282 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1284 ok(test_device ==
device,
"Got result %p, expected %p\n", test_device,
device);
1292 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh,
NULL);
1295 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1296 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
1301 for (
i = 0;
i <
size - 1;
i++)
1304 ok(test_decl[
i].
Type == decl1[
i].
Type,
"Returned type %d, expected %d\n", test_decl[
i].
Type, decl1[
i].
Type);
1305 ok(test_decl[
i].Method == decl1[
i].Method,
"Returned method %d, expected %d\n", test_decl[
i].Method, decl1[
i].Method);
1307 ok(test_decl[
i].UsageIndex == decl1[
i].UsageIndex,
"Returned usage index %d, expected %d\n", test_decl[
i].UsageIndex, decl1[
i].UsageIndex);
1310 ok(decl1[
size-1].
Stream == 0xFF,
"Returned too long vertex declaration\n");
1314 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1320 skip(
"Couldn't create mesh\n");
1333 d3dxmesh->lpVtbl->Release(d3dxmesh);
1338 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
1343 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh,
NULL);
1346 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1348 ok(test_device ==
device,
"Got result %p, expected %p\n", test_device,
device);
1356 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1357 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
1362 for (
i = 0;
i <
size - 1;
i++)
1365 ok(test_decl[
i].
Type == decl2[
i].
Type,
"Returned type %d, expected %d\n", test_decl[
i].
Type, decl2[
i].
Type);
1366 ok(test_decl[
i].Method == decl2[
i].Method,
"Returned method %d, expected %d\n", test_decl[
i].Method, decl2[
i].Method);
1368 ok(test_decl[
i].UsageIndex == decl2[
i].UsageIndex,
"Returned usage index %d, expected %d\n", test_decl[
i].UsageIndex, decl2[
i].UsageIndex);
1371 ok(decl2[
size-1].
Stream == 0xFF,
"Returned too long vertex declaration\n");
1375 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1381 skip(
"Couldn't create mesh\n");
1398 d3dxmesh->lpVtbl->Release(d3dxmesh);
1411 IDirect3DDevice9 *
device, *test_device;
1412 ID3DXMesh *d3dxmesh;
1435 skip(
"Couldn't create test context\n");
1451 d3dxmesh->lpVtbl->Release(d3dxmesh);
1461 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
1466 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh,
NULL);
1469 hr = d3dxmesh->lpVtbl->GetDevice(d3dxmesh, &test_device);
1471 ok(test_device ==
device,
"Got result %p, expected %p\n", test_device,
device);
1479 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh,
NULL);
1482 hr = d3dxmesh->lpVtbl->GetDeclaration(d3dxmesh, test_decl);
1483 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
1488 for (
i = 0;
i <
size - 1;
i++)
1491 ok(test_decl[
i].
Type == decl[
i].
Type,
"Returned type %d, expected %d\n", test_decl[
i].
Type, decl[
i].
Type);
1492 ok(test_decl[
i].Method == decl[
i].Method,
"Returned method %d, expected %d\n", test_decl[
i].Method, decl[
i].Method);
1494 ok(test_decl[
i].UsageIndex == decl[
i].UsageIndex,
"Returned usage index %d, expected %d\n",
1495 test_decl[
i].UsageIndex, decl[
i].UsageIndex);
1498 ok(decl[
size-1].
Stream == 0xFF,
"Returned too long vertex declaration\n");
1502 options = d3dxmesh->lpVtbl->GetOptions(d3dxmesh);
1508 skip(
"Couldn't create mesh\n");
1521 d3dxmesh->lpVtbl->Release(d3dxmesh);
1527#define check_vertex_buffer(mesh, vertices, num_vertices, fvf) \
1528 check_vertex_buffer_(__LINE__, mesh, vertices, num_vertices, fvf)
1531 DWORD mesh_num_vertices =
mesh->lpVtbl->GetNumVertices(
mesh);
1533 const void *mesh_vertices;
1536 ok_(__FILE__,
line)(fvf == mesh_fvf,
"expected FVF %x, got %x\n", fvf, mesh_fvf);
1537 ok_(__FILE__,
line)(num_vertices == mesh_num_vertices,
1538 "Expected %u vertices, got %u\n", num_vertices, mesh_num_vertices);
1545 if (mesh_fvf == fvf) {
1548 for (
i = 0;
i <
min(num_vertices, mesh_num_vertices);
i++)
1550 const FLOAT *exp_float = vertices;
1551 const FLOAT *got_float = mesh_vertices;
1570 last_beta_dword =
TRUE;
1577 exp_float += pos_dim;
1578 got_float += pos_dim;
1580 if (last_beta_dword) {
1582 "Vertex[%u]: Expected last beta %08x, got %08x\n",
i, *(
DWORD*)exp_float, *(
DWORD*)got_float);
1595 "Vertex[%u]: Expected psize %g, got %g\n",
i, *exp_float, *got_float);
1601 "Vertex[%u]: Expected diffuse %08x, got %08x\n",
i, *(
DWORD*)exp_float, *(
DWORD*)got_float);
1607 "Vertex[%u]: Expected specular %08x, got %08x\n",
i, *(
DWORD*)exp_float, *(
DWORD*)got_float);
1613 for (
j = 0;
j < texcount;
j++) {
1614 DWORD dim = (((fvf >> (16 + 2 *
j)) + 1) & 0x03) + 1;
1621 vertices = (
BYTE*)vertices + vertex_size;
1622 mesh_vertices = (
BYTE*)mesh_vertices + vertex_size;
1626 mesh->lpVtbl->UnlockVertexBuffer(
mesh);
1629#define check_index_buffer(mesh, indices, num_indices, index_size) \
1630 check_index_buffer_(__LINE__, mesh, indices, num_indices, index_size)
1634 DWORD mesh_num_indices =
mesh->lpVtbl->GetNumFaces(
mesh) * 3;
1635 const void *mesh_indices;
1639 ok_(__FILE__,
line)(index_size == mesh_index_size,
1640 "Expected index size %u, got %u\n", index_size, mesh_index_size);
1641 ok_(__FILE__,
line)(num_indices == mesh_num_indices,
1642 "Expected %u indices, got %u\n", num_indices, mesh_num_indices);
1649 if (mesh_index_size == index_size) {
1650 for (
i = 0;
i <
min(num_indices, mesh_num_indices);
i++)
1652 if (index_size == 4)
1657 "Index[%u]: expected %u, got %u\n",
i, *(
WORD*)
indices, *(
WORD*)mesh_indices);
1659 mesh_indices = (
BYTE*)mesh_indices + index_size;
1662 mesh->lpVtbl->UnlockIndexBuffer(
mesh);
1665#define check_matrix(got, expected) check_matrix_(__LINE__, got, expected)
1669 for (
i = 0;
i < 4;
i++) {
1670 for (
j = 0;
j < 4;
j++) {
1672 "matrix[%u][%u]: expected %g, got %g\n",
1673 i,
j,
U(*expected).m[
i][
j],
U(*got).m[
i][
j]);
1681 "%sExpected (%g, %g, %g, %g), got (%g, %g, %g, %g)\n",
prefix,
1685#define check_materials(got, got_count, expected, expected_count) \
1686 check_materials_(__LINE__, got, got_count, expected, expected_count)
1692 ok_(__FILE__,
line)(got ==
NULL,
"Expected NULL material ptr, got %p\n", got);
1712#define check_generated_adjacency(mesh, got, epsilon) check_generated_adjacency_(__LINE__, mesh, got, epsilon)
1721 skip_(__FILE__,
line)(
"Out of memory\n");
1729 for (
i = 0;
i < num_faces;
i++)
1734 "Face %u adjacencies: Expected (%u, %u, %u), got (%u, %u, %u)\n",
i,
1736 got[
i * 3], got[
i * 3 + 1], got[
i * 3 + 2]);
1742#define check_generated_effects(materials, num_materials, effects) \
1743 check_generated_effects_(__LINE__, materials, num_materials, effects)
1747 static const struct {
1753#define EFFECT_TABLE_ENTRY(str, field) \
1754 {str, sizeof(str), sizeof(materials->MatD3D.field), offsetof(D3DXMATERIAL, MatD3D.field)}
1760#undef EFFECT_TABLE_ENTRY
1763 if (!num_materials) {
1764 ok_(__FILE__,
line)(effects ==
NULL,
"Expected NULL effects, got %p\n", effects);
1767 for (
i = 0;
i < num_materials;
i++)
1773 "effect[%u] NumDefaults: Expected %u, got %u\n",
i,
1780 "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n",
i,
j,
1783 "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n",
i,
j,
1786 "effect[%u].pDefaults[%u].NumBytes: Expected %u, got %u\n",
i,
j,
1793 "effect[%u].pDefaults[%u] float value %u: Expected %g, got %g\n",
i,
j,
k,
expected, got);
1798 static const char *expected_name =
"Texture0@Name";
1801 "effect[%u].pDefaults[%u].pParamName: Expected '%s', got '%s'\n",
i,
j,
1804 "effect[%u].pDefaults[%u].Type: Expected %u, got %u\n",
i,
j,
1806 if (materials[
i].pTextureFilename) {
1808 "effect[%u] texture filename length: Expected %u, got %u\n",
i,
1811 "effect[%u] texture filename: Expected '%s', got '%s'\n",
i,
1821 if (!
p)
return NULL;
1829 TRACECALLBACK(
"ID3DXAllocateHierarchyImpl_DestroyFrame(%p, %p)\n", iface, frame);
1842 TRACECALLBACK(
"ID3DXAllocateHierarchyImpl_CreateFrame(%p, '%s', %p)\n", iface,
name, new_frame);
1906 TRACECALLBACK(
"ID3DXAllocateHierarchyImpl_CreateMeshContainer(%p, '%s', %u, %p, %p, %p, %d, %p, %p, %p)\n",
1907 iface,
name,
mesh_data->Type,
U(*mesh_data).pMesh, materials, effects,
1908 num_materials, adjacency, skin_info, *new_mesh_container);
1921 if (num_materials) {
1927 for (
i = 0;
i < num_materials;
i++)
1929 for (
i = 0;
i < num_materials;
i++) {
1930 if (materials[
i].pTextureFilename) {
1940 for (
i = 0;
i < num_materials;
i++) {
1965 default_dest->
Type = default_src->
Type;
1972 ok(adjacency !=
NULL,
"Expected non-NULL adjacency, got NULL\n");
1975 ID3DXBaseMesh *basemesh = (ID3DXBaseMesh*)
U(*mesh_data).pMesh;
1976 DWORD num_faces = basemesh->lpVtbl->GetNumFaces(basemesh);
1977 size_t size = num_faces *
sizeof(
DWORD) * 3;
1985 trace(
"FIXME: copying adjacency data for patch mesh not implemented\n");
1990 if (
U(*mesh_data).pMesh)
1991 IUnknown_AddRef(
U(*mesh_data).pMesh);
1994 skin_info->lpVtbl->AddRef(skin_info);
2012#define test_LoadMeshFromX(device, xfile_str, vertex_array, fvf, index_array, materials_array, check_adjacency) \
2013 test_LoadMeshFromX_(__LINE__, device, xfile_str, sizeof(xfile_str) - 1, vertex_array, ARRAY_SIZE(vertex_array), fvf, \
2014 index_array, ARRAY_SIZE(index_array), sizeof(*index_array), materials_array, ARRAY_SIZE(materials_array), \
2017 const void *vertices,
DWORD num_vertices,
DWORD fvf,
const void *
indices,
DWORD num_indices,
size_t index_size,
2025 DWORD num_materials = 0;
2032 check_adjacency ? &adjacency :
NULL, &materials, &effects, &num_materials, &
mesh);
2041 check_materials_(
line, materials_ptr, num_materials, expected_materials, expected_num_materials);
2043 if (check_adjacency)
2049 IUnknown_Release(
mesh);
2055 static const char empty_xfile[] =
"xof 0303txt 0032";
2057 static const char simple_xfile[] =
2067 static const WORD simple_index_buffer[] = {0, 1, 2};
2068 static const D3DXVECTOR3 simple_vertex_buffer[] = {
2069 {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}
2072 static const char framed_xfile[] =
2075 "Mesh { 3; 0.0; 0.0; 0.0;, 0.0; 1.0; 0.0;, 1.0; 1.0; 0.0;; 1; 3; 0, 1, 2;; }"
2076 "FrameTransformMatrix {"
2077 "1.0, 0.0, 0.0, 0.0,"
2078 "0.0, 1.0, 0.0, 0.0,"
2079 "0.0, 0.0, 1.0, 0.0,"
2080 "0.0, 0.0, 2.0, 1.0;;"
2082 "Mesh { 3; 0.0; 0.0; 0.0;, 0.0; 1.0; 0.0;, 2.0; 1.0; 0.0;; 1; 3; 0, 1, 2;; }"
2083 "FrameTransformMatrix {"
2084 "1.0, 0.0, 0.0, 0.0,"
2085 "0.0, 1.0, 0.0, 0.0,"
2086 "0.0, 0.0, 1.0, 0.0,"
2087 "0.0, 0.0, 3.0, 1.0;;"
2089 "Mesh { 3; 0.0; 0.0; 0.0;, 0.0; 1.0; 0.0;, 3.0; 1.0; 0.0;; 1; 3; 0, 1, 2;; }"
2091 static const WORD framed_index_buffer[] = { 0, 1, 2 };
2092 static const D3DXVECTOR3 framed_vertex_buffers[3][3] = {
2093 {{0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}},
2094 {{0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {2.0, 1.0, 0.0}},
2095 {{0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {3.0, 1.0, 0.0}},
2097 static const WORD merged_index_buffer[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
2099 static const D3DXVECTOR3 merged_vertex_buffer[] = {
2100 {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0},
2101 {0.0, 0.0, 2.0}, {0.0, 1.0, 2.0}, {2.0, 1.0, 2.0},
2102 {0.0, 0.0, 5.0}, {0.0, 1.0, 5.0}, {3.0, 1.0, 5.0},
2106 static const char box_xfile[] =
2145 "MeshMaterialList materials {"
2149 "0, 0, 0, 1, 1, 1;;"
2152 "0.0; 0.0; 1.0; 1.0;;"
2162 "1.0; 1.0; 1.0; 1.0;;"
2169 "TextureFilename { \"texture.jpg\"; }"
2172 "MeshVertexColors {"
2175 "0; 0.0; 0.0; 0.0; 0.0;;"
2176 "1; 0.0; 0.0; 1.0; 0.1;;"
2177 "2; 0.0; 1.0; 0.0; 0.2;;"
2178 "3; 0.0; 1.0; 1.0; 0.3;;"
2179 "4; 1.0; 0.0; 0.0; 0.4;;"
2180 "5; 1.0; 0.0; 1.0; 0.5;;"
2181 "6; 1.0; 1.0; 0.0; 0.6;;"
2182 "7; 1.0; 1.0; 1.0; 0.7;;"
2184 "MeshTextureCoords {"
2197 static const WORD box_index_buffer[] = {
2211 static const struct {
2216 } box_vertex_buffer[] = {
2217 {{0.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, 0x00000000, {0.0, 1.0}},
2218 {{0.0, 0.0, 1.0}, {-1.0, 0.0, 0.0}, 0x1a0000ff, {1.0, 1.0}},
2219 {{0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}, 0x3300ff00, {0.0, 0.0}},
2220 {{0.0, 1.0, 1.0}, {-1.0, 0.0, 0.0}, 0x4d00ffff, {1.0, 0.0}},
2221 {{1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, 0x66ff0000, {1.0, 1.0}},
2222 {{1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, 0x80ff00ff, {0.0, 1.0}},
2223 {{1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, 0x99ffff00, {1.0, 0.0}},
2224 {{1.0, 1.0, 1.0}, {0.0, 1.0, 0.0}, 0xb3ffffff, {0.0, 0.0}},
2225 {{0.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, 0x3300ff00, {0.0, 0.0}},
2226 {{0.0, 1.0, 1.0}, {0.0, 1.0, 0.0}, 0x4d00ffff, {1.0, 0.0}},
2227 {{1.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, 0x99ffff00, {1.0, 0.0}},
2228 {{1.0, 1.0, 1.0}, {1.0, 0.0, 0.0}, 0xb3ffffff, {0.0, 0.0}},
2229 {{0.0, 0.0, 1.0}, {0.0, -1.0, 0.0}, 0x1a0000ff, {1.0, 1.0}},
2230 {{0.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, 0x00000000, {0.0, 1.0}},
2231 {{1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, 0x66ff0000, {1.0, 1.0}},
2232 {{1.0, 0.0, 1.0}, {0.0, -1.0, 0.0}, 0x80ff00ff, {0.0, 1.0}},
2233 {{0.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, 0x1a0000ff, {1.0, 1.0}},
2234 {{1.0, 0.0, 1.0}, {0.0, 0.0, 1.0}, 0x80ff00ff, {0.0, 1.0}},
2235 {{1.0, 1.0, 1.0}, {0.0, 0.0, 1.0}, 0xb3ffffff, {0.0, 0.0}},
2236 {{0.0, 1.0, 1.0}, {0.0, 0.0, 1.0}, 0x4d00ffff, {1.0, 0.0}},
2237 {{0.0, 0.0, 0.0}, {0.0, 0.0, -1.0}, 0x00000000, {0.0, 1.0}},
2238 {{0.0, 1.0, 0.0}, {0.0, 0.0, -1.0}, 0x3300ff00, {0.0, 0.0}},
2239 {{1.0, 1.0, 0.0}, {0.0, 0.0, -1.0}, 0x99ffff00, {1.0, 0.0}},
2240 {{1.0, 0.0, 0.0}, {0.0, 0.0, -1.0}, 0x66ff0000, {1.0, 1.0}},
2245 {0.0, 0.0, 1.0, 1.0},
2246 {0.0, 0.0, 0.0, 1.0},
2247 {1.0, 1.0, 1.0, 1.0},
2248 {0.0, 0.0, 0.0, 1.0},
2255 {1.0, 1.0, 1.0, 1.0},
2256 {0.0, 0.0, 0.0, 1.0},
2257 {1.0, 1.0, 1.0, 1.0},
2258 {0.0, 0.0, 0.0, 1.0},
2261 (
char *)
"texture.jpg",
2264 static const char box_anim_xfile[] =
2303 "MeshMaterialList materials {"
2307 "0, 0, 0, 1, 1, 1;;"
2310 "0.0; 0.0; 1.0; 1.0;;"
2320 "1.0; 1.0; 1.0; 1.0;;"
2327 "TextureFilename { \"texture.jpg\"; }"
2330 "MeshVertexColors {"
2333 "0; 0.0; 0.0; 0.0; 0.0;;"
2334 "1; 0.0; 0.0; 1.0; 0.1;;"
2335 "2; 0.0; 1.0; 0.0; 0.2;;"
2336 "3; 0.0; 1.0; 1.0; 0.3;;"
2337 "4; 1.0; 0.0; 0.0; 0.4;;"
2338 "5; 1.0; 0.0; 1.0; 0.5;;"
2339 "6; 1.0; 1.0; 0.0; 0.6;;"
2340 "7; 1.0; 1.0; 1.0; 0.7;;"
2342 "MeshTextureCoords {"
2356 "FrameTransformMatrix {"
2358 "1.0, 0.0, 0.0, 0.0,"
2359 "0.0, 1.0, 0.0, 0.0,"
2360 "0.0, 0.0, 1.0, 0.0,"
2361 "0.0, 0.0, 0.0, 1.0;;"
2365 "AnimationSet AnimationSet0 {"
2366 "Animation Animation0 {"
2372 "10; 3; -100.0, 0.0, 0.0;;,"
2373 "20; 3; -75.0, 0.0, 0.0;;,"
2374 "30; 3; -50.0, 0.0, 0.0;;,"
2375 "40; 3; -25.5, 0.0, 0.0;;,"
2376 "50; 3; 0.0, 0.0, 0.0;;,"
2377 "60; 3; 25.5, 0.0, 0.0;;,"
2378 "70; 3; 50.0, 0.0, 0.0;;,"
2379 "80; 3; 75.5, 0.0, 0.0;;,"
2380 "90; 3; 100.0, 0.0, 0.0;;;"
2390 {0.5, 0.5, 0.5, 0.0},
2391 {0.0, 0.0, 0.0, 0.0},
2392 {0.5, 0.5, 0.5, 0.0},
2393 {0.0, 0.0, 0.0, 0.0},
2405 ID3DXAnimationController *controller;
2409 skip(
"Couldn't create test context\n");
2444 ok(frame_hier->
Name ==
NULL,
"Expected NULL, got '%s'\n", frame_hier->
Name);
2462 controller = (ID3DXAnimationController *)0xdeadbeef;
2468 ok(controller !=
NULL,
"Animation Controller NULL.\n");
2473 controller->lpVtbl->Release(controller);
2478 controller = (ID3DXAnimationController *)0xdeadbeef;
2486 ok(!controller,
"Animation Controller returned.\n");
2487 ok(frame_hier->
Name ==
NULL,
"Expected NULL, got '%s'\n", frame_hier->
Name);
2512 ok(!
strcmp(frame_hier->
Name,
""),
"Expected '', got '%s'\n", frame_hier->
Name);
2518 for (
i = 0;
i < 3;
i++) {
2565 IUnknown_Release(
mesh);
2576 unsigned int i,
face;
2579 {-1.0f, -1.0f, -1.0f}, {-1.0f, -1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, -1.0f},
2580 {-1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, 1.0f, -1.0f},
2581 { 1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, -1.0f},
2582 {-1.0f, -1.0f, 1.0f}, {-1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, 1.0f},
2583 {-1.0f, -1.0f, 1.0f}, { 1.0f, -1.0f, 1.0f}, { 1.0f, 1.0f, 1.0f}, {-1.0f, 1.0f, 1.0f},
2584 {-1.0f, -1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f}
2588 {-1.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f}, { 1.0f, 0.0f, 0.0f},
2589 { 0.0f, -1.0f, 0.0f}, { 0.0f, 0.0f, 1.0f}, { 0.0f, 0.0f, -1.0f}
2601 for (
i = 0;
i < 24;
i++)
2612 for (
i = 0;
i < 12;
i++)
2630 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
2633 skip(
"Couldn't create box\n");
2639 skip(
"Couldn't create mesh\n");
2640 box->lpVtbl->Release(
box);
2651 box->lpVtbl->Release(
box);
2656 IDirect3DDevice9*
device;
2660 static const DWORD adjacency[36]=
2666 1, 3, 11, 5, 6, 10};
2672 skip(
"Couldn't create test context\n");
2698 ok(adjacency[
i]==
buffer[
i],
"expected adjacency %d: %#x, received %#x\n",
i,adjacency[
i],
buffer[
i]);
2700 box->lpVtbl->Release(
box);
2727 for (
i = 0;
i < sides; ++
i)
2754 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
2757 skip(
"Couldn't create polygon\n");
2763 skip(
"Couldn't create mesh\n");
2764 polygon->lpVtbl->Release(polygon);
2775 polygon->lpVtbl->Release(polygon);
2781 IDirect3DDevice9 *
device;
2790 skip(
"Couldn't create test context\n");
2804 polygon = (
void *)0xdeadbeef;
2805 adjacency = (
void *)0xdeadbeef;
2808 ok(polygon == (
void *)0xdeadbeef,
"Polygon was changed to %p\n", polygon);
2809 ok(adjacency == (
void *)0xdeadbeef,
"Adjacency was changed to %p\n", adjacency);
2816 ok(
hr ==
D3D_OK,
"Expected D3D_OK, received %#x\n",
hr);
2822 for (
i = 0;
i < 11; ++
i)
2829 polygon->lpVtbl->Release(polygon);
2872 angle = angle_start;
2873 for (
i = 0;
i <
n;
i++)
2877 angle += angle_step;
2891 float theta_step, theta_start;
2893 float phi_step, phi_start;
2895 DWORD number_of_vertices, number_of_faces;
2900 theta_step =
D3DX_PI / stacks;
2901 theta_start = theta_step;
2904 phi_step = -2 *
D3DX_PI / slices;
2917 number_of_vertices = 2 + slices * (stacks-1);
2918 number_of_faces = 2 * slices + (stacks - 2) * (2 * slices);
2920 if (!
new_mesh(
mesh, number_of_vertices, number_of_faces))
3031 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
3034 skip(
"Couldn't create sphere\n");
3040 skip(
"Couldn't create mesh\n");
3041 sphere->lpVtbl->Release(sphere);
3047 sprintf(
name,
"sphere (%g, %u, %u)", radius, slices, stacks);
3052 sphere->lpVtbl->Release(sphere);
3058 IDirect3DDevice9*
device;
3059 ID3DXMesh* sphere =
NULL;
3076 skip(
"Couldn't create test context\n");
3106 float theta_step, theta_start;
3108 FLOAT delta_radius, radius, radius_step;
3109 FLOAT z, z_step, z_normal;
3110 DWORD number_of_vertices, number_of_faces;
3115 theta_step = -2 *
D3DX_PI / slices;
3123 number_of_vertices = 2 + (slices * (3 + stacks));
3124 number_of_faces = 2 * slices + stacks * (2 * slices);
3126 if (!
new_mesh(
mesh, number_of_vertices, number_of_faces))
3135 delta_radius = radius1 - radius2;
3137 radius_step = delta_radius / stacks;
3140 z_step =
length / stacks;
3141 z_normal = delta_radius /
length;
3142 if (
isnan(z_normal))
3210 if (
stack < stacks + 1)
3213 radius -= radius_step;
3258 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
3261 skip(
"Couldn't create cylinder\n");
3267 skip(
"Couldn't create mesh\n");
3274 sprintf(
name,
"cylinder (%g, %g, %g, %u, %u)", radius1, radius2,
length, slices, stacks);
3285 IDirect3DDevice9*
device;
3297 skip(
"Couldn't create test context\n");
3306 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
3317 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
3329 ok(
hr ==
D3D_OK,
"Got result %x, expected 0 (D3D_OK)\n",
hr);
3357 float phi, phi_step, sin_phi, cos_phi;
3358 float theta, theta_step, sin_theta, cos_theta;
3359 unsigned int numvert, numfaces,
i,
j;
3361 numvert = sides * rings;
3362 numfaces = numvert * 2;
3367 phi_step =
D3DX_PI / sides * 2.0f;
3368 theta_step =
D3DX_PI / rings * -2.0f;
3372 for (
i = 0;
i < rings; ++
i)
3376 cos_theta =
cosf(theta);
3377 sin_theta =
sinf(theta);
3379 for (
j = 0;
j < sides; ++
j)
3381 sin_phi =
sinf(phi);
3382 cos_phi =
cosf(phi);
3384 mesh->
vertices[
i * sides +
j].position.x = (innerradius * cos_phi + outerradius) * cos_theta;
3385 mesh->
vertices[
i * sides +
j].position.y = (innerradius * cos_phi + outerradius) * sin_theta;
3386 mesh->
vertices[
i * sides +
j].position.z = innerradius * sin_phi;
3394 theta += theta_step;
3397 for (
i = 0;
i < numfaces - sides * 2; ++
i)
3400 mesh->
faces[
i][1] = (
i / 2 + 1) % sides ?
i / 2 + 1 :
i / 2 + 1 - sides;
3401 mesh->
faces[
i][2] = (
i + 1) % (sides * 2) ? (
i + 1) / 2 + sides : (
i + 1) / 2;
3404 for (
j = 0;
i < numfaces; ++
i, ++
j)
3407 mesh->
faces[
i][1] = (
i / 2 + 1) % sides ?
i / 2 + 1 :
i / 2 + 1 - sides;
3408 mesh->
faces[
i][2] =
i == numfaces - 1 ? 0 : (
j + 1) / 2;