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
)(LPDIRECT3DRM
* ppDirect3DRM
);
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 D3DRMMATRIX4D identity
= {
68 { 1.0f
, 0.0f
, 0.0f
, 0.0f
},
69 { 0.0f
, 1.0f
, 0.0f
, 0.0f
},
70 { 0.0f
, 0.0f
, 1.0f
, 0.0f
},
71 { 0.0f
, 0.0f
, 0.0f
, 1.0f
}
74 static char data_bad_version
[] =
81 static char data_no_mesh
[] =
88 static char data_ok
[] =
107 static char data_full
[] =
109 "Header { 1; 0; 1; }\n"
117 " MeshMaterialList {\n"
120 " 0.0; 1.0; 0.0; 1.0;;\n"
124 " TextureFileName {\n"
125 " \"Texture.bmp\";\n"
137 " MeshTextureCoords {\n"
145 static char data_d3drm_load
[] =
172 " 0.1, 0.2, 0.3, 0.4;;\n"
178 static void test_MeshBuilder(void)
182 LPDIRECT3DRMMESHBUILDER pMeshBuilder
;
183 LPDIRECT3DRMMESH mesh
;
184 D3DRMLOADMEMORY info
;
186 DWORD val1
, val2
, val3
;
194 CHAR cname
[64] = {0};
196 hr
= pDirect3DRMCreate(&pD3DRM
);
197 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
199 hr
= IDirect3DRM_CreateMeshBuilder(pD3DRM
, &pMeshBuilder
);
200 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
202 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, NULL
, cname
);
203 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
204 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, NULL
, NULL
);
205 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
207 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, &size
, cname
);
208 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
209 size
= sizeof(cname
);
210 hr
= IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder
, &size
, cname
);
211 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
212 ok(size
== sizeof("Builder"), "wrong size: %u\n", size
);
213 ok(!strcmp(cname
, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname
);
215 info
.lpMemory
= data_bad_version
;
216 info
.dSize
= strlen(data_bad_version
);
217 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
218 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
220 info
.lpMemory
= data_no_mesh
;
221 info
.dSize
= strlen(data_no_mesh
);
222 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
223 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
225 info
.lpMemory
= data_ok
;
226 info
.dSize
= strlen(data_ok
);
227 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
228 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
231 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
232 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
233 ok(!strcmp(name
, "Object"), "Retrieved name '%s' instead of 'Object'\n", name
);
234 size
= strlen("Object"); /* No space for null character */
235 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
236 ok(hr
== E_INVALIDARG
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
237 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, NULL
);
238 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
240 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
241 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
242 ok(size
== 0, "Size should be 0 instead of %u\n", size
);
243 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, "");
244 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
246 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
247 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
248 ok(!strcmp(name
, ""), "Retrieved name '%s' instead of ''\n", name
);
250 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
251 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
253 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
254 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
256 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, NULL
, &val2
, NULL
, &val3
, NULL
);
257 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
258 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
259 ok(val2
== 4, "Wrong number of normals %d (must be 4)\n", val2
);
260 ok(val3
== 22, "Wrong number of face data bytes %d (must be 22)\n", val3
);
262 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
265 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
266 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
267 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
268 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
271 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 1, &valu
, &valv
);
272 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
273 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
274 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
277 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 2, &valu
, &valv
);
278 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
279 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
280 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
283 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 3, &valu
, &valv
);
284 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
285 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
286 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
287 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 4, &valu
, &valv
);
288 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
292 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 0, valu
, valv
);
293 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
294 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 4, valu
, valv
);
295 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
299 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
300 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
301 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
302 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
304 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
306 hr
= IDirect3DRM_CreateMeshBuilder(pD3DRM
, &pMeshBuilder
);
307 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
309 /* No group in mesh when mesh builder is not loaded */
310 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
311 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
316 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
317 ok(nb_groups
== 0, "GetCroupCount returned %u\n", nb_groups
);
319 IDirect3DRMMesh_Release(mesh
);
322 info
.lpMemory
= data_full
;
323 info
.dSize
= strlen(data_full
);
324 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
325 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
327 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
328 ok(val
== 3, "Wrong number of vertices %d (must be 3)\n", val
);
330 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
331 ok(val
== 1, "Wrong number of faces %d (must be 1)\n", val
);
333 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
334 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
335 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
336 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
337 ok(val3
== 8, "Wrong number of face data bytes %d (must be 8)\n", val3
);
338 ok(U1(v
[0]).x
== 0.1f
, "Wrong component v[0].x = %f (expected 0.1)\n", U1(v
[0]).x
);
339 ok(U2(v
[0]).y
== 0.2f
, "Wrong component v[0].y = %f (expected 0.2)\n", U2(v
[0]).y
);
340 ok(U3(v
[0]).z
== 0.3f
, "Wrong component v[0].z = %f (expected 0.3)\n", U3(v
[0]).z
);
341 ok(U1(v
[1]).x
== 0.4f
, "Wrong component v[1].x = %f (expected 0.4)\n", U1(v
[1]).x
);
342 ok(U2(v
[1]).y
== 0.5f
, "Wrong component v[1].y = %f (expected 0.5)\n", U2(v
[1]).y
);
343 ok(U3(v
[1]).z
== 0.6f
, "Wrong component v[1].z = %f (expected 0.6)\n", U3(v
[1]).z
);
344 ok(U1(v
[2]).x
== 0.7f
, "Wrong component v[2].x = %f (expected 0.7)\n", U1(v
[2]).x
);
345 ok(U2(v
[2]).y
== 0.8f
, "Wrong component v[2].y = %f (expected 0.8)\n", U2(v
[2]).y
);
346 ok(U3(v
[2]).z
== 0.9f
, "Wrong component v[2].z = %f (expected 0.9)\n", U3(v
[2]).z
);
347 ok(U1(n
[0]).x
== 1.1f
, "Wrong component n[0].x = %f (expected 1.1)\n", U1(n
[0]).x
);
348 ok(U2(n
[0]).y
== 1.2f
, "Wrong component n[0].y = %f (expected 1.2)\n", U2(n
[0]).y
);
349 ok(U3(n
[0]).z
== 1.3f
, "Wrong component n[0].z = %f (expected 1.3)\n", U3(n
[0]).z
);
350 ok(U1(n
[1]).x
== 1.4f
, "Wrong component n[1].x = %f (expected 1.4)\n", U1(n
[1]).x
);
351 ok(U2(n
[1]).y
== 1.5f
, "Wrong component n[1].y = %f (expected 1.5)\n", U2(n
[1]).y
);
352 ok(U3(n
[1]).z
== 1.6f
, "Wrong component n[1].z = %f (expected 1.6)\n", U3(n
[1]).z
);
353 ok(U1(n
[2]).x
== 1.7f
, "Wrong component n[2].x = %f (expected 1.7)\n", U1(n
[2]).x
);
354 ok(U2(n
[2]).y
== 1.8f
, "Wrong component n[2].y = %f (expected 1.8)\n", U2(n
[2]).y
);
355 ok(U3(n
[2]).z
== 1.9f
, "Wrong component n[2].z = %f (expected 1.9)\n", U3(n
[2]).z
);
356 ok(f
[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f
[0]);
357 ok(f
[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f
[1]);
358 ok(f
[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f
[2]);
359 ok(f
[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f
[3]);
360 ok(f
[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f
[4]);
361 ok(f
[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f
[5]);
362 ok(f
[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f
[6]);
363 ok(f
[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f
[7]);
365 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
366 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
370 unsigned nb_vertices
, nb_faces
, nb_face_vertices
;
372 LPDIRECT3DRMMATERIAL material
= (LPDIRECT3DRMMATERIAL
)0xdeadbeef;
373 LPDIRECT3DRMTEXTURE texture
= (LPDIRECT3DRMTEXTURE
)0xdeadbeef;
376 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
377 ok(nb_groups
== 1, "GetCroupCount returned %u\n", nb_groups
);
378 hr
= IDirect3DRMMesh_GetGroup(mesh
, 1, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
379 ok(hr
== D3DRMERR_BADVALUE
, "GetCroup returned hr = %x\n", hr
);
380 hr
= IDirect3DRMMesh_GetGroup(mesh
, 0, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
381 ok(hr
== D3DRM_OK
, "GetCroup failed returning hr = %x\n", hr
);
382 ok(nb_vertices
== 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices
);
383 ok(nb_faces
== 1, "Wrong number of faces %u (must be 1)\n", nb_faces
);
384 todo_wine
ok(nb_face_vertices
== 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices
);
385 todo_wine
ok(data_size
== 3, "Wrong number of face data bytes %u (must be 3)\n", data_size
);
386 color
= IDirect3DRMMesh_GetGroupColor(mesh
, 0);
387 ok(color
== 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color
, 0xff00ff00);
388 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, 0, &texture
);
389 ok(hr
== D3DRM_OK
, "GetCroupTexture failed returning hr = %x\n", hr
);
390 ok(texture
== NULL
, "No texture should be present\n");
391 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, 0, &material
);
392 ok(hr
== D3DRM_OK
, "GetCroupMaterial failed returning hr = %x\n", hr
);
393 ok(material
!= NULL
, "No material present\n");
394 if ((hr
== D3DRM_OK
) && material
)
396 hr
= IDirect3DRMMaterial_GetEmissive(material
, &values
[0], &values
[1], &values
[2]);
397 ok(hr
== D3DRM_OK
, "GetMaterialEmissive failed returning hr = %x\n", hr
);
398 ok(values
[0] == 0.5f
, "Emissive red component should be %f instead of %f\n", 0.5f
, values
[0]);
399 ok(values
[1] == 0.5f
, "Emissive green component should be %f instead of %f\n", 0.5f
, values
[1]);
400 ok(values
[2] == 0.5f
, "Emissive blue component should be %f instead of %f\n", 0.5f
, values
[2]);
401 hr
= IDirect3DRMMaterial_GetSpecular(material
, &values
[0], &values
[1], &values
[2]);
402 ok(hr
== D3DRM_OK
, "GetMaterialEmissive failed returning hr = %x\n", hr
);
403 ok(values
[0] == 1.0f
, "Specular red component should be %f instead of %f\n", 1.0f
, values
[0]);
404 ok(values
[1] == 0.0f
, "Specular green component should be %f instead of %f\n", 0.0f
, values
[1]);
405 ok(values
[2] == 0.0f
, "Specular blue component should be %f instead of %f\n", 0.0f
, values
[2]);
406 values
[0] = IDirect3DRMMaterial_GetPower(material
);
407 ok(values
[0] == 30.0f
, "Power value should be %f instead of %f\n", 30.0f
, values
[0]);
410 IDirect3DRMMesh_Release(mesh
);
413 hr
= IDirect3DRMMeshBuilder_Scale(pMeshBuilder
, 2, 3 ,4);
414 ok(hr
== D3DRM_OK
, "Scale failed returning hr = %x\n", hr
);
416 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
417 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
418 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
419 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
420 ok(U1(v
[0]).x
== 0.1f
*2, "Wrong component v[0].x = %f (expected %f)\n", U1(v
[0]).x
, 0.1f
*2);
421 ok(U2(v
[0]).y
== 0.2f
*3, "Wrong component v[0].y = %f (expected %f)\n", U2(v
[0]).y
, 0.2f
*3);
422 ok(U3(v
[0]).z
== 0.3f
*4, "Wrong component v[0].z = %f (expected %f)\n", U3(v
[0]).z
, 0.3f
*4);
423 ok(U1(v
[1]).x
== 0.4f
*2, "Wrong component v[1].x = %f (expected %f)\n", U1(v
[1]).x
, 0.4f
*2);
424 ok(U2(v
[1]).y
== 0.5f
*3, "Wrong component v[1].y = %f (expected %f)\n", U2(v
[1]).y
, 0.5f
*3);
425 ok(U3(v
[1]).z
== 0.6f
*4, "Wrong component v[1].z = %f (expected %f)\n", U3(v
[1]).z
, 0.6f
*4);
426 ok(U1(v
[2]).x
== 0.7f
*2, "Wrong component v[2].x = %f (expected %f)\n", U1(v
[2]).x
, 0.7f
*2);
427 ok(U2(v
[2]).y
== 0.8f
*3, "Wrong component v[2].y = %f (expected %f)\n", U2(v
[2]).y
, 0.8f
*3);
428 ok(U3(v
[2]).z
== 0.9f
*4, "Wrong component v[2].z = %f (expected %f)\n", U3(v
[2]).z
, 0.9f
*4);
429 /* Normals are not affected by Scale */
430 ok(U1(n
[0]).x
== 1.1f
, "Wrong component n[0].x = %f (expected %f)\n", U1(n
[0]).x
, 1.1f
);
431 ok(U2(n
[0]).y
== 1.2f
, "Wrong component n[0].y = %f (expected %f)\n", U2(n
[0]).y
, 1.2f
);
432 ok(U3(n
[0]).z
== 1.3f
, "Wrong component n[0].z = %f (expected %f)\n", U3(n
[0]).z
, 1.3f
);
433 ok(U1(n
[1]).x
== 1.4f
, "Wrong component n[1].x = %f (expected %f)\n", U1(n
[1]).x
, 1.4f
);
434 ok(U2(n
[1]).y
== 1.5f
, "Wrong component n[1].y = %f (expected %f)\n", U2(n
[1]).y
, 1.5f
);
435 ok(U3(n
[1]).z
== 1.6f
, "Wrong component n[1].z = %f (expected %f)\n", U3(n
[1]).z
, 1.6f
);
436 ok(U1(n
[2]).x
== 1.7f
, "Wrong component n[2].x = %f (expected %f)\n", U1(n
[2]).x
, 1.7f
);
437 ok(U2(n
[2]).y
== 1.8f
, "Wrong component n[2].y = %f (expected %f)\n", U2(n
[2]).y
, 1.8f
);
438 ok(U3(n
[2]).z
== 1.9f
, "Wrong component n[2].z = %f (expected %f)\n", U3(n
[2]).z
, 1.9f
);
440 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
442 IDirect3DRM_Release(pD3DRM
);
445 static void test_MeshBuilder3(void)
449 LPDIRECT3DRM3 pD3DRM3
;
450 LPDIRECT3DRMMESHBUILDER3 pMeshBuilder3
;
451 D3DRMLOADMEMORY info
;
456 CHAR cname
[64] = {0};
458 hr
= pDirect3DRMCreate(&pD3DRM
);
459 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
461 hr
= IDirect3DRM_QueryInterface(pD3DRM
, &IID_IDirect3DRM3
, (LPVOID
*)&pD3DRM3
);
464 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
465 IDirect3DRM_Release(pD3DRM
);
469 hr
= IDirect3DRM3_CreateMeshBuilder(pD3DRM3
, &pMeshBuilder3
);
470 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr
);
472 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, NULL
, cname
);
473 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
474 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, NULL
, NULL
);
475 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
477 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, &size
, cname
);
478 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
479 size
= sizeof(cname
);
480 hr
= IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3
, &size
, cname
);
481 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
482 ok(size
== sizeof("Builder"), "wrong size: %u\n", size
);
483 ok(!strcmp(cname
, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname
);
485 info
.lpMemory
= data_bad_version
;
486 info
.dSize
= strlen(data_bad_version
);
487 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
488 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
490 info
.lpMemory
= data_no_mesh
;
491 info
.dSize
= strlen(data_no_mesh
);
492 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
493 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
495 info
.lpMemory
= data_ok
;
496 info
.dSize
= strlen(data_ok
);
497 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
498 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
500 val
= IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3
);
501 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
503 val
= IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3
);
504 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
506 hr
= IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3
, 0, &val1
, NULL
);
507 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
508 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
510 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
513 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
514 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
515 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
516 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
519 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 1, &valu
, &valv
);
520 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
521 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
522 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
525 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 2, &valu
, &valv
);
526 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
527 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
528 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
531 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 3, &valu
, &valv
);
532 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
533 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
534 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
535 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 4, &valu
, &valv
);
536 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
540 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 0, valu
, valv
);
541 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
542 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 4, valu
, valv
);
543 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
547 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
548 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
549 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
550 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
552 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3
);
553 IDirect3DRM3_Release(pD3DRM3
);
554 IDirect3DRM_Release(pD3DRM
);
557 static void test_Mesh(void)
561 LPDIRECT3DRMMESH pMesh
;
563 CHAR cname
[64] = {0};
565 hr
= pDirect3DRMCreate(&pD3DRM
);
566 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
568 hr
= IDirect3DRM_CreateMesh(pD3DRM
, &pMesh
);
569 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr
);
571 hr
= IDirect3DRMMesh_GetClassName(pMesh
, NULL
, cname
);
572 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
573 hr
= IDirect3DRMMesh_GetClassName(pMesh
, NULL
, NULL
);
574 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
576 hr
= IDirect3DRMMesh_GetClassName(pMesh
, &size
, cname
);
577 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
578 size
= sizeof(cname
);
579 hr
= IDirect3DRMMesh_GetClassName(pMesh
, &size
, cname
);
580 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
581 ok(size
== sizeof("Mesh"), "wrong size: %u\n", size
);
582 ok(!strcmp(cname
, "Mesh"), "Expected cname to be \"Mesh\", but got \"%s\"\n", cname
);
584 IDirect3DRMMesh_Release(pMesh
);
586 IDirect3DRM_Release(pD3DRM
);
589 static void test_Frame(void)
593 LPDIRECT3DRMFRAME pFrameC
;
594 LPDIRECT3DRMFRAME pFrameP1
;
595 LPDIRECT3DRMFRAME pFrameP2
;
596 LPDIRECT3DRMFRAME pFrameTmp
;
597 LPDIRECT3DRMFRAMEARRAY pArray
;
598 LPDIRECT3DRMMESHBUILDER pMeshBuilder
;
599 LPDIRECT3DRMVISUAL pVisual1
;
600 LPDIRECT3DRMVISUAL pVisualTmp
;
601 LPDIRECT3DRMVISUALARRAY pVisualArray
;
602 LPDIRECT3DRMLIGHT pLight1
;
603 LPDIRECT3DRMLIGHT pLightTmp
;
604 LPDIRECT3DRMLIGHTARRAY pLightArray
;
606 CHAR cname
[64] = {0};
608 hr
= pDirect3DRMCreate(&pD3DRM
);
609 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
611 hr
= IDirect3DRM_CreateFrame(pD3DRM
, NULL
, &pFrameC
);
612 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
613 CHECK_REFCOUNT(pFrameC
, 1);
615 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, NULL
, cname
);
616 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
617 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, NULL
, NULL
);
618 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
620 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, &count
, cname
);
621 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
622 count
= sizeof(cname
);
623 hr
= IDirect3DRMFrame_GetClassName(pFrameC
, &count
, cname
);
624 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
625 ok(count
== sizeof("Frame"), "wrong size: %u\n", count
);
626 ok(!strcmp(cname
, "Frame"), "Expected cname to be \"Frame\", but got \"%s\"\n", cname
);
628 hr
= IDirect3DRMFrame_GetParent(pFrameC
, NULL
);
629 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
630 pFrameTmp
= (void*)0xdeadbeef;
631 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
632 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
633 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
634 CHECK_REFCOUNT(pFrameC
, 1);
637 hr
= IDirect3DRMFrame_GetChildren(pFrameC
, &pArray
);
638 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
639 ok(pArray
!= NULL
, "pArray = %p\n", pArray
);
642 count
= IDirect3DRMFrameArray_GetSize(pArray
);
643 ok(count
== 0, "count = %u\n", count
);
644 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
645 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
646 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
647 IDirect3DRMFrameArray_Release(pArray
);
650 hr
= IDirect3DRM_CreateFrame(pD3DRM
, NULL
, &pFrameP1
);
651 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
653 /* GetParent with NULL pointer */
654 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, NULL
);
655 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
656 CHECK_REFCOUNT(pFrameP1
, 1);
658 /* [Add/Delete]Child with NULL pointer */
659 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, NULL
);
660 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
661 CHECK_REFCOUNT(pFrameP1
, 1);
663 hr
= IDirect3DRMFrame_DeleteChild(pFrameP1
, NULL
);
664 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
665 CHECK_REFCOUNT(pFrameP1
, 1);
667 /* Add child to first parent */
668 pFrameTmp
= (void*)0xdeadbeef;
669 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, &pFrameTmp
);
670 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
671 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
673 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, pFrameC
);
674 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
675 CHECK_REFCOUNT(pFrameP1
, 1);
676 CHECK_REFCOUNT(pFrameC
, 2);
679 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &pArray
);
680 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
681 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
682 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
683 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
686 count
= IDirect3DRMFrameArray_GetSize(pArray
);
687 ok(count
== 1, "count = %u\n", count
);
688 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
689 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
690 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
691 ok((get_refcount((IUnknown
*)pFrameC
) == 4) || broken(get_refcount((IUnknown
*)pFrameC
) == 3),
692 "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown
*)pFrameC
));
693 IDirect3DRMFrame_Release(pFrameTmp
);
694 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
695 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
696 IDirect3DRMFrameArray_Release(pArray
);
697 CHECK_REFCOUNT(pFrameC
, 2);
700 pFrameTmp
= (void*)0xdeadbeef;
701 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
702 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
703 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
704 CHECK_REFCOUNT(pFrameP1
, 2);
706 /* Add child to second parent */
707 hr
= IDirect3DRM_CreateFrame(pD3DRM
, NULL
, &pFrameP2
);
708 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
710 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
711 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
712 CHECK_REFCOUNT(pFrameC
, 2);
715 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
716 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
719 count
= IDirect3DRMFrameArray_GetSize(pArray
);
720 ok(count
== 1, "count = %u\n", count
);
721 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
722 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
723 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
724 IDirect3DRMFrame_Release(pFrameTmp
);
725 IDirect3DRMFrameArray_Release(pArray
);
729 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &pArray
);
730 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
733 count
= IDirect3DRMFrameArray_GetSize(pArray
);
734 ok(count
== 0, "count = %u\n", count
);
735 pFrameTmp
= (void*)0xdeadbeef;
736 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
737 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
738 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
739 IDirect3DRMFrameArray_Release(pArray
);
742 pFrameTmp
= (void*)0xdeadbeef;
743 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
744 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
745 ok(pFrameTmp
== pFrameP2
, "pFrameTmp = %p\n", pFrameTmp
);
746 CHECK_REFCOUNT(pFrameP2
, 2);
747 CHECK_REFCOUNT(pFrameC
, 2);
749 /* Add child again */
750 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
751 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
752 CHECK_REFCOUNT(pFrameC
, 2);
755 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
756 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
759 count
= IDirect3DRMFrameArray_GetSize(pArray
);
760 ok(count
== 1, "count = %u\n", count
);
761 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
762 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
763 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
764 IDirect3DRMFrame_Release(pFrameTmp
);
765 IDirect3DRMFrameArray_Release(pArray
);
769 hr
= IDirect3DRMFrame_DeleteChild(pFrameP2
, pFrameC
);
770 ok(hr
== D3DRM_OK
, "Cannot delete child frame (hr = %x)\n", hr
);
771 CHECK_REFCOUNT(pFrameC
, 1);
774 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
775 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
778 count
= IDirect3DRMFrameArray_GetSize(pArray
);
779 ok(count
== 0, "count = %u\n", count
);
780 pFrameTmp
= (void*)0xdeadbeef;
781 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
782 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
783 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
784 IDirect3DRMFrameArray_Release(pArray
);
787 pFrameTmp
= (void*)0xdeadbeef;
788 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
789 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
790 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
792 /* Add two children */
793 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
794 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
795 CHECK_REFCOUNT(pFrameC
, 2);
797 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameP1
);
798 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
799 CHECK_REFCOUNT(pFrameP1
, 3);
802 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &pArray
);
803 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
806 count
= IDirect3DRMFrameArray_GetSize(pArray
);
807 ok(count
== 2, "count = %u\n", count
);
808 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 0, &pFrameTmp
);
809 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
810 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
811 IDirect3DRMFrame_Release(pFrameTmp
);
812 hr
= IDirect3DRMFrameArray_GetElement(pArray
, 1, &pFrameTmp
);
813 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
814 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
815 IDirect3DRMFrame_Release(pFrameTmp
);
816 IDirect3DRMFrameArray_Release(pArray
);
819 /* [Add/Delete]Visual with NULL pointer */
820 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, NULL
);
821 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
822 CHECK_REFCOUNT(pFrameP1
, 3);
824 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, NULL
);
825 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
826 CHECK_REFCOUNT(pFrameP1
, 3);
829 hr
= IDirect3DRM_CreateMeshBuilder(pD3DRM
, &pMeshBuilder
);
830 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
831 pVisual1
= (LPDIRECT3DRMVISUAL
)pMeshBuilder
;
833 /* Add Visual to first parent */
834 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, pVisual1
);
835 ok(hr
== D3DRM_OK
, "Cannot add visual (hr = %x)\n", hr
);
836 CHECK_REFCOUNT(pFrameP1
, 3);
837 CHECK_REFCOUNT(pVisual1
, 2);
840 hr
= IDirect3DRMFrame_GetVisuals(pFrameP1
, &pVisualArray
);
841 ok(hr
== D3DRM_OK
, "Cannot get visuals (hr = %x)\n", hr
);
844 count
= IDirect3DRMVisualArray_GetSize(pVisualArray
);
845 ok(count
== 1, "count = %u\n", count
);
846 hr
= IDirect3DRMVisualArray_GetElement(pVisualArray
, 0, &pVisualTmp
);
847 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
848 ok(pVisualTmp
== pVisual1
, "pVisualTmp = %p\n", pVisualTmp
);
849 IDirect3DRMVisual_Release(pVisualTmp
);
850 IDirect3DRMVisualArray_Release(pVisualArray
);
854 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, pVisual1
);
855 ok(hr
== D3DRM_OK
, "Cannot delete visual (hr = %x)\n", hr
);
856 CHECK_REFCOUNT(pFrameP1
, 3);
857 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
859 /* [Add/Delete]Light with NULL pointer */
860 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, NULL
);
861 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
862 CHECK_REFCOUNT(pFrameP1
, 3);
864 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, NULL
);
865 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
866 CHECK_REFCOUNT(pFrameP1
, 3);
869 hr
= IDirect3DRM_CreateLightRGB(pD3DRM
, D3DRMLIGHT_SPOT
, 0.1, 0.2, 0.3, &pLight1
);
870 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
872 /* Add Light to first parent */
873 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, pLight1
);
874 ok(hr
== D3DRM_OK
, "Cannot add light (hr = %x)\n", hr
);
875 CHECK_REFCOUNT(pFrameP1
, 3);
876 CHECK_REFCOUNT(pLight1
, 2);
879 hr
= IDirect3DRMFrame_GetLights(pFrameP1
, &pLightArray
);
880 ok(hr
== D3DRM_OK
, "Cannot get lights (hr = %x)\n", hr
);
883 count
= IDirect3DRMLightArray_GetSize(pLightArray
);
884 ok(count
== 1, "count = %u\n", count
);
885 hr
= IDirect3DRMLightArray_GetElement(pLightArray
, 0, &pLightTmp
);
886 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
887 ok(pLightTmp
== pLight1
, "pLightTmp = %p\n", pLightTmp
);
888 IDirect3DRMLight_Release(pLightTmp
);
889 IDirect3DRMLightArray_Release(pLightArray
);
893 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, pLight1
);
894 ok(hr
== D3DRM_OK
, "Cannot delete light (hr = %x)\n", hr
);
895 CHECK_REFCOUNT(pFrameP1
, 3);
896 IDirect3DRMLight_Release(pLight1
);
899 IDirect3DRMFrame_Release(pFrameP2
);
900 CHECK_REFCOUNT(pFrameC
, 2);
901 CHECK_REFCOUNT(pFrameP1
, 3);
903 IDirect3DRMFrame_Release(pFrameC
);
904 IDirect3DRMFrame_Release(pFrameP1
);
906 IDirect3DRM_Release(pD3DRM
);
909 static void test_Viewport(void)
913 LPDIRECTDRAWCLIPPER pClipper
;
914 LPDIRECT3DRMDEVICE pDevice
;
915 LPDIRECT3DRMFRAME pFrame
;
916 LPDIRECT3DRMVIEWPORT pViewport
;
921 CHAR cname
[64] = {0};
923 window
= CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW
, 0, 0, 300, 200, 0, 0, 0, 0);
924 GetClientRect(window
, &rc
);
926 hr
= pDirect3DRMCreate(&pD3DRM
);
927 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
929 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
930 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
932 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
933 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
935 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
936 hr
= IDirect3DRM3_CreateDeviceFromClipper(pD3DRM
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &pDevice
);
937 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
939 hr
= IDirect3DRM_CreateFrame(pD3DRM
, NULL
, &pFrame
);
940 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
942 hr
= IDirect3DRM_CreateViewport(pD3DRM
, pDevice
, pFrame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &pViewport
);
943 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr
);
945 hr
= IDirect3DRMViewport_GetClassName(pViewport
, NULL
, cname
);
946 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
947 hr
= IDirect3DRMViewport_GetClassName(pViewport
, NULL
, NULL
);
948 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
950 hr
= IDirect3DRMViewport_GetClassName(pViewport
, &size
, cname
);
951 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
952 size
= sizeof(cname
);
953 hr
= IDirect3DRMViewport_GetClassName(pViewport
, &size
, cname
);
954 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
955 ok(size
== sizeof("Viewport"), "wrong size: %u\n", size
);
956 ok(!strcmp(cname
, "Viewport"), "Expected cname to be \"Viewport\", but got \"%s\"\n", cname
);
958 IDirect3DRMViewport_Release(pViewport
);
959 IDirect3DRMFrame_Release(pFrame
);
960 IDirect3DRMDevice_Release(pDevice
);
961 IDirectDrawClipper_Release(pClipper
);
963 IDirect3DRM_Release(pD3DRM
);
964 DestroyWindow(window
);
967 static void test_Light(void)
971 LPDIRECT3DRMLIGHT pLight
;
975 CHAR cname
[64] = {0};
977 hr
= pDirect3DRMCreate(&pD3DRM
);
978 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
980 hr
= IDirect3DRM_CreateLightRGB(pD3DRM
, D3DRMLIGHT_SPOT
, 0.5, 0.5, 0.5, &pLight
);
981 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
983 hr
= IDirect3DRMLight_GetClassName(pLight
, NULL
, cname
);
984 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
985 hr
= IDirect3DRMLight_GetClassName(pLight
, NULL
, NULL
);
986 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
988 hr
= IDirect3DRMLight_GetClassName(pLight
, &size
, cname
);
989 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
990 size
= sizeof(cname
);
991 hr
= IDirect3DRMLight_GetClassName(pLight
, &size
, cname
);
992 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
993 ok(size
== sizeof("Light"), "wrong size: %u\n", size
);
994 ok(!strcmp(cname
, "Light"), "Expected cname to be \"Light\", but got \"%s\"\n", cname
);
996 type
= IDirect3DRMLight_GetType(pLight
);
997 ok(type
== D3DRMLIGHT_SPOT
, "wrong type (%u)\n", type
);
999 color
= IDirect3DRMLight_GetColor(pLight
);
1000 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
1002 hr
= IDirect3DRMLight_SetType(pLight
, D3DRMLIGHT_POINT
);
1003 ok(hr
== D3DRM_OK
, "Cannot set type (hr = %x)\n", hr
);
1004 type
= IDirect3DRMLight_GetType(pLight
);
1005 ok(type
== D3DRMLIGHT_POINT
, "wrong type (%u)\n", type
);
1007 hr
= IDirect3DRMLight_SetColor(pLight
, 0xff180587);
1008 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1009 color
= IDirect3DRMLight_GetColor(pLight
);
1010 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
1012 hr
= IDirect3DRMLight_SetColorRGB(pLight
, 0.5, 0.5, 0.5);
1013 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1014 color
= IDirect3DRMLight_GetColor(pLight
);
1015 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
1017 IDirect3DRMLight_Release(pLight
);
1019 IDirect3DRM_Release(pD3DRM
);
1022 static void test_Material2(void)
1025 LPDIRECT3DRM pD3DRM
;
1026 LPDIRECT3DRM3 pD3DRM3
;
1027 LPDIRECT3DRMMATERIAL2 pMaterial2
;
1030 CHAR cname
[64] = {0};
1032 hr
= pDirect3DRMCreate(&pD3DRM
);
1033 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1035 hr
= IDirect3DRM_QueryInterface(pD3DRM
, &IID_IDirect3DRM3
, (LPVOID
*)&pD3DRM3
);
1038 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
1039 IDirect3DRM_Release(pD3DRM
);
1043 hr
= IDirect3DRM3_CreateMaterial(pD3DRM3
, 18.5f
, &pMaterial2
);
1044 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr
);
1046 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, NULL
, cname
);
1047 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1048 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, NULL
, NULL
);
1049 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1051 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, &size
, cname
);
1052 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1053 size
= sizeof(cname
);
1054 hr
= IDirect3DRMMaterial2_GetClassName(pMaterial2
, &size
, cname
);
1055 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1056 ok(size
== sizeof("Material"), "wrong size: %u\n", size
);
1057 ok(!strcmp(cname
, "Material"), "Expected cname to be \"Material\", but got \"%s\"\n", cname
);
1059 r
= IDirect3DRMMaterial2_GetPower(pMaterial2
);
1060 ok(r
== 18.5f
, "wrong power (%f)\n", r
);
1062 hr
= IDirect3DRMMaterial2_GetEmissive(pMaterial2
, &r
, &g
, &b
);
1063 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1064 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
);
1066 hr
= IDirect3DRMMaterial2_GetSpecular(pMaterial2
, &r
, &g
, &b
);
1067 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1068 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
);
1070 hr
= IDirect3DRMMaterial2_GetAmbient(pMaterial2
, &r
, &g
, &b
);
1071 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1072 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
);
1074 hr
= IDirect3DRMMaterial2_SetPower(pMaterial2
, 5.87f
);
1075 ok(hr
== D3DRM_OK
, "Cannot set power (hr = %x)\n", hr
);
1076 r
= IDirect3DRMMaterial2_GetPower(pMaterial2
);
1077 ok(r
== 5.87f
, "wrong power (%f)\n", r
);
1079 hr
= IDirect3DRMMaterial2_SetEmissive(pMaterial2
, 0.5f
, 0.5f
, 0.5f
);
1080 ok(hr
== D3DRM_OK
, "Cannot set emissive (hr = %x)\n", hr
);
1081 hr
= IDirect3DRMMaterial2_GetEmissive(pMaterial2
, &r
, &g
, &b
);
1082 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
1083 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
);
1085 hr
= IDirect3DRMMaterial2_SetSpecular(pMaterial2
, 0.6f
, 0.6f
, 0.6f
);
1086 ok(hr
== D3DRM_OK
, "Cannot set specular (hr = %x)\n", hr
);
1087 hr
= IDirect3DRMMaterial2_GetSpecular(pMaterial2
, &r
, &g
, &b
);
1088 ok(hr
== D3DRM_OK
, "Cannot get specular (hr = %x)\n", hr
);
1089 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
);
1091 hr
= IDirect3DRMMaterial2_SetAmbient(pMaterial2
, 0.7f
, 0.7f
, 0.7f
);
1092 ok(hr
== D3DRM_OK
, "Cannot set ambient (hr = %x)\n", hr
);
1093 hr
= IDirect3DRMMaterial2_GetAmbient(pMaterial2
, &r
, &g
, &b
);
1094 ok(hr
== D3DRM_OK
, "Cannot get ambient (hr = %x)\n", hr
);
1095 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
);
1097 IDirect3DRMMaterial2_Release(pMaterial2
);
1099 IDirect3DRM3_Release(pD3DRM3
);
1100 IDirect3DRM_Release(pD3DRM
);
1103 static void test_Texture(void)
1106 LPDIRECT3DRM pD3DRM
;
1107 LPDIRECT3DRMTEXTURE pTexture
;
1108 D3DRMIMAGE initimg
= {
1110 TRUE
, 2 * sizeof(DWORD
), NULL
, NULL
,
1111 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
1113 DWORD pixel
[4] = { 20000, 30000, 10000, 0 };
1115 CHAR cname
[64] = {0};
1117 hr
= pDirect3DRMCreate(&pD3DRM
);
1118 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1120 initimg
.buffer1
= &pixel
;
1121 hr
= IDirect3DRM_CreateTexture(pD3DRM
, &initimg
, &pTexture
);
1122 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr
);
1124 hr
= IDirect3DRMTexture_GetClassName(pTexture
, NULL
, cname
);
1125 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1126 hr
= IDirect3DRMTexture_GetClassName(pTexture
, NULL
, NULL
);
1127 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1129 hr
= IDirect3DRMTexture_GetClassName(pTexture
, &size
, cname
);
1130 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1131 size
= sizeof(cname
);
1132 hr
= IDirect3DRMTexture_GetClassName(pTexture
, &size
, cname
);
1133 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1134 ok(size
== sizeof("Texture"), "wrong size: %u\n", size
);
1135 ok(!strcmp(cname
, "Texture"), "Expected cname to be \"Texture\", but got \"%s\"\n", cname
);
1137 IDirect3DRMTexture_Release(pTexture
);
1139 IDirect3DRM_Release(pD3DRM
);
1142 static void test_Device(void)
1145 LPDIRECT3DRM pD3DRM
;
1146 LPDIRECTDRAWCLIPPER pClipper
;
1147 LPDIRECT3DRMDEVICE pDevice
;
1148 LPDIRECT3DRMWINDEVICE pWinDevice
;
1153 CHAR cname
[64] = {0};
1155 window
= CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW
, 0, 0, 300, 200, 0, 0, 0, 0);
1156 GetClientRect(window
, &rc
);
1158 hr
= pDirect3DRMCreate(&pD3DRM
);
1159 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1161 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
1162 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
1164 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
1165 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
1167 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
1168 hr
= IDirect3DRM3_CreateDeviceFromClipper(pD3DRM
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &pDevice
);
1169 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1171 hr
= IDirect3DRMDevice_GetClassName(pDevice
, NULL
, cname
);
1172 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1173 hr
= IDirect3DRMDevice_GetClassName(pDevice
, NULL
, NULL
);
1174 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1176 hr
= IDirect3DRMDevice_GetClassName(pDevice
, &size
, cname
);
1177 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1178 size
= sizeof(cname
);
1179 hr
= IDirect3DRMDevice_GetClassName(pDevice
, &size
, cname
);
1180 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1181 ok(size
== sizeof("Device"), "wrong size: %u\n", size
);
1182 ok(!strcmp(cname
, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname
);
1185 hr
= IDirect3DRMDevice_QueryInterface(pDevice
, &IID_IDirect3DRMWinDevice
, (LPVOID
*)&pWinDevice
);
1188 win_skip("Cannot get IDirect3DRMWinDevice interface (hr = %x), skipping tests\n", hr
);
1192 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, NULL
, cname
);
1193 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1194 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, NULL
, NULL
);
1195 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1197 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, &size
, cname
);
1198 ok(hr
== E_INVALIDARG
, "GetClassName failed with %x\n", hr
);
1199 size
= sizeof(cname
);
1200 hr
= IDirect3DRMWinDevice_GetClassName(pWinDevice
, &size
, cname
);
1201 ok(hr
== D3DRM_OK
, "Cannot get classname (hr = %x)\n", hr
);
1202 ok(size
== sizeof("Device"), "wrong size: %u\n", size
);
1203 ok(!strcmp(cname
, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname
);
1205 IDirect3DRMWinDevice_Release(pWinDevice
);
1208 IDirect3DRMDevice_Release(pDevice
);
1209 IDirectDrawClipper_Release(pClipper
);
1211 IDirect3DRM_Release(pD3DRM
);
1212 DestroyWindow(window
);
1215 static void test_frame_transform(void)
1219 LPDIRECT3DRMFRAME frame
;
1220 D3DRMMATRIX4D matrix
;
1222 hr
= pDirect3DRMCreate(&d3drm
);
1223 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1225 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &frame
);
1226 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1228 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
1229 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr
);
1230 ok(!memcmp(matrix
, identity
, sizeof(D3DRMMATRIX4D
)), "Returned matrix is not identity\n");
1232 IDirect3DRM_Release(d3drm
);
1235 static int nb_objects
= 0;
1236 static const GUID
* refiids
[] =
1238 &IID_IDirect3DRMMeshBuilder
,
1239 &IID_IDirect3DRMMeshBuilder
,
1240 &IID_IDirect3DRMFrame
,
1241 &IID_IDirect3DRMMaterial
/* Not taken into account and not notified */
1244 static void __cdecl
object_load_callback(LPDIRECT3DRMOBJECT object
, REFIID objectguid
, LPVOID arg
)
1246 ok(object
!= NULL
, "Arg 1 should not be null\n");
1247 ok(IsEqualGUID(objectguid
, refiids
[nb_objects
]), "Arg 2 is incorrect\n");
1248 ok(arg
== (LPVOID
)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg
);
1252 static void test_d3drm_load(void)
1255 LPDIRECT3DRM pD3DRM
;
1256 D3DRMLOADMEMORY info
;
1257 const GUID
* req_refiids
[] = { &IID_IDirect3DRMMeshBuilder
, &IID_IDirect3DRMFrame
, &IID_IDirect3DRMMaterial
};
1259 hr
= pDirect3DRMCreate(&pD3DRM
);
1260 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1262 info
.lpMemory
= data_d3drm_load
;
1263 info
.dSize
= strlen(data_d3drm_load
);
1264 hr
= IDirect3DRM_Load(pD3DRM
, &info
, NULL
, (GUID
**)req_refiids
, 3, D3DRMLOAD_FROMMEMORY
, object_load_callback
, (LPVOID
)0xdeadbeef, NULL
, NULL
, NULL
);
1265 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
1266 ok(nb_objects
== 3, "Should have loaded 3 objects (got %d)\n", nb_objects
);
1268 IDirect3DRM_Release(pD3DRM
);
1273 if (!InitFunctionPtrs())
1277 test_MeshBuilder3();
1285 test_frame_transform();
1288 FreeLibrary(d3drm_handle
);