2 * Copyright 2010, 2012 Christian Costa
3 * Copyright 2012 André Hentschel
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
27 static HMODULE d3drm_handle
= 0;
29 static HRESULT (WINAPI
* pDirect3DRMCreate
)(IDirect3DRM
**d3drm
);
31 #define CHECK_REFCOUNT(obj,rc) \
34 int count = get_refcount( (IUnknown *)obj ); \
35 ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
38 #define D3DRM_GET_PROC(func) \
39 p ## func = (void*)GetProcAddress(d3drm_handle, #func); \
41 trace("GetProcAddress(%s) failed\n", #func); \
42 FreeLibrary(d3drm_handle); \
46 static BOOL
InitFunctionPtrs(void)
48 d3drm_handle
= LoadLibraryA("d3drm.dll");
52 skip("Could not load d3drm.dll\n");
56 D3DRM_GET_PROC(Direct3DRMCreate
)
61 static int get_refcount(IUnknown
*object
)
63 IUnknown_AddRef( object
);
64 return IUnknown_Release( object
);
67 static BOOL
match_float(float a
, float b
)
69 return (a
- b
) < 0.000001f
;
72 static D3DRMMATRIX4D identity
= {
73 { 1.0f
, 0.0f
, 0.0f
, 0.0f
},
74 { 0.0f
, 1.0f
, 0.0f
, 0.0f
},
75 { 0.0f
, 0.0f
, 1.0f
, 0.0f
},
76 { 0.0f
, 0.0f
, 0.0f
, 1.0f
}
79 static char data_bad_version
[] =
86 static char data_no_mesh
[] =
93 static char data_ok
[] =
112 static char data_full
[] =
114 "Header { 1; 0; 1; }\n"
122 " MeshMaterialList {\n"
125 " 0.0; 1.0; 0.0; 1.0;;\n"
129 " TextureFileName {\n"
130 " \"Texture.bmp\";\n"
142 " MeshTextureCoords {\n"
150 static char data_d3drm_load
[] =
177 " 0.1, 0.2, 0.3, 0.4;;\n"
183 static char data_frame_mesh_materials
[] =
185 "Header { 1; 0; 1; }\n"
201 " MeshMaterialList {\n"
202 " 3; 6; 0, 1, 1, 2, 2, 2;\n"
204 " 1.0; 0.0; 0.0; 0.1;;\n"
206 " 0.11; 0.12; 0.13;;\n"
207 " 0.14; 0.15; 0.16;;\n"
210 " 0.0; 1.0; 0.0; 0.2;;\n"
212 " 0.21; 0.22; 0.23;;\n"
213 " 0.24; 0.25; 0.26;;\n"
216 " 0.0; 0.0; 1.0; 0.3;;\n"
218 " 0.31; 0.32; 0.33;;\n"
219 " 0.34; 0.35; 0.36;;\n"
225 static void test_MeshBuilder(void)
229 LPDIRECT3DRMMESHBUILDER pMeshBuilder
;
230 LPDIRECT3DRMMESH mesh
;
231 D3DRMLOADMEMORY info
;
233 DWORD val1
, val2
, val3
;
241 CHAR cname
[64] = {0};
243 hr
= pDirect3DRMCreate(&d3drm
);
244 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
246 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
247 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
249 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, NULL
, cname
);
250 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
251 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, NULL
, NULL
);
252 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
254 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, &size
, cname
);
255 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
256 size
= sizeof(cname
);
257 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, &size
, cname
);
258 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
259 ok(size
== sizeof("Builder"), "wrong size: %u\n", size
);
260 ok(!strcmp(cname
, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname
);
262 info
.lpMemory
= data_bad_version
;
263 info
.dSize
= strlen(data_bad_version
);
264 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
265 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
267 info
.lpMemory
= data_no_mesh
;
268 info
.dSize
= strlen(data_no_mesh
);
269 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
270 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
272 info
.lpMemory
= data_ok
;
273 info
.dSize
= strlen(data_ok
);
274 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
275 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
278 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
279 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
280 ok(!strcmp(name
, "Object"), "Retrieved name '%s' instead of 'Object'\n", name
);
281 size
= strlen("Object"); /* No space for null character */
282 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
283 ok(hr
== E_INVALIDARG
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
284 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, NULL
);
285 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
287 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
288 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
289 ok(size
== 0, "Size should be 0 instead of %u\n", size
);
290 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, "");
291 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
293 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
294 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
295 ok(!strcmp(name
, ""), "Retrieved name '%s' instead of ''\n", name
);
297 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
298 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
300 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
301 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
303 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, NULL
, &val2
, NULL
, &val3
, NULL
);
304 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
305 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
306 ok(val2
== 4, "Wrong number of normals %d (must be 4)\n", val2
);
307 ok(val3
== 22, "Wrong number of face data bytes %d (must be 22)\n", val3
);
309 /* Check that Load method generated default normals */
310 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, NULL
, &val2
, n
, NULL
, NULL
);
311 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
312 ok(match_float(U1(n
[0]).x
, 0.577350f
), "Wrong component n[0].x = %f (expected %f)\n", U1(n
[0]).x
, 0.577350f
);
313 ok(match_float(U2(n
[0]).y
, 0.577350f
), "Wrong component n[0].y = %f (expected %f)\n", U2(n
[0]).y
, 0.577350f
);
314 ok(match_float(U3(n
[0]).z
, 0.577350f
), "Wrong component n[0].z = %f (expected %f)\n", U3(n
[0]).z
, 0.577350f
);
315 ok(match_float(U1(n
[1]).x
, -0.229416f
), "Wrong component n[1].x = %f (expected %f)\n", U1(n
[1]).x
, -0.229416f
);
316 ok(match_float(U2(n
[1]).y
, 0.688247f
), "Wrong component n[1].y = %f (expected %f)\n", U2(n
[1]).y
, 0.688247f
);
317 ok(match_float(U3(n
[1]).z
, 0.688247f
), "Wrong component n[1].z = %f (expected %f)\n", U3(n
[1]).z
, 0.688247f
);
318 ok(match_float(U1(n
[2]).x
, -0.229416f
), "Wrong component n[2].x = %f (expected %f)\n", U1(n
[2]).x
, -0.229416f
);
319 ok(match_float(U2(n
[2]).y
, 0.688247f
), "Wrong component n[2].y = %f (expected %f)\n", U2(n
[2]).y
, 0.688247f
);
320 ok(match_float(U3(n
[2]).z
, 0.688247f
), "Wrong component n[2].z = %f (expected %f)\n", U3(n
[2]).z
, 0.688247f
);
321 ok(match_float(U1(n
[3]).x
, -0.577350f
), "Wrong component n[3].x = %f (expected %f)\n", U1(n
[3]).x
, -0.577350f
);
322 ok(match_float(U2(n
[3]).y
, 0.577350f
), "Wrong component n[3].y = %f (expected %f)\n", U2(n
[3]).y
, 0.577350f
);
323 ok(match_float(U3(n
[3]).z
, 0.577350f
), "Wrong component n[3].z = %f (expected %f)\n", U3(n
[3]).z
, 0.577350f
);
325 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
328 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
329 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
330 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
331 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
334 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 1, &valu
, &valv
);
335 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
336 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
337 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
340 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 2, &valu
, &valv
);
341 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
342 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
343 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
346 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 3, &valu
, &valv
);
347 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
348 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
349 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
350 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 4, &valu
, &valv
);
351 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
355 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 0, valu
, valv
);
356 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
357 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 4, valu
, valv
);
358 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
362 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
363 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
364 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
365 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
367 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
369 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
370 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
372 /* No group in mesh when mesh builder is not loaded */
373 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
374 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
379 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
380 ok(nb_groups
== 0, "GetCroupCount returned %u\n", nb_groups
);
382 IDirect3DRMMesh_Release(mesh
);
385 info
.lpMemory
= data_full
;
386 info
.dSize
= strlen(data_full
);
387 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
388 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
390 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
391 ok(val
== 3, "Wrong number of vertices %d (must be 3)\n", val
);
393 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
394 ok(val
== 1, "Wrong number of faces %d (must be 1)\n", val
);
396 /* Check no buffer size and too small buffer size errors */
397 val1
= 1; val2
= 3; val3
= 8;
398 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
399 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
400 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, v
, &val2
, n
, &val3
, f
);
401 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
402 val1
= 3; val2
= 1; val3
= 8;
403 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
404 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
405 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, NULL
, n
, &val3
, f
);
406 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
407 val1
= 3; val2
= 3; val3
= 1;
408 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
409 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
410 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, NULL
, f
);
411 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
413 val1
= 3; val2
= 3; val3
= 8;
414 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
415 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
416 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
417 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
418 ok(val3
== 8, "Wrong number of face data bytes %d (must be 8)\n", val3
);
419 ok(U1(v
[0]).x
== 0.1f
, "Wrong component v[0].x = %f (expected 0.1)\n", U1(v
[0]).x
);
420 ok(U2(v
[0]).y
== 0.2f
, "Wrong component v[0].y = %f (expected 0.2)\n", U2(v
[0]).y
);
421 ok(U3(v
[0]).z
== 0.3f
, "Wrong component v[0].z = %f (expected 0.3)\n", U3(v
[0]).z
);
422 ok(U1(v
[1]).x
== 0.4f
, "Wrong component v[1].x = %f (expected 0.4)\n", U1(v
[1]).x
);
423 ok(U2(v
[1]).y
== 0.5f
, "Wrong component v[1].y = %f (expected 0.5)\n", U2(v
[1]).y
);
424 ok(U3(v
[1]).z
== 0.6f
, "Wrong component v[1].z = %f (expected 0.6)\n", U3(v
[1]).z
);
425 ok(U1(v
[2]).x
== 0.7f
, "Wrong component v[2].x = %f (expected 0.7)\n", U1(v
[2]).x
);
426 ok(U2(v
[2]).y
== 0.8f
, "Wrong component v[2].y = %f (expected 0.8)\n", U2(v
[2]).y
);
427 ok(U3(v
[2]).z
== 0.9f
, "Wrong component v[2].z = %f (expected 0.9)\n", U3(v
[2]).z
);
428 ok(U1(n
[0]).x
== 1.1f
, "Wrong component n[0].x = %f (expected 1.1)\n", U1(n
[0]).x
);
429 ok(U2(n
[0]).y
== 1.2f
, "Wrong component n[0].y = %f (expected 1.2)\n", U2(n
[0]).y
);
430 ok(U3(n
[0]).z
== 1.3f
, "Wrong component n[0].z = %f (expected 1.3)\n", U3(n
[0]).z
);
431 ok(U1(n
[1]).x
== 1.4f
, "Wrong component n[1].x = %f (expected 1.4)\n", U1(n
[1]).x
);
432 ok(U2(n
[1]).y
== 1.5f
, "Wrong component n[1].y = %f (expected 1.5)\n", U2(n
[1]).y
);
433 ok(U3(n
[1]).z
== 1.6f
, "Wrong component n[1].z = %f (expected 1.6)\n", U3(n
[1]).z
);
434 ok(U1(n
[2]).x
== 1.7f
, "Wrong component n[2].x = %f (expected 1.7)\n", U1(n
[2]).x
);
435 ok(U2(n
[2]).y
== 1.8f
, "Wrong component n[2].y = %f (expected 1.8)\n", U2(n
[2]).y
);
436 ok(U3(n
[2]).z
== 1.9f
, "Wrong component n[2].z = %f (expected 1.9)\n", U3(n
[2]).z
);
437 ok(f
[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f
[0]);
438 ok(f
[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f
[1]);
439 ok(f
[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f
[2]);
440 ok(f
[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f
[3]);
441 ok(f
[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f
[4]);
442 ok(f
[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f
[5]);
443 ok(f
[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f
[6]);
444 ok(f
[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f
[7]);
446 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
447 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
451 unsigned nb_vertices
, nb_faces
, nb_face_vertices
;
453 LPDIRECT3DRMMATERIAL material
= (LPDIRECT3DRMMATERIAL
)0xdeadbeef;
454 LPDIRECT3DRMTEXTURE texture
= (LPDIRECT3DRMTEXTURE
)0xdeadbeef;
457 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
458 ok(nb_groups
== 1, "GetCroupCount returned %u\n", nb_groups
);
459 hr
= IDirect3DRMMesh_GetGroup(mesh
, 1, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
460 ok(hr
== D3DRMERR_BADVALUE
, "GetCroup returned hr = %x\n", hr
);
461 hr
= IDirect3DRMMesh_GetGroup(mesh
, 0, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
462 ok(hr
== D3DRM_OK
, "GetCroup failed returning hr = %x\n", hr
);
463 ok(nb_vertices
== 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices
);
464 ok(nb_faces
== 1, "Wrong number of faces %u (must be 1)\n", nb_faces
);
465 ok(nb_face_vertices
== 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices
);
466 ok(data_size
== 3, "Wrong number of face data bytes %u (must be 3)\n", data_size
);
467 color
= IDirect3DRMMesh_GetGroupColor(mesh
, 0);
468 ok(color
== 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color
, 0xff00ff00);
469 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, 0, &texture
);
470 ok(hr
== D3DRM_OK
, "GetCroupTexture failed returning hr = %x\n", hr
);
471 ok(texture
== NULL
, "No texture should be present\n");
472 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, 0, &material
);
473 ok(hr
== D3DRM_OK
, "GetCroupMaterial failed returning hr = %x\n", hr
);
474 ok(material
!= NULL
, "No material present\n");
475 if ((hr
== D3DRM_OK
) && material
)
477 hr
= IDirect3DRMMaterial_GetEmissive(material
, &values
[0], &values
[1], &values
[2]);
478 ok(hr
== D3DRM_OK
, "GetMaterialEmissive failed returning hr = %x\n", hr
);
479 ok(values
[0] == 0.5f
, "Emissive red component should be %f instead of %f\n", 0.5f
, values
[0]);
480 ok(values
[1] == 0.5f
, "Emissive green component should be %f instead of %f\n", 0.5f
, values
[1]);
481 ok(values
[2] == 0.5f
, "Emissive blue component should be %f instead of %f\n", 0.5f
, values
[2]);
482 hr
= IDirect3DRMMaterial_GetSpecular(material
, &values
[0], &values
[1], &values
[2]);
483 ok(hr
== D3DRM_OK
, "GetMaterialEmissive failed returning hr = %x\n", hr
);
484 ok(values
[0] == 1.0f
, "Specular red component should be %f instead of %f\n", 1.0f
, values
[0]);
485 ok(values
[1] == 0.0f
, "Specular green component should be %f instead of %f\n", 0.0f
, values
[1]);
486 ok(values
[2] == 0.0f
, "Specular blue component should be %f instead of %f\n", 0.0f
, values
[2]);
487 values
[0] = IDirect3DRMMaterial_GetPower(material
);
488 ok(values
[0] == 30.0f
, "Power value should be %f instead of %f\n", 30.0f
, values
[0]);
491 IDirect3DRMMesh_Release(mesh
);
494 hr
= IDirect3DRMMeshBuilder_Scale(pMeshBuilder
, 2, 3 ,4);
495 ok(hr
== D3DRM_OK
, "Scale failed returning hr = %x\n", hr
);
497 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
498 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
499 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
500 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
501 ok(U1(v
[0]).x
== 0.1f
*2, "Wrong component v[0].x = %f (expected %f)\n", U1(v
[0]).x
, 0.1f
*2);
502 ok(U2(v
[0]).y
== 0.2f
*3, "Wrong component v[0].y = %f (expected %f)\n", U2(v
[0]).y
, 0.2f
*3);
503 ok(U3(v
[0]).z
== 0.3f
*4, "Wrong component v[0].z = %f (expected %f)\n", U3(v
[0]).z
, 0.3f
*4);
504 ok(U1(v
[1]).x
== 0.4f
*2, "Wrong component v[1].x = %f (expected %f)\n", U1(v
[1]).x
, 0.4f
*2);
505 ok(U2(v
[1]).y
== 0.5f
*3, "Wrong component v[1].y = %f (expected %f)\n", U2(v
[1]).y
, 0.5f
*3);
506 ok(U3(v
[1]).z
== 0.6f
*4, "Wrong component v[1].z = %f (expected %f)\n", U3(v
[1]).z
, 0.6f
*4);
507 ok(U1(v
[2]).x
== 0.7f
*2, "Wrong component v[2].x = %f (expected %f)\n", U1(v
[2]).x
, 0.7f
*2);
508 ok(U2(v
[2]).y
== 0.8f
*3, "Wrong component v[2].y = %f (expected %f)\n", U2(v
[2]).y
, 0.8f
*3);
509 ok(U3(v
[2]).z
== 0.9f
*4, "Wrong component v[2].z = %f (expected %f)\n", U3(v
[2]).z
, 0.9f
*4);
510 /* Normals are not affected by Scale */
511 ok(U1(n
[0]).x
== 1.1f
, "Wrong component n[0].x = %f (expected %f)\n", U1(n
[0]).x
, 1.1f
);
512 ok(U2(n
[0]).y
== 1.2f
, "Wrong component n[0].y = %f (expected %f)\n", U2(n
[0]).y
, 1.2f
);
513 ok(U3(n
[0]).z
== 1.3f
, "Wrong component n[0].z = %f (expected %f)\n", U3(n
[0]).z
, 1.3f
);
514 ok(U1(n
[1]).x
== 1.4f
, "Wrong component n[1].x = %f (expected %f)\n", U1(n
[1]).x
, 1.4f
);
515 ok(U2(n
[1]).y
== 1.5f
, "Wrong component n[1].y = %f (expected %f)\n", U2(n
[1]).y
, 1.5f
);
516 ok(U3(n
[1]).z
== 1.6f
, "Wrong component n[1].z = %f (expected %f)\n", U3(n
[1]).z
, 1.6f
);
517 ok(U1(n
[2]).x
== 1.7f
, "Wrong component n[2].x = %f (expected %f)\n", U1(n
[2]).x
, 1.7f
);
518 ok(U2(n
[2]).y
== 1.8f
, "Wrong component n[2].y = %f (expected %f)\n", U2(n
[2]).y
, 1.8f
);
519 ok(U3(n
[2]).z
== 1.9f
, "Wrong component n[2].z = %f (expected %f)\n", U3(n
[2]).z
, 1.9f
);
521 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
523 IDirect3DRM_Release(d3drm
);
526 static void test_MeshBuilder3(void)
530 LPDIRECT3DRM3 pD3DRM3
;
531 LPDIRECT3DRMMESHBUILDER3 pMeshBuilder3
;
532 D3DRMLOADMEMORY info
;
537 CHAR cname
[64] = {0};
539 hr
= pDirect3DRMCreate(&d3drm
);
540 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
542 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&pD3DRM3
)))
544 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
545 IDirect3DRM_Release(d3drm
);
549 hr
= IDirect3DRM3_CreateMeshBuilder(pD3DRM3
, &pMeshBuilder3
);
550 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr
);
552 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, NULL
, cname
);
553 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
554 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, NULL
, NULL
);
555 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
557 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, &size
, cname
);
558 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
559 size
= sizeof(cname
);
560 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, &size
, cname
);
561 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
562 ok(size
== sizeof("Builder"), "wrong size: %u\n", size
);
563 ok(!strcmp(cname
, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname
);
565 info
.lpMemory
= data_bad_version
;
566 info
.dSize
= strlen(data_bad_version
);
567 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
568 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
570 info
.lpMemory
= data_no_mesh
;
571 info
.dSize
= strlen(data_no_mesh
);
572 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
573 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
575 info
.lpMemory
= data_ok
;
576 info
.dSize
= strlen(data_ok
);
577 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
578 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
580 val
= IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3
);
581 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
583 val
= IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3
);
584 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
586 hr
= IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3
, 0, &val1
, NULL
);
587 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
588 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
590 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
593 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
594 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
595 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
596 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
599 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 1, &valu
, &valv
);
600 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
601 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
602 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
605 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 2, &valu
, &valv
);
606 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
607 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
608 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
611 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 3, &valu
, &valv
);
612 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
613 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
614 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
615 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 4, &valu
, &valv
);
616 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
620 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 0, valu
, valv
);
621 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
622 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 4, valu
, valv
);
623 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
627 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
628 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
629 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
630 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
632 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3
);
633 IDirect3DRM3_Release(pD3DRM3
);
634 IDirect3DRM_Release(d3drm
);
637 static void test_Mesh(void)
641 LPDIRECT3DRMMESH pMesh
;
643 CHAR cname
[64] = {0};
645 hr
= pDirect3DRMCreate(&d3drm
);
646 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
648 hr
= IDirect3DRM_CreateMesh(d3drm
, &pMesh
);
649 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr
);
651 hr
= IDirect3DRMMesh_GetClassName(pMesh
, NULL
, cname
);
652 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
653 hr
= IDirect3DRMMesh_GetClassName(pMesh
, NULL
, NULL
);
654 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
656 hr
= IDirect3DRMMesh_GetClassName(pMesh
, &size
, cname
);
657 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
658 size
= sizeof(cname
);
659 hr
= IDirect3DRMMesh_GetClassName(pMesh
, &size
, cname
);
660 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
661 ok(size
== sizeof("Mesh"), "wrong size: %u\n", size
);
662 ok(!strcmp(cname
, "Mesh"), "Expected cname to be \"Mesh\", but got \"%s\"\n", cname
);
664 IDirect3DRMMesh_Release(pMesh
);
666 IDirect3DRM_Release(d3drm
);
669 static void test_Frame(void)
673 LPDIRECT3DRMFRAME pFrameC
;
674 LPDIRECT3DRMFRAME pFrameP1
;
675 LPDIRECT3DRMFRAME pFrameP2
;
676 LPDIRECT3DRMFRAME pFrameTmp
;
677 LPDIRECT3DRMFRAMEARRAY pArray
;
678 LPDIRECT3DRMMESHBUILDER pMeshBuilder
;
679 LPDIRECT3DRMVISUAL pVisual1
;
680 LPDIRECT3DRMVISUAL pVisualTmp
;
681 LPDIRECT3DRMVISUALARRAY pVisualArray
;
682 LPDIRECT3DRMLIGHT pLight1
;
683 LPDIRECT3DRMLIGHT pLightTmp
;
684 LPDIRECT3DRMLIGHTARRAY pLightArray
;
687 CHAR cname
[64] = {0};
689 hr
= pDirect3DRMCreate(&d3drm
);
690 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
692 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameC
);
693 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
694 CHECK_REFCOUNT(pFrameC
, 1);
696 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, NULL
, cname
);
697 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
698 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, NULL
, NULL
);
699 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
701 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, &count
, cname
);
702 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
703 count
= sizeof(cname
);
704 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, &count
, cname
);
705 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
706 ok(count
== sizeof("Frame"), "wrong size: %u\n", count
);
707 ok(!strcmp(cname
, "Frame"), "Expected cname to be \"Frame\", but got \"%s\"\n", cname
);
709 hr
= IDirect3DRMFrame_GetParent(pFrameC
, NULL
);
710 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
711 pFrameTmp
= (void*)0xdeadbeef;
712 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
713 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
714 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
715 CHECK_REFCOUNT(pFrameC
, 1);
718 hr
= IDirect3DRMFrame_GetChildren(pFrameC
, &pArray
);
719 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
720 ok(pArray
!= NULL
, "pArray = %p\n", pArray
);
723 count
= IDirect3DRMFrameArray_GetSize(pArray
);
724 ok(count
== 0, "count = %u\n", count
);
725 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
726 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
727 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
728 IDirect3DRMFrameArray_Release(pArray
);
731 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP1
);
732 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
734 /* GetParent with NULL pointer */
735 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, NULL
);
736 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
737 CHECK_REFCOUNT(pFrameP1
, 1);
739 /* [Add/Delete]Child with NULL pointer */
740 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, NULL
);
741 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
742 CHECK_REFCOUNT(pFrameP1
, 1);
744 hr
= IDirect3DRMFrame_DeleteChild(pFrameP1
, NULL
);
745 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
746 CHECK_REFCOUNT(pFrameP1
, 1);
748 /* Add child to first parent */
749 pFrameTmp
= (void*)0xdeadbeef;
750 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, &pFrameTmp
);
751 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
752 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
754 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, pFrameC
);
755 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
756 CHECK_REFCOUNT(pFrameP1
, 1);
757 CHECK_REFCOUNT(pFrameC
, 2);
760 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &pArray
);
761 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
762 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
763 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
764 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
767 count
= IDirect3DRMFrameArray_GetSize(pArray
);
768 ok(count
== 1, "count = %u\n", count
);
769 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
770 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
771 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
772 ok((get_refcount((IUnknown
*)pFrameC
) == 4) || broken(get_refcount((IUnknown
*)pFrameC
) == 3),
773 "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown
*)pFrameC
));
774 IDirect3DRMFrame_Release(pFrameTmp
);
775 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
776 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
777 IDirect3DRMFrameArray_Release(pArray
);
778 CHECK_REFCOUNT(pFrameC
, 2);
781 pFrameTmp
= (void*)0xdeadbeef;
782 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
783 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
784 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
785 CHECK_REFCOUNT(pFrameP1
, 2);
787 /* Add child to second parent */
788 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP2
);
789 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
791 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
792 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
793 CHECK_REFCOUNT(pFrameC
, 2);
796 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
797 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
800 count
= IDirect3DRMFrameArray_GetSize(pArray
);
801 ok(count
== 1, "count = %u\n", count
);
802 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
803 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
804 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
805 IDirect3DRMFrame_Release(pFrameTmp
);
806 IDirect3DRMFrameArray_Release(pArray
);
810 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &pArray
);
811 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
814 count
= IDirect3DRMFrameArray_GetSize(pArray
);
815 ok(count
== 0, "count = %u\n", count
);
816 pFrameTmp
= (void*)0xdeadbeef;
817 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
818 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
819 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
820 IDirect3DRMFrameArray_Release(pArray
);
823 pFrameTmp
= (void*)0xdeadbeef;
824 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
825 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
826 ok(pFrameTmp
== pFrameP2
, "pFrameTmp = %p\n", pFrameTmp
);
827 CHECK_REFCOUNT(pFrameP2
, 2);
828 CHECK_REFCOUNT(pFrameC
, 2);
830 /* Add child again */
831 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
832 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
833 CHECK_REFCOUNT(pFrameC
, 2);
836 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
837 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
840 count
= IDirect3DRMFrameArray_GetSize(pArray
);
841 ok(count
== 1, "count = %u\n", count
);
842 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
843 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
844 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
845 IDirect3DRMFrame_Release(pFrameTmp
);
846 IDirect3DRMFrameArray_Release(pArray
);
850 hr
= IDirect3DRMFrame_DeleteChild(pFrameP2
, pFrameC
);
851 ok(hr
== D3DRM_OK
, "Cannot delete child frame (hr = %x)\n", hr
);
852 CHECK_REFCOUNT(pFrameC
, 1);
855 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
856 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
859 count
= IDirect3DRMFrameArray_GetSize(pArray
);
860 ok(count
== 0, "count = %u\n", count
);
861 pFrameTmp
= (void*)0xdeadbeef;
862 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
863 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
864 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
865 IDirect3DRMFrameArray_Release(pArray
);
868 pFrameTmp
= (void*)0xdeadbeef;
869 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
870 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
871 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
873 /* Add two children */
874 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
875 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
876 CHECK_REFCOUNT(pFrameC
, 2);
878 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameP1
);
879 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
880 CHECK_REFCOUNT(pFrameP1
, 3);
883 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
884 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
887 count
= IDirect3DRMFrameArray_GetSize(pArray
);
888 ok(count
== 2, "count = %u\n", count
);
889 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
890 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
891 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
892 IDirect3DRMFrame_Release(pFrameTmp
);
893 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 1, &pFrameTmp
);
894 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
895 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
896 IDirect3DRMFrame_Release(pFrameTmp
);
897 IDirect3DRMFrameArray_Release(pArray
);
900 /* [Add/Delete]Visual with NULL pointer */
901 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, NULL
);
902 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
903 CHECK_REFCOUNT(pFrameP1
, 3);
905 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, NULL
);
906 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
907 CHECK_REFCOUNT(pFrameP1
, 3);
910 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
911 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
912 pVisual1
= (LPDIRECT3DRMVISUAL
)pMeshBuilder
;
914 /* Add Visual to first parent */
915 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, pVisual1
);
916 ok(hr
== D3DRM_OK
, "Cannot add visual (hr = %x)\n", hr
);
917 CHECK_REFCOUNT(pFrameP1
, 3);
918 CHECK_REFCOUNT(pVisual1
, 2);
921 hr
= IDirect3DRMFrame_GetVisuals(pFrameP1
, &pVisualArray
);
922 ok(hr
== D3DRM_OK
, "Cannot get visuals (hr = %x)\n", hr
);
925 count
= IDirect3DRMVisualArray_GetSize(pVisualArray
);
926 ok(count
== 1, "count = %u\n", count
);
927 hr
= IDirect3DRMVisualArray_GetElement(pVisualArray
, 0, &pVisualTmp
);
928 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
929 ok(pVisualTmp
== pVisual1
, "pVisualTmp = %p\n", pVisualTmp
);
930 IDirect3DRMVisual_Release(pVisualTmp
);
931 IDirect3DRMVisualArray_Release(pVisualArray
);
935 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, pVisual1
);
936 ok(hr
== D3DRM_OK
, "Cannot delete visual (hr = %x)\n", hr
);
937 CHECK_REFCOUNT(pFrameP1
, 3);
938 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
940 /* [Add/Delete]Light with NULL pointer */
941 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, NULL
);
942 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
943 CHECK_REFCOUNT(pFrameP1
, 3);
945 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, NULL
);
946 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
947 CHECK_REFCOUNT(pFrameP1
, 3);
950 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.1, 0.2, 0.3, &pLight1
);
951 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
953 /* Add Light to first parent */
954 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, pLight1
);
955 ok(hr
== D3DRM_OK
, "Cannot add light (hr = %x)\n", hr
);
956 CHECK_REFCOUNT(pFrameP1
, 3);
957 CHECK_REFCOUNT(pLight1
, 2);
960 hr
= IDirect3DRMFrame_GetLights(pFrameP1
, &pLightArray
);
961 ok(hr
== D3DRM_OK
, "Cannot get lights (hr = %x)\n", hr
);
964 count
= IDirect3DRMLightArray_GetSize(pLightArray
);
965 ok(count
== 1, "count = %u\n", count
);
966 hr
= IDirect3DRMLightArray_GetElement(pLightArray
, 0, &pLightTmp
);
967 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
968 ok(pLightTmp
== pLight1
, "pLightTmp = %p\n", pLightTmp
);
969 IDirect3DRMLight_Release(pLightTmp
);
970 IDirect3DRMLightArray_Release(pLightArray
);
974 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, pLight1
);
975 ok(hr
== D3DRM_OK
, "Cannot delete light (hr = %x)\n", hr
);
976 CHECK_REFCOUNT(pFrameP1
, 3);
977 IDirect3DRMLight_Release(pLight1
);
979 /* Test SceneBackground on first parent */
980 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
981 ok(color
== 0xff000000, "wrong color (%x)\n", color
);
983 hr
= IDirect3DRMFrame_SetSceneBackground(pFrameP1
, 0xff180587);
984 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
985 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
986 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
988 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1
, 0.5, 0.5, 0.5);
989 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
990 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
991 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
994 IDirect3DRMFrame_Release(pFrameP2
);
995 CHECK_REFCOUNT(pFrameC
, 2);
996 CHECK_REFCOUNT(pFrameP1
, 3);
998 IDirect3DRMFrame_Release(pFrameC
);
999 IDirect3DRMFrame_Release(pFrameP1
);
1001 IDirect3DRM_Release(d3drm
);
1004 static void test_Viewport(void)
1006 IDirectDrawClipper
*pClipper
;
1009 LPDIRECT3DRMDEVICE pDevice
;
1010 LPDIRECT3DRMFRAME pFrame
;
1011 LPDIRECT3DRMVIEWPORT pViewport
;
1016 CHAR cname
[64] = {0};
1018 window
= CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW
, 0, 0, 300, 200, 0, 0, 0, 0);
1019 GetClientRect(window
, &rc
);
1021 hr
= pDirect3DRMCreate(&d3drm
);
1022 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1024 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
1025 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
1027 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
1028 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
1030 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
1031 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &pDevice
);
1032 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1034 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrame
);
1035 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1037 hr
= IDirect3DRM_CreateViewport(d3drm
, pDevice
, pFrame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &pViewport
);
1038 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr
);
1040 hr
= IDirect3DRMViewport_GetClassName(pViewport
, NULL
, cname
);
1041 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1042 hr
= IDirect3DRMViewport_GetClassName(pViewport
, NULL
, NULL
);
1043 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1045 hr
= IDirect3DRMViewport_GetClassName(pViewport
, &size
, cname
);
1046 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1047 size
= sizeof(cname
);
1048 hr
= IDirect3DRMViewport_GetClassName(pViewport
, &size
, cname
);
1049 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1050 ok(size
== sizeof("Viewport"), "wrong size: %u\n", size
);
1051 ok(!strcmp(cname
, "Viewport"), "Expected cname to be \"Viewport\", but got \"%s\"\n", cname
);
1053 IDirect3DRMViewport_Release(pViewport
);
1054 IDirect3DRMFrame_Release(pFrame
);
1055 IDirect3DRMDevice_Release(pDevice
);
1056 IDirectDrawClipper_Release(pClipper
);
1058 IDirect3DRM_Release(d3drm
);
1059 DestroyWindow(window
);
1062 static void test_Light(void)
1066 LPDIRECT3DRMLIGHT pLight
;
1067 D3DRMLIGHTTYPE type
;
1070 CHAR cname
[64] = {0};
1072 hr
= pDirect3DRMCreate(&d3drm
);
1073 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1075 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.5, 0.5, 0.5, &pLight
);
1076 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
1078 hr
= IDirect3DRMLight_GetClassName(pLight
, NULL
, cname
);
1079 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1080 hr
= IDirect3DRMLight_GetClassName(pLight
, NULL
, NULL
);
1081 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1083 hr
= IDirect3DRMLight_GetClassName(pLight
, &size
, cname
);
1084 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1085 size
= sizeof(cname
);
1086 hr
= IDirect3DRMLight_GetClassName(pLight
, &size
, cname
);
1087 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1088 ok(size
== sizeof("Light"), "wrong size: %u\n", size
);
1089 ok(!strcmp(cname
, "Light"), "Expected cname to be \"Light\", but got \"%s\"\n", cname
);
1091 type
= IDirect3DRMLight_GetType(pLight
);
1092 ok(type
== D3DRMLIGHT_SPOT
, "wrong type (%u)\n", type
);
1094 color
= IDirect3DRMLight_GetColor(pLight
);
1095 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
1097 hr
= IDirect3DRMLight_SetType(pLight
, D3DRMLIGHT_POINT
);
1098 ok(hr
== D3DRM_OK
, "Cannot set type (hr = %x)\n", hr
);
1099 type
= IDirect3DRMLight_GetType(pLight
);
1100 ok(type
== D3DRMLIGHT_POINT
, "wrong type (%u)\n", type
);
1102 hr
= IDirect3DRMLight_SetColor(pLight
, 0xff180587);
1103 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1104 color
= IDirect3DRMLight_GetColor(pLight
);
1105 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
1107 hr
= IDirect3DRMLight_SetColorRGB(pLight
, 0.5, 0.5, 0.5);
1108 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1109 color
= IDirect3DRMLight_GetColor(pLight
);
1110 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
1112 IDirect3DRMLight_Release(pLight
);
1114 IDirect3DRM_Release(d3drm
);
1117 static void test_Material2(void)
1121 LPDIRECT3DRM3 pD3DRM3
;
1122 LPDIRECT3DRMMATERIAL2 pMaterial2
;
1125 CHAR cname
[64] = {0};
1127 hr
= pDirect3DRMCreate(&d3drm
);
1128 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1130 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&pD3DRM3
)))
1132 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
1133 IDirect3DRM_Release(d3drm
);
1137 hr
= IDirect3DRM3_CreateMaterial(pD3DRM3
, 18.5f
, &pMaterial2
);
1138 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr
);
1140 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, NULL
, cname
);
1141 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1142 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, NULL
, NULL
);
1143 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1145 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, &size
, cname
);
1146 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1147 size
= sizeof(cname
);
1148 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, &size
, cname
);
1149 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1150 ok(size
== sizeof("Material"), "wrong size: %u\n", size
);
1151 ok(!strcmp(cname
, "Material"), "Expected cname to be \"Material\", but got \"%s\"\n", cname
);
1153 r
= IDirect3DRMMaterial2_GetPower(pMaterial2
);
1154 ok(r
== 18.5f
, "wrong power (%f)\n", r
);
1156 hr
= IDirect3DRMMaterial2_GetEmissive(pMaterial2
, &r
, &g
, &b
);
1157 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1158 ok(r
== 0.0f
&& g
== 0.0f
&& b
== 0.0f
, "wrong emissive r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r
, g
, b
);
1160 hr
= IDirect3DRMMaterial2_GetSpecular(pMaterial2
, &r
, &g
, &b
);
1161 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1162 ok(r
== 1.0f
&& g
== 1.0f
&& b
== 1.0f
, "wrong specular r=%f g=%f b=%f, expected r=1.0 g=1.0 b=1.0\n", r
, g
, b
);
1164 hr
= IDirect3DRMMaterial2_GetAmbient(pMaterial2
, &r
, &g
, &b
);
1165 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1166 ok(r
== 0.0f
&& g
== 0.0f
&& b
== 0.0f
, "wrong ambient r=%f g=%f b=%f, expected r=0.0 g=0.0 b=0.0\n", r
, g
, b
);
1168 hr
= IDirect3DRMMaterial2_SetPower(pMaterial2
, 5.87f
);
1169 ok(hr
== D3DRM_OK
, "Cannot set power (hr = %x)\n", hr
);
1170 r
= IDirect3DRMMaterial2_GetPower(pMaterial2
);
1171 ok(r
== 5.87f
, "wrong power (%f)\n", r
);
1173 hr
= IDirect3DRMMaterial2_SetEmissive(pMaterial2
, 0.5f
, 0.5f
, 0.5f
);
1174 ok(hr
== D3DRM_OK
, "Cannot set emissive (hr = %x)\n", hr
);
1175 hr
= IDirect3DRMMaterial2_GetEmissive(pMaterial2
, &r
, &g
, &b
);
1176 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1177 ok(r
== 0.5f
&& g
== 0.5f
&& b
== 0.5f
, "wrong emissive r=%f g=%f b=%f, expected r=0.5 g=0.5 b=0.5\n", r
, g
, b
);
1179 hr
= IDirect3DRMMaterial2_SetSpecular(pMaterial2
, 0.6f
, 0.6f
, 0.6f
);
1180 ok(hr
== D3DRM_OK
, "Cannot set specular (hr = %x)\n", hr
);
1181 hr
= IDirect3DRMMaterial2_GetSpecular(pMaterial2
, &r
, &g
, &b
);
1182 ok(hr
== D3DRM_OK
, "Cannot get specular (hr = %x)\n", hr
);
1183 ok(r
== 0.6f
&& g
== 0.6f
&& b
== 0.6f
, "wrong specular r=%f g=%f b=%f, expected r=0.6 g=0.6 b=0.6\n", r
, g
, b
);
1185 hr
= IDirect3DRMMaterial2_SetAmbient(pMaterial2
, 0.7f
, 0.7f
, 0.7f
);
1186 ok(hr
== D3DRM_OK
, "Cannot set ambient (hr = %x)\n", hr
);
1187 hr
= IDirect3DRMMaterial2_GetAmbient(pMaterial2
, &r
, &g
, &b
);
1188 ok(hr
== D3DRM_OK
, "Cannot get ambient (hr = %x)\n", hr
);
1189 ok(r
== 0.7f
&& g
== 0.7f
&& b
== 0.7f
, "wrong ambient r=%f g=%f b=%f, expected r=0.7 g=0.7 b=0.7\n", r
, g
, b
);
1191 IDirect3DRMMaterial2_Release(pMaterial2
);
1193 IDirect3DRM3_Release(pD3DRM3
);
1194 IDirect3DRM_Release(d3drm
);
1197 static void test_Texture(void)
1201 LPDIRECT3DRMTEXTURE pTexture
;
1202 D3DRMIMAGE initimg
= {
1204 TRUE
, 2 * sizeof(DWORD
), NULL
, NULL
,
1205 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
1207 DWORD pixel
[4] = { 20000, 30000, 10000, 0 };
1209 CHAR cname
[64] = {0};
1211 hr
= pDirect3DRMCreate(&d3drm
);
1212 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1214 initimg
.buffer1
= &pixel
;
1215 hr
= IDirect3DRM_CreateTexture(d3drm
, &initimg
, &pTexture
);
1216 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr
);
1218 hr
= IDirect3DRMTexture_GetClassName(pTexture
, NULL
, cname
);
1219 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1220 hr
= IDirect3DRMTexture_GetClassName(pTexture
, NULL
, NULL
);
1221 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1223 hr
= IDirect3DRMTexture_GetClassName(pTexture
, &size
, cname
);
1224 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1225 size
= sizeof(cname
);
1226 hr
= IDirect3DRMTexture_GetClassName(pTexture
, &size
, cname
);
1227 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1228 ok(size
== sizeof("Texture"), "wrong size: %u\n", size
);
1229 ok(!strcmp(cname
, "Texture"), "Expected cname to be \"Texture\", but got \"%s\"\n", cname
);
1231 IDirect3DRMTexture_Release(pTexture
);
1233 IDirect3DRM_Release(d3drm
);
1236 static void test_Device(void)
1238 IDirectDrawClipper
*pClipper
;
1241 LPDIRECT3DRMDEVICE pDevice
;
1242 LPDIRECT3DRMWINDEVICE pWinDevice
;
1247 CHAR cname
[64] = {0};
1249 window
= CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW
, 0, 0, 300, 200, 0, 0, 0, 0);
1250 GetClientRect(window
, &rc
);
1252 hr
= pDirect3DRMCreate(&d3drm
);
1253 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1255 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
1256 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
1258 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
1259 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
1261 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
1262 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &pDevice
);
1263 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1265 hr
= IDirect3DRMDevice_GetClassName(pDevice
, NULL
, cname
);
1266 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1267 hr
= IDirect3DRMDevice_GetClassName(pDevice
, NULL
, NULL
);
1268 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1270 hr
= IDirect3DRMDevice_GetClassName(pDevice
, &size
, cname
);
1271 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1272 size
= sizeof(cname
);
1273 hr
= IDirect3DRMDevice_GetClassName(pDevice
, &size
, cname
);
1274 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1275 ok(size
== sizeof("Device"), "wrong size: %u\n", size
);
1276 ok(!strcmp(cname
, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname
);
1279 hr
= IDirect3DRMDevice_QueryInterface(pDevice
, &IID_IDirect3DRMWinDevice
, (LPVOID
*)&pWinDevice
);
1282 win_skip("Cannot get IDirect3DRMWinDevice interface (hr = %x), skipping tests\n", hr
);
1286 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, NULL
, cname
);
1287 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1288 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, NULL
, NULL
);
1289 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1291 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, &size
, cname
);
1292 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1293 size
= sizeof(cname
);
1294 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, &size
, cname
);
1295 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1296 ok(size
== sizeof("Device"), "wrong size: %u\n", size
);
1297 ok(!strcmp(cname
, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname
);
1299 IDirect3DRMWinDevice_Release(pWinDevice
);
1302 IDirect3DRMDevice_Release(pDevice
);
1303 IDirectDrawClipper_Release(pClipper
);
1305 IDirect3DRM_Release(d3drm
);
1306 DestroyWindow(window
);
1309 static void test_frame_transform(void)
1313 LPDIRECT3DRMFRAME frame
;
1314 D3DRMMATRIX4D matrix
;
1316 hr
= pDirect3DRMCreate(&d3drm
);
1317 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1319 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &frame
);
1320 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1322 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
1323 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr
);
1324 ok(!memcmp(matrix
, identity
, sizeof(D3DRMMATRIX4D
)), "Returned matrix is not identity\n");
1326 IDirect3DRM_Release(d3drm
);
1329 static int nb_objects
= 0;
1330 static const GUID
* refiids
[] =
1332 &IID_IDirect3DRMMeshBuilder
,
1333 &IID_IDirect3DRMMeshBuilder
,
1334 &IID_IDirect3DRMFrame
,
1335 &IID_IDirect3DRMMaterial
/* Not taken into account and not notified */
1338 static void __cdecl
object_load_callback(LPDIRECT3DRMOBJECT object
, REFIID objectguid
, LPVOID arg
)
1340 ok(object
!= NULL
, "Arg 1 should not be null\n");
1341 ok(IsEqualGUID(objectguid
, refiids
[nb_objects
]), "Arg 2 is incorrect\n");
1342 ok(arg
== (LPVOID
)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg
);
1346 static void test_d3drm_load(void)
1350 D3DRMLOADMEMORY info
;
1351 const GUID
* req_refiids
[] = { &IID_IDirect3DRMMeshBuilder
, &IID_IDirect3DRMFrame
, &IID_IDirect3DRMMaterial
};
1353 hr
= pDirect3DRMCreate(&d3drm
);
1354 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1356 info
.lpMemory
= data_d3drm_load
;
1357 info
.dSize
= strlen(data_d3drm_load
);
1358 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 3, D3DRMLOAD_FROMMEMORY
,
1359 object_load_callback
, (void *)0xdeadbeef, NULL
, NULL
, NULL
);
1360 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
1361 ok(nb_objects
== 3, "Should have loaded 3 objects (got %d)\n", nb_objects
);
1363 IDirect3DRM_Release(d3drm
);
1366 IDirect3DRMMeshBuilder
*mesh_builder
= NULL
;
1368 static void __cdecl
object_load_callback_frame(IDirect3DRMObject
*object
, REFIID object_guid
, void *arg
)
1371 IDirect3DRMFrame
*frame
;
1372 IDirect3DRMVisualArray
*array
;
1373 IDirect3DRMVisual
*visual
;
1377 hr
= IDirect3DRMObject_QueryInterface(object
, &IID_IDirect3DRMFrame
, (void**)&frame
);
1378 ok(hr
== D3DRM_OK
, "IDirect3DRMObject_QueryInterface returned %x\n", hr
);
1380 hr
= IDirect3DRMFrame_GetVisuals(frame
, &array
);
1381 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetVisuals returned %x\n", hr
);
1383 size
= IDirect3DRMVisualArray_GetSize(array
);
1384 ok(size
== 1, "Wrong size %u returned, expected 1\n", size
);
1386 hr
= IDirect3DRMVisualArray_GetElement(array
, 0, &visual
);
1387 ok(hr
== D3DRM_OK
, "IDirect3DRMVisualArray_GetElement returned %x\n", hr
);
1389 hr
= IDirect3DRMVisual_QueryInterface(visual
, &IID_IDirect3DRMMeshBuilder
, (void**)&mesh_builder
);
1390 ok(hr
== D3DRM_OK
, "IDirect3DRMVisualArray_GetSize returned %x\n", hr
);
1392 size
= sizeof(name
);
1393 hr
= IDirect3DRMMeshBuilder_GetName(mesh_builder
, &size
, name
);
1394 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr
);
1395 ok(!strcmp(name
, "mesh1"), "Wrong name %s, expected mesh1\n", name
);
1397 IDirect3DRMVisual_Release(visual
);
1398 IDirect3DRMVisualArray_Release(array
);
1399 IDirect3DRMFrame_Release(frame
);
1405 int vertex_per_face
;
1412 { 4, 3, 3, 9, 0x4c0000ff, 30.0f
, { 0.31f
, 0.32f
, 0.33f
}, { 0.34f
, 0.35f
, 0.36f
} },
1413 { 4, 2, 3, 6, 0x3300ff00, 20.0f
, { 0.21f
, 0.22f
, 0.23f
}, { 0.24f
, 0.25f
, 0.26f
} },
1414 { 3, 1, 3, 3, 0x19ff0000, 10.0f
, { 0.11f
, 0.12f
, 0.13f
}, { 0.14f
, 0.15f
, 0.16f
} }
1417 static void test_frame_mesh_materials(void)
1421 D3DRMLOADMEMORY info
;
1422 const GUID
*req_refiids
[] = { &IID_IDirect3DRMFrame
};
1423 IDirect3DRMMesh
*mesh
;
1425 IDirect3DRMMaterial
*material
;
1426 IDirect3DRMTexture
*texture
;
1429 hr
= pDirect3DRMCreate(&d3drm
);
1430 ok(hr
== D3DRM_OK
, "Direct3DRMCreate returned %x\n", hr
);
1432 info
.lpMemory
= data_frame_mesh_materials
;
1433 info
.dSize
= strlen(data_frame_mesh_materials
);
1434 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 1, D3DRMLOAD_FROMMEMORY
, object_load_callback_frame
, (void*)0xdeadbeef, NULL
, NULL
, NULL
);
1435 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
1437 hr
= IDirect3DRMMeshBuilder_CreateMesh(mesh_builder
, &mesh
);
1438 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_CreateMesh returned %x\n", hr
);
1440 size
= IDirect3DRMMesh_GetGroupCount(mesh
);
1441 ok(size
== 3, "Wrong size %u returned, expected 3\n", size
);
1443 for (i
= 0; i
< size
; i
++)
1445 D3DVALUE red
, green
, blue
, power
;
1447 unsigned vertex_count
, face_count
, vertex_per_face
;
1448 DWORD face_data_size
;
1450 hr
= IDirect3DRMMesh_GetGroup(mesh
, i
, &vertex_count
, &face_count
, &vertex_per_face
, &face_data_size
, NULL
);
1451 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroup returned %x\n", i
, hr
);
1452 ok(vertex_count
== groups
[i
].vertex_count
, "Group %d: Wrong vertex count %d, expected %d\n", i
, vertex_count
, groups
[i
].vertex_count
);
1453 ok(face_count
== groups
[i
].face_count
, "Group %d: Wrong face count %d; expected %d\n", i
, face_count
, groups
[i
].face_count
);
1454 ok(vertex_per_face
== groups
[i
].vertex_per_face
, "Group %d: Wrong vertex per face %d, expected %d\n", i
, vertex_per_face
, groups
[i
].vertex_per_face
);
1455 ok(face_data_size
== groups
[i
].face_data_size
, "Group %d: Wrong face data size %d, expected %d\n", i
, face_data_size
, groups
[i
].face_data_size
);
1457 color
= IDirect3DRMMesh_GetGroupColor(mesh
, i
);
1458 ok(color
== groups
[i
].color
, "Group %d: Wrong color %x, expected %x\n", i
, color
, groups
[i
].color
);
1460 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, i
, &material
);
1461 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroupMaterial returned %x\n", i
, hr
);
1462 ok(material
!= NULL
, "Group %d: No material\n", i
);
1463 power
= IDirect3DRMMaterial_GetPower(material
);
1464 ok(power
== groups
[i
].power
, "Group %d: Wrong power %f, expected %f\n", i
, power
, groups
[i
].power
);
1465 hr
= IDirect3DRMMaterial_GetSpecular(material
, &red
, &green
, &blue
);
1466 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMaterial_GetSpecular returned %x\n", i
, hr
);
1467 ok(red
== groups
[i
].specular
[0], "Group %d: Wrong specular red %f, expected %f\n", i
, red
, groups
[i
].specular
[0]);
1468 ok(green
== groups
[i
].specular
[1], "Group %d: Wrong specular green %f, pD3DRMexpected %f\n", i
, green
, groups
[i
].specular
[1]);
1469 ok(blue
== groups
[i
].specular
[2], "Group %d: Wrong specular blue %f, expected %f\n", i
, blue
, groups
[i
].specular
[2]);
1470 hr
= IDirect3DRMMaterial_GetEmissive(material
, &red
, &green
, &blue
);
1471 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMaterial_GetEmissive returned %x\n", i
, hr
);
1472 ok(red
== groups
[i
].emissive
[0], "Group %d: Wrong emissive red %f, expected %f\n", i
, red
, groups
[i
].emissive
[0]);
1473 ok(green
== groups
[i
].emissive
[1], "Group %d: Wrong emissive green %f, expected %f\n", i
, green
, groups
[i
].emissive
[1]);
1474 ok(blue
== groups
[i
].emissive
[2], "Group %d: Wrong emissive blue %f, expected %f\n", i
, blue
, groups
[i
].emissive
[2]);
1476 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, i
, &texture
);
1477 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroupTexture returned %x\n", i
, hr
);
1478 ok(!texture
, "Group %d: Unexpected texture\n", i
);
1481 IDirect3DRMMaterial_Release(material
);
1483 IDirect3DRMTexture_Release(texture
);
1486 IDirect3DRMMesh_Release(mesh
);
1487 IDirect3DRMMeshBuilder_Release(mesh_builder
);
1488 IDirect3DRM_Release(d3drm
);
1493 if (!InitFunctionPtrs())
1497 test_MeshBuilder3();
1505 test_frame_transform();
1507 test_frame_mesh_materials();
1509 FreeLibrary(d3drm_handle
);