2 * Copyright 2010, 2012 Christian Costa
3 * Copyright 2012 André Hentschel
4 * Copyright 2011-2014 Henri Verbeet for CodeWeavers
5 * Copyright 2014-2015 Aaryaman Vasishta
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
32 #define CHECK_REFCOUNT(obj,rc) \
35 int count = get_refcount( (IUnknown *)obj ); \
36 ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
39 static ULONG
get_refcount(IUnknown
*object
)
41 IUnknown_AddRef( object
);
42 return IUnknown_Release( object
);
45 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
55 if (abs(x
- y
) > ulps
)
61 #define check_vector(a, b, c, d, e) check_vector_(__LINE__, a, b, c, d, e)
62 static void check_vector_(unsigned int line
, const D3DVECTOR
*v
, float x
, float y
, float z
, unsigned int ulps
)
64 BOOL ret
= compare_float(U1(v
)->x
, x
, ulps
)
65 && compare_float(U2(v
)->y
, y
, ulps
)
66 && compare_float(U3(v
)->z
, z
, ulps
);
68 ok_(__FILE__
, line
)(ret
, "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
69 U1(v
)->x
, U2(v
)->y
, U3(v
)->z
, x
, y
, z
);
72 #define vector_eq(a, b) vector_eq_(__LINE__, a, b)
73 static void vector_eq_(unsigned int line
, const D3DVECTOR
*left
, const D3DVECTOR
*right
)
75 check_vector_(line
, left
, U1(right
)->x
, U2(right
)->y
, U3(right
)->z
, 0);
78 static D3DRMMATRIX4D identity
= {
79 { 1.0f
, 0.0f
, 0.0f
, 0.0f
},
80 { 0.0f
, 1.0f
, 0.0f
, 0.0f
},
81 { 0.0f
, 0.0f
, 1.0f
, 0.0f
},
82 { 0.0f
, 0.0f
, 0.0f
, 1.0f
}
85 static HWND
create_window(void)
87 RECT r
= {0, 0, 640, 480};
89 AdjustWindowRect(&r
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, FALSE
);
91 return CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
92 CW_USEDEFAULT
, CW_USEDEFAULT
, r
.right
- r
.left
, r
.bottom
- r
.top
, NULL
, NULL
, NULL
, NULL
);
95 #define test_class_name(a, b) test_class_name_(__LINE__, a, b)
96 static void test_class_name_(unsigned int line
, IDirect3DRMObject
*object
, const char *name
)
102 hr
= IDirect3DRMObject_GetClassName(object
, NULL
, cname
);
103 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
104 hr
= IDirect3DRMViewport_GetClassName(object
, NULL
, NULL
);
105 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
108 hr
= IDirect3DRMObject_GetClassName(object
, &size
, NULL
);
109 ok_(__FILE__
, line
)(hr
== D3DRM_OK
, "Failed to get classname size, hr %#x.\n", hr
);
110 ok_(__FILE__
, line
)(size
== strlen(name
) + 1, "wrong size: %u\n", size
);
113 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
114 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
115 ok_(__FILE__
, line
)(size
== 1, "Got size %u.\n", size
);
117 size
= sizeof(cname
);
118 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
119 ok_(__FILE__
, line
)(hr
== D3DRM_OK
, "Failed to get classname, hr %#x.\n", hr
);
120 ok_(__FILE__
, line
)(size
== strlen(name
) + 1, "wrong size: %u\n", size
);
121 ok_(__FILE__
, line
)(!strcmp(cname
, name
), "Expected cname to be \"%s\", but got \"%s\".\n", name
, cname
);
123 size
= strlen(name
) + 1;
124 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
125 ok_(__FILE__
, line
)(hr
== D3DRM_OK
, "Failed to get classname, hr %#x.\n", hr
);
126 ok_(__FILE__
, line
)(size
== strlen(name
) + 1, "wrong size: %u\n", size
);
127 ok_(__FILE__
, line
)(!strcmp(cname
, name
), "Expected cname to be \"%s\", but got \"%s\".\n", name
, cname
);
130 strcpy(cname
, "XXX");
131 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
132 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
133 ok_(__FILE__
, line
)(size
== strlen(name
), "Wrong classname size: %u.\n", size
);
134 ok_(__FILE__
, line
)(!strcmp(cname
, "XXX"), "Expected unchanged buffer, but got \"%s\".\n", cname
);
137 static char data_bad_version
[] =
144 static char data_no_mesh
[] =
151 static char data_ok
[] =
170 static char data_full
[] =
172 "Header { 1; 0; 1; }\n"
180 " MeshMaterialList {\n"
183 " 0.0; 1.0; 0.0; 1.0;;\n"
187 " TextureFileName {\n"
188 " \"Texture.bmp\";\n"
200 " MeshTextureCoords {\n"
208 static char data_d3drm_load
[] =
235 " 0.1, 0.2, 0.3, 0.4;;\n"
241 static char data_frame_mesh_materials
[] =
243 "Header { 1; 0; 1; }\n"
259 " MeshMaterialList {\n"
260 " 3; 6; 0, 1, 1, 2, 2, 2;\n"
262 " 1.0; 0.0; 0.0; 0.1;;\n"
264 " 0.11; 0.12; 0.13;;\n"
265 " 0.14; 0.15; 0.16;;\n"
268 " 0.0; 1.0; 0.0; 0.2;;\n"
270 " 0.21; 0.22; 0.23;;\n"
271 " 0.24; 0.25; 0.26;;\n"
274 " 0.0; 0.0; 1.0; 0.3;;\n"
276 " 0.31; 0.32; 0.33;;\n"
277 " 0.34; 0.35; 0.36;;\n"
283 static void test_MeshBuilder(void)
287 IDirect3DRMMeshBuilder
*pMeshBuilder
;
288 IDirect3DRMMeshBuilder3
*meshbuilder3
;
289 IDirect3DRMMesh
*mesh
;
290 D3DRMLOADMEMORY info
;
292 DWORD val1
, val2
, val3
;
302 hr
= Direct3DRMCreate(&d3drm
);
303 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
305 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
306 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
308 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMObject
, (void **)&unk
);
309 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
310 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
311 IUnknown_Release(unk
);
313 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMVisual
, (void **)&unk
);
314 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMVisual, %#x.\n", hr
);
315 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
316 IUnknown_Release(unk
);
318 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMMeshBuilder3
, (void **)&meshbuilder3
);
319 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMMeshBuilder3, %#x.\n", hr
);
321 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3
, &IID_IDirect3DRMObject
, (void **)&unk
);
322 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
323 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
324 IUnknown_Release(unk
);
326 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3
, &IID_IDirect3DRMVisual
, (void **)&unk
);
327 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMVisual, %#x.\n", hr
);
328 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
329 IUnknown_Release(unk
);
331 IDirect3DRMMeshBuilder3_Release(meshbuilder3
);
333 test_class_name((IDirect3DRMObject
*)pMeshBuilder
, "Builder");
335 info
.lpMemory
= data_bad_version
;
336 info
.dSize
= strlen(data_bad_version
);
337 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
338 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
340 info
.lpMemory
= data_no_mesh
;
341 info
.dSize
= strlen(data_no_mesh
);
342 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
343 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
345 info
.lpMemory
= data_ok
;
346 info
.dSize
= strlen(data_ok
);
347 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
348 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
351 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
352 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
353 ok(!strcmp(name
, "Object"), "Retrieved name '%s' instead of 'Object'\n", name
);
354 size
= strlen("Object"); /* No space for null character */
355 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
356 ok(hr
== E_INVALIDARG
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
357 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, NULL
);
358 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
360 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
361 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
362 ok(size
== 0, "Size should be 0 instead of %u\n", size
);
363 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, "");
364 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
366 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
367 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
368 ok(!strcmp(name
, ""), "Retrieved name '%s' instead of ''\n", name
);
370 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
371 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
373 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
374 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
376 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, NULL
, &val2
, NULL
, &val3
, NULL
);
377 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
378 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
379 ok(val2
== 4, "Wrong number of normals %d (must be 4)\n", val2
);
380 ok(val3
== 22, "Wrong number of face data bytes %d (must be 22)\n", val3
);
382 /* Check that Load method generated default normals */
383 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, NULL
, &val2
, n
, NULL
, NULL
);
384 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
385 check_vector(&n
[0], 0.577350f
, 0.577350f
, 0.577350f
, 32);
386 check_vector(&n
[1], -0.229416f
, 0.688247f
, 0.688247f
, 32);
387 check_vector(&n
[2], -0.229416f
, 0.688247f
, 0.688247f
, 32);
388 check_vector(&n
[3], -0.577350f
, 0.577350f
, 0.577350f
, 32);
390 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
393 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
394 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
395 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
396 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
399 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 1, &valu
, &valv
);
400 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
401 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
402 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
405 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 2, &valu
, &valv
);
406 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
407 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
408 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
411 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 3, &valu
, &valv
);
412 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
413 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
414 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
415 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 4, &valu
, &valv
);
416 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
420 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 0, valu
, valv
);
421 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
422 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 4, valu
, valv
);
423 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
427 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
428 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
429 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
430 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
432 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
434 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
435 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
437 /* No group in mesh when mesh builder is not loaded */
438 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
439 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
444 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
445 ok(nb_groups
== 0, "GetCroupCount returned %u\n", nb_groups
);
447 IDirect3DRMMesh_Release(mesh
);
450 info
.lpMemory
= data_full
;
451 info
.dSize
= strlen(data_full
);
452 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
453 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
455 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
456 ok(val
== 3, "Wrong number of vertices %d (must be 3)\n", val
);
458 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
459 ok(val
== 1, "Wrong number of faces %d (must be 1)\n", val
);
461 /* Check no buffer size and too small buffer size errors */
462 val1
= 1; val2
= 3; val3
= 8;
463 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
464 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
465 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, v
, &val2
, n
, &val3
, f
);
466 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
467 val1
= 3; val2
= 1; val3
= 8;
468 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
469 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
470 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, NULL
, n
, &val3
, f
);
471 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
472 val1
= 3; val2
= 3; val3
= 1;
473 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
474 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
475 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, NULL
, f
);
476 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
478 val1
= 3; val2
= 3; val3
= 8;
479 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
480 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
481 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
482 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
483 ok(val3
== 8, "Wrong number of face data bytes %d (must be 8)\n", val3
);
484 check_vector(&v
[0], 0.1f
, 0.2f
, 0.3f
, 32);
485 check_vector(&v
[1], 0.4f
, 0.5f
, 0.6f
, 32);
486 check_vector(&v
[2], 0.7f
, 0.8f
, 0.9f
, 32);
487 check_vector(&n
[0], 1.1f
, 1.2f
, 1.3f
, 32);
488 check_vector(&n
[1], 1.4f
, 1.5f
, 1.6f
, 32);
489 check_vector(&n
[2], 1.7f
, 1.8f
, 1.9f
, 32);
490 ok(f
[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f
[0]);
491 ok(f
[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f
[1]);
492 ok(f
[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f
[2]);
493 ok(f
[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f
[3]);
494 ok(f
[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f
[4]);
495 ok(f
[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f
[5]);
496 ok(f
[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f
[6]);
497 ok(f
[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f
[7]);
499 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
500 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
504 unsigned nb_vertices
, nb_faces
, nb_face_vertices
;
506 IDirect3DRMMaterial
*material
= (IDirect3DRMMaterial
*)0xdeadbeef;
507 IDirect3DRMTexture
*texture
= (IDirect3DRMTexture
*)0xdeadbeef;
510 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
511 ok(nb_groups
== 1, "GetCroupCount returned %u\n", nb_groups
);
512 hr
= IDirect3DRMMesh_GetGroup(mesh
, 1, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
513 ok(hr
== D3DRMERR_BADVALUE
, "GetCroup returned hr = %x\n", hr
);
514 hr
= IDirect3DRMMesh_GetGroup(mesh
, 0, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
515 ok(hr
== D3DRM_OK
, "GetCroup failed returning hr = %x\n", hr
);
516 ok(nb_vertices
== 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices
);
517 ok(nb_faces
== 1, "Wrong number of faces %u (must be 1)\n", nb_faces
);
518 ok(nb_face_vertices
== 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices
);
519 ok(data_size
== 3, "Wrong number of face data bytes %u (must be 3)\n", data_size
);
520 color
= IDirect3DRMMesh_GetGroupColor(mesh
, 0);
521 ok(color
== 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color
, 0xff00ff00);
522 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, 0, &texture
);
523 ok(hr
== D3DRM_OK
, "GetCroupTexture failed returning hr = %x\n", hr
);
524 ok(texture
== NULL
, "No texture should be present\n");
525 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, 0, &material
);
526 ok(hr
== D3DRM_OK
, "GetCroupMaterial failed returning hr = %x\n", hr
);
527 ok(material
!= NULL
, "No material present\n");
528 hr
= IDirect3DRMMaterial_GetEmissive(material
, &values
[0], &values
[1], &values
[2]);
529 ok(hr
== D3DRM_OK
, "Failed to get emissive color, hr %#x.\n", hr
);
530 ok(values
[0] == 0.5f
, "Got unexpected red component %.8e.\n", values
[0]);
531 ok(values
[1] == 0.5f
, "Got unexpected green component %.8e.\n", values
[1]);
532 ok(values
[2] == 0.5f
, "Got unexpected blue component %.8e.\n", values
[2]);
533 hr
= IDirect3DRMMaterial_GetSpecular(material
, &values
[0], &values
[1], &values
[2]);
534 ok(hr
== D3DRM_OK
, "Failed to get specular color, hr %#x.\n", hr
);
535 ok(values
[0] == 1.0f
, "Got unexpected red component %.8e.\n", values
[0]);
536 ok(values
[1] == 0.0f
, "Got unexpected green component %.8e.\n", values
[1]);
537 ok(values
[2] == 0.0f
, "Got unexpected blue component %.8e.\n", values
[2]);
538 values
[0] = IDirect3DRMMaterial_GetPower(material
);
539 ok(values
[0] == 30.0f
, "Got unexpected power value %.8e.\n", values
[0]);
540 IDirect3DRMMaterial_Release(material
);
542 IDirect3DRMMesh_Release(mesh
);
545 hr
= IDirect3DRMMeshBuilder_Scale(pMeshBuilder
, 2, 3 ,4);
546 ok(hr
== D3DRM_OK
, "Scale failed returning hr = %x\n", hr
);
548 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
549 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
550 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
551 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
553 check_vector(&v
[0], 0.1f
* 2, 0.2f
* 3, 0.3f
* 4, 32);
554 check_vector(&v
[1], 0.4f
* 2, 0.5f
* 3, 0.6f
* 4, 32);
555 check_vector(&v
[2], 0.7f
* 2, 0.8f
* 3, 0.9f
* 4, 32);
556 /* Normals are not affected by Scale */
557 check_vector(&n
[0], 1.1f
, 1.2f
, 1.3f
, 32);
558 check_vector(&n
[1], 1.4f
, 1.5f
, 1.6f
, 32);
559 check_vector(&n
[2], 1.7f
, 1.8f
, 1.9f
, 32);
561 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
563 IDirect3DRM_Release(d3drm
);
566 static void test_MeshBuilder3(void)
570 IDirect3DRM3
*d3drm3
;
571 IDirect3DRMMeshBuilder3
*pMeshBuilder3
;
572 D3DRMLOADMEMORY info
;
577 hr
= Direct3DRMCreate(&d3drm
);
578 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
580 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
582 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
583 IDirect3DRM_Release(d3drm
);
587 hr
= IDirect3DRM3_CreateMeshBuilder(d3drm3
, &pMeshBuilder3
);
588 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr
);
590 test_class_name((IDirect3DRMObject
*)pMeshBuilder3
, "Builder");
592 info
.lpMemory
= data_bad_version
;
593 info
.dSize
= strlen(data_bad_version
);
594 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
595 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
597 info
.lpMemory
= data_no_mesh
;
598 info
.dSize
= strlen(data_no_mesh
);
599 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
600 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
602 info
.lpMemory
= data_ok
;
603 info
.dSize
= strlen(data_ok
);
604 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
605 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
607 val
= IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3
);
608 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
610 val
= IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3
);
611 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
613 hr
= IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3
, 0, &val1
, NULL
);
614 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
615 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
617 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
620 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
621 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
622 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
623 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
626 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 1, &valu
, &valv
);
627 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
628 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
629 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
632 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 2, &valu
, &valv
);
633 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
634 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
635 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
638 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 3, &valu
, &valv
);
639 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
640 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
641 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
642 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 4, &valu
, &valv
);
643 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
647 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 0, valu
, valv
);
648 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
649 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 4, valu
, valv
);
650 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
654 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
655 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
656 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
657 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
659 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3
);
660 IDirect3DRM3_Release(d3drm3
);
661 IDirect3DRM_Release(d3drm
);
664 static void test_Mesh(void)
668 IDirect3DRMMesh
*mesh
;
671 hr
= Direct3DRMCreate(&d3drm
);
672 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
674 hr
= IDirect3DRM_CreateMesh(d3drm
, &mesh
);
675 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr
);
677 test_class_name((IDirect3DRMObject
*)mesh
, "Mesh");
679 hr
= IDirect3DRMMesh_QueryInterface(mesh
, &IID_IDirect3DRMObject
, (void **)&unk
);
680 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
681 IUnknown_Release(unk
);
683 hr
= IDirect3DRMMesh_QueryInterface(mesh
, &IID_IDirect3DRMVisual
, (void **)&unk
);
684 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMVisual, %#x.\n", hr
);
685 IUnknown_Release(unk
);
687 IDirect3DRMMesh_Release(mesh
);
689 IDirect3DRM_Release(d3drm
);
692 static void test_Face(void)
696 IDirect3DRM2
*d3drm2
;
697 IDirect3DRM3
*d3drm3
;
698 IDirect3DRMMeshBuilder2
*MeshBuilder2
;
699 IDirect3DRMMeshBuilder3
*MeshBuilder3
;
700 IDirect3DRMFace
*face1
;
701 IDirect3DRMObject
*obj
;
702 IDirect3DRMFace2
*face2
;
703 IDirect3DRMFaceArray
*array1
;
704 D3DRMLOADMEMORY info
;
705 D3DVECTOR v1
[4], n1
[4], v2
[4], n2
[4];
709 hr
= Direct3DRMCreate(&d3drm
);
710 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
712 hr
= IDirect3DRM_CreateFace(d3drm
, &face1
);
713 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr
);
716 skip("Cannot get IDirect3DRMFace interface (hr = %x), skipping tests\n", hr
);
717 IDirect3DRM_Release(d3drm
);
721 hr
= IDirect3DRMFace_QueryInterface(face1
, &IID_IDirect3DRMObject
, (void **)&obj
);
722 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
723 ok(obj
== (IDirect3DRMObject
*)face1
, "Unexpected interface pointer.\n");
724 IDirect3DRMObject_Release(obj
);
726 test_class_name((IDirect3DRMObject
*)face1
, "Face");
728 icount
= IDirect3DRMFace_GetVertexCount(face1
);
729 ok(!icount
, "wrong VertexCount: %i\n", icount
);
731 IDirect3DRMFace_Release(face1
);
733 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM2
, (void **)&d3drm2
)))
735 win_skip("Cannot get IDirect3DRM2 interface (hr = %x), skipping tests\n", hr
);
736 IDirect3DRM_Release(d3drm
);
740 hr
= IDirect3DRM2_CreateMeshBuilder(d3drm2
, &MeshBuilder2
);
741 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder2 interface (hr = %x)\n", hr
);
743 icount
= IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2
);
744 ok(!icount
, "wrong FaceCount: %i\n", icount
);
747 hr
= IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2
, &array1
);
749 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
751 hr
= IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2
, &face1
);
752 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr
);
754 icount
= IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2
);
756 ok(icount
== 1, "wrong FaceCount: %i\n", icount
);
759 hr
= IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2
, &array1
);
761 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
763 ok(array1
!= NULL
, "pArray = %p\n", array1
);
766 IDirect3DRMFace
*face
;
767 count
= IDirect3DRMFaceArray_GetSize(array1
);
768 ok(count
== 1, "count = %u\n", count
);
769 hr
= IDirect3DRMFaceArray_GetElement(array1
, 0, &face
);
770 ok(hr
== D3DRM_OK
, "Cannot get face (hr = %x)\n", hr
);
771 IDirect3DRMFace_Release(face
);
772 IDirect3DRMFaceArray_Release(array1
);
775 icount
= IDirect3DRMFace_GetVertexCount(face1
);
776 ok(!icount
, "wrong VertexCount: %i\n", icount
);
778 IDirect3DRMFace_Release(face1
);
779 IDirect3DRMMeshBuilder2_Release(MeshBuilder2
);
781 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
783 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
784 IDirect3DRM_Release(d3drm
);
788 hr
= IDirect3DRM3_CreateMeshBuilder(d3drm3
, &MeshBuilder3
);
789 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr
);
791 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
792 ok(!icount
, "wrong FaceCount: %i\n", icount
);
794 hr
= IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3
, &face2
);
795 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace2 interface (hr = %x)\n", hr
);
797 hr
= IDirect3DRMFace2_QueryInterface(face2
, &IID_IDirect3DRMObject
, (void **)&obj
);
798 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
800 hr
= IDirect3DRMFace2_QueryInterface(face2
, &IID_IDirect3DRMFace
, (void **)&face1
);
801 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
802 ok(obj
== (IDirect3DRMObject
*)face1
, "Unexpected interface pointer.\n");
804 IDirect3DRMFace_Release(face1
);
805 IDirect3DRMObject_Release(obj
);
807 test_class_name((IDirect3DRMObject
*)face2
, "Face");
809 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
811 ok(icount
== 1, "wrong FaceCount: %i\n", icount
);
814 hr
= IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3
, &array1
);
816 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
818 ok(array1
!= NULL
, "pArray = %p\n", array1
);
821 IDirect3DRMFace
*face
;
822 count
= IDirect3DRMFaceArray_GetSize(array1
);
823 ok(count
== 1, "count = %u\n", count
);
824 hr
= IDirect3DRMFaceArray_GetElement(array1
, 0, &face
);
825 ok(hr
== D3DRM_OK
, "Cannot get face (hr = %x)\n", hr
);
826 IDirect3DRMFace_Release(face
);
827 IDirect3DRMFaceArray_Release(array1
);
830 icount
= IDirect3DRMFace2_GetVertexCount(face2
);
831 ok(!icount
, "wrong VertexCount: %i\n", icount
);
833 info
.lpMemory
= data_ok
;
834 info
.dSize
= strlen(data_ok
);
835 hr
= IDirect3DRMMeshBuilder3_Load(MeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
836 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
838 icount
= IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3
);
839 ok(icount
== 4, "Wrong number of vertices %d (must be 4)\n", icount
);
841 icount
= IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3
);
842 ok(icount
== 4, "Wrong number of normals %d (must be 4)\n", icount
);
844 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
846 ok(icount
== 4, "Wrong number of faces %d (must be 4)\n", icount
);
849 hr
= IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3
, 0, &count
, v1
);
850 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
851 ok(count
== 4, "Wrong number of vertices %d (must be 4)\n", count
);
853 hr
= IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3
, 0, &count
, n1
);
854 ok(hr
== D3DRM_OK
, "Cannot get normals information (hr = %x)\n", hr
);
855 ok(count
== 4, "Wrong number of normals %d (must be 4)\n", count
);
858 hr
= IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3
, &array1
);
860 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
862 ok(array1
!= NULL
, "pArray = %p\n", array1
);
865 IDirect3DRMFace
*face
;
866 count
= IDirect3DRMFaceArray_GetSize(array1
);
867 ok(count
== 4, "count = %u\n", count
);
868 hr
= IDirect3DRMFaceArray_GetElement(array1
, 1, &face
);
869 ok(hr
== D3DRM_OK
, "Cannot get face (hr = %x)\n", hr
);
870 hr
= IDirect3DRMFace_GetVertices(face
, &count
, v2
, n2
);
871 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
872 ok(count
== 3, "Wrong number of vertices %d (must be 3)\n", count
);
874 vector_eq(&v1
[0], &v2
[0]);
875 vector_eq(&v1
[1], &v2
[1]);
876 vector_eq(&v1
[2], &v2
[2]);
878 vector_eq(&n1
[0], &n2
[0]);
879 vector_eq(&n1
[1], &n2
[1]);
880 vector_eq(&n1
[2], &n2
[2]);
882 IDirect3DRMFace_Release(face
);
883 IDirect3DRMFaceArray_Release(array1
);
886 IDirect3DRMFace2_Release(face2
);
887 IDirect3DRMMeshBuilder3_Release(MeshBuilder3
);
888 IDirect3DRM3_Release(d3drm3
);
889 IDirect3DRM2_Release(d3drm2
);
890 IDirect3DRM_Release(d3drm
);
893 static void test_Frame(void)
897 IDirect3DRMFrame
*pFrameC
;
898 IDirect3DRMFrame
*pFrameP1
;
899 IDirect3DRMFrame
*pFrameP2
;
900 IDirect3DRMFrame
*pFrameTmp
;
901 IDirect3DRMFrame
*scene_frame
;
902 IDirect3DRMFrameArray
*frame_array
;
903 IDirect3DRMMeshBuilder
*mesh_builder
;
904 IDirect3DRMVisual
*visual1
;
905 IDirect3DRMVisual
*visual_tmp
;
906 IDirect3DRMVisualArray
*visual_array
;
907 IDirect3DRMLight
*light1
;
908 IDirect3DRMLight
*light_tmp
;
909 IDirect3DRMLightArray
*light_array
;
914 hr
= Direct3DRMCreate(&d3drm
);
915 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
917 ref
= get_refcount((IUnknown
*)d3drm
);
918 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameC
);
919 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
920 CHECK_REFCOUNT(pFrameC
, 1);
921 ref2
= get_refcount((IUnknown
*)d3drm
);
922 ok(ref2
> ref
, "Expected d3drm object to be referenced.\n");
924 test_class_name((IDirect3DRMObject
*)pFrameC
, "Frame");
926 hr
= IDirect3DRMFrame_GetParent(pFrameC
, NULL
);
927 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
928 pFrameTmp
= (void*)0xdeadbeef;
929 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
930 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
931 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
932 CHECK_REFCOUNT(pFrameC
, 1);
935 hr
= IDirect3DRMFrame_GetChildren(pFrameC
, &frame_array
);
936 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
937 ok(!!frame_array
, "frame_array = %p\n", frame_array
);
940 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
941 ok(count
== 0, "count = %u\n", count
);
942 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
943 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
944 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
945 IDirect3DRMFrameArray_Release(frame_array
);
948 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP1
);
949 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
951 /* GetParent with NULL pointer */
952 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, NULL
);
953 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
954 CHECK_REFCOUNT(pFrameP1
, 1);
956 /* [Add/Delete]Child with NULL pointer */
957 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, NULL
);
958 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
959 CHECK_REFCOUNT(pFrameP1
, 1);
961 hr
= IDirect3DRMFrame_DeleteChild(pFrameP1
, NULL
);
962 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
963 CHECK_REFCOUNT(pFrameP1
, 1);
965 /* Add child to first parent */
966 pFrameTmp
= (void*)0xdeadbeef;
967 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, &pFrameTmp
);
968 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
969 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
971 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, pFrameC
);
972 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
973 CHECK_REFCOUNT(pFrameP1
, 1);
974 CHECK_REFCOUNT(pFrameC
, 2);
976 hr
= IDirect3DRMFrame_GetScene(pFrameC
, NULL
);
977 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
978 hr
= IDirect3DRMFrame_GetScene(pFrameC
, &scene_frame
);
979 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
980 ok(scene_frame
== pFrameP1
, "Expected scene frame == %p, got %p.\n", pFrameP1
, scene_frame
);
981 CHECK_REFCOUNT(pFrameP1
, 2);
982 IDirect3DRMFrame_Release(scene_frame
);
983 hr
= IDirect3DRMFrame_GetScene(pFrameP1
, &scene_frame
);
984 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
985 ok(scene_frame
== pFrameP1
, "Expected scene frame == %p, got %p.\n", pFrameP1
, scene_frame
);
986 CHECK_REFCOUNT(pFrameP1
, 2);
987 IDirect3DRMFrame_Release(scene_frame
);
990 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &frame_array
);
991 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
992 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
993 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
994 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
997 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
998 ok(count
== 1, "count = %u\n", count
);
999 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1000 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1001 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1002 ok((get_refcount((IUnknown
*)pFrameC
) == 4) || broken(get_refcount((IUnknown
*)pFrameC
) == 3),
1003 "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown
*)pFrameC
));
1004 IDirect3DRMFrame_Release(pFrameTmp
);
1005 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
1006 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
1007 IDirect3DRMFrameArray_Release(frame_array
);
1008 CHECK_REFCOUNT(pFrameC
, 2);
1011 pFrameTmp
= (void*)0xdeadbeef;
1012 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1013 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1014 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
1015 CHECK_REFCOUNT(pFrameP1
, 2);
1016 IDirect3DRMFrame_Release(pFrameTmp
);
1017 CHECK_REFCOUNT(pFrameP1
, 1);
1019 /* Add child to second parent */
1020 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP2
);
1021 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1023 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1024 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1025 CHECK_REFCOUNT(pFrameC
, 2);
1028 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1029 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1032 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1033 ok(count
== 1, "count = %u\n", count
);
1034 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1035 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1036 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1037 IDirect3DRMFrame_Release(pFrameTmp
);
1038 IDirect3DRMFrameArray_Release(frame_array
);
1042 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &frame_array
);
1043 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1046 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1047 ok(count
== 0, "count = %u\n", count
);
1048 pFrameTmp
= (void*)0xdeadbeef;
1049 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1050 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
1051 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1052 IDirect3DRMFrameArray_Release(frame_array
);
1054 hr
= IDirect3DRMFrame_GetScene(pFrameC
, &scene_frame
);
1055 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
1056 ok(scene_frame
== pFrameP2
, "Expected scene frame == %p, got %p.\n", pFrameP2
, scene_frame
);
1057 CHECK_REFCOUNT(pFrameP2
, 2);
1058 IDirect3DRMFrame_Release(scene_frame
);
1059 hr
= IDirect3DRMFrame_GetScene(pFrameP2
, &scene_frame
);
1060 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
1061 ok(scene_frame
== pFrameP2
, "Expected scene frame == %p, got %p.\n", pFrameP2
, scene_frame
);
1062 CHECK_REFCOUNT(pFrameP2
, 2);
1063 IDirect3DRMFrame_Release(scene_frame
);
1065 pFrameTmp
= (void*)0xdeadbeef;
1066 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1067 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1068 ok(pFrameTmp
== pFrameP2
, "pFrameTmp = %p\n", pFrameTmp
);
1069 CHECK_REFCOUNT(pFrameP2
, 2);
1070 CHECK_REFCOUNT(pFrameC
, 2);
1071 IDirect3DRMFrame_Release(pFrameTmp
);
1072 CHECK_REFCOUNT(pFrameP2
, 1);
1074 /* Add child again */
1075 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1076 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1077 CHECK_REFCOUNT(pFrameC
, 2);
1080 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1081 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1084 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1085 ok(count
== 1, "count = %u\n", count
);
1086 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1087 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1088 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1089 IDirect3DRMFrame_Release(pFrameTmp
);
1090 IDirect3DRMFrameArray_Release(frame_array
);
1094 hr
= IDirect3DRMFrame_DeleteChild(pFrameP2
, pFrameC
);
1095 ok(hr
== D3DRM_OK
, "Cannot delete child frame (hr = %x)\n", hr
);
1096 CHECK_REFCOUNT(pFrameC
, 1);
1099 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1100 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1103 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1104 ok(count
== 0, "count = %u\n", count
);
1105 pFrameTmp
= (void*)0xdeadbeef;
1106 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1107 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
1108 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1109 IDirect3DRMFrameArray_Release(frame_array
);
1112 pFrameTmp
= (void*)0xdeadbeef;
1113 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1114 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1115 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1117 /* Add two children */
1118 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1119 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1120 CHECK_REFCOUNT(pFrameC
, 2);
1122 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameP1
);
1123 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1124 CHECK_REFCOUNT(pFrameP1
, 2);
1127 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1128 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1131 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1132 ok(count
== 2, "count = %u\n", count
);
1133 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1134 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1135 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1136 IDirect3DRMFrame_Release(pFrameTmp
);
1137 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 1, &pFrameTmp
);
1138 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1139 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
1140 IDirect3DRMFrame_Release(pFrameTmp
);
1141 IDirect3DRMFrameArray_Release(frame_array
);
1144 /* [Add/Delete]Visual with NULL pointer */
1145 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, NULL
);
1146 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1147 CHECK_REFCOUNT(pFrameP1
, 2);
1149 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, NULL
);
1150 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1151 CHECK_REFCOUNT(pFrameP1
, 2);
1154 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &mesh_builder
);
1155 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
1156 visual1
= (IDirect3DRMVisual
*)mesh_builder
;
1158 /* Add Visual to first parent */
1159 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, visual1
);
1160 ok(hr
== D3DRM_OK
, "Cannot add visual (hr = %x)\n", hr
);
1161 CHECK_REFCOUNT(pFrameP1
, 2);
1162 CHECK_REFCOUNT(visual1
, 2);
1164 visual_array
= NULL
;
1165 hr
= IDirect3DRMFrame_GetVisuals(pFrameP1
, &visual_array
);
1166 ok(hr
== D3DRM_OK
, "Cannot get visuals (hr = %x)\n", hr
);
1169 count
= IDirect3DRMVisualArray_GetSize(visual_array
);
1170 ok(count
== 1, "count = %u\n", count
);
1171 hr
= IDirect3DRMVisualArray_GetElement(visual_array
, 0, &visual_tmp
);
1172 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1173 ok(visual_tmp
== visual1
, "visual_tmp = %p\n", visual_tmp
);
1174 IDirect3DRMVisual_Release(visual_tmp
);
1175 IDirect3DRMVisualArray_Release(visual_array
);
1179 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, visual1
);
1180 ok(hr
== D3DRM_OK
, "Cannot delete visual (hr = %x)\n", hr
);
1181 CHECK_REFCOUNT(pFrameP1
, 2);
1182 IDirect3DRMMeshBuilder_Release(mesh_builder
);
1184 /* [Add/Delete]Light with NULL pointer */
1185 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, NULL
);
1186 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1187 CHECK_REFCOUNT(pFrameP1
, 2);
1189 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, NULL
);
1190 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1191 CHECK_REFCOUNT(pFrameP1
, 2);
1194 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.1, 0.2, 0.3, &light1
);
1195 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
1197 /* Add Light to first parent */
1198 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, light1
);
1199 ok(hr
== D3DRM_OK
, "Cannot add light (hr = %x)\n", hr
);
1200 CHECK_REFCOUNT(pFrameP1
, 2);
1201 CHECK_REFCOUNT(light1
, 2);
1204 hr
= IDirect3DRMFrame_GetLights(pFrameP1
, &light_array
);
1205 ok(hr
== D3DRM_OK
, "Cannot get lights (hr = %x)\n", hr
);
1208 count
= IDirect3DRMLightArray_GetSize(light_array
);
1209 ok(count
== 1, "count = %u\n", count
);
1210 hr
= IDirect3DRMLightArray_GetElement(light_array
, 0, &light_tmp
);
1211 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1212 ok(light_tmp
== light1
, "light_tmp = %p\n", light_tmp
);
1213 IDirect3DRMLight_Release(light_tmp
);
1214 IDirect3DRMLightArray_Release(light_array
);
1218 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, light1
);
1219 ok(hr
== D3DRM_OK
, "Cannot delete light (hr = %x)\n", hr
);
1220 CHECK_REFCOUNT(pFrameP1
, 2);
1221 IDirect3DRMLight_Release(light1
);
1223 /* Test SceneBackground on first parent */
1224 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1225 ok(color
== 0xff000000, "wrong color (%x)\n", color
);
1227 hr
= IDirect3DRMFrame_SetSceneBackground(pFrameP1
, 0xff180587);
1228 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1229 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1230 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
1232 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1
, 0.5, 0.5, 0.5);
1233 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1234 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1235 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
1238 IDirect3DRMFrame_Release(pFrameP2
);
1239 CHECK_REFCOUNT(pFrameC
, 1);
1240 CHECK_REFCOUNT(pFrameP1
, 1);
1242 IDirect3DRMFrame_Release(pFrameC
);
1243 IDirect3DRMFrame_Release(pFrameP1
);
1245 IDirect3DRM_Release(d3drm
);
1248 struct destroy_context
1250 IDirect3DRMObject
*obj
;
1251 unsigned int test_idx
;
1255 struct callback_order
1259 } corder
[3], d3drm_corder
[3];
1261 static void CDECL
destroy_callback(IDirect3DRMObject
*obj
, void *arg
)
1263 struct destroy_context
*ctxt
= arg
;
1264 ok(ctxt
->called
== 1 || ctxt
->called
== 2, "got called counter %d\n", ctxt
->called
);
1265 ok(obj
== ctxt
->obj
, "called with %p, expected %p\n", obj
, ctxt
->obj
);
1266 d3drm_corder
[ctxt
->called
].callback
= &destroy_callback
;
1267 d3drm_corder
[ctxt
->called
++].context
= ctxt
;
1270 static void CDECL
destroy_callback1(IDirect3DRMObject
*obj
, void *arg
)
1272 struct destroy_context
*ctxt
= (struct destroy_context
*)arg
;
1273 ok(ctxt
->called
== 0, "got called counter %d\n", ctxt
->called
);
1274 ok(obj
== ctxt
->obj
, "called with %p, expected %p\n", obj
, ctxt
->obj
);
1275 d3drm_corder
[ctxt
->called
].callback
= &destroy_callback1
;
1276 d3drm_corder
[ctxt
->called
++].context
= ctxt
;
1279 static void test_destroy_callback(unsigned int test_idx
, REFCLSID clsid
, REFIID iid
)
1281 struct destroy_context context
;
1282 IDirect3DRMObject
*obj
;
1288 hr
= Direct3DRMCreate(&d3drm
);
1289 ok(SUCCEEDED(hr
), "Test %u: Cannot get IDirect3DRM interface (hr = %x).\n", test_idx
, hr
);
1291 hr
= IDirect3DRM_CreateObject(d3drm
, clsid
, NULL
, iid
, (void **)&unknown
);
1292 ok(hr
== D3DRM_OK
, "Test %u: Cannot get IDirect3DRMObject interface (hr = %x).\n", test_idx
, hr
);
1293 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirect3DRMObject
, (void**)&obj
);
1294 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1295 IUnknown_Release(unknown
);
1298 context
.test_idx
= test_idx
;
1301 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, NULL
, &context
);
1302 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected D3DRMERR_BADVALUE (hr = %x).\n", test_idx
, hr
);
1304 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1305 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1306 corder
[2].callback
= &destroy_callback
;
1307 corder
[2].context
= &context
;
1309 /* same callback added twice */
1310 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1311 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1312 corder
[1].callback
= &destroy_callback
;
1313 corder
[1].context
= &context
;
1315 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback1
, NULL
);
1316 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1318 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback1
, &context
);
1319 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1322 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback1
, &context
);
1323 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1324 corder
[0].callback
= &destroy_callback1
;
1325 corder
[0].context
= &context
;
1327 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, NULL
, NULL
);
1328 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected D3DRM_BADVALUE (hr = %x).\n", test_idx
, hr
);
1331 IDirect3DRMObject_Release(obj
);
1332 ok(context
.called
== 3, "Test %u: got %d, expected 3.\n", test_idx
, context
.called
);
1333 for (i
= 0; i
< context
.called
; i
++)
1335 ok(corder
[i
].callback
== d3drm_corder
[i
].callback
1336 && corder
[i
].context
== d3drm_corder
[i
].context
,
1337 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder
[i
].callback
,
1338 d3drm_corder
[i
].context
, corder
[i
].callback
, corder
[i
].context
);
1341 /* test this pattern - add cb1, add cb2, add cb1, delete cb1 */
1342 hr
= IDirect3DRM_CreateObject(d3drm
, clsid
, NULL
, iid
, (void **)&unknown
);
1343 ok(hr
== D3DRM_OK
, "Test %u: Cannot get IDirect3DRMObject interface (hr = %x).\n", test_idx
, hr
);
1344 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirect3DRMObject
, (void**)&obj
);
1345 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1346 IUnknown_Release(unknown
);
1348 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1349 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1350 corder
[1].callback
= &destroy_callback
;
1351 corder
[1].context
= &context
;
1353 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback1
, &context
);
1354 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1355 corder
[0].callback
= &destroy_callback1
;
1356 corder
[0].context
= &context
;
1358 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1359 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1361 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback
, &context
);
1362 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1365 hr
= IDirect3DRMObject_QueryInterface(obj
, &IID_IDirect3DRMObject
, (void**)&context
.obj
);
1366 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1367 IDirect3DRMObject_Release(context
.obj
);
1368 IUnknown_Release(unknown
);
1369 ok(context
.called
== 2, "Test %u: got %d, expected 2.\n", test_idx
, context
.called
);
1370 for (i
= 0; i
< context
.called
; i
++)
1372 ok(corder
[i
].callback
== d3drm_corder
[i
].callback
1373 && corder
[i
].context
== d3drm_corder
[i
].context
,
1374 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder
[i
].callback
,
1375 d3drm_corder
[i
].context
, corder
[i
].callback
, corder
[i
].context
);
1379 static void test_object(void)
1389 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice
, FALSE
},
1390 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice2
, FALSE
},
1391 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice3
, FALSE
},
1392 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMWinDevice
, FALSE
},
1393 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture
, FALSE
},
1394 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture2
, FALSE
},
1395 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture3
, FALSE
},
1396 { &CLSID_CDirect3DRMViewport
, &IID_IDirect3DRMViewport
, FALSE
},
1397 { &CLSID_CDirect3DRMViewport
, &IID_IDirect3DRMViewport2
, FALSE
},
1398 { &CLSID_CDirect3DRMFace
, &IID_IDirect3DRMFace
},
1399 { &CLSID_CDirect3DRMFace
, &IID_IDirect3DRMFace2
},
1400 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder
},
1401 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder2
},
1402 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder3
},
1403 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame
},
1404 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame2
},
1405 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame3
},
1406 { &CLSID_CDirect3DRMLight
, &IID_IDirect3DRMLight
},
1407 { &CLSID_CDirect3DRMMaterial
, &IID_IDirect3DRMMaterial
},
1408 { &CLSID_CDirect3DRMMaterial
, &IID_IDirect3DRMMaterial2
},
1410 IDirect3DRM
*d3drm1
;
1411 IDirect3DRM2
*d3drm2
;
1412 IDirect3DRM3
*d3drm3
;
1413 IUnknown
*unknown
= (IUnknown
*)0xdeadbeef;
1415 ULONG ref1
, ref2
, ref3
, ref4
;
1418 hr
= Direct3DRMCreate(&d3drm1
);
1419 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
1420 ref1
= get_refcount((IUnknown
*)d3drm1
);
1421 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
1422 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
1423 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
1424 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
1426 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_DirectDraw
, NULL
, &IID_IDirectDraw
, (void **)&unknown
);
1427 ok(hr
== CLASSFACTORY_E_FIRST
, "Expected hr == CLASSFACTORY_E_FIRST, got %#x.\n", hr
);
1428 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1430 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
1432 BOOL takes_ref
= IsEqualGUID(tests
[i
].clsid
, &CLSID_CDirect3DRMMeshBuilder
) ||
1433 IsEqualGUID(tests
[i
].clsid
, &CLSID_CDirect3DRMFrame
) ||
1434 IsEqualGUID(tests
[i
].clsid
, &CLSID_CDirect3DRMLight
) ||
1435 IsEqualGUID(tests
[i
].clsid
, &CLSID_CDirect3DRMMaterial
);
1437 unknown
= (IUnknown
*)0xdeadbeef;
1438 hr
= IDirect3DRM_CreateObject(d3drm1
, NULL
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1439 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i
, hr
);
1440 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1441 unknown
= (IUnknown
*)0xdeadbeef;
1442 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, NULL
, (void **)&unknown
);
1443 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i
, hr
);
1444 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1445 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, NULL
, NULL
);
1446 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i
, hr
);
1448 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1449 todo_wine_if(tests
[i
].todo
)
1450 ok(SUCCEEDED(hr
), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i
, hr
);
1453 ref2
= get_refcount((IUnknown
*)d3drm1
);
1455 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1457 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1459 ref3
= get_refcount((IUnknown
*)d3drm2
);
1460 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1461 ref4
= get_refcount((IUnknown
*)d3drm3
);
1462 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1463 IUnknown_Release(unknown
);
1464 ref2
= get_refcount((IUnknown
*)d3drm1
);
1465 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1466 ref3
= get_refcount((IUnknown
*)d3drm2
);
1467 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1468 ref4
= get_refcount((IUnknown
*)d3drm3
);
1469 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1471 /* test Add/Destroy callbacks */
1472 test_destroy_callback(i
, tests
[i
].clsid
, tests
[i
].iid
);
1474 hr
= IDirect3DRM2_CreateObject(d3drm2
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1475 ok(SUCCEEDED(hr
), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i
, hr
);
1476 ref2
= get_refcount((IUnknown
*)d3drm1
);
1478 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1480 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1481 ref3
= get_refcount((IUnknown
*)d3drm2
);
1482 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1483 ref4
= get_refcount((IUnknown
*)d3drm3
);
1484 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1485 IUnknown_Release(unknown
);
1486 ref2
= get_refcount((IUnknown
*)d3drm1
);
1487 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1488 ref3
= get_refcount((IUnknown
*)d3drm2
);
1489 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1490 ref4
= get_refcount((IUnknown
*)d3drm3
);
1491 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1493 hr
= IDirect3DRM3_CreateObject(d3drm3
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1494 ok(SUCCEEDED(hr
), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i
, hr
);
1495 ref2
= get_refcount((IUnknown
*)d3drm1
);
1497 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1499 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1500 ref3
= get_refcount((IUnknown
*)d3drm2
);
1501 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1502 ref4
= get_refcount((IUnknown
*)d3drm3
);
1503 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1504 IUnknown_Release(unknown
);
1505 ref2
= get_refcount((IUnknown
*)d3drm1
);
1506 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1507 ref3
= get_refcount((IUnknown
*)d3drm2
);
1508 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1509 ref4
= get_refcount((IUnknown
*)d3drm3
);
1510 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1514 IDirect3DRM_Release(d3drm1
);
1515 IDirect3DRM2_Release(d3drm2
);
1516 IDirect3DRM3_Release(d3drm3
);
1519 static void test_Viewport(void)
1521 IDirectDrawClipper
*clipper
;
1523 IDirect3DRM
*d3drm1
;
1524 IDirect3DRM2
*d3drm2
;
1525 IDirect3DRM3
*d3drm3
;
1526 IDirect3DRMDevice
*device1
, *d3drm_device1
;
1527 IDirect3DRMDevice3
*device3
, *d3drm_device3
;
1528 IDirect3DRMFrame
*frame
;
1529 IDirect3DRMFrame3
*frame3
;
1530 IDirect3DRMViewport
*viewport
;
1531 IDirect3DRMViewport2
*viewport2
;
1532 IDirect3DViewport
*d3d_viewport
;
1534 D3DVALUE expected_val
;
1535 IDirect3DRMObject
*obj
, *obj2
;
1539 DWORD data
, ref1
, ref2
, ref3
, ref4
;
1540 DWORD initial_ref1
, initial_ref2
, initial_ref3
, device_ref
, frame_ref
, frame_ref2
, viewport_ref
;
1542 window
= create_window();
1543 GetClientRect(window
, &rc
);
1545 hr
= Direct3DRMCreate(&d3drm1
);
1546 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1547 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
1548 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
1549 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
1550 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
1551 initial_ref1
= get_refcount((IUnknown
*)d3drm1
);
1552 initial_ref2
= get_refcount((IUnknown
*)d3drm2
);
1553 initial_ref3
= get_refcount((IUnknown
*)d3drm3
);
1555 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
1556 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
1558 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
1559 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
1561 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
1562 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
1563 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1564 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice
, (void **)&device1
);
1565 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr
);
1567 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame
);
1568 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1569 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
1570 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %x).\n", hr
);
1572 ref1
= get_refcount((IUnknown
*)d3drm1
);
1573 ref2
= get_refcount((IUnknown
*)d3drm2
);
1574 ref3
= get_refcount((IUnknown
*)d3drm3
);
1575 device_ref
= get_refcount((IUnknown
*)device1
);
1576 frame_ref
= get_refcount((IUnknown
*)frame
);
1578 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, 0, 0, 0, 0, &viewport
);
1579 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
1580 ref4
= get_refcount((IUnknown
*)d3drm1
);
1581 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1582 ref4
= get_refcount((IUnknown
*)d3drm2
);
1583 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1584 ref4
= get_refcount((IUnknown
*)d3drm3
);
1585 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1586 ref4
= get_refcount((IUnknown
*)device1
);
1587 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1588 ref4
= get_refcount((IUnknown
*)frame
);
1589 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1591 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1592 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1593 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device1
, d3drm_device1
);
1594 IDirect3DRMDevice_Release(d3drm_device1
);
1596 IDirect3DRMViewport_Release(viewport
);
1597 ref4
= get_refcount((IUnknown
*)d3drm1
);
1598 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1599 ref4
= get_refcount((IUnknown
*)d3drm2
);
1600 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1601 ref4
= get_refcount((IUnknown
*)d3drm3
);
1602 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1603 ref4
= get_refcount((IUnknown
*)device1
);
1604 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1605 ref4
= get_refcount((IUnknown
*)frame
);
1606 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1608 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, 0, 0, 0, 0, &viewport
);
1609 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
1610 ref4
= get_refcount((IUnknown
*)d3drm1
);
1611 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1612 ref4
= get_refcount((IUnknown
*)d3drm2
);
1613 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1614 ref4
= get_refcount((IUnknown
*)d3drm3
);
1615 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1616 ref4
= get_refcount((IUnknown
*)device1
);
1617 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1618 ref4
= get_refcount((IUnknown
*)frame
);
1619 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1621 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1622 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1623 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device1
, d3drm_device1
);
1624 IDirect3DRMDevice_Release(d3drm_device1
);
1626 IDirect3DRMViewport_Release(viewport
);
1627 ref4
= get_refcount((IUnknown
*)d3drm1
);
1628 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1629 ref4
= get_refcount((IUnknown
*)d3drm2
);
1630 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1631 ref4
= get_refcount((IUnknown
*)d3drm3
);
1632 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1633 ref4
= get_refcount((IUnknown
*)device1
);
1634 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1635 ref4
= get_refcount((IUnknown
*)frame
);
1636 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1638 device_ref
= get_refcount((IUnknown
*)device3
);
1639 frame_ref2
= get_refcount((IUnknown
*)frame3
);
1641 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, 0, 0, 0, 0, &viewport2
);
1642 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
1643 ref4
= get_refcount((IUnknown
*)d3drm1
);
1644 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1645 ref4
= get_refcount((IUnknown
*)d3drm2
);
1646 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1647 ref4
= get_refcount((IUnknown
*)d3drm3
);
1648 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1649 ref4
= get_refcount((IUnknown
*)device3
);
1650 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1651 ref4
= get_refcount((IUnknown
*)frame3
);
1652 ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
1654 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
1655 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
1656 ok(device3
== d3drm_device3
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
1657 IDirect3DRMDevice3_Release(d3drm_device3
);
1659 IDirect3DRMViewport2_Release(viewport2
);
1660 ref4
= get_refcount((IUnknown
*)d3drm1
);
1661 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1662 ref4
= get_refcount((IUnknown
*)d3drm2
);
1663 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1664 ref4
= get_refcount((IUnknown
*)d3drm3
);
1665 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1666 ref4
= get_refcount((IUnknown
*)device3
);
1667 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1668 ref4
= get_refcount((IUnknown
*)frame3
);
1669 ok(ref4
== frame_ref2
, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
1671 /* Test all failures together */
1672 hr
= IDirect3DRM_CreateViewport(d3drm1
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1673 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1674 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1675 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1676 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport
);
1677 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1678 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport
);
1679 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1680 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport
);
1681 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1682 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1683 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1685 hr
= IDirect3DRM2_CreateViewport(d3drm2
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1686 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1687 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1688 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1689 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport
);
1690 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1691 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport
);
1692 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1693 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport
);
1694 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1695 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1696 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1698 hr
= IDirect3DRM3_CreateViewport(d3drm3
, NULL
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1699 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1700 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1701 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1702 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport2
);
1703 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1704 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport2
);
1705 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1706 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport2
);
1707 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1708 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1709 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1711 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1712 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
1713 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1714 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1715 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1716 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1717 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1718 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1719 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1720 IDirect3DViewport_Release(d3d_viewport
);
1721 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1722 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1723 IDirect3DViewport_Release(d3d_viewport
);
1725 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1726 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1727 vp
.dwSize
= sizeof(vp
);
1728 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1729 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1730 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1731 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1732 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1733 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1734 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1735 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1736 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1737 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1738 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1739 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1740 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1741 IDirect3DViewport_Release(d3d_viewport
);
1742 IDirect3DRMViewport_Release(viewport
);
1744 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1745 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
1746 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1747 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1748 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1749 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1750 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1751 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1752 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1753 IDirect3DViewport_Release(d3d_viewport
);
1754 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1755 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1756 IDirect3DViewport_Release(d3d_viewport
);
1758 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1759 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1760 vp
.dwSize
= sizeof(vp
);
1761 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1762 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1763 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1764 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1765 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1766 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1767 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1768 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1769 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1770 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1771 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1772 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1773 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1774 IDirect3DViewport_Release(d3d_viewport
);
1775 IDirect3DRMViewport2_Release(viewport2
);
1777 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1778 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr
);
1779 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1780 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1781 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1782 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1783 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1784 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1785 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1786 IDirect3DViewport_Release(d3d_viewport
);
1787 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1788 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1789 IDirect3DViewport_Release(d3d_viewport
);
1791 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1792 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1793 vp
.dwSize
= sizeof(vp
);
1794 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1795 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1796 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1797 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1798 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1799 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1800 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1801 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1802 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1803 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1804 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1805 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1806 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1807 IDirect3DViewport_Release(d3d_viewport
);
1809 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMObject
, (void**)&obj
);
1810 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1811 ok((IDirect3DRMObject
*)viewport
== obj
, "got object pointer %p, expected %p\n", obj
, viewport
);
1813 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMViewport2
, (void**)&viewport2
);
1814 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1816 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IDirect3DRMObject
, (void**)&obj2
);
1817 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1818 ok(obj
== obj2
, "got object pointer %p, expected %p\n", obj2
, obj
);
1819 ok((IUnknown
*)viewport
!= (IUnknown
*)viewport2
, "got viewport1 %p, viewport2 %p\n", viewport
, viewport2
);
1821 IDirect3DRMViewport2_Release(viewport2
);
1822 IDirect3DRMObject_Release(obj
);
1823 IDirect3DRMObject_Release(obj2
);
1825 test_class_name((IDirect3DRMObject
*)viewport
, "Viewport");
1828 hr
= IDirect3DRMViewport_SetAppData(viewport
, 0);
1829 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1831 hr
= IDirect3DRMViewport_SetAppData(viewport
, 0);
1832 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1834 hr
= IDirect3DRMViewport_SetAppData(viewport
, 1);
1835 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1837 hr
= IDirect3DRMViewport_SetAppData(viewport
, 1);
1838 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1840 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMViewport2
, (void**)&viewport2
);
1841 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1843 data
= IDirect3DRMViewport2_GetAppData(viewport2
);
1844 ok(data
== 1, "got %x\n", data
);
1845 IDirect3DRMViewport2_Release(viewport2
);
1846 IDirect3DRMViewport_Release(viewport
);
1848 /* IDirect3DRMViewport*::Init tests */
1849 ref1
= get_refcount((IUnknown
*)d3drm1
);
1850 ref2
= get_refcount((IUnknown
*)d3drm2
);
1851 ref3
= get_refcount((IUnknown
*)d3drm3
);
1852 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMViewport
, NULL
, &IID_IDirect3DRMViewport
,
1853 (void **)&viewport
);
1854 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x).\n", hr
);
1855 ref4
= get_refcount((IUnknown
*)d3drm1
);
1856 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1857 ref4
= get_refcount((IUnknown
*)d3drm2
);
1858 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1859 ref4
= get_refcount((IUnknown
*)d3drm3
);
1860 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1862 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1863 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1864 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1865 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1867 /* Test all failures together */
1868 hr
= IDirect3DRMViewport_Init(viewport
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1869 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1870 hr
= IDirect3DRMViewport_Init(viewport
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1871 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1872 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
1873 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1874 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
);
1875 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1876 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1);
1877 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1879 device_ref
= get_refcount((IUnknown
*)device1
);
1880 frame_ref
= get_refcount((IUnknown
*)frame
);
1881 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1882 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMViewport interface (hr = %#x).\n", hr
);
1883 ref4
= get_refcount((IUnknown
*)d3drm1
);
1884 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1885 ref4
= get_refcount((IUnknown
*)d3drm2
);
1886 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1887 ref4
= get_refcount((IUnknown
*)d3drm3
);
1888 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1889 ref4
= get_refcount((IUnknown
*)device1
);
1890 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1891 ref4
= get_refcount((IUnknown
*)frame
);
1892 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1894 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1895 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
1896 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
1897 IDirect3DRMDevice_Release(d3drm_device1
);
1899 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1900 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1901 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1902 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1903 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1904 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1905 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1906 IDirect3DViewport_Release(d3d_viewport
);
1907 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1908 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1909 IDirect3DViewport_Release(d3d_viewport
);
1911 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1912 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1913 vp
.dwSize
= sizeof(vp
);
1914 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1915 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1916 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1917 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1918 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1919 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1920 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1921 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1922 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1923 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1924 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1925 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1926 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1927 IDirect3DViewport_Release(d3d_viewport
);
1929 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1930 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1932 IDirect3DRMViewport_Release(viewport
);
1933 ref4
= get_refcount((IUnknown
*)d3drm1
);
1934 todo_wine
ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1935 ref4
= get_refcount((IUnknown
*)d3drm2
);
1936 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1937 ref4
= get_refcount((IUnknown
*)d3drm3
);
1938 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1939 ref4
= get_refcount((IUnknown
*)device1
);
1940 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1941 ref4
= get_refcount((IUnknown
*)frame
);
1942 todo_wine
ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1944 ref1
= get_refcount((IUnknown
*)d3drm1
);
1945 ref2
= get_refcount((IUnknown
*)d3drm2
);
1946 ref3
= get_refcount((IUnknown
*)d3drm3
);
1947 hr
= IDirect3DRM3_CreateObject(d3drm2
, &CLSID_CDirect3DRMViewport
, NULL
, &IID_IDirect3DRMViewport2
,
1948 (void **)&viewport2
);
1949 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x).\n", hr
);
1950 ref4
= get_refcount((IUnknown
*)d3drm1
);
1951 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1952 ref4
= get_refcount((IUnknown
*)d3drm2
);
1953 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1954 ref4
= get_refcount((IUnknown
*)d3drm3
);
1955 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1957 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1958 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1959 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
1960 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1962 hr
= IDirect3DRMViewport2_Init(viewport2
, NULL
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1963 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1964 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1965 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1966 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
1967 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1968 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
);
1969 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1970 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1);
1971 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1973 device_ref
= get_refcount((IUnknown
*)device3
);
1974 frame_ref2
= get_refcount((IUnknown
*)frame3
);
1975 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1976 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMViewport2 interface (hr = %#x).\n", hr
);
1977 ref4
= get_refcount((IUnknown
*)device3
);
1978 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1979 ref4
= get_refcount((IUnknown
*)frame3
);
1980 ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
1982 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
1983 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
1984 ok(device3
== d3drm_device3
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
1985 IDirect3DRMDevice3_Release(d3drm_device3
);
1987 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1988 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1989 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1990 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1991 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1992 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1993 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1994 IDirect3DViewport_Release(d3d_viewport
);
1995 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1996 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1997 IDirect3DViewport_Release(d3d_viewport
);
1999 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2000 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2001 vp
.dwSize
= sizeof(vp
);
2002 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2003 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
2004 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
2005 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
2006 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
2007 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
2008 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2009 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2010 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2011 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2012 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2013 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2014 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2015 IDirect3DViewport_Release(d3d_viewport
);
2017 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2018 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2020 IDirect3DRMViewport2_Release(viewport2
);
2021 ref4
= get_refcount((IUnknown
*)d3drm1
);
2022 todo_wine
ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2023 ref4
= get_refcount((IUnknown
*)d3drm2
);
2024 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
2025 ref4
= get_refcount((IUnknown
*)d3drm3
);
2026 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
2027 ref4
= get_refcount((IUnknown
*)device3
);
2028 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
2029 ref4
= get_refcount((IUnknown
*)frame3
);
2030 todo_wine
ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
2032 IDirect3DRMDevice3_Release(device3
);
2033 IDirect3DRMDevice_Release(device1
);
2034 ref4
= get_refcount((IUnknown
*)d3drm1
);
2035 ok(ref4
> initial_ref1
, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1
, ref4
);
2036 ref4
= get_refcount((IUnknown
*)d3drm2
);
2037 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2
, ref4
);
2038 ref4
= get_refcount((IUnknown
*)d3drm3
);
2039 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3
, ref4
);
2040 ref4
= get_refcount((IUnknown
*)frame
);
2041 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
2042 ref4
= get_refcount((IUnknown
*)frame3
);
2043 ok(ref4
== frame_ref2
, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
2045 IDirect3DRMFrame3_Release(frame3
);
2046 ref4
= get_refcount((IUnknown
*)d3drm1
);
2047 ok(ref4
> initial_ref1
, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1
, ref4
);
2048 ref4
= get_refcount((IUnknown
*)d3drm2
);
2049 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2
, ref4
);
2050 ref4
= get_refcount((IUnknown
*)d3drm3
);
2051 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3
, ref4
);
2053 IDirect3DRMFrame_Release(frame
);
2054 ref4
= get_refcount((IUnknown
*)d3drm1
);
2055 ok(ref4
== initial_ref1
, "Expected ref4 == initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1
, ref4
);
2056 ref4
= get_refcount((IUnknown
*)d3drm2
);
2057 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2
, ref4
);
2058 ref4
= get_refcount((IUnknown
*)d3drm3
);
2059 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3
, ref4
);
2060 IDirectDrawClipper_Release(clipper
);
2062 IDirect3DRM3_Release(d3drm3
);
2063 IDirect3DRM2_Release(d3drm2
);
2064 IDirect3DRM_Release(d3drm1
);
2065 DestroyWindow(window
);
2068 static void test_Light(void)
2070 IDirect3DRMObject
*object
;
2073 IDirect3DRMLight
*light
;
2074 D3DRMLIGHTTYPE type
;
2077 hr
= Direct3DRMCreate(&d3drm
);
2078 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2080 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.5, 0.5, 0.5, &light
);
2081 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
2083 hr
= IDirect3DRMLight_QueryInterface(light
, &IID_IDirect3DRMObject
, (void **)&object
);
2084 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr %#x.\n", hr
);
2085 IDirect3DRMObject_Release(object
);
2087 test_class_name((IDirect3DRMObject
*)light
, "Light");
2089 type
= IDirect3DRMLight_GetType(light
);
2090 ok(type
== D3DRMLIGHT_SPOT
, "wrong type (%u)\n", type
);
2092 color
= IDirect3DRMLight_GetColor(light
);
2093 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
2095 hr
= IDirect3DRMLight_SetType(light
, D3DRMLIGHT_POINT
);
2096 ok(hr
== D3DRM_OK
, "Cannot set type (hr = %x)\n", hr
);
2097 type
= IDirect3DRMLight_GetType(light
);
2098 ok(type
== D3DRMLIGHT_POINT
, "wrong type (%u)\n", type
);
2100 hr
= IDirect3DRMLight_SetColor(light
, 0xff180587);
2101 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
2102 color
= IDirect3DRMLight_GetColor(light
);
2103 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
2105 hr
= IDirect3DRMLight_SetColorRGB(light
, 0.5, 0.5, 0.5);
2106 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
2107 color
= IDirect3DRMLight_GetColor(light
);
2108 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
2110 IDirect3DRMLight_Release(light
);
2112 IDirect3DRM_Release(d3drm
);
2115 static void test_Material2(void)
2119 IDirect3DRM3
*d3drm3
;
2120 IDirect3DRMMaterial2
*material2
;
2123 hr
= Direct3DRMCreate(&d3drm
);
2124 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2126 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
2128 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
2129 IDirect3DRM_Release(d3drm
);
2133 hr
= IDirect3DRM3_CreateMaterial(d3drm3
, 18.5f
, &material2
);
2134 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr
);
2136 test_class_name((IDirect3DRMObject
*)material2
, "Material");
2138 r
= IDirect3DRMMaterial2_GetPower(material2
);
2139 ok(r
== 18.5f
, "wrong power (%f)\n", r
);
2141 hr
= IDirect3DRMMaterial2_GetEmissive(material2
, &r
, &g
, &b
);
2142 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2143 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
);
2145 hr
= IDirect3DRMMaterial2_GetSpecular(material2
, &r
, &g
, &b
);
2146 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2147 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
);
2149 hr
= IDirect3DRMMaterial2_GetAmbient(material2
, &r
, &g
, &b
);
2150 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2151 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
);
2153 hr
= IDirect3DRMMaterial2_SetPower(material2
, 5.87f
);
2154 ok(hr
== D3DRM_OK
, "Cannot set power (hr = %x)\n", hr
);
2155 r
= IDirect3DRMMaterial2_GetPower(material2
);
2156 ok(r
== 5.87f
, "wrong power (%f)\n", r
);
2158 hr
= IDirect3DRMMaterial2_SetEmissive(material2
, 0.5f
, 0.5f
, 0.5f
);
2159 ok(hr
== D3DRM_OK
, "Cannot set emissive (hr = %x)\n", hr
);
2160 hr
= IDirect3DRMMaterial2_GetEmissive(material2
, &r
, &g
, &b
);
2161 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2162 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
);
2164 hr
= IDirect3DRMMaterial2_SetSpecular(material2
, 0.6f
, 0.6f
, 0.6f
);
2165 ok(hr
== D3DRM_OK
, "Cannot set specular (hr = %x)\n", hr
);
2166 hr
= IDirect3DRMMaterial2_GetSpecular(material2
, &r
, &g
, &b
);
2167 ok(hr
== D3DRM_OK
, "Cannot get specular (hr = %x)\n", hr
);
2168 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
);
2170 hr
= IDirect3DRMMaterial2_SetAmbient(material2
, 0.7f
, 0.7f
, 0.7f
);
2171 ok(hr
== D3DRM_OK
, "Cannot set ambient (hr = %x)\n", hr
);
2172 hr
= IDirect3DRMMaterial2_GetAmbient(material2
, &r
, &g
, &b
);
2173 ok(hr
== D3DRM_OK
, "Cannot get ambient (hr = %x)\n", hr
);
2174 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
);
2176 IDirect3DRMMaterial2_Release(material2
);
2178 IDirect3DRM3_Release(d3drm3
);
2179 IDirect3DRM_Release(d3drm
);
2182 static void test_Texture(void)
2185 IDirect3DRM
*d3drm1
;
2186 IDirect3DRM2
*d3drm2
;
2187 IDirect3DRM3
*d3drm3
;
2188 IDirect3DRMTexture
*texture1
;
2189 IDirect3DRMTexture2
*texture2
;
2190 IDirect3DRMTexture3
*texture3
;
2191 IDirectDrawSurface
*surface
;
2193 D3DRMIMAGE initimg
=
2196 TRUE
, 2 * sizeof(DWORD
), NULL
, NULL
,
2197 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
2202 TRUE
, 0, (void *)0xcafebabe, NULL
,
2203 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
2207 DWORD pixel
[4] = { 20000, 30000, 10000, 0 };
2208 ULONG ref1
, ref2
, ref3
, ref4
;
2210 hr
= Direct3DRMCreate(&d3drm1
);
2211 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2212 ref1
= get_refcount((IUnknown
*)d3drm1
);
2214 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
2215 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
2217 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
2218 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
2220 /* Test NULL params */
2221 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
2222 hr
= IDirect3DRM_CreateTexture(d3drm1
, NULL
, &texture1
);
2223 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2224 ok(!texture1
, "Expected texture returned == NULL, got %p.\n", texture1
);
2225 hr
= IDirect3DRM_CreateTexture(d3drm1
, NULL
, NULL
);
2226 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2228 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
2229 hr
= IDirect3DRM2_CreateTexture(d3drm2
, NULL
, &texture2
);
2230 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2231 ok(!texture2
, "Expected texture returned == NULL, got %p.\n", texture2
);
2232 hr
= IDirect3DRM2_CreateTexture(d3drm2
, NULL
, NULL
);
2233 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2235 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
2236 hr
= IDirect3DRM3_CreateTexture(d3drm3
, NULL
, &texture3
);
2237 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2238 ok(!texture3
, "Expected texture returned == NULL, got %p.\n", texture3
);
2239 hr
= IDirect3DRM3_CreateTexture(d3drm3
, NULL
, NULL
);
2240 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2242 /* Tests for validation of D3DRMIMAGE struct */
2243 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg
, &texture1
);
2244 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
2245 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg
, &texture2
);
2246 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2247 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
2248 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2249 IDirect3DRMTexture_Release(texture1
);
2250 IDirect3DRMTexture2_Release(texture2
);
2251 IDirect3DRMTexture3_Release(texture3
);
2254 testimg
.palette
= (void *)0xdeadbeef;
2255 testimg
.palette_size
= 0x39;
2256 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg
, &texture1
);
2257 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
2258 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg
, &texture2
);
2259 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2260 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
2261 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2262 IDirect3DRMTexture_Release(texture1
);
2263 IDirect3DRMTexture2_Release(texture2
);
2264 IDirect3DRMTexture3_Release(texture3
);
2267 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
2268 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2269 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2270 ok(!texture1
, "Expected texture == NULL, got %p.\n", texture1
);
2271 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
2272 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2273 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2274 ok(!texture2
, "Expected texture == NULL, got %p.\n", texture2
);
2275 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
2276 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2277 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2278 ok(!texture3
, "Expected texture == NULL, got %p.\n", texture3
);
2280 initimg
.red_mask
= 0;
2281 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2282 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2283 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2284 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2285 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2286 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2287 initimg
.red_mask
= 0x000000ff;
2288 initimg
.green_mask
= 0;
2289 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2290 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2291 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2292 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2293 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2294 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2295 initimg
.green_mask
= 0x0000ff00;
2296 initimg
.blue_mask
= 0;
2297 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2298 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2299 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2300 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2301 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2302 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2303 initimg
.blue_mask
= 0x00ff0000;
2304 initimg
.buffer1
= NULL
;
2305 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2306 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2307 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2308 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2309 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2310 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2312 initimg
.buffer1
= &pixel
;
2313 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2314 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
2315 ref2
= get_refcount((IUnknown
*)d3drm1
);
2316 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2317 ref3
= get_refcount((IUnknown
*)d3drm2
);
2318 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2319 ref4
= get_refcount((IUnknown
*)d3drm3
);
2320 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2321 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2322 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2323 ref2
= get_refcount((IUnknown
*)d3drm1
);
2324 ok(ref2
> ref1
+ 1, "expected ref2 > (ref1 + 1), got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2325 ref3
= get_refcount((IUnknown
*)d3drm2
);
2326 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2327 ref4
= get_refcount((IUnknown
*)d3drm3
);
2328 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2329 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2330 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2331 ref2
= get_refcount((IUnknown
*)d3drm1
);
2332 ok(ref2
> ref1
+ 2, "expected ref2 > (ref1 + 2), got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2333 ref3
= get_refcount((IUnknown
*)d3drm2
);
2334 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2335 ref4
= get_refcount((IUnknown
*)d3drm3
);
2336 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2338 /* Created from image, GetSurface() does not work. */
2339 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, NULL
);
2340 ok(hr
== D3DRMERR_BADVALUE
, "GetSurface() expected to fail, %#x\n", hr
);
2342 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &surface
);
2343 ok(hr
== D3DRMERR_NOTCREATEDFROMDDS
, "GetSurface() expected to fail, %#x\n", hr
);
2345 /* Test all failures together */
2346 test_class_name((IDirect3DRMObject
*)texture1
, "Texture");
2347 test_class_name((IDirect3DRMObject
*)texture2
, "Texture");
2348 test_class_name((IDirect3DRMObject
*)texture3
, "Texture");
2350 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
2351 ok(!!d3drm_img
, "Failed to get image.\n");
2352 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2354 IDirect3DRMTexture_Release(texture1
);
2355 ref2
= get_refcount((IUnknown
*)d3drm1
);
2356 ok(ref2
- 2 == ref1
, "expected (ref2 - 2) == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2357 ref3
= get_refcount((IUnknown
*)d3drm2
);
2358 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2359 ref4
= get_refcount((IUnknown
*)d3drm3
);
2360 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2363 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
2364 ok(!!d3drm_img
, "Failed to get image.\n");
2365 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2367 IDirect3DRMTexture2_Release(texture2
);
2368 ref2
= get_refcount((IUnknown
*)d3drm1
);
2369 ok(ref2
- 1 == ref1
, "expected (ref2 - 1) == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2370 ref3
= get_refcount((IUnknown
*)d3drm2
);
2371 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2372 ref4
= get_refcount((IUnknown
*)d3drm3
);
2373 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2376 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
2377 ok(!!d3drm_img
, "Failed to get image.\n");
2378 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2380 IDirect3DRMTexture3_Release(texture3
);
2381 ref2
= get_refcount((IUnknown
*)d3drm1
);
2382 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2383 ref3
= get_refcount((IUnknown
*)d3drm2
);
2384 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2385 ref4
= get_refcount((IUnknown
*)d3drm3
);
2386 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2388 /* InitFromImage tests */
2389 /* Tests for validation of D3DRMIMAGE struct */
2391 testimg
.palette
= NULL
;
2392 testimg
.palette_size
= 0;
2393 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
2394 (void **)&texture2
);
2395 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr
);
2396 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
2397 (void **)&texture3
);
2398 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr
);
2399 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &testimg
);
2400 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2401 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
2402 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2403 IDirect3DRMTexture2_Release(texture2
);
2404 IDirect3DRMTexture3_Release(texture3
);
2407 testimg
.palette
= (void *)0xdeadbeef;
2408 testimg
.palette_size
= 0x39;
2409 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
2410 (void **)&texture2
);
2411 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr
);
2412 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
2413 (void **)&texture3
);
2414 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr
);
2415 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &testimg
);
2416 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2417 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
2418 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2419 IDirect3DRMTexture2_Release(texture2
);
2420 IDirect3DRMTexture3_Release(texture3
);
2422 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
2423 (void **)&texture2
);
2424 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr
);
2425 ref2
= get_refcount((IUnknown
*)texture2
);
2426 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, NULL
);
2427 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2428 ref3
= get_refcount((IUnknown
*)texture2
);
2429 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
2431 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
2432 (void **)&texture3
);
2433 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr
);
2434 ref2
= get_refcount((IUnknown
*)texture3
);
2435 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, NULL
);
2436 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2437 ref3
= get_refcount((IUnknown
*)texture3
);
2438 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
2441 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2442 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2443 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2444 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2446 initimg
.red_mask
= 0;
2447 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2448 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2449 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2450 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2451 initimg
.red_mask
= 0x000000ff;
2452 initimg
.green_mask
= 0;
2453 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2454 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2455 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2456 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2457 initimg
.green_mask
= 0x0000ff00;
2458 initimg
.blue_mask
= 0;
2459 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2460 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2461 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2462 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2463 initimg
.blue_mask
= 0x00ff0000;
2464 initimg
.buffer1
= NULL
;
2465 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2466 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2467 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2468 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2469 initimg
.buffer1
= &pixel
;
2472 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2473 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 from image (hr = %#x).\n", hr
);
2474 ref2
= get_refcount((IUnknown
*)d3drm1
);
2475 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2476 ref3
= get_refcount((IUnknown
*)d3drm2
);
2477 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2478 ref4
= get_refcount((IUnknown
*)d3drm3
);
2479 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2481 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2482 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2483 /* Release leaked reference to d3drm1 */
2484 IDirect3DRM_Release(d3drm1
);
2486 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
2487 ok(!!d3drm_img
, "Failed to get image.\n");
2488 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2489 IDirect3DRMTexture2_Release(texture2
);
2490 ref2
= get_refcount((IUnknown
*)d3drm1
);
2491 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2492 ref3
= get_refcount((IUnknown
*)d3drm2
);
2493 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2494 ref4
= get_refcount((IUnknown
*)d3drm3
);
2495 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2498 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2499 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 from image (hr = %#x).\n", hr
);
2500 ref2
= get_refcount((IUnknown
*)d3drm1
);
2501 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2502 ref3
= get_refcount((IUnknown
*)d3drm2
);
2503 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2504 ref4
= get_refcount((IUnknown
*)d3drm3
);
2505 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2507 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2508 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2509 IDirect3DRM_Release(d3drm1
);
2511 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
2512 ok(!!d3drm_img
, "Failed to get image.\n");
2513 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2514 IDirect3DRMTexture3_Release(texture3
);
2515 ref2
= get_refcount((IUnknown
*)d3drm1
);
2516 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2517 ref3
= get_refcount((IUnknown
*)d3drm2
);
2518 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2519 ref4
= get_refcount((IUnknown
*)d3drm3
);
2520 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2522 IDirect3DRM3_Release(d3drm3
);
2523 IDirect3DRM2_Release(d3drm2
);
2524 IDirect3DRM_Release(d3drm1
);
2527 static void test_Device(void)
2529 IDirectDrawClipper
*pClipper
;
2532 IDirect3DRMDevice
*device
;
2533 IDirect3DRMWinDevice
*win_device
;
2538 window
= create_window();
2539 GetClientRect(window
, &rc
);
2541 hr
= Direct3DRMCreate(&d3drm
);
2542 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2544 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
2545 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
2547 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
2548 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
2550 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
2551 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &device
);
2552 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
2554 test_class_name((IDirect3DRMObject
*)device
, "Device");
2557 if (FAILED(hr
= IDirect3DRMDevice_QueryInterface(device
, &IID_IDirect3DRMWinDevice
, (void **)&win_device
)))
2559 win_skip("Cannot get IDirect3DRMWinDevice interface (hr = %x), skipping tests\n", hr
);
2563 test_class_name((IDirect3DRMObject
*)win_device
, "Device");
2564 IDirect3DRMWinDevice_Release(win_device
);
2567 IDirect3DRMDevice_Release(device
);
2568 IDirectDrawClipper_Release(pClipper
);
2570 IDirect3DRM_Release(d3drm
);
2571 DestroyWindow(window
);
2574 static void test_frame_transform(void)
2578 IDirect3DRMFrame
*frame
;
2579 D3DRMMATRIX4D matrix
;
2581 hr
= Direct3DRMCreate(&d3drm
);
2582 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2584 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &frame
);
2585 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
2587 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
2588 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr
);
2589 ok(!memcmp(matrix
, identity
, sizeof(D3DRMMATRIX4D
)), "Returned matrix is not identity\n");
2591 IDirect3DRMFrame_Release(frame
);
2592 IDirect3DRM_Release(d3drm
);
2595 static int nb_objects
= 0;
2596 static const GUID
* refiids
[] =
2598 &IID_IDirect3DRMMeshBuilder
,
2599 &IID_IDirect3DRMMeshBuilder
,
2600 &IID_IDirect3DRMFrame
,
2601 &IID_IDirect3DRMMaterial
/* Not taken into account and not notified */
2604 static void __cdecl
object_load_callback(IDirect3DRMObject
*object
, REFIID objectguid
, void *arg
)
2606 ok(object
!= NULL
, "Arg 1 should not be null\n");
2607 ok(IsEqualGUID(objectguid
, refiids
[nb_objects
]), "Arg 2 is incorrect\n");
2608 ok(arg
== (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg
);
2612 static void test_d3drm_load(void)
2616 D3DRMLOADMEMORY info
;
2617 const GUID
* req_refiids
[] = { &IID_IDirect3DRMMeshBuilder
, &IID_IDirect3DRMFrame
, &IID_IDirect3DRMMaterial
};
2619 hr
= Direct3DRMCreate(&d3drm
);
2620 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2622 info
.lpMemory
= data_d3drm_load
;
2623 info
.dSize
= strlen(data_d3drm_load
);
2624 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 3, D3DRMLOAD_FROMMEMORY
,
2625 object_load_callback
, (void *)0xdeadbeef, NULL
, NULL
, NULL
);
2626 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
2627 ok(nb_objects
== 3, "Should have loaded 3 objects (got %d)\n", nb_objects
);
2629 IDirect3DRM_Release(d3drm
);
2632 IDirect3DRMMeshBuilder
*mesh_builder
= NULL
;
2634 static void __cdecl
object_load_callback_frame(IDirect3DRMObject
*object
, REFIID object_guid
, void *arg
)
2637 IDirect3DRMFrame
*frame
;
2638 IDirect3DRMVisualArray
*array
;
2639 IDirect3DRMVisual
*visual
;
2643 hr
= IDirect3DRMObject_QueryInterface(object
, &IID_IDirect3DRMFrame
, (void**)&frame
);
2644 ok(hr
== D3DRM_OK
, "IDirect3DRMObject_QueryInterface returned %x\n", hr
);
2646 hr
= IDirect3DRMFrame_GetVisuals(frame
, &array
);
2647 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetVisuals returned %x\n", hr
);
2649 size
= IDirect3DRMVisualArray_GetSize(array
);
2650 ok(size
== 1, "Wrong size %u returned, expected 1\n", size
);
2652 hr
= IDirect3DRMVisualArray_GetElement(array
, 0, &visual
);
2653 ok(hr
== D3DRM_OK
, "IDirect3DRMVisualArray_GetElement returned %x\n", hr
);
2655 hr
= IDirect3DRMVisual_QueryInterface(visual
, &IID_IDirect3DRMMeshBuilder
, (void**)&mesh_builder
);
2656 ok(hr
== D3DRM_OK
, "IDirect3DRMVisualArray_GetSize returned %x\n", hr
);
2658 size
= sizeof(name
);
2659 hr
= IDirect3DRMMeshBuilder_GetName(mesh_builder
, &size
, name
);
2660 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr
);
2661 ok(!strcmp(name
, "mesh1"), "Wrong name %s, expected mesh1\n", name
);
2663 IDirect3DRMVisual_Release(visual
);
2664 IDirect3DRMVisualArray_Release(array
);
2665 IDirect3DRMFrame_Release(frame
);
2671 int vertex_per_face
;
2678 { 4, 3, 3, 9, 0x4c0000ff, 30.0f
, { 0.31f
, 0.32f
, 0.33f
}, { 0.34f
, 0.35f
, 0.36f
} },
2679 { 4, 2, 3, 6, 0x3300ff00, 20.0f
, { 0.21f
, 0.22f
, 0.23f
}, { 0.24f
, 0.25f
, 0.26f
} },
2680 { 3, 1, 3, 3, 0x19ff0000, 10.0f
, { 0.11f
, 0.12f
, 0.13f
}, { 0.14f
, 0.15f
, 0.16f
} }
2683 static void test_frame_mesh_materials(void)
2687 D3DRMLOADMEMORY info
;
2688 const GUID
*req_refiids
[] = { &IID_IDirect3DRMFrame
};
2689 IDirect3DRMMesh
*mesh
;
2691 IDirect3DRMMaterial
*material
;
2692 IDirect3DRMTexture
*texture
;
2695 hr
= Direct3DRMCreate(&d3drm
);
2696 ok(hr
== D3DRM_OK
, "Direct3DRMCreate returned %x\n", hr
);
2698 info
.lpMemory
= data_frame_mesh_materials
;
2699 info
.dSize
= strlen(data_frame_mesh_materials
);
2700 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 1, D3DRMLOAD_FROMMEMORY
, object_load_callback_frame
, (void*)0xdeadbeef, NULL
, NULL
, NULL
);
2701 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
2703 hr
= IDirect3DRMMeshBuilder_CreateMesh(mesh_builder
, &mesh
);
2704 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_CreateMesh returned %x\n", hr
);
2706 size
= IDirect3DRMMesh_GetGroupCount(mesh
);
2707 ok(size
== 3, "Wrong size %u returned, expected 3\n", size
);
2709 for (i
= 0; i
< size
; i
++)
2711 D3DVALUE red
, green
, blue
, power
;
2713 unsigned vertex_count
, face_count
, vertex_per_face
;
2714 DWORD face_data_size
;
2716 hr
= IDirect3DRMMesh_GetGroup(mesh
, i
, &vertex_count
, &face_count
, &vertex_per_face
, &face_data_size
, NULL
);
2717 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroup returned %x\n", i
, hr
);
2718 ok(vertex_count
== groups
[i
].vertex_count
, "Group %d: Wrong vertex count %d, expected %d\n", i
, vertex_count
, groups
[i
].vertex_count
);
2719 ok(face_count
== groups
[i
].face_count
, "Group %d: Wrong face count %d; expected %d\n", i
, face_count
, groups
[i
].face_count
);
2720 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
);
2721 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
);
2723 color
= IDirect3DRMMesh_GetGroupColor(mesh
, i
);
2724 ok(color
== groups
[i
].color
, "Group %d: Wrong color %x, expected %x\n", i
, color
, groups
[i
].color
);
2726 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, i
, &material
);
2727 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroupMaterial returned %x\n", i
, hr
);
2728 ok(material
!= NULL
, "Group %d: No material\n", i
);
2729 power
= IDirect3DRMMaterial_GetPower(material
);
2730 ok(power
== groups
[i
].power
, "Group %d: Wrong power %f, expected %f\n", i
, power
, groups
[i
].power
);
2731 hr
= IDirect3DRMMaterial_GetSpecular(material
, &red
, &green
, &blue
);
2732 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMaterial_GetSpecular returned %x\n", i
, hr
);
2733 ok(red
== groups
[i
].specular
[0], "Group %d: Wrong specular red %f, expected %f\n", i
, red
, groups
[i
].specular
[0]);
2734 ok(green
== groups
[i
].specular
[1], "Group %d: Wrong specular green %f, pD3DRMexpected %f\n", i
, green
, groups
[i
].specular
[1]);
2735 ok(blue
== groups
[i
].specular
[2], "Group %d: Wrong specular blue %f, expected %f\n", i
, blue
, groups
[i
].specular
[2]);
2736 hr
= IDirect3DRMMaterial_GetEmissive(material
, &red
, &green
, &blue
);
2737 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMaterial_GetEmissive returned %x\n", i
, hr
);
2738 ok(red
== groups
[i
].emissive
[0], "Group %d: Wrong emissive red %f, expected %f\n", i
, red
, groups
[i
].emissive
[0]);
2739 ok(green
== groups
[i
].emissive
[1], "Group %d: Wrong emissive green %f, expected %f\n", i
, green
, groups
[i
].emissive
[1]);
2740 ok(blue
== groups
[i
].emissive
[2], "Group %d: Wrong emissive blue %f, expected %f\n", i
, blue
, groups
[i
].emissive
[2]);
2742 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, i
, &texture
);
2743 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroupTexture returned %x\n", i
, hr
);
2744 ok(!texture
, "Group %d: Unexpected texture\n", i
);
2747 IDirect3DRMMaterial_Release(material
);
2749 IDirect3DRMTexture_Release(texture
);
2752 IDirect3DRMMesh_Release(mesh
);
2753 IDirect3DRMMeshBuilder_Release(mesh_builder
);
2754 IDirect3DRM_Release(d3drm
);
2760 REFIID refcount_iid
;
2765 static void test_qi(const char *test_name
, IUnknown
*base_iface
,
2766 REFIID refcount_iid
, const struct qi_test
*tests
, UINT entry_count
)
2768 ULONG refcount
, expected_refcount
;
2769 IUnknown
*iface1
, *iface2
;
2773 for (i
= 0; i
< entry_count
; ++i
)
2775 hr
= IUnknown_QueryInterface(base_iface
, tests
[i
].iid
, (void **)&iface1
);
2776 ok(hr
== tests
[i
].hr
, "Got hr %#x for test \"%s\" %u.\n", hr
, test_name
, i
);
2779 for (j
= 0; j
< entry_count
; ++j
)
2781 hr
= IUnknown_QueryInterface(iface1
, tests
[j
].iid
, (void **)&iface2
);
2782 ok(hr
== tests
[j
].hr
, "Got hr %#x for test \"%s\" %u, %u.\n", hr
, test_name
, i
, j
);
2785 expected_refcount
= 0;
2786 if (IsEqualGUID(refcount_iid
, tests
[j
].refcount_iid
))
2787 ++expected_refcount
;
2788 if (IsEqualGUID(tests
[i
].refcount_iid
, tests
[j
].refcount_iid
))
2789 ++expected_refcount
;
2790 refcount
= IUnknown_Release(iface2
);
2791 ok(refcount
== expected_refcount
, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
2792 refcount
, test_name
, i
, j
, expected_refcount
);
2793 if (tests
[i
].vtable_iid
&& tests
[j
].vtable_iid
&& IsEqualGUID(tests
[i
].vtable_iid
, tests
[j
].vtable_iid
))
2794 ok(iface1
== iface2
,
2795 "Expected iface1 == iface2 for test \"%s\" %u, %u. Got iface1 = %p, iface 2 = %p.\n",
2796 test_name
, i
, j
, iface1
, iface2
);
2797 else if (tests
[i
].vtable_iid
&& tests
[j
].vtable_iid
)
2798 ok(iface1
!= iface2
,
2799 "Expected iface1 != iface2 for test \"%s\" %u, %u. Got iface1 == iface2 == %p.\n",
2800 test_name
, i
, j
, iface1
);
2804 expected_refcount
= 0;
2805 if (IsEqualGUID(refcount_iid
, tests
[i
].refcount_iid
))
2806 ++expected_refcount
;
2807 refcount
= IUnknown_Release(iface1
);
2808 ok(refcount
== expected_refcount
, "Got refcount %u for test \"%s\" %u, expected %u.\n",
2809 refcount
, test_name
, i
, expected_refcount
);
2814 static void test_d3drm_qi(void)
2816 static const struct qi_test tests
[] =
2818 { &IID_IDirect3DRM3
, &IID_IDirect3DRM3
, &IID_IDirect3DRM3
, S_OK
},
2819 { &IID_IDirect3DRM2
, &IID_IDirect3DRM2
, &IID_IDirect3DRM2
, S_OK
},
2820 { &IID_IDirect3DRM
, &IID_IDirect3DRM
, &IID_IDirect3DRM
, S_OK
},
2821 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2822 { &IID_IDirect3DRMObject
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2823 { &IID_IDirect3DRMObject2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2824 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2825 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2826 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2827 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2828 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2829 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2830 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2831 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2832 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2833 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2834 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2835 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2836 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2837 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2838 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2839 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2840 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2841 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2842 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2843 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2844 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2845 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2846 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2847 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2848 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2849 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2850 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2851 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2852 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2853 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2854 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2855 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2856 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2857 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2858 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2859 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2860 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2861 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2862 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2863 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2864 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2865 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2866 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2867 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2868 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2869 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2870 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2871 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2872 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2873 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2874 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2875 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2876 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2877 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2878 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2879 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2880 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2881 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2882 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2883 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2884 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2885 { &IID_IUnknown
, &IID_IDirect3DRM
, &IID_IDirect3DRM
, S_OK
},
2890 hr
= Direct3DRMCreate(&d3drm
);
2891 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2893 test_qi("d3drm_qi", (IUnknown
*)d3drm
, &IID_IDirect3DRM
, tests
, sizeof(tests
) / sizeof(*tests
));
2895 IDirect3DRM_Release(d3drm
);
2898 static void test_frame_qi(void)
2900 static const struct qi_test tests
[] =
2902 { &IID_IDirect3DRMFrame3
, &IID_IUnknown
, &IID_IDirect3DRMFrame3
, S_OK
},
2903 { &IID_IDirect3DRMFrame2
, &IID_IUnknown
, &IID_IDirect3DRMFrame2
, S_OK
},
2904 { &IID_IDirect3DRMFrame
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
2905 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2906 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2907 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
2908 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2909 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2910 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2911 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2912 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2913 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2914 { &IID_IDirect3DRMVisual
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
2915 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2916 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2917 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2918 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2919 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2920 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2921 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2922 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2923 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2924 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2925 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2926 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2927 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2928 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2929 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2930 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2931 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2932 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2933 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2934 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2935 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2936 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2937 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2938 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2939 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2940 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2941 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2942 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2943 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2944 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2945 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2946 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2947 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2948 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2949 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2950 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2951 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2952 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2953 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2954 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2955 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2956 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2957 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2958 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2959 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2960 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2961 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2962 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2963 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2964 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2965 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2966 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2967 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2968 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
2971 IDirect3DRM
*d3drm1
;
2972 IDirect3DRM2
*d3drm2
;
2973 IDirect3DRM3
*d3drm3
;
2974 IDirect3DRMFrame
*frame1
;
2975 IDirect3DRMFrame2
*frame2
;
2976 IDirect3DRMFrame3
*frame3
;
2979 hr
= Direct3DRMCreate(&d3drm1
);
2980 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2982 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
2983 ok(hr
== D3DRM_OK
, "Failed to create frame1 (hr = %x)\n", hr
);
2984 hr
= IDirect3DRMFrame_QueryInterface(frame1
, &IID_IUnknown
, (void **)&unknown
);
2985 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame1 (hr = %x)\n", hr
);
2986 IDirect3DRMFrame_Release(frame1
);
2987 test_qi("frame1_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
2988 IUnknown_Release(unknown
);
2990 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
2991 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
2992 hr
= IDirect3DRM2_CreateFrame(d3drm2
, NULL
, &frame2
);
2993 ok(hr
== D3DRM_OK
, "Failed to create frame2 (hr = %x)\n", hr
);
2994 hr
= IDirect3DRMFrame2_QueryInterface(frame2
, &IID_IUnknown
, (void **)&unknown
);
2995 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame2 (hr = %x)\n", hr
);
2996 IDirect3DRMFrame2_Release(frame2
);
2997 test_qi("frame2_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
2998 IUnknown_Release(unknown
);
3000 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3001 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
3002 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
3003 ok(hr
== D3DRM_OK
, "Failed to create frame3 (hr = %x)\n", hr
);
3004 hr
= IDirect3DRMFrame3_QueryInterface(frame3
, &IID_IUnknown
, (void **)&unknown
);
3005 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame3 (hr = %x)\n", hr
);
3006 IDirect3DRMFrame3_Release(frame3
);
3007 test_qi("frame3_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
3008 IUnknown_Release(unknown
);
3010 IDirect3DRM3_Release(d3drm3
);
3011 IDirect3DRM2_Release(d3drm2
);
3012 IDirect3DRM_Release(d3drm1
);
3015 static void test_device_qi(void)
3017 static const struct qi_test tests
[] =
3019 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3020 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3021 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3022 { &IID_IDirect3DRMDevice
, &IID_IUnknown
, &IID_IDirect3DRMDevice
, S_OK
, },
3023 { &IID_IDirect3DRMDevice2
, &IID_IUnknown
, &IID_IDirect3DRMDevice2
, S_OK
, },
3024 { &IID_IDirect3DRMDevice3
, &IID_IUnknown
, &IID_IDirect3DRMDevice3
, S_OK
, },
3025 { &IID_IDirect3DRMWinDevice
, &IID_IUnknown
, &IID_IDirect3DRMWinDevice
, S_OK
, },
3026 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMDevice
, S_OK
, },
3027 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3028 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3029 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3030 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3031 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3032 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3033 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3034 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3035 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3036 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3037 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3038 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3039 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3040 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3041 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3042 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3043 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3044 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3045 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3046 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3047 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3048 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3049 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3050 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3051 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3052 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3053 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3054 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3055 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3056 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3057 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3058 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3059 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3060 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3061 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3062 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3063 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3064 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3065 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3066 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3067 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3068 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3069 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3070 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3071 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3072 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3073 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3074 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3075 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3076 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3077 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3078 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3079 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3080 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3081 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3082 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3083 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3084 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3085 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3086 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
3089 IDirect3DRM
*d3drm1
;
3090 IDirect3DRM2
*d3drm2
;
3091 IDirect3DRM3
*d3drm3
;
3092 IDirectDrawClipper
*clipper
;
3093 IDirect3DRMDevice
*device1
;
3094 IDirect3DRMDevice2
*device2
;
3095 IDirect3DRMDevice3
*device3
;
3101 window
= create_window();
3102 GetClientRect(window
, &rc
);
3103 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3104 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
3105 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3106 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
3108 hr
= Direct3DRMCreate(&d3drm1
);
3109 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
3110 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
3111 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
3112 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
3113 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IUnknown
, (void **)&unknown
);
3114 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice (hr = %x)\n", hr
);
3115 IDirect3DRMDevice_Release(device1
);
3116 test_qi("device1_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
3117 IUnknown_Release(unknown
);
3119 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3120 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
3121 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device2
);
3122 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface (hr = %x)\n", hr
);
3123 hr
= IDirect3DRMDevice2_QueryInterface(device2
, &IID_IUnknown
, (void **)&unknown
);
3124 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice2 (hr = %x)\n", hr
);
3125 IDirect3DRMDevice2_Release(device2
);
3126 test_qi("device2_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
3127 IUnknown_Release(unknown
);
3129 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3130 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
3131 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
3132 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
3133 IDirect3DRMDevice3_QueryInterface(device3
, &IID_IUnknown
, (void **)&unknown
);
3134 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice3 (hr = %x)\n", hr
);
3135 IDirect3DRMDevice3_Release(device3
);
3136 test_qi("device3_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
3137 IUnknown_Release(unknown
);
3139 IDirectDrawClipper_Release(clipper
);
3140 IDirect3DRM3_Release(d3drm3
);
3141 IDirect3DRM2_Release(d3drm2
);
3142 IDirect3DRM_Release(d3drm1
);
3143 DestroyWindow(window
);
3147 static HRESULT CALLBACK
surface_callback(IDirectDrawSurface
*surface
, DDSURFACEDESC
*desc
, void *context
)
3149 IDirectDrawSurface
**primary
= context
;
3151 if (desc
->ddsCaps
.dwCaps
& DDSCAPS_PRIMARYSURFACE
)
3154 return DDENUMRET_CANCEL
;
3156 IDirectDrawSurface_Release(surface
);
3158 return DDENUMRET_OK
;
3161 static void test_create_device_from_clipper1(void)
3163 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3164 IDirect3DRM
*d3drm1
= NULL
;
3165 IDirectDraw
*ddraw
= NULL
;
3166 IUnknown
*unknown
= NULL
;
3167 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
3168 IDirect3DDevice
*d3ddevice1
= NULL
;
3169 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
3170 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
3171 IDirectDrawSurface7
*surface7
= NULL
;
3172 DDSURFACEDESC desc
, surface_desc
;
3173 DWORD expected_flags
, ret_val
;
3175 GUID driver
= IID_IDirect3DRGBDevice
;
3177 ULONG ref1
, ref2
, cref1
, cref2
;
3180 window
= create_window();
3181 GetClientRect(window
, &rc
);
3182 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3183 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr
);
3184 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3185 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x).\n", hr
);
3187 hr
= Direct3DRMCreate(&d3drm1
);
3188 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3189 ref1
= get_refcount((IUnknown
*)d3drm1
);
3190 cref1
= get_refcount((IUnknown
*)clipper
);
3192 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 0, 0, &device1
);
3193 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3194 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
3196 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3197 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, NULL
, &driver
, 300, 200, &device1
);
3198 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3200 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 300, 200, NULL
);
3201 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3203 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 300, 200, &device1
);
3204 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3205 ref2
= get_refcount((IUnknown
*)d3drm1
);
3206 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
3207 cref2
= get_refcount((IUnknown
*)clipper
);
3208 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1
, cref2
);
3209 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
3210 ok(ret_val
== 300, "Expected device width = 300, got %u.\n", ret_val
);
3211 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
3212 ok(ret_val
== 200, "Expected device height == 200, got %u.\n", ret_val
);
3214 /* Fetch immediate mode device in order to access render target */
3215 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
3216 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3218 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
3219 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3221 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
3222 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr
);
3224 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3225 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
3226 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr
);
3227 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
3228 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
3229 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3230 IUnknown_Release(unknown
);
3231 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3232 NULL
, &d3drm_primary
, surface_callback
);
3233 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3234 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
3235 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
3236 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface (hr = %x).\n", hr
);
3237 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
3239 IDirectDrawClipper_Release(d3drm_clipper
);
3240 IDirectDrawSurface_Release(d3drm_primary
);
3241 IDirectDrawSurface7_Release(surface7
);
3242 IDirectDraw_Release(ddraw
);
3244 /* Check properties of render target and depth surface */
3245 surface_desc
.dwSize
= sizeof(surface_desc
);
3246 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3247 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3249 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3250 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
3251 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
3252 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, surface_desc
.ddsCaps
.dwCaps
);
3253 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3254 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, surface_desc
.dwFlags
);
3256 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3257 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3258 desc
.dwSize
= sizeof(desc
);
3259 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3260 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3261 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %u bpp, got %u bpp.\n",
3262 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
3264 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3265 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3267 desc
.dwSize
= sizeof(desc
);
3268 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3269 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3271 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3272 desc
.dwWidth
, desc
.dwHeight
);
3273 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3274 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3275 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3276 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc
.dwZBufferBitDepth
);
3277 ok(desc
.ddpfPixelFormat
.dwStencilBitMask
== 0, "Expected 0 stencil bits, got %x.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
3279 /* Release old objects and check refcount of device and clipper */
3280 IDirectDrawSurface_Release(ds
);
3282 IDirectDrawSurface_Release(surface
);
3284 IDirect3DDevice_Release(d3ddevice1
);
3286 IDirect3DRMDevice_Release(device1
);
3287 ref2
= get_refcount((IUnknown
*)d3drm1
);
3288 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
3289 cref2
= get_refcount((IUnknown
*)clipper
);
3290 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1
, cref2
);
3292 /* Test if render target format follows the screen format */
3293 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3294 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3295 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
3296 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp (hr = %x).\n", hr
);
3298 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3299 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3300 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %u.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
3302 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
3303 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3305 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
3306 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3308 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
3309 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3311 surface_desc
.dwSize
= sizeof(surface_desc
);
3312 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3313 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3314 todo_wine
ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %ubpp.\n",
3315 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
3317 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
3318 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#x.\n", hr
);
3321 IDirectDrawSurface_Release(ds
);
3322 IDirectDrawSurface_Release(surface
);
3323 IDirect3DDevice_Release(d3ddevice1
);
3324 IDirect3DRMDevice_Release(device1
);
3325 IDirect3DRM_Release(d3drm1
);
3326 IDirectDrawClipper_Release(clipper
);
3327 IDirectDraw_Release(ddraw
);
3328 DestroyWindow(window
);
3331 static void test_create_device_from_clipper2(void)
3333 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3334 IDirect3DRM
*d3drm1
= NULL
;
3335 IDirect3DRM2
*d3drm2
= NULL
;
3336 IDirectDraw
*ddraw
= NULL
;
3337 IUnknown
*unknown
= NULL
;
3338 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
3339 IDirect3DDevice2
*d3ddevice2
= NULL
;
3340 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
3341 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
3342 IDirectDrawSurface7
*surface7
= NULL
;
3343 DDSURFACEDESC desc
, surface_desc
;
3344 DWORD expected_flags
, ret_val
;
3346 GUID driver
= IID_IDirect3DRGBDevice
;
3348 ULONG ref1
, ref2
, ref3
, cref1
, cref2
;
3351 window
= create_window();
3352 GetClientRect(window
, &rc
);
3353 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3354 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr
);
3355 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3356 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x).\n", hr
);
3358 hr
= Direct3DRMCreate(&d3drm1
);
3359 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3360 ref1
= get_refcount((IUnknown
*)d3drm1
);
3361 cref1
= get_refcount((IUnknown
*)clipper
);
3363 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3364 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
3365 ref2
= get_refcount((IUnknown
*)d3drm2
);
3367 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 0, 0, &device2
);
3368 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3369 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
3371 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3372 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, NULL
, &driver
, 300, 200, &device2
);
3373 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3375 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 300, 200, NULL
);
3376 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3378 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 300, 200, &device2
);
3379 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
3380 ref3
= get_refcount((IUnknown
*)d3drm1
);
3381 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
3382 ref3
= get_refcount((IUnknown
*)d3drm2
);
3383 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3384 cref2
= get_refcount((IUnknown
*)clipper
);
3385 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1
, cref2
);
3386 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
3387 ok(ret_val
== 300, "Expected device width = 300, got %u.\n", ret_val
);
3388 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
3389 ok(ret_val
== 200, "Expected device height == 200, got %u.\n", ret_val
);
3391 /* Fetch immediate mode device in order to access render target */
3392 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
3393 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3395 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3396 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3398 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
3399 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr
);
3401 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3402 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
3403 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr
);
3404 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
3405 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
3406 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3407 IUnknown_Release(unknown
);
3408 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3409 NULL
, &d3drm_primary
, surface_callback
);
3410 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3411 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
3412 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
3413 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface (hr = %x).\n", hr
);
3414 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
3416 IDirectDrawClipper_Release(d3drm_clipper
);
3417 IDirectDrawSurface_Release(d3drm_primary
);
3418 IDirectDrawSurface7_Release(surface7
);
3419 IDirectDraw_Release(ddraw
);
3421 /* Check properties of render target and depth surface */
3422 surface_desc
.dwSize
= sizeof(surface_desc
);
3423 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3424 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3426 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3427 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
3428 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
3429 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, surface_desc
.ddsCaps
.dwCaps
);
3430 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3431 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, surface_desc
.dwFlags
);
3433 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3434 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3435 desc
.dwSize
= sizeof(desc
);
3436 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3437 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3438 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %u bpp, got %u bpp.\n",
3439 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
3441 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3442 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3444 desc
.dwSize
= sizeof(desc
);
3445 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3446 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3448 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3449 desc
.dwWidth
, desc
.dwHeight
);
3450 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3451 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3452 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3453 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc
.dwZBufferBitDepth
);
3454 ok(desc
.ddpfPixelFormat
.dwStencilBitMask
== 0, "Expected 0 stencil bits, got %x.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
3456 /* Release old objects and check refcount of device and clipper */
3457 IDirectDrawSurface_Release(ds
);
3459 IDirectDrawSurface_Release(surface
);
3461 IDirect3DDevice2_Release(d3ddevice2
);
3463 IDirect3DRMDevice2_Release(device2
);
3464 ref3
= get_refcount((IUnknown
*)d3drm1
);
3465 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
3466 ref3
= get_refcount((IUnknown
*)d3drm2
);
3467 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3468 cref2
= get_refcount((IUnknown
*)clipper
);
3469 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1
, cref2
);
3471 /* Test if render target format follows the screen format */
3472 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3473 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3474 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
3475 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp (hr = %x).\n", hr
);
3477 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3478 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3479 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %u.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
3481 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device2
);
3482 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
3484 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
3485 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3487 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3488 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3490 surface_desc
.dwSize
= sizeof(surface_desc
);
3491 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3492 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3493 todo_wine
ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %ubpp.\n",
3494 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
3496 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
3497 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#x.\n", hr
);
3499 IDirectDrawSurface_Release(surface
);
3500 IDirect3DDevice2_Release(d3ddevice2
);
3501 IDirect3DRMDevice2_Release(device2
);
3502 IDirect3DRM2_Release(d3drm2
);
3503 IDirect3DRM_Release(d3drm1
);
3504 IDirectDrawClipper_Release(clipper
);
3505 IDirectDraw_Release(ddraw
);
3506 DestroyWindow(window
);
3509 static void test_create_device_from_clipper3(void)
3511 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3512 IDirect3DRM
*d3drm1
= NULL
;
3513 IDirect3DRM3
*d3drm3
= NULL
;
3514 IDirectDraw
*ddraw
= NULL
;
3515 IUnknown
*unknown
= NULL
;
3516 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
3517 IDirect3DDevice2
*d3ddevice2
= NULL
;
3518 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
3519 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
3520 IDirectDrawSurface7
*surface7
= NULL
;
3521 DDSURFACEDESC desc
, surface_desc
;
3522 DWORD expected_flags
, ret_val
;
3524 GUID driver
= IID_IDirect3DRGBDevice
;
3526 ULONG ref1
, ref2
, ref3
, cref1
, cref2
;
3529 window
= create_window();
3530 GetClientRect(window
, &rc
);
3531 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3532 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr
);
3533 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3534 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x).\n", hr
);
3536 hr
= Direct3DRMCreate(&d3drm1
);
3537 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3538 ref1
= get_refcount((IUnknown
*)d3drm1
);
3539 cref1
= get_refcount((IUnknown
*)clipper
);
3541 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3542 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
3543 ref2
= get_refcount((IUnknown
*)d3drm3
);
3545 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 0, 0, &device3
);
3546 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3547 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
3549 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3550 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, NULL
, &driver
, 300, 200, &device3
);
3551 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3553 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 300, 200, NULL
);
3554 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3556 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 300, 200, &device3
);
3557 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
3558 ref3
= get_refcount((IUnknown
*)d3drm1
);
3559 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
3560 ref3
= get_refcount((IUnknown
*)d3drm3
);
3561 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3562 cref2
= get_refcount((IUnknown
*)clipper
);
3563 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1
, cref2
);
3564 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
3565 ok(ret_val
== 300, "Expected device width = 300, got %u.\n", ret_val
);
3566 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
3567 ok(ret_val
== 200, "Expected device height == 200, got %u.\n", ret_val
);
3569 /* Fetch immediate mode device in order to access render target */
3570 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
3571 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3573 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3574 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3576 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
3577 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr
);
3579 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3580 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
3581 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr
);
3582 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
3583 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
3584 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3585 IUnknown_Release(unknown
);
3586 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3587 NULL
, &d3drm_primary
, surface_callback
);
3588 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3589 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
3590 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
3591 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface (hr = %x).\n", hr
);
3592 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
3594 IDirectDrawClipper_Release(d3drm_clipper
);
3595 IDirectDrawSurface_Release(d3drm_primary
);
3596 IDirectDrawSurface7_Release(surface7
);
3597 IDirectDraw_Release(ddraw
);
3599 /* Check properties of render target and depth surface */
3600 surface_desc
.dwSize
= sizeof(surface_desc
);
3601 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3602 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3604 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3605 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
3606 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
3607 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, surface_desc
.ddsCaps
.dwCaps
);
3608 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3609 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, surface_desc
.dwFlags
);
3611 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3612 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3613 desc
.dwSize
= sizeof(desc
);
3614 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3615 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3616 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %u bpp, got %u bpp.\n",
3617 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
3619 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3620 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3622 desc
.dwSize
= sizeof(desc
);
3623 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3624 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3626 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3627 desc
.dwWidth
, desc
.dwHeight
);
3628 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3629 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3630 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3631 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc
.dwZBufferBitDepth
);
3632 ok(desc
.ddpfPixelFormat
.dwStencilBitMask
== 0, "Expected 0 stencil bits, got %x.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
3634 /* Release old objects and check refcount of device and clipper */
3635 IDirectDrawSurface_Release(ds
);
3637 IDirectDrawSurface_Release(surface
);
3639 IDirect3DDevice2_Release(d3ddevice2
);
3641 IDirect3DRMDevice3_Release(device3
);
3642 ref3
= get_refcount((IUnknown
*)d3drm1
);
3643 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
3644 ref3
= get_refcount((IUnknown
*)d3drm3
);
3645 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3646 cref2
= get_refcount((IUnknown
*)clipper
);
3647 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1
, cref2
);
3649 /* Test if render target format follows the screen format */
3650 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3651 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3652 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
3653 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp (hr = %x).\n", hr
);
3655 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3656 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3657 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %u.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
3659 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
3660 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
3662 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
3663 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3665 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3666 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3668 surface_desc
.dwSize
= sizeof(surface_desc
);
3669 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3670 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3671 todo_wine
ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %ubpp.\n",
3672 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
3674 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
3675 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#x.\n", hr
);
3677 IDirectDrawSurface_Release(surface
);
3678 IDirect3DDevice2_Release(d3ddevice2
);
3679 IDirect3DRMDevice3_Release(device3
);
3680 IDirect3DRM3_Release(d3drm3
);
3681 IDirect3DRM_Release(d3drm1
);
3682 IDirectDrawClipper_Release(clipper
);
3683 IDirectDraw_Release(ddraw
);
3684 DestroyWindow(window
);
3687 static void test_create_device_from_surface1(void)
3689 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3691 IDirectDraw
*ddraw
= NULL
;
3692 IDirect3DRM
*d3drm1
= NULL
;
3693 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
3694 IDirect3DDevice
*d3ddevice1
= NULL
;
3695 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
3696 DWORD expected_flags
, ret_val
;
3698 GUID driver
= IID_IDirect3DRGBDevice
;
3699 ULONG ref1
, ref2
, surface_ref1
, surface_ref2
;
3701 BOOL use_sysmem_zbuffer
= FALSE
;
3704 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3705 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3707 window
= create_window();
3708 GetClientRect(window
, &rc
);
3710 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
3711 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
3713 hr
= Direct3DRMCreate(&d3drm1
);
3714 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3715 ref1
= get_refcount((IUnknown
*)d3drm1
);
3717 /* Create a surface and use it to create the retained mode device. */
3718 memset(&desc
, 0, sizeof(desc
));
3719 desc
.dwSize
= sizeof(desc
);
3720 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
3721 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
3722 desc
.dwWidth
= rc
.right
;
3723 desc
.dwHeight
= rc
.bottom
;
3725 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3726 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3728 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
3729 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr
);
3730 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
3731 IDirectDrawSurface_Release(surface
);
3733 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
3734 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3735 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3736 surface_ref1
= get_refcount((IUnknown
*)surface
);
3738 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, NULL
);
3739 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got %x.\n", hr
);
3740 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, NULL
, &device1
);
3741 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
3742 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, NULL
, surface
, &device1
);
3743 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
3745 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
3746 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3747 ref2
= get_refcount((IUnknown
*)d3drm1
);
3748 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
3749 surface_ref2
= get_refcount((IUnknown
*)surface
);
3750 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n", surface_ref1
, surface_ref2
);
3751 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
3752 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
3753 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
3754 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
3756 /* Check if CreateDeviceFromSurface creates a primary surface */
3757 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3758 NULL
, &d3drm_surface
, surface_callback
);
3759 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3760 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
3762 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
3763 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3765 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&d3drm_surface
);
3766 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3767 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
3769 /* Check properties of attached depth surface */
3770 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
3771 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3773 memset(&desc
, 0, sizeof(desc
));
3774 desc
.dwSize
= sizeof(desc
);
3775 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3776 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3778 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
3779 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
3780 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
3781 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3782 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3783 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3785 IDirectDrawSurface_Release(ds
);
3786 IDirect3DDevice_Release(d3ddevice1
);
3787 IDirectDrawSurface_Release(d3drm_surface
);
3789 IDirect3DRMDevice_Release(device1
);
3790 ref2
= get_refcount((IUnknown
*)d3drm1
);
3791 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
3792 surface_ref2
= get_refcount((IUnknown
*)surface
);
3793 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n",
3794 surface_ref1
, surface_ref2
);
3795 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3796 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3797 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
3798 ref1
= IDirectDrawSurface_Release(ds
);
3799 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
3800 ref1
= IDirectDrawSurface_Release(surface
);
3801 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
3803 memset(&desc
, 0, sizeof(desc
));
3804 desc
.dwSize
= sizeof(desc
);
3805 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
3806 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
3807 desc
.dwWidth
= rc
.right
;
3808 desc
.dwHeight
= rc
.bottom
;
3810 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3811 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3813 memset(&desc
, 0, sizeof(desc
));
3814 desc
.dwSize
= sizeof(desc
);
3815 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
3816 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
3817 desc
.dwZBufferBitDepth
= 16;
3818 desc
.dwWidth
= rc
.right
;
3819 desc
.dwHeight
= rc
.bottom
;
3820 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
3821 ok(hr
== DD_OK
, "Cannot create depth surface (hr = %x).\n", hr
);
3822 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
3823 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
3825 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
3826 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3828 hr
= IDirect3DRMDevice2_GetDirect3DDevice(device1
, &d3ddevice1
);
3829 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3831 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&d3drm_surface
);
3832 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3833 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
3835 /* Check if depth surface matches the one we created */
3836 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
3837 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3838 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
3840 IDirectDrawSurface_Release(d3drm_ds
);
3841 IDirectDrawSurface_Release(d3drm_surface
);
3842 IDirectDrawSurface_Release(ds
);
3844 IDirect3DDevice_Release(d3ddevice1
);
3845 IDirect3DRMDevice_Release(device1
);
3846 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3847 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3848 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
3849 ref1
= IDirectDrawSurface_Release(ds
);
3850 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
3851 ref1
= IDirectDrawSurface_Release(surface
);
3852 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
3853 IDirect3DRM_Release(d3drm1
);
3854 IDirectDraw_Release(ddraw
);
3855 DestroyWindow(window
);
3858 static void test_create_device_from_surface2(void)
3860 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3862 IDirectDraw
*ddraw
= NULL
;
3863 IDirect3DRM
*d3drm1
= NULL
;
3864 IDirect3DRM2
*d3drm2
= NULL
;
3865 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
3866 IDirect3DDevice2
*d3ddevice2
= NULL
;
3867 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
3868 DWORD expected_flags
, ret_val
;
3870 GUID driver
= IID_IDirect3DRGBDevice
;
3871 ULONG ref1
, ref2
, ref3
, surface_ref1
, surface_ref2
;
3873 BOOL use_sysmem_zbuffer
= FALSE
;
3876 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3877 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3879 window
= create_window();
3880 GetClientRect(window
, &rc
);
3882 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
3883 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
3885 hr
= Direct3DRMCreate(&d3drm1
);
3886 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3887 ref1
= get_refcount((IUnknown
*)d3drm1
);
3889 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3890 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
3891 ref2
= get_refcount((IUnknown
*)d3drm2
);
3893 /* Create a surface and use it to create the retained mode device. */
3894 memset(&desc
, 0, sizeof(desc
));
3895 desc
.dwSize
= sizeof(desc
);
3896 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
3897 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
3898 desc
.dwWidth
= rc
.right
;
3899 desc
.dwHeight
= rc
.bottom
;
3901 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3902 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3904 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
3905 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr
);
3906 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
3907 IDirectDrawSurface_Release(surface
);
3909 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
3910 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3911 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3912 surface_ref1
= get_refcount((IUnknown
*)surface
);
3914 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, NULL
);
3915 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got %x.\n", hr
);
3916 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, NULL
, &device2
);
3917 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
3918 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, NULL
, surface
, &device2
);
3919 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
3921 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
3922 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
3923 ref3
= get_refcount((IUnknown
*)d3drm1
);
3924 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
3925 ref3
= get_refcount((IUnknown
*)d3drm2
);
3926 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3927 surface_ref2
= get_refcount((IUnknown
*)surface
);
3928 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n", surface_ref1
, surface_ref2
);
3929 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
3930 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
3931 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
3932 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
3934 /* Check if CreateDeviceFromSurface creates a primary surface */
3935 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3936 NULL
, &d3drm_surface
, surface_callback
);
3937 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3938 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
3940 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
3941 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3943 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
3944 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3945 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
3947 /* Check properties of attached depth surface */
3948 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
3949 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3951 memset(&desc
, 0, sizeof(desc
));
3952 desc
.dwSize
= sizeof(desc
);
3953 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3954 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3956 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
3957 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
3958 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
3959 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3960 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3961 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3963 IDirectDrawSurface_Release(ds
);
3964 IDirect3DDevice2_Release(d3ddevice2
);
3965 IDirectDrawSurface_Release(d3drm_surface
);
3967 IDirect3DRMDevice2_Release(device2
);
3968 ref3
= get_refcount((IUnknown
*)d3drm1
);
3969 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
3970 ref3
= get_refcount((IUnknown
*)d3drm2
);
3971 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3972 surface_ref2
= get_refcount((IUnknown
*)surface
);
3973 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n",
3974 surface_ref1
, surface_ref2
);
3975 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3976 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3977 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
3978 ref1
= IDirectDrawSurface_Release(ds
);
3979 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
3981 ref1
= IDirectDrawSurface_Release(surface
);
3982 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
3984 memset(&desc
, 0, sizeof(desc
));
3985 desc
.dwSize
= sizeof(desc
);
3986 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
3987 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
3988 desc
.dwWidth
= rc
.right
;
3989 desc
.dwHeight
= rc
.bottom
;
3991 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3992 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3994 memset(&desc
, 0, sizeof(desc
));
3995 desc
.dwSize
= sizeof(desc
);
3996 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
3997 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
3998 desc
.dwZBufferBitDepth
= 16;
3999 desc
.dwWidth
= rc
.right
;
4000 desc
.dwHeight
= rc
.bottom
;
4001 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
4002 ok(hr
== DD_OK
, "Cannot create depth surface (hr = %x).\n", hr
);
4003 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
4004 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4006 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4007 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
4009 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4010 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4012 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4013 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4014 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4016 /* Check if depth surface matches the one we created */
4017 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4018 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4019 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4021 IDirectDrawSurface_Release(d3drm_ds
);
4022 IDirectDrawSurface_Release(d3drm_surface
);
4023 IDirectDrawSurface_Release(ds
);
4025 IDirect3DDevice2_Release(d3ddevice2
);
4026 IDirect3DRMDevice2_Release(device2
);
4027 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4028 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4029 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4030 ref1
= IDirectDrawSurface_Release(ds
);
4031 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4032 ref1
= IDirectDrawSurface_Release(surface
);
4033 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4034 IDirect3DRM2_Release(d3drm2
);
4035 IDirect3DRM_Release(d3drm1
);
4036 IDirectDraw_Release(ddraw
);
4037 DestroyWindow(window
);
4040 static void test_create_device_from_surface3(void)
4042 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4044 IDirectDraw
*ddraw
= NULL
;
4045 IDirect3DRM
*d3drm1
= NULL
;
4046 IDirect3DRM3
*d3drm3
= NULL
;
4047 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
4048 IDirect3DDevice2
*d3ddevice2
= NULL
;
4049 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
4050 DWORD expected_flags
, ret_val
;
4052 GUID driver
= IID_IDirect3DRGBDevice
;
4053 ULONG ref1
, ref2
, ref3
, surface_ref1
, surface_ref2
;
4055 BOOL use_sysmem_zbuffer
= FALSE
;
4058 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4059 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4061 window
= create_window();
4062 GetClientRect(window
, &rc
);
4064 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4065 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4067 hr
= Direct3DRMCreate(&d3drm1
);
4068 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4069 ref1
= get_refcount((IUnknown
*)d3drm1
);
4071 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
4072 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
4073 ref2
= get_refcount((IUnknown
*)d3drm3
);
4075 /* Create a surface and use it to create the retained mode device. */
4076 memset(&desc
, 0, sizeof(desc
));
4077 desc
.dwSize
= sizeof(desc
);
4078 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4079 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
4080 desc
.dwWidth
= rc
.right
;
4081 desc
.dwHeight
= rc
.bottom
;
4083 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4084 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4086 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4087 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr
);
4088 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
4089 IDirectDrawSurface_Release(surface
);
4091 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
4092 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4093 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4094 surface_ref1
= get_refcount((IUnknown
*)surface
);
4096 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, NULL
);
4097 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got %x.\n", hr
);
4098 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, NULL
, 0, &device3
);
4099 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
4100 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, NULL
, surface
, 0, &device3
);
4101 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
4103 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4104 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4105 ref3
= get_refcount((IUnknown
*)d3drm1
);
4106 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4107 ref3
= get_refcount((IUnknown
*)d3drm3
);
4108 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4109 surface_ref2
= get_refcount((IUnknown
*)surface
);
4110 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n", surface_ref1
, surface_ref2
);
4111 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
4112 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4113 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
4114 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4116 /* Check if CreateDeviceFromSurface creates a primary surface */
4117 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4118 NULL
, &d3drm_surface
, surface_callback
);
4119 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4120 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
4122 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4123 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4125 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4126 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4127 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4129 /* Check properties of attached depth surface */
4130 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
4131 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4133 memset(&desc
, 0, sizeof(desc
));
4134 desc
.dwSize
= sizeof(desc
);
4135 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4136 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4138 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
4139 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4140 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4141 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4142 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4143 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4145 IDirectDrawSurface_Release(ds
);
4146 IDirect3DDevice2_Release(d3ddevice2
);
4147 IDirectDrawSurface_Release(d3drm_surface
);
4148 IDirect3DRMDevice3_Release(device3
);
4150 ref3
= get_refcount((IUnknown
*)d3drm1
);
4151 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
4152 ref3
= get_refcount((IUnknown
*)d3drm3
);
4153 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4154 surface_ref2
= get_refcount((IUnknown
*)surface
);
4155 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n",
4156 surface_ref1
, surface_ref2
);
4157 /* In version 3, d3drm will destroy all references of the depth surface it created internally. */
4158 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4159 todo_wine
ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %x.\n", hr
);
4161 IDirectDrawSurface_Release(ds
);
4162 ref1
= IDirectDrawSurface_Release(surface
);
4163 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4165 memset(&desc
, 0, sizeof(desc
));
4166 desc
.dwSize
= sizeof(desc
);
4167 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4168 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4169 desc
.dwWidth
= rc
.right
;
4170 desc
.dwHeight
= rc
.bottom
;
4172 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4173 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4175 memset(&desc
, 0, sizeof(desc
));
4176 desc
.dwSize
= sizeof(desc
);
4177 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4178 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
4179 desc
.dwZBufferBitDepth
= 16;
4180 desc
.dwWidth
= rc
.right
;
4181 desc
.dwHeight
= rc
.bottom
;
4182 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
4183 ok(hr
== DD_OK
, "Cannot create depth surface (hr = %x).\n", hr
);
4184 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
4185 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4187 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, D3DRMDEVICE_NOZBUFFER
, &device3
);
4188 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4190 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4191 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4193 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4194 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4195 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4197 /* Check if depth surface matches the one we created */
4198 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4199 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4200 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4202 IDirectDrawSurface_Release(d3drm_ds
);
4203 IDirectDrawSurface_Release(d3drm_surface
);
4204 IDirectDrawSurface_Release(ds
);
4205 IDirect3DDevice2_Release(d3ddevice2
);
4206 IDirect3DRMDevice3_Release(device3
);
4207 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4208 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4209 /* The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4210 ref1
= IDirectDrawSurface_Release(ds
);
4211 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4213 /* What happens if we pass no flags and still attach our own depth surface? */
4214 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4215 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4217 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4218 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4220 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4221 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4222 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4224 /* Check if depth surface matches the one we created */
4225 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4226 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4227 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4229 IDirectDrawSurface_Release(d3drm_ds
);
4230 IDirectDrawSurface_Release(d3drm_surface
);
4231 IDirect3DDevice2_Release(d3ddevice2
);
4232 IDirect3DRMDevice3_Release(device3
);
4233 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4234 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4235 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4236 ref1
= IDirectDrawSurface_Release(ds
);
4237 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4238 ref1
= IDirectDrawSurface_Release(surface
);
4239 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4241 memset(&desc
, 0, sizeof(desc
));
4242 desc
.dwSize
= sizeof(desc
);
4243 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4244 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4245 desc
.dwWidth
= rc
.right
;
4246 desc
.dwHeight
= rc
.bottom
;
4248 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4249 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4251 /* What happens if we don't pass D3DRMDEVICE_NOZBUFFER and still not attach our own depth surface? */
4252 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, D3DRMDEVICE_NOZBUFFER
, &device3
);
4253 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4255 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4256 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4258 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4259 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4260 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4262 /* Check if depth surface matches the one we created */
4263 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4264 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %x).\n", hr
);
4265 IDirectDrawSurface_Release(d3drm_surface
);
4267 IDirect3DDevice2_Release(d3ddevice2
);
4268 IDirect3DRMDevice3_Release(device3
);
4269 ref1
= IDirectDrawSurface_Release(surface
);
4270 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4271 IDirect3DRM3_Release(d3drm3
);
4272 IDirect3DRM_Release(d3drm1
);
4273 IDirectDraw_Release(ddraw
);
4274 DestroyWindow(window
);
4277 static IDirect3DDevice
*create_device1(IDirectDraw
*ddraw
, HWND window
, IDirectDrawSurface
**ds
)
4279 static const DWORD z_depths
[] = { 32, 24, 16 };
4280 IDirectDrawSurface
*surface
;
4281 IDirect3DDevice
*device
= NULL
;
4282 DDSURFACEDESC surface_desc
;
4287 GetClientRect(window
, &rc
);
4288 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4289 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4291 memset(&surface_desc
, 0, sizeof(surface_desc
));
4292 surface_desc
.dwSize
= sizeof(surface_desc
);
4293 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4294 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4295 surface_desc
.dwWidth
= rc
.right
;
4296 surface_desc
.dwHeight
= rc
.bottom
;
4298 hr
= IDirectDraw_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
4299 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4301 /* We used to use EnumDevices() for this, but it seems
4302 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
4303 * relationship with reality. */
4304 for (i
= 0; i
< sizeof(z_depths
) / sizeof(*z_depths
); ++i
)
4306 memset(&surface_desc
, 0, sizeof(surface_desc
));
4307 surface_desc
.dwSize
= sizeof(surface_desc
);
4308 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4309 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
4310 U2(surface_desc
).dwZBufferBitDepth
= z_depths
[i
];
4311 surface_desc
.dwWidth
= rc
.right
;
4312 surface_desc
.dwHeight
= rc
.bottom
;
4313 if (FAILED(IDirectDraw_CreateSurface(ddraw
, &surface_desc
, ds
, NULL
)))
4316 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, *ds
);
4317 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4320 IDirectDrawSurface_Release(*ds
);
4324 if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface
, &IID_IDirect3DHALDevice
, (void **)&device
)))
4327 IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, *ds
);
4328 IDirectDrawSurface_Release(*ds
);
4332 IDirectDrawSurface_Release(surface
);
4336 static void test_create_device_from_d3d1(void)
4338 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
4339 IDirect3D
*d3d1
= NULL
, *temp_d3d1
;
4340 IDirect3DRM
*d3drm1
= NULL
;
4341 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
4342 IDirect3DRMDevice2
*device2
;
4343 IDirect3DRMDevice3
*device3
;
4344 IDirect3DDevice
*d3ddevice1
= NULL
, *d3drm_d3ddevice1
= NULL
, *temp_d3ddevice1
;
4345 IDirect3DDevice2
*d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4346 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
4347 DWORD expected_flags
, ret_val
;
4348 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4352 ULONG ref1
, ref2
, ref3
, ref4
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
4355 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
4356 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4358 window
= create_window();
4359 GetClientRect(window
, &rc
);
4361 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
4362 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
4363 d3d_ref1
= get_refcount((IUnknown
*)d3d1
);
4365 /* Create the immediate mode device */
4366 d3ddevice1
= create_device1(ddraw1
, window
, &ds
);
4367 if (d3ddevice1
== NULL
)
4369 win_skip("Cannot create IM device, skipping tests.\n");
4370 IDirect3D_Release(d3d1
);
4371 IDirectDraw_Release(ddraw1
);
4374 device_ref1
= get_refcount((IUnknown
*)d3ddevice1
);
4376 hr
= Direct3DRMCreate(&d3drm1
);
4377 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4378 ref1
= get_refcount((IUnknown
*)d3drm1
);
4380 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, NULL
, d3ddevice1
, &device1
);
4381 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4382 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
4383 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, NULL
, &device1
);
4384 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4385 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, d3ddevice1
, NULL
);
4386 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4388 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, d3ddevice1
, &device1
);
4389 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice interface (hr = %x)\n", hr
);
4390 ref2
= get_refcount((IUnknown
*)d3drm1
);
4391 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
4392 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4393 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4394 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
4395 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4396 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
4397 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4398 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
4399 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4401 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
4402 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr
);
4403 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4404 ok(SUCCEEDED(hr
), "Expected hr == D3DRM_OK, got %#x.\n", hr
);
4405 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4406 IDirect3DRMDevice2_Release(device2
);
4408 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4409 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
4410 ok(hr
== DD_OK
, "Cannot get IDirect3DRMDevice3 Interface (hr = %x).\n", hr
);
4411 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4412 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4413 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4414 IDirect3DRMDevice3_Release(device3
);
4416 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4417 NULL
, &surface
, surface_callback
);
4418 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4419 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4421 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3drm_d3ddevice1
);
4422 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
4423 ok(d3ddevice1
== d3drm_d3ddevice1
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice1
, d3drm_d3ddevice1
);
4425 /* Check properties of render target and depth surfaces */
4426 hr
= IDirect3DDevice_QueryInterface(d3drm_d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
4427 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4429 memset(&desc
, 0, sizeof(desc
));
4430 desc
.dwSize
= sizeof(desc
);
4431 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4432 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
4434 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4435 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4436 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4437 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4438 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4439 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4441 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4442 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4443 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4445 desc
.dwSize
= sizeof(desc
);
4446 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4447 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4449 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4450 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4451 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4452 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4453 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4455 IDirectDrawSurface_Release(d3drm_ds
);
4456 IDirectDrawSurface_Release(ds
);
4457 IDirectDrawSurface_Release(surface
);
4458 IDirect3DDevice_Release(d3drm_d3ddevice1
);
4459 IDirect3DRMDevice_Release(device1
);
4460 ref2
= get_refcount((IUnknown
*)d3drm1
);
4461 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
4462 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4463 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4465 /* InitFromD3D tests */
4466 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice
, (void **)&device1
);
4467 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr
);
4469 hr
= IDirect3DRMDevice_InitFromD3D(device1
, NULL
, d3ddevice1
);
4470 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4471 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, NULL
);
4472 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4474 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
4475 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice interface (hr = %#x)\n", hr
);
4476 ref2
= get_refcount((IUnknown
*)d3drm1
);
4477 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
4478 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4479 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4480 device_ref1
, device_ref2
);
4481 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
4482 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4483 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
4484 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4485 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
4486 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4488 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
4489 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4490 ref3
= get_refcount((IUnknown
*)d3drm1
);
4491 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4492 ref3
= get_refcount((IUnknown
*)d3ddevice1
);
4493 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4494 ref3
= get_refcount((IUnknown
*)d3d1
);
4495 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4496 /* Release leaked references */
4497 while (IDirect3DRM_Release(d3drm1
) > ref2
);
4498 while (IDirect3DDevice_Release(d3ddevice1
) > device_ref2
);
4499 while (IDirect3D_Release(d3d1
) > d3d_ref2
);
4501 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
4502 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface (hr = %#x).\n", hr
);
4503 ref4
= get_refcount((IUnknown
*)temp_ddraw1
);
4505 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D
, (void **)&temp_d3d1
);
4506 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr
);
4507 temp_d3ddevice1
= create_device1(temp_ddraw1
, window
, &surface
);
4508 hr
= IDirect3DRMDevice_InitFromD3D(device1
, temp_d3d1
, temp_d3ddevice1
);
4509 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4510 ref3
= get_refcount((IUnknown
*)d3drm1
);
4511 ok(ref3
> ref2
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4512 ref3
= get_refcount((IUnknown
*)temp_d3ddevice1
);
4513 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4514 ref3
= get_refcount((IUnknown
*)temp_d3d1
);
4515 todo_wine
ok(ref3
< d3d_ref2
, "Expected ref3 < d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4516 /* Release leaked references */
4517 while (IDirect3DRM_Release(d3drm1
) > ref2
);
4518 while (IDirect3DDevice_Release(temp_d3ddevice1
) > 0);
4519 while (IDirect3D_Release(temp_d3d1
) > ref4
);
4520 IDirectDrawSurface_Release(surface
);
4521 IDirectDraw_Release(temp_ddraw1
);
4523 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4524 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
4525 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr
);
4526 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4527 ok(SUCCEEDED(hr
), "Expected hr == D3DRM_OK, got %#x.\n", hr
);
4528 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4529 IDirect3DRMDevice2_Release(device2
);
4531 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4532 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
4533 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 Interface (hr = %#x).\n", hr
);
4534 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4535 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4536 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4537 IDirect3DRMDevice3_Release(device3
);
4540 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4541 NULL
, &surface
, surface_callback
);
4542 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces (hr = %#x).\n", hr
);
4543 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4545 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3drm_d3ddevice1
);
4546 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice interface (hr = %#x).\n", hr
);
4547 ok(d3ddevice1
== d3drm_d3ddevice1
, "Expected Immediate Mode device created == %p, got %p.\n",
4548 d3ddevice1
, d3drm_d3ddevice1
);
4550 /* Check properties of render target and depth surfaces */
4551 hr
= IDirect3DDevice_QueryInterface(d3drm_d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
4552 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
4554 memset(&desc
, 0, sizeof(desc
));
4555 desc
.dwSize
= sizeof(desc
);
4556 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4557 ok(SUCCEEDED(hr
), "Cannot get surface desc structure (hr = %#x).\n", hr
);
4559 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4560 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4561 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
4562 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4563 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4564 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4566 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4567 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
4568 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4570 desc
.dwSize
= sizeof(desc
);
4571 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4572 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure (hr = %#x).\n", hr
);
4574 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4575 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4576 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %#x, got %#x.\n",
4577 DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4578 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4579 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
4581 IDirectDrawSurface_Release(d3drm_ds
);
4582 IDirectDrawSurface_Release(ds
);
4583 IDirectDrawSurface_Release(surface
);
4584 IDirect3DDevice_Release(d3drm_d3ddevice1
);
4585 IDirect3DRMDevice_Release(device1
);
4586 ref2
= get_refcount((IUnknown
*)d3drm1
);
4587 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
4588 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4589 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4590 device_ref1
, device_ref2
);
4591 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
4592 todo_wine
ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
,
4595 IDirect3DRM_Release(d3drm1
);
4596 IDirect3DDevice_Release(d3ddevice1
);
4597 IDirect3D_Release(d3d1
);
4598 IDirectDraw_Release(ddraw1
);
4599 DestroyWindow(window
);
4602 static IDirect3DDevice2
*create_device2(IDirectDraw2
*ddraw
, HWND window
, IDirectDrawSurface
**ds
)
4604 static const DWORD z_depths
[] = { 32, 24, 16 };
4605 IDirectDrawSurface
*surface
;
4606 IDirect3DDevice2
*device
= NULL
;
4607 DDSURFACEDESC surface_desc
;
4613 GetClientRect(window
, &rc
);
4614 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4615 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4617 memset(&surface_desc
, 0, sizeof(surface_desc
));
4618 surface_desc
.dwSize
= sizeof(surface_desc
);
4619 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4620 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4621 surface_desc
.dwWidth
= rc
.right
;
4622 surface_desc
.dwHeight
= rc
.bottom
;
4624 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
4625 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4627 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
4630 IDirectDrawSurface_Release(surface
);
4635 /* We used to use EnumDevices() for this, but it seems
4636 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
4637 * relationship with reality. */
4638 for (i
= 0; i
< sizeof(z_depths
) / sizeof(*z_depths
); ++i
)
4640 memset(&surface_desc
, 0, sizeof(surface_desc
));
4641 surface_desc
.dwSize
= sizeof(surface_desc
);
4642 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4643 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
4644 U2(surface_desc
).dwZBufferBitDepth
= z_depths
[i
];
4645 surface_desc
.dwWidth
= rc
.right
;
4646 surface_desc
.dwHeight
= rc
.bottom
;
4647 if (FAILED(IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, ds
, NULL
)))
4650 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, *ds
);
4651 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4654 IDirectDrawSurface_Release(*ds
);
4658 if (SUCCEEDED(IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
)))
4661 IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, *ds
);
4662 IDirectDrawSurface_Release(*ds
);
4666 IDirect3D2_Release(d3d
);
4667 IDirectDrawSurface_Release(surface
);
4671 static void test_create_device_from_d3d2(void)
4673 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
4674 IDirectDraw2
*ddraw2
= NULL
, *temp_ddraw2
;
4676 IDirect3D2
*d3d2
= NULL
, *temp_d3d2
;
4677 IDirect3DRM
*d3drm1
= NULL
;
4678 IDirect3DRM2
*d3drm2
= NULL
;
4679 IDirect3DRMDevice
*device1
;
4680 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
4681 IDirect3DDevice
*d3ddevice1
;
4682 IDirect3DDevice2
*d3ddevice2
= NULL
, *d3drm_d3ddevice2
= NULL
, *temp_d3ddevice2
;
4683 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
4684 DWORD expected_flags
, ret_val
;
4685 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4689 ULONG ref1
, ref2
, ref3
, ref4
, ref5
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
4692 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
4693 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4695 window
= create_window();
4696 GetClientRect(window
, &rc
);
4698 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
4699 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
4700 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
4701 ok(hr
== DD_OK
, "Cannot get IDirectDraw2 interface (hr = %x).\n", hr
);
4702 d3d_ref1
= get_refcount((IUnknown
*)d3d2
);
4704 /* Create the immediate mode device */
4705 d3ddevice2
= create_device2(ddraw2
, window
, &ds
);
4706 if (d3ddevice2
== NULL
)
4708 win_skip("Cannot create IM device, skipping tests.\n");
4709 IDirect3D2_Release(d3d2
);
4710 IDirectDraw2_Release(ddraw2
);
4711 IDirectDraw_Release(ddraw1
);
4714 device_ref1
= get_refcount((IUnknown
*)d3ddevice2
);
4716 hr
= Direct3DRMCreate(&d3drm1
);
4717 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4718 ref1
= get_refcount((IUnknown
*)d3drm1
);
4720 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
4721 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
4722 ref2
= get_refcount((IUnknown
*)d3drm2
);
4724 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, NULL
, d3ddevice2
, &device2
);
4725 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4726 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
4727 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, NULL
, &device2
);
4728 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4729 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, d3ddevice2
, NULL
);
4730 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4732 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, d3ddevice2
, &device2
);
4733 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice2 interface (hr = %x)\n", hr
);
4734 ref3
= get_refcount((IUnknown
*)d3drm1
);
4735 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4736 ref3
= get_refcount((IUnknown
*)d3drm2
);
4737 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4738 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4739 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4740 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4741 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4742 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4743 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4744 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4745 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4747 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4748 NULL
, &surface
, surface_callback
);
4749 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4750 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4752 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3drm_d3ddevice2
);
4753 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4754 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
, d3drm_d3ddevice2
);
4756 /* Check properties of render target and depth surfaces */
4757 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
4758 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4760 memset(&desc
, 0, sizeof(desc
));
4761 desc
.dwSize
= sizeof(desc
);
4762 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4763 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
4765 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4766 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4767 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4768 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4769 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4770 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4772 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4773 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4774 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4776 desc
.dwSize
= sizeof(desc
);
4777 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4778 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4780 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4781 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4782 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4783 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4784 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4786 IDirectDrawSurface_Release(d3drm_ds
);
4787 IDirectDrawSurface_Release(ds
);
4788 IDirectDrawSurface_Release(surface
);
4789 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
4790 IDirect3DRMDevice2_Release(device2
);
4791 ref3
= get_refcount((IUnknown
*)d3drm1
);
4792 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
4793 ref3
= get_refcount((IUnknown
*)d3drm2
);
4794 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4795 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4796 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4797 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4798 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4800 /* InitFromD3D tests */
4801 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
4802 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface (hr = %#x).\n", hr
);
4804 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
4805 ok(SUCCEEDED(hr
), "Cannot get IDirect3D interface (hr = %x).\n", hr
);
4806 if (SUCCEEDED(hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice
, (void **)&d3ddevice1
)))
4808 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, d3d1
, d3ddevice1
);
4809 ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
4810 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, NULL
, d3ddevice1
);
4811 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4812 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, d3d1
, NULL
);
4813 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4814 hr
= IDirect3DRMDevice2_QueryInterface(device2
, &IID_IDirect3DRMDevice
, (void **)&device1
);
4815 ok(SUCCEEDED(hr
), "Cannot obtain IDirect3DRMDevice interface (hr = %#x).\n", hr
);
4816 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
4817 todo_wine
ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
4818 IDirect3DRMDevice_Release(device1
);
4821 IDirect3DRMDevice_Release(device1
);
4822 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice2
,
4824 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface (hr = %#x).\n", hr
);
4827 IDirect3D_Release(d3d1
);
4828 IDirect3DDevice_Release(d3ddevice1
);
4830 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, NULL
, d3ddevice2
);
4831 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4832 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, NULL
);
4833 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4835 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, d3ddevice2
);
4836 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice2 interface (hr = %#x)\n", hr
);
4837 ref4
= get_refcount((IUnknown
*)d3drm1
);
4838 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
4839 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4840 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4841 device_ref1
, device_ref2
);
4842 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4843 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4844 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4845 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4846 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4847 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4849 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, d3ddevice2
);
4850 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4851 ref3
= get_refcount((IUnknown
*)d3drm1
);
4852 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4853 ref3
= get_refcount((IUnknown
*)d3ddevice2
);
4854 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4855 ref3
= get_refcount((IUnknown
*)d3d2
);
4856 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4857 /* Release leaked references */
4858 while (IDirect3DRM_Release(d3drm1
) > ref4
);
4859 while (IDirect3DDevice2_Release(d3ddevice2
) > device_ref2
);
4860 while (IDirect3D2_Release(d3d2
) > d3d_ref2
);
4862 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
4863 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface (hr = %#x).\n", hr
);
4864 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D2
, (void **)&temp_d3d2
);
4865 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr
);
4866 ref5
= get_refcount((IUnknown
*)temp_d3d2
);
4868 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirectDraw2
, (void **)&temp_ddraw2
);
4869 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface (hr = %#x).\n", hr
);
4871 temp_d3ddevice2
= create_device2(temp_ddraw2
, window
, &surface
);
4872 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, temp_d3d2
, temp_d3ddevice2
);
4873 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4874 ref3
= get_refcount((IUnknown
*)d3drm1
);
4875 ok(ref3
> ref4
, "expected ref3 > ref4, got ref3 = %u , ref4 = %u.\n", ref3
, ref4
);
4876 ref3
= get_refcount((IUnknown
*)temp_d3ddevice2
);
4877 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4878 ref3
= get_refcount((IUnknown
*)temp_d3d2
);
4879 ok(ref3
== d3d_ref2
, "Expected ref3 == d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4880 /* Release leaked references */
4881 while (IDirect3DRM_Release(d3drm1
) > ref4
);
4882 while (IDirect3DDevice2_Release(temp_d3ddevice2
) > 0);
4883 while (IDirect3D2_Release(temp_d3d2
) >= ref5
);
4884 IDirectDrawSurface_Release(surface
);
4885 IDirectDraw2_Release(temp_ddraw2
);
4886 IDirectDraw_Release(temp_ddraw1
);
4889 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4890 NULL
, &surface
, surface_callback
);
4891 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces (hr = %#x).\n", hr
);
4892 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4894 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3drm_d3ddevice2
);
4895 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface (hr = %#x).\n", hr
);
4896 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
,
4899 /* Check properties of render target and depth surfaces */
4900 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
4901 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
4903 memset(&desc
, 0, sizeof(desc
));
4904 desc
.dwSize
= sizeof(desc
);
4905 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4906 ok(SUCCEEDED(hr
), "Cannot get surface desc structure (hr = %#x).\n", hr
);
4908 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4909 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4910 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
4911 "Expected caps containing %#x, got %#x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4912 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4913 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
4915 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4916 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
4917 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4919 desc
.dwSize
= sizeof(desc
);
4920 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4921 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure (hr = %x).\n", hr
);
4923 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4924 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4925 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %#x, got %#x.\n",
4926 DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4927 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4928 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
4930 IDirectDrawSurface_Release(d3drm_ds
);
4931 IDirectDrawSurface_Release(ds
);
4932 IDirectDrawSurface_Release(surface
);
4933 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
4934 IDirect3DRMDevice2_Release(device2
);
4935 ref3
= get_refcount((IUnknown
*)d3drm1
);
4936 ok(ref1
== ref3
, "Expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
4937 ref3
= get_refcount((IUnknown
*)d3drm2
);
4938 ok(ref3
== ref2
, "Expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4939 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4940 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4941 device_ref1
, device_ref2
);
4942 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4943 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4945 IDirect3DRM2_Release(d3drm2
);
4946 IDirect3DRM_Release(d3drm1
);
4947 IDirect3DDevice2_Release(d3ddevice2
);
4948 IDirect3D2_Release(d3d2
);
4949 IDirectDraw2_Release(ddraw2
);
4950 IDirectDraw_Release(ddraw1
);
4951 DestroyWindow(window
);
4954 static void test_create_device_from_d3d3(void)
4956 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
4957 IDirectDraw2
*ddraw2
= NULL
, *temp_ddraw2
;
4959 IDirect3D2
*d3d2
= NULL
, *temp_d3d2
;
4960 IDirect3DRM
*d3drm1
= NULL
;
4961 IDirect3DRM3
*d3drm3
= NULL
;
4962 IDirect3DRMDevice
*device1
;
4963 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
4964 IDirect3DDevice
*d3ddevice1
;
4965 IDirect3DDevice2
*d3ddevice2
= NULL
, *d3drm_d3ddevice2
= NULL
, *temp_d3ddevice2
;
4966 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
4967 DWORD expected_flags
, ret_val
;
4968 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4972 ULONG ref1
, ref2
, ref3
, ref4
, ref5
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
4975 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
4976 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4978 window
= create_window();
4979 GetClientRect(window
, &rc
);
4981 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
4982 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
4983 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
4984 ok(hr
== DD_OK
, "Cannot get IDirectDraw2 interface (hr = %x).\n", hr
);
4985 d3d_ref1
= get_refcount((IUnknown
*)d3d2
);
4987 /* Create the immediate mode device */
4988 d3ddevice2
= create_device2(ddraw2
, window
, &ds
);
4989 if (d3ddevice2
== NULL
)
4991 win_skip("Cannot create IM device, skipping tests.\n");
4992 IDirect3D2_Release(d3d2
);
4993 IDirectDraw2_Release(ddraw2
);
4994 IDirectDraw_Release(ddraw1
);
4997 device_ref1
= get_refcount((IUnknown
*)d3ddevice2
);
4999 hr
= Direct3DRMCreate(&d3drm1
);
5000 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
5001 ref1
= get_refcount((IUnknown
*)d3drm1
);
5003 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5004 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
5005 ref2
= get_refcount((IUnknown
*)d3drm3
);
5007 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, NULL
, d3ddevice2
, &device3
);
5008 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
5009 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
5010 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, NULL
, &device3
);
5011 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
5012 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3ddevice2
, NULL
);
5013 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
5015 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3ddevice2
, &device3
);
5016 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
5017 ref3
= get_refcount((IUnknown
*)d3drm1
);
5018 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
5019 ref3
= get_refcount((IUnknown
*)d3drm3
);
5020 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5021 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5022 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
5023 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
5024 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
5025 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
5026 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
5028 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5029 NULL
, &surface
, surface_callback
);
5030 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
5031 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5033 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3drm_d3ddevice2
);
5034 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
5035 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
, d3drm_d3ddevice2
);
5037 /* Check properties of render target and depth surfaces */
5038 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5039 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
5041 memset(&desc
, 0, sizeof(desc
));
5042 desc
.dwSize
= sizeof(desc
);
5043 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5044 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
5046 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5047 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5048 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
5049 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
5050 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5051 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
5053 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5054 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
5055 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5057 desc
.dwSize
= sizeof(desc
);
5058 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5059 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
5061 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5062 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5063 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
5064 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5065 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
5067 IDirectDrawSurface_Release(d3drm_ds
);
5068 IDirectDrawSurface_Release(ds
);
5069 IDirectDrawSurface_Release(surface
);
5070 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5071 IDirect3DRMDevice3_Release(device3
);
5072 ref3
= get_refcount((IUnknown
*)d3drm1
);
5073 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
5074 ref3
= get_refcount((IUnknown
*)d3drm3
);
5075 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5076 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5077 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
5078 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5079 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5081 /* InitFromD3D tests */
5082 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
5083 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %#x).\n", hr
);
5085 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
5086 ok(SUCCEEDED(hr
), "Cannot get IDirect3D interface (hr = %#x).\n", hr
);
5087 if (SUCCEEDED(hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice
, (void **)&d3ddevice1
)))
5089 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, d3d1
, d3ddevice1
);
5090 ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
5091 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, NULL
, d3ddevice1
);
5092 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5093 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, d3d1
, NULL
);
5094 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5095 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice
, (void **)&device1
);
5096 ok(SUCCEEDED(hr
), "Cannot obtain IDirect3DRMDevice interface (hr = %#x).\n", hr
);
5097 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
5098 todo_wine
ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
5099 IDirect3DRMDevice_Release(device1
);
5102 IDirect3DRMDevice_Release(device1
);
5103 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice3
,
5105 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %#x).\n", hr
);
5108 IDirect3D_Release(d3d1
);
5109 IDirect3DDevice_Release(d3ddevice1
);
5111 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, NULL
, d3ddevice2
);
5112 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5113 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, NULL
);
5114 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5116 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, d3ddevice2
);
5117 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice2 interface (hr = %#x)\n", hr
);
5118 ref4
= get_refcount((IUnknown
*)d3drm1
);
5119 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
5120 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5121 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5122 device_ref1
, device_ref2
);
5123 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5124 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5125 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
5126 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
5127 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
5128 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
5130 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, d3ddevice2
);
5131 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
5132 ref3
= get_refcount((IUnknown
*)d3drm1
);
5133 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
5134 ref3
= get_refcount((IUnknown
*)d3ddevice2
);
5135 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
5136 ref3
= get_refcount((IUnknown
*)d3d2
);
5137 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
5138 /* Release leaked references */
5139 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5140 while (IDirect3DDevice2_Release(d3ddevice2
) > device_ref2
);
5141 while (IDirect3D2_Release(d3d2
) > d3d_ref2
);
5143 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
5144 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface (hr = %#x).\n", hr
);
5145 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D2
, (void **)&temp_d3d2
);
5146 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr
);
5147 ref5
= get_refcount((IUnknown
*)temp_d3d2
);
5149 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirectDraw2
, (void **)&temp_ddraw2
);
5150 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface (hr = %#x).\n", hr
);
5152 temp_d3ddevice2
= create_device2(temp_ddraw2
, window
, &surface
);
5153 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, temp_d3d2
, temp_d3ddevice2
);
5154 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
5155 ref3
= get_refcount((IUnknown
*)d3drm1
);
5156 ok(ref3
> ref4
, "expected ref3 > ref4, got ref3 = %u , ref4 = %u.\n", ref3
, ref4
);
5157 ref3
= get_refcount((IUnknown
*)temp_d3ddevice2
);
5158 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
5159 ref3
= get_refcount((IUnknown
*)temp_d3d2
);
5160 ok(ref3
== d3d_ref2
, "Expected ref3 == d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
5161 /* Release leaked references */
5162 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5163 while (IDirect3DDevice2_Release(temp_d3ddevice2
) > 0);
5164 while (IDirect3D2_Release(temp_d3d2
) >= ref5
);
5165 IDirectDrawSurface_Release(surface
);
5166 IDirectDraw2_Release(temp_ddraw2
);
5167 IDirectDraw_Release(temp_ddraw1
);
5170 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5171 NULL
, &surface
, surface_callback
);
5172 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces (hr = %#x).\n", hr
);
5173 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5175 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3drm_d3ddevice2
);
5176 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface (hr = %#x).\n", hr
);
5177 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
,
5180 /* Check properties of render target and depth surfaces */
5181 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5182 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
5184 memset(&desc
, 0, sizeof(desc
));
5185 desc
.dwSize
= sizeof(desc
);
5186 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5187 ok(SUCCEEDED(hr
), "Cannot get surface desc structure (hr = %x).\n", hr
);
5189 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5190 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5191 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
5192 "Expected caps containing %#x, got %#x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
5193 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5194 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
5196 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5197 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
5198 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5200 desc
.dwSize
= sizeof(desc
);
5201 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5202 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure (hr = %x).\n", hr
);
5204 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5205 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5206 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %#x.\n",
5207 DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
5208 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5209 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
5211 IDirectDrawSurface_Release(d3drm_ds
);
5212 IDirectDrawSurface_Release(ds
);
5213 IDirectDrawSurface_Release(surface
);
5214 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5215 IDirect3DRMDevice3_Release(device3
);
5216 ref3
= get_refcount((IUnknown
*)d3drm1
);
5217 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
5218 ref3
= get_refcount((IUnknown
*)d3drm3
);
5219 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5220 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5221 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5222 device_ref1
, device_ref2
);
5223 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5224 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5226 IDirect3DRM3_Release(d3drm3
);
5227 IDirect3DRM_Release(d3drm1
);
5228 IDirect3DDevice2_Release(d3ddevice2
);
5229 IDirect3D2_Release(d3d2
);
5230 IDirectDraw2_Release(ddraw2
);
5231 IDirectDraw_Release(ddraw1
);
5232 DestroyWindow(window
);
5235 static char *create_bitmap(unsigned int w
, unsigned int h
, BOOL palettized
)
5237 unsigned int bpp
= palettized
? 8 : 24;
5238 BITMAPFILEHEADER file_header
;
5239 DWORD written
, size
, ret
;
5240 unsigned char *buffer
;
5241 char path
[MAX_PATH
];
5247 ret
= GetTempPathA(MAX_PATH
, path
);
5248 ok(ret
, "Failed to get temporary file path.\n");
5249 filename
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
5250 ret
= GetTempFileNameA(path
, "d3d", 0, filename
);
5251 ok(ret
, "Failed to get filename.\n");
5252 file
= CreateFileA(filename
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
5253 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to open temporary file \"%s\".\n", filename
);
5255 size
= FIELD_OFFSET(BITMAPINFO
, bmiColors
[palettized
? 256 : 0]);
5257 memset(&file_header
, 0, sizeof(file_header
));
5258 file_header
.bfType
= 0x4d42; /* BM */
5259 file_header
.bfOffBits
= sizeof(file_header
) + size
;
5260 file_header
.bfSize
= file_header
.bfOffBits
+ w
* h
* (bpp
/ 8);
5261 ret
= WriteFile(file
, &file_header
, sizeof(file_header
), &written
, NULL
);
5262 ok(ret
&& written
== sizeof(file_header
), "Failed to write file header.\n");
5264 info
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
5265 info
->bmiHeader
.biSize
= sizeof(info
->bmiHeader
);
5266 info
->bmiHeader
.biBitCount
= bpp
;
5267 info
->bmiHeader
.biPlanes
= 1;
5268 info
->bmiHeader
.biWidth
= w
;
5269 info
->bmiHeader
.biHeight
= h
;
5270 info
->bmiHeader
.biCompression
= BI_RGB
;
5273 for (i
= 0; i
< 256; ++i
)
5275 info
->bmiColors
[i
].rgbBlue
= i
;
5276 info
->bmiColors
[i
].rgbGreen
= i
;
5277 info
->bmiColors
[i
].rgbRed
= i
;
5280 ret
= WriteFile(file
, info
, size
, &written
, NULL
);
5281 ok(ret
&& written
== size
, "Failed to write bitmap info.\n");
5282 HeapFree(GetProcessHeap(), 0, info
);
5284 size
= w
* h
* (bpp
/ 8);
5285 buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
5286 for (i
= 0, j
= 0; i
< size
;)
5295 buffer
[i
++] = j
% 251;
5296 buffer
[i
++] = j
% 239;
5297 buffer
[i
++] = j
++ % 247;
5300 ret
= WriteFile(file
, buffer
, size
, &written
, NULL
);
5301 ok(ret
&& written
== size
, "Failed to write bitmap data.\n");
5302 HeapFree(GetProcessHeap(), 0, buffer
);
5309 static void test_bitmap_data(unsigned int test_idx
, const D3DRMIMAGE
*img
,
5310 BOOL upside_down
, unsigned int w
, unsigned int h
, BOOL palettized
)
5312 const unsigned char *data
= img
->buffer1
;
5315 ok(img
->width
== w
, "Test %u: Got unexpected image width %u, expected %u.\n", test_idx
, img
->width
, w
);
5316 ok(img
->height
== h
, "Test %u: Got unexpected image height %u, expected %u.\n", test_idx
, img
->height
, h
);
5317 ok(img
->aspectx
== 1, "Test %u: Got unexpected image aspectx %u.\n", test_idx
, img
->aspectx
);
5318 ok(img
->aspecty
== 1, "Test %u: Got unexpected image aspecty %u.\n", test_idx
, img
->aspecty
);
5319 ok(!img
->buffer2
, "Test %u: Got unexpected image buffer2 %p.\n", test_idx
, img
->buffer2
);
5321 /* The image is palettized if the total number of colors used is <= 256. */
5322 if (w
* h
> 256 && !palettized
)
5324 /* D3drm aligns the 24bpp texture to 4 bytes in the buffer, with one
5325 * byte padding from 24bpp texture. */
5326 ok(img
->depth
== 32, "Test %u: Got unexpected image depth %u.\n", test_idx
, img
->depth
);
5327 ok(img
->rgb
== TRUE
, "Test %u: Got unexpected image rgb %#x.\n", test_idx
, img
->rgb
);
5328 ok(img
->bytes_per_line
== w
* 4, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5329 test_idx
, img
->bytes_per_line
, w
* 4);
5330 ok(img
->red_mask
== 0xff0000, "Test %u: Got unexpected image red mask %#x.\n", test_idx
, img
->red_mask
);
5331 ok(img
->green_mask
== 0x00ff00, "Test %u: Got unexpected image green mask %#x.\n", test_idx
, img
->green_mask
);
5332 ok(img
->blue_mask
== 0x0000ff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx
, img
->blue_mask
);
5333 ok(!img
->alpha_mask
, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx
, img
->alpha_mask
);
5334 ok(!img
->palette_size
, "Test %u: Got unexpected palette size %u.\n", test_idx
, img
->palette_size
);
5335 ok(!img
->palette
, "Test %u: Got unexpected image palette %p.\n", test_idx
, img
->palette
);
5336 for (i
= 0; i
< h
; ++i
)
5338 for (j
= 0; j
< w
; ++j
)
5340 const unsigned char *ptr
= &data
[i
* img
->bytes_per_line
+ j
* 4];
5341 unsigned int idx
= upside_down
? (h
- 1 - i
) * w
+ j
: i
* w
+ j
;
5343 if (ptr
[0] != idx
% 251 || ptr
[1] != idx
% 239 || ptr
[2] != idx
% 247 || ptr
[3] != 0xff)
5345 ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
5346 "expected 0x%02x%02x%02x%02x.\n", test_idx
, ptr
[0], ptr
[1], ptr
[2], ptr
[3],
5347 j
, i
, idx
% 251, idx
% 239, idx
% 247, 0xff);
5355 ok(img
->depth
== 8, "Test %u: Got unexpected image depth %u.\n", test_idx
, img
->depth
);
5356 ok(!img
->rgb
, "Test %u: Got unexpected image rgb %#x.\n", test_idx
, img
->rgb
);
5357 ok(img
->red_mask
== 0xff, "Test %u: Got unexpected image red mask %#x.\n", test_idx
, img
->red_mask
);
5358 ok(img
->green_mask
== 0xff, "Test %u: Got unexpected image green mask %#x.\n", test_idx
, img
->green_mask
);
5359 ok(img
->blue_mask
== 0xff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx
, img
->blue_mask
);
5360 ok(!img
->alpha_mask
, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx
, img
->alpha_mask
);
5361 ok(!!img
->palette
, "Test %u: Got unexpected image palette %p.\n", test_idx
, img
->palette
);
5364 /* In this case, bytes_per_line is aligned to the next multiple of
5366 ok(img
->bytes_per_line
== ((w
+ 3) & ~3), "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5367 test_idx
, img
->bytes_per_line
, (w
+ 3) & ~3);
5368 ok(img
->palette_size
== w
* h
, "Test %u: Got unexpected palette size %u, expected %u.\n",
5369 test_idx
, img
->palette_size
, w
* h
);
5370 for (i
= 0; i
< img
->palette_size
; ++i
)
5372 unsigned int idx
= upside_down
? (h
- 1) * w
- i
+ (i
% w
) * 2 : i
;
5373 ok(img
->palette
[i
].red
== idx
% 251
5374 && img
->palette
[i
].green
== idx
% 239 && img
->palette
[i
].blue
== idx
% 247,
5375 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
5376 test_idx
, i
, img
->palette
[i
].red
, img
->palette
[i
].green
, img
->palette
[i
].blue
);
5377 ok(img
->palette
[i
].flags
== D3DRMPALETTE_READONLY
,
5378 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
5379 test_idx
, i
, img
->palette
[i
].flags
);
5381 for (i
= 0; i
< h
; ++i
)
5383 for (j
= 0; j
< w
; ++j
)
5385 if (data
[i
* img
->bytes_per_line
+ j
] != i
* w
+ j
)
5387 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
5388 test_idx
, data
[i
* img
->bytes_per_line
+ j
], j
, i
, i
* w
+ j
);
5396 /* bytes_per_line is not always aligned by d3drm depending on the
5398 ok(img
->bytes_per_line
== w
, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5399 test_idx
, img
->bytes_per_line
, w
);
5400 ok(img
->palette_size
== 256, "Test %u: Got unexpected palette size %u.\n", test_idx
, img
->palette_size
);
5401 for (i
= 0; i
< 256; ++i
)
5403 ok(img
->palette
[i
].red
== i
&& img
->palette
[i
].green
== i
&& img
->palette
[i
].blue
== i
,
5404 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
5405 test_idx
, i
, img
->palette
[i
].red
, img
->palette
[i
].green
, img
->palette
[i
].blue
);
5406 ok(img
->palette
[i
].flags
== D3DRMPALETTE_READONLY
,
5407 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
5408 test_idx
, i
, img
->palette
[i
].flags
);
5410 for (i
= 0; i
< h
; ++i
)
5412 for (j
= 0; j
< w
; ++j
)
5414 unsigned int idx
= upside_down
? (h
- 1 - i
) * w
+ j
: i
* w
+ j
;
5415 if (data
[i
* img
->bytes_per_line
+ j
] != idx
% 256)
5417 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
5418 test_idx
, data
[i
* img
->bytes_per_line
+ j
], j
, i
, idx
% 256);
5425 static void test_load_texture(void)
5427 IDirect3DRMTexture3
*texture3
;
5428 IDirect3DRMTexture2
*texture2
;
5429 IDirect3DRMTexture
*texture1
;
5430 D3DRMIMAGE
*d3drm_img
;
5431 IDirect3DRM3
*d3drm3
;
5432 IDirect3DRM2
*d3drm2
;
5433 IDirect3DRM
*d3drm1
;
5454 hr
= Direct3DRMCreate(&d3drm1
);
5455 ok(hr
== D3DRM_OK
, "Failed to create IDirect3DRM object, hr %#x.\n", hr
);
5456 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5457 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM2 interface, hr %#x.\n", hr
);
5458 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5459 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM3 interface, hr %#x.\n", hr
);
5461 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); ++i
)
5463 filename
= create_bitmap(tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5465 hr
= IDirect3DRM_LoadTexture(d3drm1
, filename
, &texture1
);
5466 ok(SUCCEEDED(hr
), "Test %u: Failed to load texture, hr %#x.\n", i
, hr
);
5467 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
5468 todo_wine
ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5470 test_bitmap_data(i
* 4, d3drm_img
, FALSE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5471 IDirect3DRMTexture_Release(texture1
);
5473 hr
= IDirect3DRM2_LoadTexture(d3drm2
, filename
, &texture2
);
5474 ok(SUCCEEDED(hr
), "Test %u: Failed to load texture, hr %#x.\n", i
, hr
);
5475 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
5476 todo_wine
ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5478 test_bitmap_data(i
* 4 + 1, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5479 IDirect3DRMTexture2_Release(texture2
);
5481 hr
= IDirect3DRM3_LoadTexture(d3drm3
, filename
, &texture3
);
5482 ok(SUCCEEDED(hr
), "Test %u: Failed to load texture, hr %#x.\n", i
, hr
);
5483 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
5484 todo_wine
ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5486 test_bitmap_data(i
* 4 + 2, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5487 /* Test whether querying a version 1 texture from version 3 causes a
5488 * change in the loading behavior. */
5489 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture
, (void **)&texture1
);
5490 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMTexture interface, hr %#x.\n", hr
);
5491 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
5492 todo_wine
ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5494 test_bitmap_data(i
* 4 + 3, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5495 IDirect3DRMTexture_Release(texture1
);
5496 IDirect3DRMTexture3_Release(texture3
);
5498 ret
= DeleteFileA(filename
);
5499 ok(ret
, "Test %u: Failed to delete bitmap \"%s\".\n", i
, filename
);
5500 HeapFree(GetProcessHeap(), 0, filename
);
5503 IDirect3DRM3_Release(d3drm3
);
5504 IDirect3DRM2_Release(d3drm2
);
5505 IDirect3DRM_Release(d3drm1
);
5508 static void test_texture_qi(void)
5510 static const struct qi_test tests
[] =
5512 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5513 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5514 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5515 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5516 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5517 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5518 { &IID_IDirect3DRMWinDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5519 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
5520 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5521 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5522 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5523 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5524 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5525 { &IID_IDirect3DRMVisual
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
5526 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5527 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5528 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5529 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5530 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5531 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5532 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5533 { &IID_IDirect3DRMTexture
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
5534 { &IID_IDirect3DRMTexture2
, &IID_IUnknown
, &IID_IDirect3DRMTexture2
, S_OK
},
5535 { &IID_IDirect3DRMTexture3
, &IID_IUnknown
, &IID_IDirect3DRMTexture3
, S_OK
},
5536 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5537 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5538 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5539 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5540 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5541 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5542 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5543 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5544 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5545 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5546 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5547 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5548 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5549 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5550 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5551 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5552 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5553 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5554 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5555 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5556 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5557 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5558 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5559 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5560 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5561 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5562 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5563 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5564 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5565 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5566 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5567 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5568 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5569 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5570 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5571 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5572 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5573 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5574 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5575 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5576 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5577 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5578 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5579 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
5582 IDirect3DRM
*d3drm1
;
5583 IDirect3DRM2
*d3drm2
;
5584 IDirect3DRM3
*d3drm3
;
5585 IDirect3DRMTexture
*texture1
;
5586 IDirect3DRMTexture2
*texture2
;
5587 IDirect3DRMTexture3
*texture3
;
5592 hr
= Direct3DRMCreate(&d3drm1
);
5593 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x)\n", hr
);
5594 filename
= create_bitmap(1, 1, TRUE
);
5595 hr
= IDirect3DRM_LoadTexture(d3drm1
, filename
, &texture1
);
5596 ok(SUCCEEDED(hr
), "Failed to load texture (hr = %#x).\n", hr
);
5597 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
5598 hr
= IDirect3DRMTexture_QueryInterface(texture1
, &IID_IUnknown
, (void **)&unknown
);
5599 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture (hr = %#x)\n", hr
);
5600 IDirect3DRMTexture_Release(texture1
);
5601 test_qi("texture1_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
5602 IUnknown_Release(unknown
);
5604 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5605 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
5606 hr
= IDirect3DRM2_LoadTexture(d3drm2
, filename
, &texture2
);
5607 ok(SUCCEEDED(hr
), "Failed to load texture (hr = %#x).\n", hr
);
5608 hr
= IDirect3DRMTexture2_QueryInterface(texture2
, &IID_IUnknown
, (void **)&unknown
);
5609 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture2 (hr = %#x)\n", hr
);
5610 IDirect3DRMTexture2_Release(texture2
);
5611 test_qi("texture2_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
5612 IUnknown_Release(unknown
);
5614 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5615 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
5616 hr
= IDirect3DRM3_LoadTexture(d3drm3
, filename
, &texture3
);
5617 ok(SUCCEEDED(hr
), "Failed to load texture (hr = %#x).\n", hr
);
5618 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
5619 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IUnknown
, (void **)&unknown
);
5620 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture3 (hr = %#x)\n", hr
);
5621 IDirect3DRMTexture3_Release(texture3
);
5622 test_qi("texture3_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
5623 IUnknown_Release(unknown
);
5625 IDirect3DRM3_Release(d3drm3
);
5626 IDirect3DRM2_Release(d3drm2
);
5627 IDirect3DRM_Release(d3drm1
);
5628 check
= DeleteFileA(filename
);
5629 ok(check
, "Cannot delete image stored in %s (error = %d).\n", filename
, GetLastError());
5630 HeapFree(GetProcessHeap(), 0, filename
);
5633 static void test_viewport_qi(void)
5635 IDirect3DRM
*d3drm1
;
5636 IDirect3DRM2
*d3drm2
;
5637 IDirect3DRM3
*d3drm3
;
5638 IDirect3DRMFrame
*frame1
, *camera1
;
5639 IDirect3DRMFrame3
*frame3
, *camera3
;
5640 IDirect3DRMDevice
*device1
;
5641 IDirect3DRMDevice3
*device3
;
5642 IDirectDrawClipper
*clipper
;
5643 IDirect3DRMViewport
*viewport1
;
5644 IDirect3DRMViewport2
*viewport2
;
5646 GUID driver
= IID_IDirect3DRGBDevice
;
5649 static const struct qi_test tests
[] =
5651 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5652 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5653 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5654 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5655 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5656 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5657 { &IID_IDirect3DRMWinDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5658 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMViewport
, S_OK
},
5659 { &IID_IDirect3DRMViewport
, &IID_IUnknown
, &IID_IDirect3DRMViewport
, S_OK
},
5660 { &IID_IDirect3DRMViewport2
, &IID_IUnknown
, &IID_IDirect3DRMViewport2
, S_OK
},
5661 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5662 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5663 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5664 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5665 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5666 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5667 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5668 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5669 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5670 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5671 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5672 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5673 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5674 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5675 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5676 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5677 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5678 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5679 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5680 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5681 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5682 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5683 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5684 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5685 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5686 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5687 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5688 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5689 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5690 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5691 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5692 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5693 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5694 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5695 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5696 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5697 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5698 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5699 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5700 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5701 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5702 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5703 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5704 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5705 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5706 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5707 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5708 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5709 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5710 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5711 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5712 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5713 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5714 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5715 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5716 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5717 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5718 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
5721 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
5722 ok(SUCCEEDED(hr
), "Cannot get IDirectDrawClipper interface (hr = %#x).\n", hr
);
5724 hr
= Direct3DRMCreate(&d3drm1
);
5725 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
5727 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 640, 480, &device1
);
5728 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr
);
5729 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
5730 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
5731 hr
= IDirect3DRM_CreateFrame(d3drm1
, frame1
, &camera1
);
5732 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
5733 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, camera1
, 0, 0, 640, 480, &viewport1
);
5734 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
5735 hr
= IDirect3DRMViewport_QueryInterface(viewport1
, &IID_IUnknown
, (void **)&unknown
);
5736 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface (hr = %#x).\n", hr
);
5737 IDirect3DRMViewport_Release(viewport1
);
5738 test_qi("viewport1_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
5739 IUnknown_Release(unknown
);
5741 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5742 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
5743 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, camera1
, 0, 0, 640, 480, &viewport1
);
5744 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
5745 hr
= IDirect3DRMViewport_QueryInterface(viewport1
, &IID_IUnknown
, (void **)&unknown
);
5746 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface (hr = %#x).\n", hr
);
5747 IDirect3DRMViewport_Release(viewport1
);
5748 test_qi("viewport1_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
5749 IUnknown_Release(unknown
);
5750 IDirect3DRMDevice_Release(device1
);
5751 IDirect3DRMFrame_Release(camera1
);
5752 IDirect3DRMFrame_Release(frame1
);
5754 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5755 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
5756 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 640, 480, &device3
);
5757 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %#x).\n", hr
);
5758 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
5759 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
5760 hr
= IDirect3DRM3_CreateFrame(d3drm3
, frame3
, &camera3
);
5761 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
5762 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, 640, 480, &viewport2
);
5763 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
5764 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IUnknown
, (void **)&unknown
);
5765 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface (hr = %#x).\n", hr
);
5766 IDirect3DRMViewport_Release(viewport2
);
5767 test_qi("viewport2_qi", unknown
, &IID_IUnknown
, tests
, sizeof(tests
) / sizeof(*tests
));
5768 IUnknown_Release(unknown
);
5769 IDirect3DRMDevice3_Release(device3
);
5770 IDirect3DRMFrame3_Release(camera3
);
5771 IDirect3DRMFrame3_Release(frame3
);
5773 IDirectDrawClipper_Release(clipper
);
5774 IDirect3DRM3_Release(d3drm3
);
5775 IDirect3DRM2_Release(d3drm2
);
5776 IDirect3DRM_Release(d3drm1
);
5779 static D3DCOLOR
get_surface_color(IDirectDrawSurface
*surface
, UINT x
, UINT y
)
5781 RECT rect
= { x
, y
, x
+ 1, y
+ 1 };
5782 DDSURFACEDESC surface_desc
;
5786 memset(&surface_desc
, 0, sizeof(surface_desc
));
5787 surface_desc
.dwSize
= sizeof(surface_desc
);
5789 hr
= IDirectDrawSurface_Lock(surface
, &rect
, &surface_desc
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
5790 ok(SUCCEEDED(hr
), "Failed to lock surface, hr %#x.\n", hr
);
5794 color
= *((DWORD
*)surface_desc
.lpSurface
) & 0x00ffffff;
5796 hr
= IDirectDrawSurface_Unlock(surface
, NULL
);
5797 ok(SUCCEEDED(hr
), "Failed to unlock surface, hr %#x.\n", hr
);
5802 static IDirect3DDevice2
*create_device2_without_ds(IDirectDraw2
*ddraw
, HWND window
)
5804 IDirectDrawSurface
*surface
;
5805 IDirect3DDevice2
*device
= NULL
;
5806 DDSURFACEDESC surface_desc
;
5811 GetClientRect(window
, &rc
);
5812 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
5813 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
5815 memset(&surface_desc
, 0, sizeof(surface_desc
));
5816 surface_desc
.dwSize
= sizeof(surface_desc
);
5817 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
5818 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
5819 surface_desc
.dwWidth
= rc
.right
;
5820 surface_desc
.dwHeight
= rc
.bottom
;
5822 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
5823 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
5825 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
5828 IDirectDrawSurface_Release(surface
);
5832 IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
);
5834 IDirect3D2_Release(d3d
);
5835 IDirectDrawSurface_Release(surface
);
5839 static BOOL
compare_color(D3DCOLOR c1
, D3DCOLOR c2
, BYTE max_diff
)
5841 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
5843 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
5845 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
5847 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
5851 static void clear_depth_surface(IDirectDrawSurface
*surface
, DWORD value
)
5856 memset(&fx
, 0, sizeof(fx
));
5857 fx
.dwSize
= sizeof(fx
);
5858 U5(fx
).dwFillDepth
= value
;
5860 hr
= IDirectDrawSurface_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_DEPTHFILL
| DDBLT_WAIT
, &fx
);
5861 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
5864 static void set_execute_data(IDirect3DExecuteBuffer
*execute_buffer
, UINT vertex_count
, UINT offset
, UINT len
)
5866 D3DEXECUTEDATA exec_data
;
5869 memset(&exec_data
, 0, sizeof(exec_data
));
5870 exec_data
.dwSize
= sizeof(exec_data
);
5871 exec_data
.dwVertexCount
= vertex_count
;
5872 exec_data
.dwInstructionOffset
= offset
;
5873 exec_data
.dwInstructionLength
= len
;
5874 hr
= IDirect3DExecuteBuffer_SetExecuteData(execute_buffer
, &exec_data
);
5875 ok(SUCCEEDED(hr
), "Failed to set execute data, hr %#x.\n", hr
);
5878 static void emit_set_ts(void **ptr
, D3DTRANSFORMSTATETYPE state
, DWORD value
)
5880 D3DINSTRUCTION
*inst
= *ptr
;
5881 D3DSTATE
*ts
= (D3DSTATE
*)(inst
+ 1);
5883 inst
->bOpcode
= D3DOP_STATETRANSFORM
;
5884 inst
->bSize
= sizeof(*ts
);
5887 U1(*ts
).dtstTransformStateType
= state
;
5888 U2(*ts
).dwArg
[0] = value
;
5893 static void emit_set_rs(void **ptr
, D3DRENDERSTATETYPE state
, DWORD value
)
5895 D3DINSTRUCTION
*inst
= *ptr
;
5896 D3DSTATE
*rs
= (D3DSTATE
*)(inst
+ 1);
5898 inst
->bOpcode
= D3DOP_STATERENDER
;
5899 inst
->bSize
= sizeof(*rs
);
5902 U1(*rs
).drstRenderStateType
= state
;
5903 U2(*rs
).dwArg
[0] = value
;
5908 static void emit_process_vertices(void **ptr
, DWORD flags
, WORD base_idx
, DWORD vertex_count
)
5910 D3DINSTRUCTION
*inst
= *ptr
;
5911 D3DPROCESSVERTICES
*pv
= (D3DPROCESSVERTICES
*)(inst
+ 1);
5913 inst
->bOpcode
= D3DOP_PROCESSVERTICES
;
5914 inst
->bSize
= sizeof(*pv
);
5917 pv
->dwFlags
= flags
;
5918 pv
->wStart
= base_idx
;
5920 pv
->dwCount
= vertex_count
;
5926 static void emit_tquad(void **ptr
, WORD base_idx
)
5928 D3DINSTRUCTION
*inst
= *ptr
;
5929 D3DTRIANGLE
*tri
= (D3DTRIANGLE
*)(inst
+ 1);
5931 inst
->bOpcode
= D3DOP_TRIANGLE
;
5932 inst
->bSize
= sizeof(*tri
);
5935 U1(*tri
).v1
= base_idx
;
5936 U2(*tri
).v2
= base_idx
+ 1;
5937 U3(*tri
).v3
= base_idx
+ 2;
5938 tri
->wFlags
= D3DTRIFLAG_START
;
5941 U1(*tri
).v1
= base_idx
+ 2;
5942 U2(*tri
).v2
= base_idx
+ 1;
5943 U3(*tri
).v3
= base_idx
+ 3;
5944 tri
->wFlags
= D3DTRIFLAG_ODD
;
5950 static void emit_end(void **ptr
)
5952 D3DINSTRUCTION
*inst
= *ptr
;
5954 inst
->bOpcode
= D3DOP_EXIT
;
5961 static void d3d_draw_quad1(IDirect3DDevice
*device
, IDirect3DViewport
*viewport
)
5963 IDirect3DExecuteBuffer
*execute_buffer
;
5964 D3DEXECUTEBUFFERDESC exec_desc
;
5968 D3DMATRIXHANDLE world_handle
, view_handle
, proj_handle
;
5969 static D3DMATRIX mat
=
5971 1.0f
, 0.0f
, 0.0f
, 0.0f
,
5972 0.0f
, 1.0f
, 0.0f
, 0.0f
,
5973 0.0f
, 0.0f
, 1.0f
, 0.0f
,
5974 0.0f
, 0.0f
, 0.0f
, 1.0f
,
5976 static const D3DLVERTEX quad_strip
[] =
5978 {{-1.0f
}, {-1.0f
}, {0.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
5979 {{-1.0f
}, { 1.0f
}, {0.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
5980 {{ 1.0f
}, {-1.0f
}, {1.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
5981 {{ 1.0f
}, { 1.0f
}, {1.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
5984 hr
= IDirect3DDevice_CreateMatrix(device
, &world_handle
);
5985 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#x.\n", hr
);
5986 hr
= IDirect3DDevice_SetMatrix(device
, world_handle
, &mat
);
5987 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#x.\n", hr
);
5988 hr
= IDirect3DDevice_CreateMatrix(device
, &view_handle
);
5989 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#x.\n", hr
);
5990 hr
= IDirect3DDevice_SetMatrix(device
, view_handle
, &mat
);
5991 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#x.\n", hr
);
5992 hr
= IDirect3DDevice_CreateMatrix(device
, &proj_handle
);
5993 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#x.\n", hr
);
5994 hr
= IDirect3DDevice_SetMatrix(device
, proj_handle
, &mat
);
5995 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#x.\n", hr
);
5997 memset(&exec_desc
, 0, sizeof(exec_desc
));
5998 exec_desc
.dwSize
= sizeof(exec_desc
);
5999 exec_desc
.dwFlags
= D3DDEB_BUFSIZE
| D3DDEB_CAPS
;
6000 exec_desc
.dwBufferSize
= 1024;
6001 exec_desc
.dwCaps
= D3DDEBCAPS_SYSTEMMEMORY
;
6003 hr
= IDirect3DDevice_CreateExecuteBuffer(device
, &exec_desc
, &execute_buffer
, NULL
);
6004 ok(SUCCEEDED(hr
), "Failed to create execute buffer, hr %#x.\n", hr
);
6006 hr
= IDirect3DExecuteBuffer_Lock(execute_buffer
, &exec_desc
);
6007 ok(SUCCEEDED(hr
), "Failed to lock execute buffer, hr %#x.\n", hr
);
6009 memcpy(exec_desc
.lpData
, quad_strip
, sizeof(quad_strip
));
6010 ptr
= ((BYTE
*)exec_desc
.lpData
) + sizeof(quad_strip
);
6011 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_WORLD
, world_handle
);
6012 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_VIEW
, view_handle
);
6013 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_PROJECTION
, proj_handle
);
6014 emit_set_rs(&ptr
, D3DRENDERSTATE_CLIPPING
, FALSE
);
6015 emit_set_rs(&ptr
, D3DRENDERSTATE_ZENABLE
, TRUE
);
6016 emit_set_rs(&ptr
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
6017 emit_set_rs(&ptr
, D3DRENDERSTATE_CULLMODE
, D3DCULL_NONE
);
6018 emit_set_rs(&ptr
, D3DRENDERSTATE_SHADEMODE
, D3DSHADE_FLAT
);
6020 emit_process_vertices(&ptr
, D3DPROCESSVERTICES_TRANSFORM
, 0, 4);
6021 emit_tquad(&ptr
, 0);
6024 inst_length
= (BYTE
*)ptr
- (BYTE
*)exec_desc
.lpData
;
6025 inst_length
-= sizeof(quad_strip
);
6027 hr
= IDirect3DExecuteBuffer_Unlock(execute_buffer
);
6028 ok(SUCCEEDED(hr
), "Failed to unlock execute buffer, hr %#x.\n", hr
);
6030 hr
= IDirect3DDevice_BeginScene(device
);
6031 set_execute_data(execute_buffer
, 4, sizeof(quad_strip
), inst_length
);
6032 hr
= IDirect3DDevice_Execute(device
, execute_buffer
, viewport
, D3DEXECUTE_CLIPPED
);
6033 ok(SUCCEEDED(hr
), "Failed to execute exec buffer, hr %#x.\n", hr
);
6034 hr
= IDirect3DDevice_EndScene(device
);
6035 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
6037 IDirect3DExecuteBuffer_Release(execute_buffer
);
6040 static void test_viewport_clear1(void)
6042 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
6044 IDirectDrawClipper
*clipper
;
6045 IDirect3DRM
*d3drm1
;
6046 IDirect3DRMFrame
*frame1
, *camera1
;
6047 IDirect3DRMDevice
*device1
;
6048 IDirect3DViewport
*d3d_viewport
;
6049 IDirect3DRMViewport
*viewport1
;
6050 IDirect3DDevice
*d3d_device1
;
6051 IDirectDrawSurface
*surface
, *ds
, *d3drm_ds
;
6053 GUID driver
= IID_IDirect3DRGBDevice
;
6058 window
= create_window();
6059 GetClientRect(window
, &rc
);
6061 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
6062 ok(SUCCEEDED(hr
), "Cannot create IDirectDraw interface (hr = %#x).\n", hr
);
6064 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
6065 ok(SUCCEEDED(hr
), "Failed to set cooperative level (hr = %#x).\n", hr
);
6067 hr
= IDirectDraw_CreateClipper(ddraw
, 0, &clipper
, NULL
);
6068 ok(SUCCEEDED(hr
), "Cannot create clipper (hr = %#x).\n", hr
);
6070 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
6071 ok(SUCCEEDED(hr
), "Cannot set HWnd to Clipper (hr = %#x)\n", hr
);
6073 hr
= Direct3DRMCreate(&d3drm1
);
6074 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
6076 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
6077 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %#x)\n", hr
);
6079 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
6080 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
6081 hr
= IDirect3DRM_CreateFrame(d3drm1
, frame1
, &camera1
);
6082 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
6084 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, camera1
, 0, 0, rc
.right
,
6085 rc
.bottom
, &viewport1
);
6086 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
6088 /* Fetch immediate mode device and viewport */
6089 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3d_device1
);
6090 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice interface (hr = %#x).\n", hr
);
6091 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport1
, &d3d_viewport
);
6092 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
6094 hr
= IDirect3DDevice_QueryInterface(d3d_device1
, &IID_IDirectDrawSurface
, (void **)&surface
);
6095 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
6097 ret_color
= get_surface_color(surface
, 320, 240);
6098 ok(compare_color(ret_color
, 0, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6100 /* Clear uses the scene frame's background color. */
6101 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 1.0f
, 1.0f
, 1.0f
);
6102 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6103 ret_color
= IDirect3DRMFrame_GetSceneBackground(frame1
);
6104 ok(ret_color
== 0xffffffff, "Expected scene color returned == 0xffffffff, got %#x.\n", ret_color
);
6105 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(camera1
, 0.0f
, 1.0f
, 0.0f
);
6106 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6107 ret_color
= IDirect3DRMFrame_GetSceneBackground(camera1
);
6108 ok(ret_color
== 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color
);
6110 hr
= IDirect3DRMViewport_Clear(viewport1
);
6111 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6112 ret_color
= get_surface_color(surface
, 320, 240);
6113 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6115 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 0.0f
, 0.0f
, 1.0f
);
6116 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6117 ret_color
= IDirect3DRMFrame_GetSceneBackground(frame1
);
6118 ok(ret_color
== 0xff0000ff, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color
);
6120 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
6121 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6122 hr
= IDirect3DRMViewport_Clear(viewport1
);
6123 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6124 ret_color
= get_surface_color(surface
, 100, 200);
6125 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6127 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
6129 ret_color
= get_surface_color(surface
, 100, 200);
6130 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6132 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
6133 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
6135 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
6136 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6137 hr
= IDirect3DRMViewport_Clear(viewport1
);
6138 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6139 ret_color
= get_surface_color(surface
, 100, 200);
6140 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6142 /* Fill the depth surface with a value lower than the quad's depth value. */
6143 clear_depth_surface(ds
, 0x7fff);
6145 /* Depth test passes here */
6146 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
6147 ret_color
= get_surface_color(surface
, 100, 200);
6148 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6149 /* Depth test fails here */
6150 ret_color
= get_surface_color(surface
, 500, 400);
6151 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6153 /* Check what happens if we release the depth surface that d3drm created, and clear the viewport */
6154 hr
= IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, ds
);
6155 ok(SUCCEEDED(hr
), "Cannot delete attached surface (hr = %#x).\n", hr
);
6156 d3drm_ds
= (IDirectDrawSurface
*)0xdeadbeef;
6157 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
6158 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#x.\n", hr
);
6159 ok(d3drm_ds
== NULL
, "Expected NULL z-surface, got %p.\n", d3drm_ds
);
6161 clear_depth_surface(ds
, 0x7fff);
6162 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
6163 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6164 hr
= IDirect3DRMViewport_Clear(viewport1
);
6165 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6167 ret_color
= get_surface_color(surface
, 100, 200);
6168 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6170 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
6171 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
6172 IDirectDrawSurface_Release(ds
);
6174 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
6176 ret_color
= get_surface_color(surface
, 100, 200);
6177 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6178 ret_color
= get_surface_color(surface
, 500, 400);
6179 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6181 IDirect3DViewport_Release(d3d_viewport
);
6182 IDirectDrawSurface_Release(surface
);
6183 IDirect3DDevice_Release(d3d_device1
);
6184 IDirect3DRMViewport_Release(viewport1
);
6185 IDirect3DRMFrame_Release(frame1
);
6186 IDirect3DRMFrame_Release(camera1
);
6187 IDirect3DRMDevice_Release(device1
);
6188 IDirect3DRM_Release(d3drm1
);
6189 IDirectDrawClipper_Release(clipper
);
6190 IDirectDraw_Release(ddraw
);
6191 DestroyWindow(window
);
6194 static void draw_quad2(IDirect3DDevice2
*device
, IDirect3DViewport
*viewport
)
6196 static D3DLVERTEX tquad
[] =
6198 {{-1.0f
}, {-1.0f
}, {0.0f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
6199 {{-1.0f
}, { 1.0f
}, {0.0f
}, 0, {0xffbada55}, {0}, {0.0f
}, {1.0f
}},
6200 {{ 1.0f
}, {-1.0f
}, {1.0f
}, 0, {0xffbada55}, {0}, {1.0f
}, {0.0f
}},
6201 {{ 1.0f
}, { 1.0f
}, {1.0f
}, 0, {0xffbada55}, {0}, {1.0f
}, {1.0f
}},
6203 static D3DMATRIX mat
=
6205 1.0f
, 0.0f
, 0.0f
, 0.0f
,
6206 0.0f
, 1.0f
, 0.0f
, 0.0f
,
6207 0.0f
, 0.0f
, 1.0f
, 0.0f
,
6208 0.0f
, 0.0f
, 0.0f
, 1.0f
,
6210 IDirect3DViewport2
*viewport2
;
6213 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, &mat
);
6214 ok(SUCCEEDED(hr
), "Failed to set world transform, hr %#x.\n", hr
);
6215 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_VIEW
, &mat
);
6216 ok(SUCCEEDED(hr
), "Failed to set view transform, hr %#x.\n", hr
);
6217 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_PROJECTION
, &mat
);
6218 ok(SUCCEEDED(hr
), "Failed to set projection transform, hr %#x.\n", hr
);
6220 hr
= IDirect3DViewport_QueryInterface(viewport
, &IID_IDirect3DViewport2
, (void **)&viewport2
);
6221 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport2 interface (hr = %#x).\n", hr
);
6222 hr
= IDirect3DDevice2_SetCurrentViewport(device
, viewport2
);
6223 ok(SUCCEEDED(hr
), "Failed to activate the viewport, hr %#x.\n", hr
);
6224 IDirect3DViewport2_Release(viewport2
);
6226 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, D3DZB_TRUE
);
6227 ok(SUCCEEDED(hr
), "Failed to enable z testing, hr %#x.\n", hr
);
6228 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZFUNC
, D3DCMP_LESSEQUAL
);
6229 ok(SUCCEEDED(hr
), "Failed to set the z function, hr %#x.\n", hr
);
6231 hr
= IDirect3DDevice2_BeginScene(device
);
6232 ok(SUCCEEDED(hr
), "Failed to begin scene, hr %#x.\n", hr
);
6233 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_LVERTEX
, tquad
, 4, 0);
6234 ok(SUCCEEDED(hr
), "Failed to draw, hr %#x.\n", hr
);
6235 hr
= IDirect3DDevice2_EndScene(device
);
6236 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
6239 static void test_viewport_clear2(void)
6241 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
6243 IDirectDraw
*ddraw1
;
6244 IDirectDraw2
*ddraw2
;
6245 IDirectDrawClipper
*clipper
;
6246 IDirect3DRM
*d3drm1
;
6247 IDirect3DRM3
*d3drm3
;
6248 IDirect3DRMFrame3
*frame3
, *camera3
;
6249 IDirect3DRMDevice3
*device3
;
6250 IDirect3DViewport
*d3d_viewport
;
6251 IDirect3DRMViewport2
*viewport2
;
6252 IDirect3DDevice2
*d3d_device2
;
6253 IDirectDrawSurface
*surface
, *ds
, *d3drm_ds
;
6255 GUID driver
= IID_IDirect3DRGBDevice
;
6260 window
= create_window();
6261 GetClientRect(window
, &rc
);
6263 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
6264 ok(SUCCEEDED(hr
), "Cannot create IDirectDraw interface (hr = %#x).\n", hr
);
6266 hr
= IDirectDraw_SetCooperativeLevel(ddraw1
, window
, DDSCL_NORMAL
);
6267 ok(SUCCEEDED(hr
), "Failed to set cooperative level (hr = %#x).\n", hr
);
6269 hr
= IDirectDraw_CreateClipper(ddraw1
, 0, &clipper
, NULL
);
6270 ok(SUCCEEDED(hr
), "Cannot create clipper (hr = %#x).\n", hr
);
6272 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
6273 ok(SUCCEEDED(hr
), "Cannot set HWnd to Clipper (hr = %#x)\n", hr
);
6275 hr
= Direct3DRMCreate(&d3drm1
);
6276 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
6278 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6279 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
6281 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
6282 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice3 interface (hr = %#x)\n", hr
);
6284 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
6285 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
6286 hr
= IDirect3DRM3_CreateFrame(d3drm3
, frame3
, &camera3
);
6287 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
6289 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, rc
.right
,
6290 rc
.bottom
, &viewport2
);
6291 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
6293 /* Fetch immediate mode device in order to access render target and test its color. */
6294 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3d_device2
);
6295 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface (hr = %#x).\n", hr
);
6297 hr
= IDirect3DDevice2_GetRenderTarget(d3d_device2
, &surface
);
6298 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
6300 ret_color
= get_surface_color(surface
, 320, 240);
6301 ok(compare_color(ret_color
, 0, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6303 /* Clear uses the scene frame's background color. */
6304 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 1.0f
, 1.0f
, 1.0f
);
6305 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6306 ret_color
= IDirect3DRMFrame3_GetSceneBackground(frame3
);
6307 ok(ret_color
== 0xffffffff, "Expected scene color returned == 0xffffffff, got %#x.\n", ret_color
);
6308 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(camera3
, 0.0f
, 1.0f
, 0.0f
);
6309 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6310 ret_color
= IDirect3DRMFrame3_GetSceneBackground(camera3
);
6311 ok(ret_color
== 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color
);
6313 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6314 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6315 ret_color
= get_surface_color(surface
, 320, 240);
6316 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6318 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
6319 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
6321 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6322 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6324 /* d3drm seems to be calling BeginScene when Clear is called. */
6325 hr
= IDirect3DDevice2_BeginScene(d3d_device2
);
6326 todo_wine
ok(hr
== D3DERR_SCENE_IN_SCENE
, "Expected hr == D3DERR_SCENE_IN_SCENE, got %#x.\n", hr
);
6327 hr
= IDirect3DDevice2_EndScene(d3d_device2
);
6328 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
6330 ret_color
= get_surface_color(surface
, 320, 240);
6331 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6333 /* We're using d3d to draw using IDirect3DDevice2 created from d3drm. */
6334 draw_quad2(d3d_device2
, d3d_viewport
);
6335 ret_color
= get_surface_color(surface
, 320, 240);
6336 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6338 /* Without calling Configure, Clear doesn't work. */
6339 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6340 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6341 ret_color
= get_surface_color(surface
, 320, 240);
6342 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6344 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6345 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6346 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6347 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6349 ret_color
= get_surface_color(surface
, 320, 240);
6350 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6352 /* Fetch attached depth surface and see if viewport clears it if it's detached from the render target. */
6353 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
6354 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
6356 clear_depth_surface(ds
, 0x39);
6357 draw_quad2(d3d_device2
, d3d_viewport
);
6359 ret_color
= get_surface_color(surface
, 320, 240);
6360 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6362 hr
= IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, ds
);
6363 ok(SUCCEEDED(hr
), "Cannot delete attached surface (hr = %#x).\n", hr
);
6364 d3drm_ds
= (IDirectDrawSurface
*)0xdeadbeef;
6365 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
6366 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#x.\n", hr
);
6367 ok(d3drm_ds
== NULL
, "Expected NULL z-surface, got %p.\n", d3drm_ds
);
6369 clear_depth_surface(ds
, 0x7fff);
6371 /* This version of Clear still clears the depth surface even if it's deleted from the render target. */
6372 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6373 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6374 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6375 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6377 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
6378 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
6379 ret_color
= get_surface_color(surface
, 320, 240);
6380 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6382 draw_quad2(d3d_device2
, d3d_viewport
);
6383 ret_color
= get_surface_color(surface
, 100, 200);
6384 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6385 ret_color
= get_surface_color(surface
, 500, 400);
6386 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6388 /* Clear with no flags */
6389 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6390 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6391 hr
= IDirect3DRMViewport2_Clear(viewport2
, 0);
6392 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6393 ret_color
= get_surface_color(surface
, 320, 240);
6394 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6396 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6397 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6398 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6399 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6400 ret_color
= get_surface_color(surface
, 320, 240);
6401 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6403 IDirect3DViewport_Release(d3d_viewport
);
6404 IDirectDrawSurface_Release(surface
);
6405 IDirectDrawSurface_Release(ds
);
6406 IDirect3DDevice2_Release(d3d_device2
);
6407 IDirect3DRMViewport2_Release(viewport2
);
6408 IDirect3DRMDevice3_Release(device3
);
6410 /* Create device without depth surface attached */
6411 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
6412 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface (hr = %#x).\n", hr
);
6413 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
6414 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
6415 d3d_device2
= create_device2_without_ds(ddraw2
, window
);
6419 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3d_device2
, &device3
);
6420 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRMDevice interface (hr = %#x)\n", hr
);
6421 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, rc
.right
,
6422 rc
.bottom
, &viewport2
);
6423 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
6424 hr
= IDirect3DDevice2_GetRenderTarget(d3d_device2
, &surface
);
6425 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
6427 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6428 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6429 ret_color
= get_surface_color(surface
, 320, 240);
6430 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6432 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ZBUFFER
);
6433 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6435 IDirectDrawSurface_Release(surface
);
6436 IDirect3DRMViewport2_Release(viewport2
);
6437 IDirect3DRMDevice3_Release(device3
);
6438 IDirect3DDevice2_Release(d3d_device2
);
6441 IDirect3DRMFrame3_Release(camera3
);
6442 IDirect3DRMFrame3_Release(frame3
);
6443 IDirect3DRM3_Release(d3drm3
);
6444 IDirect3DRM_Release(d3drm1
);
6445 IDirectDrawClipper_Release(clipper
);
6446 IDirect3D2_Release(d3d2
);
6447 IDirectDraw2_Release(ddraw2
);
6448 IDirectDraw_Release(ddraw1
);
6449 DestroyWindow(window
);
6452 static void test_create_texture_from_surface(void)
6454 D3DRMIMAGE testimg
=
6457 TRUE
, 0, (void *)0xcafebabe, NULL
,
6458 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
6460 IDirectDrawSurface
*surface
= NULL
, *surface2
= NULL
, *ds
= NULL
;
6461 IDirect3DRMTexture
*texture1
;
6462 IDirect3DRMTexture2
*texture2
;
6463 IDirect3DRMTexture3
*texture3
;
6464 IDirectDraw
*ddraw
= NULL
;
6465 IDirect3DRM
*d3drm1
= NULL
;
6466 IDirect3DRM2
*d3drm2
= NULL
;
6467 IDirect3DRM3
*d3drm3
= NULL
;
6468 ULONG ref1
, ref2
, ref3
;
6475 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
6476 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
6478 window
= create_window();
6479 GetClientRect(window
, &rc
);
6481 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
6482 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
6484 hr
= Direct3DRMCreate(&d3drm1
);
6485 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
6487 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
6488 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
6490 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6491 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
6493 /* Create a surface and use it to create a texture. */
6494 memset(&desc
, 0, sizeof(desc
));
6495 desc
.dwSize
= sizeof(desc
);
6496 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
6497 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
6498 desc
.dwWidth
= rc
.right
;
6499 desc
.dwHeight
= rc
.bottom
;
6501 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
6502 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
6504 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface2
, NULL
);
6505 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
6507 /* Test NULL params */
6508 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
6509 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, NULL
, &texture1
);
6510 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6511 ok(!texture1
, "Expected texture returned == NULL, got %p.\n", texture1
);
6513 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, NULL
, NULL
);
6514 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6516 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
6517 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, NULL
, &texture2
);
6518 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6519 ok(!texture2
, "Expected texture returned == NULL, got %p.\n", texture2
);
6521 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, NULL
, NULL
);
6522 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6524 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
6525 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, NULL
, &texture3
);
6526 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6527 ok(!texture3
, "Expected texture returned == NULL, got %p.\n", texture3
);
6529 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, NULL
, NULL
);
6530 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6532 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
6533 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, surface
, &texture1
);
6534 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6536 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
6537 image
= IDirect3DRMTexture_GetImage(texture1
);
6538 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
6539 hr
= IDirect3DRMTexture_InitFromSurface(texture1
, NULL
);
6540 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
6541 IDirect3DRMTexture_Release(texture1
);
6543 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
6544 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, surface
, &texture2
);
6545 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6546 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
6547 image
= IDirect3DRMTexture2_GetImage(texture2
);
6548 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
6549 hr
= IDirect3DRMTexture2_InitFromSurface(texture2
, NULL
);
6550 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
6551 IDirect3DRMTexture_Release(texture2
);
6553 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
6554 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, surface
, &texture3
);
6555 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6556 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
6557 image
= IDirect3DRMTexture3_GetImage(texture3
);
6558 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
6559 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, NULL
);
6560 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
6561 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, NULL
);
6562 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6563 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &ds
);
6564 ok(SUCCEEDED(hr
), "Failed to get surface, hr %#x.\n", hr
);
6565 ok(ds
== surface
, "Expected same surface back.\n");
6566 IDirectDrawSurface_Release(ds
);
6568 /* Init already initialized texture with same surface. */
6569 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface
);
6570 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6572 /* Init already initialized texture with different surface. */
6573 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface2
);
6574 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6576 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &ds
);
6577 ok(SUCCEEDED(hr
), "Failed to get surface, hr %#x.\n", hr
);
6578 ok(ds
== surface
, "Expected same surface back.\n");
6579 IDirectDrawSurface_Release(ds
);
6581 ref1
= get_refcount((IUnknown
*)d3drm1
);
6582 ref2
= get_refcount((IUnknown
*)d3drm2
);
6583 ref3
= get_refcount((IUnknown
*)d3drm3
);
6584 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
6585 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6586 ok(ref1
< get_refcount((IUnknown
*)d3drm1
), "Expected d3drm1 reference taken.\n");
6587 ok(ref2
== get_refcount((IUnknown
*)d3drm2
), "Expected d3drm2 reference unchanged.\n");
6588 ok(ref3
== get_refcount((IUnknown
*)d3drm3
), "Expected d3drm3 reference unchanged.\n");
6589 /* Release leaked reference to d3drm1 */
6590 IDirect3DRM_Release(d3drm1
);
6592 IDirect3DRMTexture_Release(texture3
);
6594 /* Create from image, initialize from surface. */
6595 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
6596 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
6598 ref1
= get_refcount((IUnknown
*)d3drm1
);
6599 ref2
= get_refcount((IUnknown
*)d3drm2
);
6600 ref3
= get_refcount((IUnknown
*)d3drm3
);
6601 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface
);
6602 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6603 ok(ref1
< get_refcount((IUnknown
*)d3drm1
), "Expected d3drm1 reference taken.\n");
6604 ok(ref2
== get_refcount((IUnknown
*)d3drm2
), "Expected d3drm2 reference unchanged.\n");
6605 ok(ref3
== get_refcount((IUnknown
*)d3drm3
), "Expected d3drm3 reference unchanged.\n");
6606 /* Release leaked reference to d3drm1 */
6607 IDirect3DRM_Release(d3drm1
);
6608 IDirect3DRMTexture3_Release(texture3
);
6610 IDirectDrawSurface_Release(surface2
);
6611 IDirectDrawSurface_Release(surface
);
6612 IDirect3DRM3_Release(d3drm3
);
6613 IDirect3DRM2_Release(d3drm2
);
6614 IDirect3DRM_Release(d3drm1
);
6615 IDirectDraw_Release(ddraw
);
6621 test_MeshBuilder3();
6631 test_frame_transform();
6633 test_frame_mesh_materials();
6637 test_create_device_from_clipper1();
6638 test_create_device_from_clipper2();
6639 test_create_device_from_clipper3();
6640 test_create_device_from_surface1();
6641 test_create_device_from_surface2();
6642 test_create_device_from_surface3();
6643 test_create_device_from_d3d1();
6644 test_create_device_from_d3d2();
6645 test_create_device_from_d3d3();
6646 test_load_texture();
6649 test_viewport_clear1();
6650 test_viewport_clear2();
6651 test_create_texture_from_surface();