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
);
112 size
= size2
= !!*name
;
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
== size2
, "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 #define test_object_name(a) test_object_name_(__LINE__, a)
138 static void test_object_name_(unsigned int line
, IDirect3DRMObject
*object
)
144 hr
= IDirect3DRMObject_GetName(object
, NULL
, NULL
);
145 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
148 hr
= IDirect3DRMObject_GetName(object
, NULL
, name
);
149 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#x.\n", hr
);
150 ok_(__FILE__
, line
)(name
[0] == 0x1f, "Unexpected buffer contents, %#x.\n", name
[0]);
152 /* Name is not set yet. */
154 hr
= IDirect3DRMObject_GetName(object
, &size
, NULL
);
155 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
156 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %u.\n", size
);
160 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
161 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
162 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %u.\n", size
);
163 ok_(__FILE__
, line
)(name
[0] == 0, "Unexpected name \"%s\".\n", name
);
167 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
168 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
169 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %u.\n", size
);
170 ok_(__FILE__
, line
)(name
[0] == 0x1f, "Unexpected name \"%s\".\n", name
);
172 hr
= IDirect3DRMObject_SetName(object
, NULL
);
173 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
175 hr
= IDirect3DRMObject_SetName(object
, "name");
176 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to set a name, hr %#x.\n", hr
);
179 hr
= IDirect3DRMObject_GetName(object
, &size
, NULL
);
180 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
181 ok_(__FILE__
, line
)(size
== strlen("name") + 1, "Unexpected size %u.\n", size
);
183 size
= strlen("name") + 1;
184 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
185 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
186 ok_(__FILE__
, line
)(size
== strlen("name") + 1, "Unexpected size %u.\n", size
);
187 ok_(__FILE__
, line
)(!strcmp(name
, "name"), "Unexpected name \"%s\".\n", name
);
191 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
192 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Failed to get object name, hr %#x.\n", hr
);
193 ok_(__FILE__
, line
)(size
== 2, "Unexpected size %u.\n", size
);
194 ok_(__FILE__
, line
)(name
[0] == 0x1f, "Got unexpected name \"%s\".\n", name
);
196 hr
= IDirect3DRMObject_SetName(object
, NULL
);
197 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to set object name, hr %#x.\n", hr
);
200 hr
= IDirect3DRMObject_GetName(object
, &size
, NULL
);
201 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
202 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %u.\n", size
);
206 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
207 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#x.\n", hr
);
208 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %u.\n", size
);
209 ok_(__FILE__
, line
)(name
[0] == 0, "Got unexpected name \"%s\".\n", name
);
212 static char data_bad_version
[] =
219 static char data_no_mesh
[] =
226 static char data_ok
[] =
245 static char data_full
[] =
247 "Header { 1; 0; 1; }\n"
255 " MeshMaterialList {\n"
258 " 0.0; 1.0; 0.0; 1.0;;\n"
262 " TextureFileName {\n"
263 " \"Texture.bmp\";\n"
275 " MeshTextureCoords {\n"
283 static char data_d3drm_load
[] =
310 " 0.1, 0.2, 0.3, 0.4;;\n"
316 static char data_frame_mesh_materials
[] =
318 "Header { 1; 0; 1; }\n"
334 " MeshMaterialList {\n"
335 " 3; 6; 0, 1, 1, 2, 2, 2;\n"
337 " 1.0; 0.0; 0.0; 0.1;;\n"
339 " 0.11; 0.12; 0.13;;\n"
340 " 0.14; 0.15; 0.16;;\n"
343 " 0.0; 1.0; 0.0; 0.2;;\n"
345 " 0.21; 0.22; 0.23;;\n"
346 " 0.24; 0.25; 0.26;;\n"
349 " 0.0; 0.0; 1.0; 0.3;;\n"
351 " 0.31; 0.32; 0.33;;\n"
352 " 0.34; 0.35; 0.36;;\n"
358 static void test_MeshBuilder(void)
362 IDirect3DRMMeshBuilder
*pMeshBuilder
;
363 IDirect3DRMMeshBuilder3
*meshbuilder3
;
364 IDirect3DRMMesh
*mesh
;
365 D3DRMLOADMEMORY info
;
367 DWORD val1
, val2
, val3
;
377 hr
= Direct3DRMCreate(&d3drm
);
378 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
380 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
381 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
383 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMObject
, (void **)&unk
);
384 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
385 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
386 IUnknown_Release(unk
);
388 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMVisual
, (void **)&unk
);
389 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMVisual, %#x.\n", hr
);
390 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
391 IUnknown_Release(unk
);
393 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMMeshBuilder3
, (void **)&meshbuilder3
);
394 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMMeshBuilder3, %#x.\n", hr
);
396 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3
, &IID_IDirect3DRMObject
, (void **)&unk
);
397 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
398 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
399 IUnknown_Release(unk
);
401 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3
, &IID_IDirect3DRMVisual
, (void **)&unk
);
402 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMVisual, %#x.\n", hr
);
403 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
404 IUnknown_Release(unk
);
406 IDirect3DRMMeshBuilder3_Release(meshbuilder3
);
408 test_class_name((IDirect3DRMObject
*)pMeshBuilder
, "Builder");
409 test_object_name((IDirect3DRMObject
*)pMeshBuilder
);
411 info
.lpMemory
= data_bad_version
;
412 info
.dSize
= strlen(data_bad_version
);
413 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
414 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
416 info
.lpMemory
= data_no_mesh
;
417 info
.dSize
= strlen(data_no_mesh
);
418 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
419 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
421 info
.lpMemory
= data_ok
;
422 info
.dSize
= strlen(data_ok
);
423 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
424 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
427 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
428 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
429 ok(!strcmp(name
, "Object"), "Retrieved name '%s' instead of 'Object'\n", name
);
430 size
= strlen("Object"); /* No space for null character */
431 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
432 ok(hr
== E_INVALIDARG
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
433 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, NULL
);
434 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
436 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
437 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
438 ok(size
== 0, "Size should be 0 instead of %u\n", size
);
439 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, "");
440 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr
);
442 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
443 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr
);
444 ok(!strcmp(name
, ""), "Retrieved name '%s' instead of ''\n", name
);
446 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
447 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
449 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
450 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
452 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, NULL
, &val2
, NULL
, &val3
, NULL
);
453 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
454 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
455 ok(val2
== 4, "Wrong number of normals %d (must be 4)\n", val2
);
456 ok(val3
== 22, "Wrong number of face data bytes %d (must be 22)\n", val3
);
458 /* Check that Load method generated default normals */
459 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, NULL
, &val2
, n
, NULL
, NULL
);
460 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
461 check_vector(&n
[0], 0.577350f
, 0.577350f
, 0.577350f
, 32);
462 check_vector(&n
[1], -0.229416f
, 0.688247f
, 0.688247f
, 32);
463 check_vector(&n
[2], -0.229416f
, 0.688247f
, 0.688247f
, 32);
464 check_vector(&n
[3], -0.577350f
, 0.577350f
, 0.577350f
, 32);
466 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
469 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
470 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
471 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
472 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
475 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 1, &valu
, &valv
);
476 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
477 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
478 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
481 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 2, &valu
, &valv
);
482 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
483 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
484 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
487 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 3, &valu
, &valv
);
488 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
489 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
490 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
491 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 4, &valu
, &valv
);
492 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
496 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 0, valu
, valv
);
497 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
498 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 4, valu
, valv
);
499 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
503 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
504 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
505 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
506 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
508 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
510 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
511 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
513 /* No group in mesh when mesh builder is not loaded */
514 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
515 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
520 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
521 ok(nb_groups
== 0, "GetCroupCount returned %u\n", nb_groups
);
523 IDirect3DRMMesh_Release(mesh
);
526 info
.lpMemory
= data_full
;
527 info
.dSize
= strlen(data_full
);
528 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
529 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
531 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
532 ok(val
== 3, "Wrong number of vertices %d (must be 3)\n", val
);
534 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
535 ok(val
== 1, "Wrong number of faces %d (must be 1)\n", val
);
537 /* Check no buffer size and too small buffer size errors */
538 val1
= 1; val2
= 3; val3
= 8;
539 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
540 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
541 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, v
, &val2
, n
, &val3
, f
);
542 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
543 val1
= 3; val2
= 1; val3
= 8;
544 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
545 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
546 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, NULL
, n
, &val3
, f
);
547 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
548 val1
= 3; val2
= 3; val3
= 1;
549 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
550 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
551 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, NULL
, f
);
552 ok(hr
== D3DRMERR_BADVALUE
, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr
);
554 val1
= 3; val2
= 3; val3
= 8;
555 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
556 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
557 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
558 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
559 ok(val3
== 8, "Wrong number of face data bytes %d (must be 8)\n", val3
);
560 check_vector(&v
[0], 0.1f
, 0.2f
, 0.3f
, 32);
561 check_vector(&v
[1], 0.4f
, 0.5f
, 0.6f
, 32);
562 check_vector(&v
[2], 0.7f
, 0.8f
, 0.9f
, 32);
563 check_vector(&n
[0], 1.1f
, 1.2f
, 1.3f
, 32);
564 check_vector(&n
[1], 1.4f
, 1.5f
, 1.6f
, 32);
565 check_vector(&n
[2], 1.7f
, 1.8f
, 1.9f
, 32);
566 ok(f
[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f
[0]);
567 ok(f
[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f
[1]);
568 ok(f
[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f
[2]);
569 ok(f
[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f
[3]);
570 ok(f
[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f
[4]);
571 ok(f
[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f
[5]);
572 ok(f
[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f
[6]);
573 ok(f
[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f
[7]);
575 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
576 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr = %x\n", hr
);
580 unsigned nb_vertices
, nb_faces
, nb_face_vertices
;
582 IDirect3DRMMaterial
*material
= (IDirect3DRMMaterial
*)0xdeadbeef;
583 IDirect3DRMTexture
*texture
= (IDirect3DRMTexture
*)0xdeadbeef;
586 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
587 ok(nb_groups
== 1, "GetCroupCount returned %u\n", nb_groups
);
588 hr
= IDirect3DRMMesh_GetGroup(mesh
, 1, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
589 ok(hr
== D3DRMERR_BADVALUE
, "GetCroup returned hr = %x\n", hr
);
590 hr
= IDirect3DRMMesh_GetGroup(mesh
, 0, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
591 ok(hr
== D3DRM_OK
, "GetCroup failed returning hr = %x\n", hr
);
592 ok(nb_vertices
== 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices
);
593 ok(nb_faces
== 1, "Wrong number of faces %u (must be 1)\n", nb_faces
);
594 ok(nb_face_vertices
== 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices
);
595 ok(data_size
== 3, "Wrong number of face data bytes %u (must be 3)\n", data_size
);
596 color
= IDirect3DRMMesh_GetGroupColor(mesh
, 0);
597 ok(color
== 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color
, 0xff00ff00);
598 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, 0, &texture
);
599 ok(hr
== D3DRM_OK
, "GetCroupTexture failed returning hr = %x\n", hr
);
600 ok(texture
== NULL
, "No texture should be present\n");
601 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, 0, &material
);
602 ok(hr
== D3DRM_OK
, "GetCroupMaterial failed returning hr = %x\n", hr
);
603 ok(material
!= NULL
, "No material present\n");
604 hr
= IDirect3DRMMaterial_GetEmissive(material
, &values
[0], &values
[1], &values
[2]);
605 ok(hr
== D3DRM_OK
, "Failed to get emissive color, hr %#x.\n", hr
);
606 ok(values
[0] == 0.5f
, "Got unexpected red component %.8e.\n", values
[0]);
607 ok(values
[1] == 0.5f
, "Got unexpected green component %.8e.\n", values
[1]);
608 ok(values
[2] == 0.5f
, "Got unexpected blue component %.8e.\n", values
[2]);
609 hr
= IDirect3DRMMaterial_GetSpecular(material
, &values
[0], &values
[1], &values
[2]);
610 ok(hr
== D3DRM_OK
, "Failed to get specular color, hr %#x.\n", hr
);
611 ok(values
[0] == 1.0f
, "Got unexpected red component %.8e.\n", values
[0]);
612 ok(values
[1] == 0.0f
, "Got unexpected green component %.8e.\n", values
[1]);
613 ok(values
[2] == 0.0f
, "Got unexpected blue component %.8e.\n", values
[2]);
614 values
[0] = IDirect3DRMMaterial_GetPower(material
);
615 ok(values
[0] == 30.0f
, "Got unexpected power value %.8e.\n", values
[0]);
616 IDirect3DRMMaterial_Release(material
);
618 IDirect3DRMMesh_Release(mesh
);
621 hr
= IDirect3DRMMeshBuilder_Scale(pMeshBuilder
, 2, 3 ,4);
622 ok(hr
== D3DRM_OK
, "Scale failed returning hr = %x\n", hr
);
624 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
625 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
626 ok(val2
== 3, "Wrong number of normals %d (must be 3)\n", val2
);
627 ok(val1
== 3, "Wrong number of vertices %d (must be 3)\n", val1
);
629 check_vector(&v
[0], 0.1f
* 2, 0.2f
* 3, 0.3f
* 4, 32);
630 check_vector(&v
[1], 0.4f
* 2, 0.5f
* 3, 0.6f
* 4, 32);
631 check_vector(&v
[2], 0.7f
* 2, 0.8f
* 3, 0.9f
* 4, 32);
632 /* Normals are not affected by Scale */
633 check_vector(&n
[0], 1.1f
, 1.2f
, 1.3f
, 32);
634 check_vector(&n
[1], 1.4f
, 1.5f
, 1.6f
, 32);
635 check_vector(&n
[2], 1.7f
, 1.8f
, 1.9f
, 32);
637 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
639 IDirect3DRM_Release(d3drm
);
642 static void test_MeshBuilder3(void)
646 IDirect3DRM3
*d3drm3
;
647 IDirect3DRMMeshBuilder3
*pMeshBuilder3
;
648 D3DRMLOADMEMORY info
;
653 hr
= Direct3DRMCreate(&d3drm
);
654 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
656 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
658 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
659 IDirect3DRM_Release(d3drm
);
663 hr
= IDirect3DRM3_CreateMeshBuilder(d3drm3
, &pMeshBuilder3
);
664 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr
);
666 test_class_name((IDirect3DRMObject
*)pMeshBuilder3
, "Builder");
667 test_object_name((IDirect3DRMObject
*)pMeshBuilder3
);
669 info
.lpMemory
= data_bad_version
;
670 info
.dSize
= strlen(data_bad_version
);
671 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
672 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr
);
674 info
.lpMemory
= data_no_mesh
;
675 info
.dSize
= strlen(data_no_mesh
);
676 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
677 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr
);
679 info
.lpMemory
= data_ok
;
680 info
.dSize
= strlen(data_ok
);
681 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
682 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
684 val
= IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3
);
685 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
687 val
= IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3
);
688 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
690 hr
= IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3
, 0, &val1
, NULL
);
691 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
692 ok(val1
== 4, "Wrong number of vertices %d (must be 4)\n", val1
);
694 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
697 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
698 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
699 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
700 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
703 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 1, &valu
, &valv
);
704 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
705 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
706 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
709 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 2, &valu
, &valv
);
710 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
711 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
712 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
715 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 3, &valu
, &valv
);
716 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
717 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
718 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
719 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 4, &valu
, &valv
);
720 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
724 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 0, valu
, valv
);
725 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates (hr = %x)\n", hr
);
726 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 4, valu
, valv
);
727 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
731 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
732 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates (hr = %x)\n", hr
);
733 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
734 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
736 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3
);
737 IDirect3DRM3_Release(d3drm3
);
738 IDirect3DRM_Release(d3drm
);
741 static void test_Mesh(void)
745 IDirect3DRMMesh
*mesh
;
748 hr
= Direct3DRMCreate(&d3drm
);
749 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
751 hr
= IDirect3DRM_CreateMesh(d3drm
, &mesh
);
752 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr
);
754 test_class_name((IDirect3DRMObject
*)mesh
, "Mesh");
755 test_object_name((IDirect3DRMObject
*)mesh
);
757 hr
= IDirect3DRMMesh_QueryInterface(mesh
, &IID_IDirect3DRMObject
, (void **)&unk
);
758 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
759 IUnknown_Release(unk
);
761 hr
= IDirect3DRMMesh_QueryInterface(mesh
, &IID_IDirect3DRMVisual
, (void **)&unk
);
762 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMVisual, %#x.\n", hr
);
763 IUnknown_Release(unk
);
765 IDirect3DRMMesh_Release(mesh
);
767 IDirect3DRM_Release(d3drm
);
770 static void test_Face(void)
774 IDirect3DRM2
*d3drm2
;
775 IDirect3DRM3
*d3drm3
;
776 IDirect3DRMMeshBuilder2
*MeshBuilder2
;
777 IDirect3DRMMeshBuilder3
*MeshBuilder3
;
778 IDirect3DRMFace
*face1
;
779 IDirect3DRMObject
*obj
;
780 IDirect3DRMFace2
*face2
;
781 IDirect3DRMFaceArray
*array1
;
782 D3DRMLOADMEMORY info
;
783 D3DVECTOR v1
[4], n1
[4], v2
[4], n2
[4];
788 hr
= Direct3DRMCreate(&d3drm
);
789 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
791 hr
= IDirect3DRM_CreateFace(d3drm
, &face1
);
792 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr
);
795 skip("Cannot get IDirect3DRMFace interface (hr = %x), skipping tests\n", hr
);
796 IDirect3DRM_Release(d3drm
);
800 hr
= IDirect3DRMFace_QueryInterface(face1
, &IID_IDirect3DRMObject
, (void **)&obj
);
801 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
802 ok(obj
== (IDirect3DRMObject
*)face1
, "Unexpected interface pointer.\n");
803 IDirect3DRMObject_Release(obj
);
805 test_class_name((IDirect3DRMObject
*)face1
, "Face");
806 test_object_name((IDirect3DRMObject
*)face1
);
808 icount
= IDirect3DRMFace_GetVertexCount(face1
);
809 ok(!icount
, "wrong VertexCount: %i\n", icount
);
811 IDirect3DRMFace_Release(face1
);
813 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM2
, (void **)&d3drm2
)))
815 win_skip("Cannot get IDirect3DRM2 interface (hr = %x), skipping tests\n", hr
);
816 IDirect3DRM_Release(d3drm
);
820 hr
= IDirect3DRM2_CreateMeshBuilder(d3drm2
, &MeshBuilder2
);
821 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder2 interface (hr = %x)\n", hr
);
823 icount
= IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2
);
824 ok(!icount
, "wrong FaceCount: %i\n", icount
);
827 hr
= IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2
, &array1
);
829 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
831 hr
= IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2
, &face1
);
832 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr
);
834 icount
= IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2
);
836 ok(icount
== 1, "wrong FaceCount: %i\n", icount
);
839 hr
= IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2
, &array1
);
841 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
843 ok(array1
!= NULL
, "pArray = %p\n", array1
);
846 IDirect3DRMFace
*face
;
847 count
= IDirect3DRMFaceArray_GetSize(array1
);
848 ok(count
== 1, "count = %u\n", count
);
849 hr
= IDirect3DRMFaceArray_GetElement(array1
, 0, &face
);
850 ok(hr
== D3DRM_OK
, "Cannot get face (hr = %x)\n", hr
);
851 IDirect3DRMFace_Release(face
);
852 IDirect3DRMFaceArray_Release(array1
);
855 icount
= IDirect3DRMFace_GetVertexCount(face1
);
856 ok(!icount
, "wrong VertexCount: %i\n", icount
);
858 IDirect3DRMFace_Release(face1
);
859 IDirect3DRMMeshBuilder2_Release(MeshBuilder2
);
861 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
863 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
864 IDirect3DRM_Release(d3drm
);
868 hr
= IDirect3DRM3_CreateMeshBuilder(d3drm3
, &MeshBuilder3
);
869 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr
);
871 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
872 ok(!icount
, "wrong FaceCount: %i\n", icount
);
874 hr
= IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3
, &face2
);
875 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace2 interface (hr = %x)\n", hr
);
877 hr
= IDirect3DRMFace2_QueryInterface(face2
, &IID_IDirect3DRMObject
, (void **)&obj
);
878 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
880 hr
= IDirect3DRMFace2_QueryInterface(face2
, &IID_IDirect3DRMFace
, (void **)&face1
);
881 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, %#x.\n", hr
);
882 ok(obj
== (IDirect3DRMObject
*)face1
, "Unexpected interface pointer.\n");
884 IDirect3DRMFace_Release(face1
);
885 IDirect3DRMObject_Release(obj
);
887 test_class_name((IDirect3DRMObject
*)face2
, "Face");
888 test_object_name((IDirect3DRMObject
*)face2
);
890 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
892 ok(icount
== 1, "wrong FaceCount: %i\n", icount
);
895 hr
= IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3
, &array1
);
897 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
899 ok(array1
!= NULL
, "pArray = %p\n", array1
);
902 IDirect3DRMFace
*face
;
903 count
= IDirect3DRMFaceArray_GetSize(array1
);
904 ok(count
== 1, "count = %u\n", count
);
905 hr
= IDirect3DRMFaceArray_GetElement(array1
, 0, &face
);
906 ok(hr
== D3DRM_OK
, "Cannot get face (hr = %x)\n", hr
);
907 IDirect3DRMFace_Release(face
);
908 IDirect3DRMFaceArray_Release(array1
);
911 icount
= IDirect3DRMFace2_GetVertexCount(face2
);
912 ok(!icount
, "wrong VertexCount: %i\n", icount
);
914 info
.lpMemory
= data_ok
;
915 info
.dSize
= strlen(data_ok
);
916 hr
= IDirect3DRMMeshBuilder3_Load(MeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
917 ok(hr
== D3DRM_OK
, "Cannot load mesh data (hr = %x)\n", hr
);
919 icount
= IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3
);
920 ok(icount
== 4, "Wrong number of vertices %d (must be 4)\n", icount
);
922 icount
= IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3
);
923 ok(icount
== 4, "Wrong number of normals %d (must be 4)\n", icount
);
925 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
927 ok(icount
== 4, "Wrong number of faces %d (must be 4)\n", icount
);
930 hr
= IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3
, 0, &count
, v1
);
931 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
932 ok(count
== 4, "Wrong number of vertices %d (must be 4)\n", count
);
934 hr
= IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3
, 0, &count
, n1
);
935 ok(hr
== D3DRM_OK
, "Cannot get normals information (hr = %x)\n", hr
);
936 ok(count
== 4, "Wrong number of normals %d (must be 4)\n", count
);
939 hr
= IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3
, &array1
);
941 ok(hr
== D3DRM_OK
, "Cannot get FaceArray (hr = %x)\n", hr
);
943 ok(array1
!= NULL
, "pArray = %p\n", array1
);
946 IDirect3DRMFace
*face
;
947 count
= IDirect3DRMFaceArray_GetSize(array1
);
948 ok(count
== 4, "count = %u\n", count
);
949 hr
= IDirect3DRMFaceArray_GetElement(array1
, 1, &face
);
950 ok(hr
== D3DRM_OK
, "Cannot get face (hr = %x)\n", hr
);
951 hr
= IDirect3DRMFace_GetVertices(face
, &count
, v2
, n2
);
952 ok(hr
== D3DRM_OK
, "Cannot get vertices information (hr = %x)\n", hr
);
953 ok(count
== 3, "Wrong number of vertices %d (must be 3)\n", count
);
955 vector_eq(&v1
[0], &v2
[0]);
956 vector_eq(&v1
[1], &v2
[1]);
957 vector_eq(&v1
[2], &v2
[2]);
959 vector_eq(&n1
[0], &n2
[0]);
960 vector_eq(&n1
[1], &n2
[1]);
961 vector_eq(&n1
[2], &n2
[2]);
963 IDirect3DRMFace_Release(face
);
964 IDirect3DRMFaceArray_Release(array1
);
967 /* Setting face color. */
968 hr
= IDirect3DRMFace2_SetColor(face2
, 0x1f180587);
969 ok(SUCCEEDED(hr
), "Failed to set face color, hr %#x.\n", hr
);
970 color
= IDirect3DRMFace2_GetColor(face2
);
971 ok(color
== 0x1f180587, "Unexpected color %8x.\n", color
);
973 hr
= IDirect3DRMFace2_SetColorRGB(face2
, 0.5f
, 0.5f
, 0.5f
);
974 ok(SUCCEEDED(hr
), "Failed to set color, hr %#x.\n", hr
);
975 color
= IDirect3DRMFace2_GetColor(face2
);
976 ok(color
== 0xff7f7f7f, "Unexpected color %8x.\n", color
);
978 IDirect3DRMFace2_Release(face2
);
979 IDirect3DRMMeshBuilder3_Release(MeshBuilder3
);
980 IDirect3DRM3_Release(d3drm3
);
981 IDirect3DRM2_Release(d3drm2
);
982 IDirect3DRM_Release(d3drm
);
985 static void test_Frame(void)
989 IDirect3DRMFrame
*pFrameC
;
990 IDirect3DRMFrame
*pFrameP1
;
991 IDirect3DRMFrame
*pFrameP2
;
992 IDirect3DRMFrame
*pFrameTmp
;
993 IDirect3DRMFrame
*scene_frame
;
994 IDirect3DRMFrameArray
*frame_array
;
995 IDirect3DRMMeshBuilder
*mesh_builder
;
996 IDirect3DRMVisual
*visual1
;
997 IDirect3DRMVisual
*visual_tmp
;
998 IDirect3DRMVisualArray
*visual_array
;
999 IDirect3DRMLight
*light1
;
1000 IDirect3DRMLight
*light_tmp
;
1001 IDirect3DRMLightArray
*light_array
;
1002 IDirect3DRMFrame3
*frame3
;
1003 DWORD count
, options
;
1007 hr
= Direct3DRMCreate(&d3drm
);
1008 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1010 ref
= get_refcount((IUnknown
*)d3drm
);
1011 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameC
);
1012 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1013 CHECK_REFCOUNT(pFrameC
, 1);
1014 ref2
= get_refcount((IUnknown
*)d3drm
);
1015 ok(ref2
> ref
, "Expected d3drm object to be referenced.\n");
1017 test_class_name((IDirect3DRMObject
*)pFrameC
, "Frame");
1018 test_object_name((IDirect3DRMObject
*)pFrameC
);
1020 hr
= IDirect3DRMFrame_GetParent(pFrameC
, NULL
);
1021 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr
);
1022 pFrameTmp
= (void*)0xdeadbeef;
1023 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1024 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1025 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1026 CHECK_REFCOUNT(pFrameC
, 1);
1029 hr
= IDirect3DRMFrame_GetChildren(pFrameC
, &frame_array
);
1030 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1031 ok(!!frame_array
, "frame_array = %p\n", frame_array
);
1034 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1035 ok(count
== 0, "count = %u\n", count
);
1036 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1037 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
1038 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1039 IDirect3DRMFrameArray_Release(frame_array
);
1042 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP1
);
1043 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1045 /* GetParent with NULL pointer */
1046 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, NULL
);
1047 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
1048 CHECK_REFCOUNT(pFrameP1
, 1);
1050 /* [Add/Delete]Child with NULL pointer */
1051 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, NULL
);
1052 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1053 CHECK_REFCOUNT(pFrameP1
, 1);
1055 hr
= IDirect3DRMFrame_DeleteChild(pFrameP1
, NULL
);
1056 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1057 CHECK_REFCOUNT(pFrameP1
, 1);
1059 /* Add child to first parent */
1060 pFrameTmp
= (void*)0xdeadbeef;
1061 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, &pFrameTmp
);
1062 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1063 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1065 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, pFrameC
);
1066 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1067 CHECK_REFCOUNT(pFrameP1
, 1);
1068 CHECK_REFCOUNT(pFrameC
, 2);
1070 hr
= IDirect3DRMFrame_GetScene(pFrameC
, NULL
);
1071 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1072 hr
= IDirect3DRMFrame_GetScene(pFrameC
, &scene_frame
);
1073 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
1074 ok(scene_frame
== pFrameP1
, "Expected scene frame == %p, got %p.\n", pFrameP1
, scene_frame
);
1075 CHECK_REFCOUNT(pFrameP1
, 2);
1076 IDirect3DRMFrame_Release(scene_frame
);
1077 hr
= IDirect3DRMFrame_GetScene(pFrameP1
, &scene_frame
);
1078 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
1079 ok(scene_frame
== pFrameP1
, "Expected scene frame == %p, got %p.\n", pFrameP1
, scene_frame
);
1080 CHECK_REFCOUNT(pFrameP1
, 2);
1081 IDirect3DRMFrame_Release(scene_frame
);
1084 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &frame_array
);
1085 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1086 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
1087 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
1088 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
1091 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1092 ok(count
== 1, "count = %u\n", count
);
1093 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1094 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1095 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1096 ok((get_refcount((IUnknown
*)pFrameC
) == 4) || broken(get_refcount((IUnknown
*)pFrameC
) == 3),
1097 "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown
*)pFrameC
));
1098 IDirect3DRMFrame_Release(pFrameTmp
);
1099 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
1100 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown
*)pFrameC
));
1101 IDirect3DRMFrameArray_Release(frame_array
);
1102 CHECK_REFCOUNT(pFrameC
, 2);
1105 pFrameTmp
= (void*)0xdeadbeef;
1106 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1107 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1108 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
1109 CHECK_REFCOUNT(pFrameP1
, 2);
1110 IDirect3DRMFrame_Release(pFrameTmp
);
1111 CHECK_REFCOUNT(pFrameP1
, 1);
1113 /* Add child to second parent */
1114 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP2
);
1115 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1117 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1118 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1119 CHECK_REFCOUNT(pFrameC
, 2);
1122 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1123 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1126 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1127 ok(count
== 1, "count = %u\n", count
);
1128 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1129 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1130 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1131 IDirect3DRMFrame_Release(pFrameTmp
);
1132 IDirect3DRMFrameArray_Release(frame_array
);
1136 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &frame_array
);
1137 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1140 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1141 ok(count
== 0, "count = %u\n", count
);
1142 pFrameTmp
= (void*)0xdeadbeef;
1143 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1144 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
1145 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1146 IDirect3DRMFrameArray_Release(frame_array
);
1148 hr
= IDirect3DRMFrame_GetScene(pFrameC
, &scene_frame
);
1149 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
1150 ok(scene_frame
== pFrameP2
, "Expected scene frame == %p, got %p.\n", pFrameP2
, scene_frame
);
1151 CHECK_REFCOUNT(pFrameP2
, 2);
1152 IDirect3DRMFrame_Release(scene_frame
);
1153 hr
= IDirect3DRMFrame_GetScene(pFrameP2
, &scene_frame
);
1154 ok(SUCCEEDED(hr
), "Cannot get scene (hr == %#x).\n", hr
);
1155 ok(scene_frame
== pFrameP2
, "Expected scene frame == %p, got %p.\n", pFrameP2
, scene_frame
);
1156 CHECK_REFCOUNT(pFrameP2
, 2);
1157 IDirect3DRMFrame_Release(scene_frame
);
1159 pFrameTmp
= (void*)0xdeadbeef;
1160 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1161 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1162 ok(pFrameTmp
== pFrameP2
, "pFrameTmp = %p\n", pFrameTmp
);
1163 CHECK_REFCOUNT(pFrameP2
, 2);
1164 CHECK_REFCOUNT(pFrameC
, 2);
1165 IDirect3DRMFrame_Release(pFrameTmp
);
1166 CHECK_REFCOUNT(pFrameP2
, 1);
1168 /* Add child again */
1169 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1170 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1171 CHECK_REFCOUNT(pFrameC
, 2);
1174 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1175 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1178 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1179 ok(count
== 1, "count = %u\n", count
);
1180 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1181 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1182 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1183 IDirect3DRMFrame_Release(pFrameTmp
);
1184 IDirect3DRMFrameArray_Release(frame_array
);
1188 hr
= IDirect3DRMFrame_DeleteChild(pFrameP2
, pFrameC
);
1189 ok(hr
== D3DRM_OK
, "Cannot delete child frame (hr = %x)\n", hr
);
1190 CHECK_REFCOUNT(pFrameC
, 1);
1193 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1194 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1197 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1198 ok(count
== 0, "count = %u\n", count
);
1199 pFrameTmp
= (void*)0xdeadbeef;
1200 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1201 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr
);
1202 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1203 IDirect3DRMFrameArray_Release(frame_array
);
1206 pFrameTmp
= (void*)0xdeadbeef;
1207 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1208 ok(hr
== D3DRM_OK
, "Cannot get parent frame (hr = %x)\n", hr
);
1209 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1211 /* Add two children */
1212 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1213 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1214 CHECK_REFCOUNT(pFrameC
, 2);
1216 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameP1
);
1217 ok(hr
== D3DRM_OK
, "Cannot add child frame (hr = %x)\n", hr
);
1218 CHECK_REFCOUNT(pFrameP1
, 2);
1221 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1222 ok(hr
== D3DRM_OK
, "Cannot get children (hr = %x)\n", hr
);
1225 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1226 ok(count
== 2, "count = %u\n", count
);
1227 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1228 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1229 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1230 IDirect3DRMFrame_Release(pFrameTmp
);
1231 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 1, &pFrameTmp
);
1232 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1233 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
1234 IDirect3DRMFrame_Release(pFrameTmp
);
1235 IDirect3DRMFrameArray_Release(frame_array
);
1238 /* [Add/Delete]Visual with NULL pointer */
1239 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, NULL
);
1240 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1241 CHECK_REFCOUNT(pFrameP1
, 2);
1243 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, NULL
);
1244 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1245 CHECK_REFCOUNT(pFrameP1
, 2);
1248 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &mesh_builder
);
1249 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr
);
1250 visual1
= (IDirect3DRMVisual
*)mesh_builder
;
1252 /* Add Visual to first parent */
1253 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, visual1
);
1254 ok(hr
== D3DRM_OK
, "Cannot add visual (hr = %x)\n", hr
);
1255 CHECK_REFCOUNT(pFrameP1
, 2);
1256 CHECK_REFCOUNT(visual1
, 2);
1258 visual_array
= NULL
;
1259 hr
= IDirect3DRMFrame_GetVisuals(pFrameP1
, &visual_array
);
1260 ok(hr
== D3DRM_OK
, "Cannot get visuals (hr = %x)\n", hr
);
1263 count
= IDirect3DRMVisualArray_GetSize(visual_array
);
1264 ok(count
== 1, "count = %u\n", count
);
1265 hr
= IDirect3DRMVisualArray_GetElement(visual_array
, 0, &visual_tmp
);
1266 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1267 ok(visual_tmp
== visual1
, "visual_tmp = %p\n", visual_tmp
);
1268 IDirect3DRMVisual_Release(visual_tmp
);
1269 IDirect3DRMVisualArray_Release(visual_array
);
1273 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, visual1
);
1274 ok(hr
== D3DRM_OK
, "Cannot delete visual (hr = %x)\n", hr
);
1275 CHECK_REFCOUNT(pFrameP1
, 2);
1276 IDirect3DRMMeshBuilder_Release(mesh_builder
);
1278 /* [Add/Delete]Light with NULL pointer */
1279 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, NULL
);
1280 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1281 CHECK_REFCOUNT(pFrameP1
, 2);
1283 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, NULL
);
1284 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr
);
1285 CHECK_REFCOUNT(pFrameP1
, 2);
1288 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.1, 0.2, 0.3, &light1
);
1289 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
1291 /* Add Light to first parent */
1292 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, light1
);
1293 ok(hr
== D3DRM_OK
, "Cannot add light (hr = %x)\n", hr
);
1294 CHECK_REFCOUNT(pFrameP1
, 2);
1295 CHECK_REFCOUNT(light1
, 2);
1298 hr
= IDirect3DRMFrame_GetLights(pFrameP1
, &light_array
);
1299 ok(hr
== D3DRM_OK
, "Cannot get lights (hr = %x)\n", hr
);
1302 count
= IDirect3DRMLightArray_GetSize(light_array
);
1303 ok(count
== 1, "count = %u\n", count
);
1304 hr
= IDirect3DRMLightArray_GetElement(light_array
, 0, &light_tmp
);
1305 ok(hr
== D3DRM_OK
, "Cannot get element (hr = %x)\n", hr
);
1306 ok(light_tmp
== light1
, "light_tmp = %p\n", light_tmp
);
1307 IDirect3DRMLight_Release(light_tmp
);
1308 IDirect3DRMLightArray_Release(light_array
);
1312 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, light1
);
1313 ok(hr
== D3DRM_OK
, "Cannot delete light (hr = %x)\n", hr
);
1314 CHECK_REFCOUNT(pFrameP1
, 2);
1315 IDirect3DRMLight_Release(light1
);
1317 /* Test SceneBackground on first parent */
1318 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1319 ok(color
== 0xff000000, "wrong color (%x)\n", color
);
1321 hr
= IDirect3DRMFrame_SetSceneBackground(pFrameP1
, 0xff180587);
1322 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1323 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1324 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
1326 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1
, 0.5, 0.5, 0.5);
1327 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
1328 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1329 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
1331 /* Traversal options. */
1332 hr
= IDirect3DRMFrame_QueryInterface(pFrameP2
, &IID_IDirect3DRMFrame3
, (void **)&frame3
);
1333 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMFrame3 interface, hr %#x.\n", hr
);
1335 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, NULL
);
1336 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
1339 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, &options
);
1340 ok(SUCCEEDED(hr
), "Failed to get traversal options, hr %#x.\n", hr
);
1341 ok(options
== (D3DRMFRAME_RENDERENABLE
| D3DRMFRAME_PICKENABLE
), "Unexpected default options %#x.\n", options
);
1343 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, 0);
1344 ok(SUCCEEDED(hr
), "Unexpected hr %#x.\n", hr
);
1346 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, 0xf0000000);
1347 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
1349 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, 0xf0000000 | D3DRMFRAME_PICKENABLE
);
1350 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
1353 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, &options
);
1354 ok(SUCCEEDED(hr
), "Failed to get traversal options, hr %#x.\n", hr
);
1355 ok(options
== 0, "Unexpected traversal options %#x.\n", options
);
1357 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, D3DRMFRAME_PICKENABLE
);
1358 ok(SUCCEEDED(hr
), "Failed to set traversal options, hr %#x.\n", hr
);
1361 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, &options
);
1362 ok(SUCCEEDED(hr
), "Failed to get traversal options, hr %#x.\n", hr
);
1363 ok(options
== D3DRMFRAME_PICKENABLE
, "Unexpected traversal options %#x.\n", options
);
1365 IDirect3DRMFrame3_Release(frame3
);
1368 IDirect3DRMFrame_Release(pFrameP2
);
1369 CHECK_REFCOUNT(pFrameC
, 1);
1370 CHECK_REFCOUNT(pFrameP1
, 1);
1372 IDirect3DRMFrame_Release(pFrameC
);
1373 IDirect3DRMFrame_Release(pFrameP1
);
1375 IDirect3DRM_Release(d3drm
);
1378 struct destroy_context
1380 IDirect3DRMObject
*obj
;
1381 unsigned int test_idx
;
1385 struct callback_order
1389 } corder
[3], d3drm_corder
[3];
1391 static void CDECL
destroy_callback(IDirect3DRMObject
*obj
, void *arg
)
1393 struct destroy_context
*ctxt
= arg
;
1394 ok(ctxt
->called
== 1 || ctxt
->called
== 2, "got called counter %d\n", ctxt
->called
);
1395 ok(obj
== ctxt
->obj
, "called with %p, expected %p\n", obj
, ctxt
->obj
);
1396 d3drm_corder
[ctxt
->called
].callback
= &destroy_callback
;
1397 d3drm_corder
[ctxt
->called
++].context
= ctxt
;
1400 static void CDECL
destroy_callback1(IDirect3DRMObject
*obj
, void *arg
)
1402 struct destroy_context
*ctxt
= (struct destroy_context
*)arg
;
1403 ok(ctxt
->called
== 0, "got called counter %d\n", ctxt
->called
);
1404 ok(obj
== ctxt
->obj
, "called with %p, expected %p\n", obj
, ctxt
->obj
);
1405 d3drm_corder
[ctxt
->called
].callback
= &destroy_callback1
;
1406 d3drm_corder
[ctxt
->called
++].context
= ctxt
;
1409 static void test_destroy_callback(unsigned int test_idx
, REFCLSID clsid
, REFIID iid
)
1411 struct destroy_context context
;
1412 IDirect3DRMObject
*obj
;
1418 hr
= Direct3DRMCreate(&d3drm
);
1419 ok(SUCCEEDED(hr
), "Test %u: Cannot get IDirect3DRM interface (hr = %x).\n", test_idx
, hr
);
1421 hr
= IDirect3DRM_CreateObject(d3drm
, clsid
, NULL
, iid
, (void **)&unknown
);
1422 ok(hr
== D3DRM_OK
, "Test %u: Cannot get IDirect3DRMObject interface (hr = %x).\n", test_idx
, hr
);
1423 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirect3DRMObject
, (void**)&obj
);
1424 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1425 IUnknown_Release(unknown
);
1428 context
.test_idx
= test_idx
;
1431 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, NULL
, &context
);
1432 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected D3DRMERR_BADVALUE (hr = %x).\n", test_idx
, hr
);
1434 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1435 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1436 corder
[2].callback
= &destroy_callback
;
1437 corder
[2].context
= &context
;
1439 /* same callback added twice */
1440 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1441 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1442 corder
[1].callback
= &destroy_callback
;
1443 corder
[1].context
= &context
;
1445 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback1
, NULL
);
1446 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1448 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback1
, &context
);
1449 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1452 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback1
, &context
);
1453 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1454 corder
[0].callback
= &destroy_callback1
;
1455 corder
[0].context
= &context
;
1457 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, NULL
, NULL
);
1458 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected D3DRM_BADVALUE (hr = %x).\n", test_idx
, hr
);
1461 IDirect3DRMObject_Release(obj
);
1462 ok(context
.called
== 3, "Test %u: got %d, expected 3.\n", test_idx
, context
.called
);
1463 for (i
= 0; i
< context
.called
; i
++)
1465 ok(corder
[i
].callback
== d3drm_corder
[i
].callback
1466 && corder
[i
].context
== d3drm_corder
[i
].context
,
1467 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder
[i
].callback
,
1468 d3drm_corder
[i
].context
, corder
[i
].callback
, corder
[i
].context
);
1471 /* test this pattern - add cb1, add cb2, add cb1, delete cb1 */
1472 hr
= IDirect3DRM_CreateObject(d3drm
, clsid
, NULL
, iid
, (void **)&unknown
);
1473 ok(hr
== D3DRM_OK
, "Test %u: Cannot get IDirect3DRMObject interface (hr = %x).\n", test_idx
, hr
);
1474 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirect3DRMObject
, (void**)&obj
);
1475 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1476 IUnknown_Release(unknown
);
1478 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1479 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1480 corder
[1].callback
= &destroy_callback
;
1481 corder
[1].context
= &context
;
1483 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback1
, &context
);
1484 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1485 corder
[0].callback
= &destroy_callback1
;
1486 corder
[0].context
= &context
;
1488 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1489 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1491 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback
, &context
);
1492 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1495 hr
= IDirect3DRMObject_QueryInterface(obj
, &IID_IDirect3DRMObject
, (void**)&context
.obj
);
1496 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx
, hr
);
1497 IDirect3DRMObject_Release(context
.obj
);
1498 IUnknown_Release(unknown
);
1499 ok(context
.called
== 2, "Test %u: got %d, expected 2.\n", test_idx
, context
.called
);
1500 for (i
= 0; i
< context
.called
; i
++)
1502 ok(corder
[i
].callback
== d3drm_corder
[i
].callback
1503 && corder
[i
].context
== d3drm_corder
[i
].context
,
1504 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder
[i
].callback
,
1505 d3drm_corder
[i
].context
, corder
[i
].callback
, corder
[i
].context
);
1508 IDirect3DRM_Release(d3drm
);
1511 static void test_object(void)
1517 BOOL takes_d3drm_ref
;
1521 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice
},
1522 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice2
},
1523 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice3
},
1524 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMWinDevice
},
1525 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture
},
1526 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture2
},
1527 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture3
},
1528 { &CLSID_CDirect3DRMViewport
, &IID_IDirect3DRMViewport
},
1529 { &CLSID_CDirect3DRMViewport
, &IID_IDirect3DRMViewport2
},
1530 { &CLSID_CDirect3DRMFace
, &IID_IDirect3DRMFace
},
1531 { &CLSID_CDirect3DRMFace
, &IID_IDirect3DRMFace2
},
1532 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder
, TRUE
},
1533 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder2
, TRUE
},
1534 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder3
, TRUE
},
1535 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame
, TRUE
},
1536 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame2
, TRUE
},
1537 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame3
, TRUE
},
1538 { &CLSID_CDirect3DRMLight
, &IID_IDirect3DRMLight
, TRUE
},
1539 { &CLSID_CDirect3DRMMaterial
, &IID_IDirect3DRMMaterial
, TRUE
},
1540 { &CLSID_CDirect3DRMMaterial
, &IID_IDirect3DRMMaterial2
, TRUE
},
1541 { &CLSID_CDirect3DRMMesh
, &IID_IDirect3DRMMesh
, TRUE
},
1542 { &CLSID_CDirect3DRMAnimation
, &IID_IDirect3DRMAnimation
, TRUE
},
1543 { &CLSID_CDirect3DRMAnimation
, &IID_IDirect3DRMAnimation2
, TRUE
},
1544 { &CLSID_CDirect3DRMWrap
, &IID_IDirect3DRMWrap
},
1546 IDirect3DRM
*d3drm1
;
1547 IDirect3DRM2
*d3drm2
;
1548 IDirect3DRM3
*d3drm3
;
1549 IUnknown
*unknown
= (IUnknown
*)0xdeadbeef;
1551 ULONG ref1
, ref2
, ref3
, ref4
;
1554 hr
= Direct3DRMCreate(&d3drm1
);
1555 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
1556 ref1
= get_refcount((IUnknown
*)d3drm1
);
1557 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
1558 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
1559 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
1560 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
1562 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_DirectDraw
, NULL
, &IID_IDirectDraw
, (void **)&unknown
);
1563 ok(hr
== CLASSFACTORY_E_FIRST
, "Expected hr == CLASSFACTORY_E_FIRST, got %#x.\n", hr
);
1564 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1566 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
1568 unknown
= (IUnknown
*)0xdeadbeef;
1569 hr
= IDirect3DRM_CreateObject(d3drm1
, NULL
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1570 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i
, hr
);
1571 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1572 unknown
= (IUnknown
*)0xdeadbeef;
1573 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, NULL
, (void **)&unknown
);
1574 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i
, hr
);
1575 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1576 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, NULL
, NULL
);
1577 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i
, hr
);
1579 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1580 ok(SUCCEEDED(hr
), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i
, hr
);
1583 ref2
= get_refcount((IUnknown
*)d3drm1
);
1584 if (tests
[i
].takes_d3drm_ref
)
1585 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1587 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1589 ref3
= get_refcount((IUnknown
*)d3drm2
);
1590 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1591 ref4
= get_refcount((IUnknown
*)d3drm3
);
1592 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1593 IUnknown_Release(unknown
);
1594 ref2
= get_refcount((IUnknown
*)d3drm1
);
1595 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1596 ref3
= get_refcount((IUnknown
*)d3drm2
);
1597 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1598 ref4
= get_refcount((IUnknown
*)d3drm3
);
1599 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1601 /* test Add/Destroy callbacks */
1602 test_destroy_callback(i
, tests
[i
].clsid
, tests
[i
].iid
);
1604 hr
= IDirect3DRM2_CreateObject(d3drm2
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1605 ok(SUCCEEDED(hr
), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i
, hr
);
1606 ref2
= get_refcount((IUnknown
*)d3drm1
);
1607 if (tests
[i
].takes_d3drm_ref
)
1608 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1610 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1611 ref3
= get_refcount((IUnknown
*)d3drm2
);
1612 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1613 ref4
= get_refcount((IUnknown
*)d3drm3
);
1614 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1615 IUnknown_Release(unknown
);
1616 ref2
= get_refcount((IUnknown
*)d3drm1
);
1617 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1618 ref3
= get_refcount((IUnknown
*)d3drm2
);
1619 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1620 ref4
= get_refcount((IUnknown
*)d3drm3
);
1621 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1623 hr
= IDirect3DRM3_CreateObject(d3drm3
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1624 ok(SUCCEEDED(hr
), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i
, hr
);
1625 ref2
= get_refcount((IUnknown
*)d3drm1
);
1626 if (tests
[i
].takes_d3drm_ref
)
1627 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1629 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1630 ref3
= get_refcount((IUnknown
*)d3drm2
);
1631 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1632 ref4
= get_refcount((IUnknown
*)d3drm3
);
1633 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1634 IUnknown_Release(unknown
);
1635 ref2
= get_refcount((IUnknown
*)d3drm1
);
1636 ok(ref2
== ref1
, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
1637 ref3
= get_refcount((IUnknown
*)d3drm2
);
1638 ok(ref3
== ref1
, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i
, ref1
, ref3
);
1639 ref4
= get_refcount((IUnknown
*)d3drm3
);
1640 ok(ref4
== ref1
, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i
, ref1
, ref4
);
1644 IDirect3DRM_Release(d3drm1
);
1645 IDirect3DRM2_Release(d3drm2
);
1646 IDirect3DRM3_Release(d3drm3
);
1649 static void test_Viewport(void)
1651 IDirectDrawClipper
*clipper
;
1653 IDirect3DRM
*d3drm1
;
1654 IDirect3DRM2
*d3drm2
;
1655 IDirect3DRM3
*d3drm3
;
1656 IDirect3DRMDevice
*device1
, *d3drm_device1
;
1657 IDirect3DRMDevice3
*device3
, *d3drm_device3
;
1658 IDirect3DRMFrame
*frame
;
1659 IDirect3DRMFrame3
*frame3
;
1660 IDirect3DRMViewport
*viewport
;
1661 IDirect3DRMViewport2
*viewport2
;
1662 IDirect3DViewport
*d3d_viewport
;
1664 D3DVALUE expected_val
;
1665 IDirect3DRMObject
*obj
, *obj2
;
1669 DWORD data
, ref1
, ref2
, ref3
, ref4
;
1670 DWORD initial_ref1
, initial_ref2
, initial_ref3
, device_ref
, frame_ref
, frame_ref2
, viewport_ref
;
1672 window
= create_window();
1673 GetClientRect(window
, &rc
);
1675 hr
= Direct3DRMCreate(&d3drm1
);
1676 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
1677 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
1678 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
1679 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
1680 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
1681 initial_ref1
= get_refcount((IUnknown
*)d3drm1
);
1682 initial_ref2
= get_refcount((IUnknown
*)d3drm2
);
1683 initial_ref3
= get_refcount((IUnknown
*)d3drm3
);
1685 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
1686 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
1688 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
1689 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
1691 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
1692 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
1693 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1694 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice
, (void **)&device1
);
1695 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr
);
1697 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame
);
1698 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
1699 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
1700 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %x).\n", hr
);
1702 ref1
= get_refcount((IUnknown
*)d3drm1
);
1703 ref2
= get_refcount((IUnknown
*)d3drm2
);
1704 ref3
= get_refcount((IUnknown
*)d3drm3
);
1705 device_ref
= get_refcount((IUnknown
*)device1
);
1706 frame_ref
= get_refcount((IUnknown
*)frame
);
1708 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, 0, 0, 0, 0, &viewport
);
1709 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
1710 ref4
= get_refcount((IUnknown
*)d3drm1
);
1711 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1712 ref4
= get_refcount((IUnknown
*)d3drm2
);
1713 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1714 ref4
= get_refcount((IUnknown
*)d3drm3
);
1715 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1716 ref4
= get_refcount((IUnknown
*)device1
);
1717 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1718 ref4
= get_refcount((IUnknown
*)frame
);
1719 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1721 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1722 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1723 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device1
, d3drm_device1
);
1724 IDirect3DRMDevice_Release(d3drm_device1
);
1726 IDirect3DRMViewport_Release(viewport
);
1727 ref4
= get_refcount((IUnknown
*)d3drm1
);
1728 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1729 ref4
= get_refcount((IUnknown
*)d3drm2
);
1730 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1731 ref4
= get_refcount((IUnknown
*)d3drm3
);
1732 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1733 ref4
= get_refcount((IUnknown
*)device1
);
1734 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1735 ref4
= get_refcount((IUnknown
*)frame
);
1736 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1738 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, 0, 0, 0, 0, &viewport
);
1739 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
1740 ref4
= get_refcount((IUnknown
*)d3drm1
);
1741 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1742 ref4
= get_refcount((IUnknown
*)d3drm2
);
1743 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1744 ref4
= get_refcount((IUnknown
*)d3drm3
);
1745 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1746 ref4
= get_refcount((IUnknown
*)device1
);
1747 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1748 ref4
= get_refcount((IUnknown
*)frame
);
1749 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1751 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1752 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
1753 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device1
, d3drm_device1
);
1754 IDirect3DRMDevice_Release(d3drm_device1
);
1756 IDirect3DRMViewport_Release(viewport
);
1757 ref4
= get_refcount((IUnknown
*)d3drm1
);
1758 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1759 ref4
= get_refcount((IUnknown
*)d3drm2
);
1760 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1761 ref4
= get_refcount((IUnknown
*)d3drm3
);
1762 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1763 ref4
= get_refcount((IUnknown
*)device1
);
1764 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1765 ref4
= get_refcount((IUnknown
*)frame
);
1766 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
1768 device_ref
= get_refcount((IUnknown
*)device3
);
1769 frame_ref2
= get_refcount((IUnknown
*)frame3
);
1771 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, 0, 0, 0, 0, &viewport2
);
1772 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
1773 ref4
= get_refcount((IUnknown
*)d3drm1
);
1774 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1775 ref4
= get_refcount((IUnknown
*)d3drm2
);
1776 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1777 ref4
= get_refcount((IUnknown
*)d3drm3
);
1778 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1779 ref4
= get_refcount((IUnknown
*)device3
);
1780 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1781 ref4
= get_refcount((IUnknown
*)frame3
);
1782 ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
1784 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
1785 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
1786 ok(device3
== d3drm_device3
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
1787 IDirect3DRMDevice3_Release(d3drm_device3
);
1789 IDirect3DRMViewport2_Release(viewport2
);
1790 ref4
= get_refcount((IUnknown
*)d3drm1
);
1791 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1792 ref4
= get_refcount((IUnknown
*)d3drm2
);
1793 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1794 ref4
= get_refcount((IUnknown
*)d3drm3
);
1795 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1796 ref4
= get_refcount((IUnknown
*)device3
);
1797 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
1798 ref4
= get_refcount((IUnknown
*)frame3
);
1799 ok(ref4
== frame_ref2
, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
1801 /* Test all failures together */
1802 hr
= IDirect3DRM_CreateViewport(d3drm1
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1803 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1804 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1805 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1806 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport
);
1807 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1808 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport
);
1809 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1810 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport
);
1811 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1812 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1813 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1815 hr
= IDirect3DRM2_CreateViewport(d3drm2
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1816 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1817 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1818 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1819 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport
);
1820 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1821 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport
);
1822 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1823 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport
);
1824 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1825 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1826 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1828 hr
= IDirect3DRM3_CreateViewport(d3drm3
, NULL
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1829 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1830 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1831 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1832 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport2
);
1833 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1834 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport2
);
1835 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1836 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport2
);
1837 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1838 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1839 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
1841 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1842 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
1843 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1844 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1845 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1846 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1847 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1848 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1849 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1850 IDirect3DViewport_Release(d3d_viewport
);
1851 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1852 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1853 IDirect3DViewport_Release(d3d_viewport
);
1855 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1856 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1857 vp
.dwSize
= sizeof(vp
);
1858 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1859 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1860 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1861 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1862 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1863 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1864 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1865 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1866 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1867 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1868 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1869 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1870 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1871 IDirect3DViewport_Release(d3d_viewport
);
1872 IDirect3DRMViewport_Release(viewport
);
1874 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1875 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
1876 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1877 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1878 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1879 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1880 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1881 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1882 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1883 IDirect3DViewport_Release(d3d_viewport
);
1884 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1885 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1886 IDirect3DViewport_Release(d3d_viewport
);
1888 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
1889 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1890 vp
.dwSize
= sizeof(vp
);
1891 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1892 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1893 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1894 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1895 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1896 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1897 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1898 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1899 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1900 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1901 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1902 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1903 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1904 IDirect3DViewport_Release(d3d_viewport
);
1905 IDirect3DRMViewport2_Release(viewport2
);
1907 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1908 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr
);
1909 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1910 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1911 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
1912 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1913 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1914 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1915 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1916 IDirect3DViewport_Release(d3d_viewport
);
1917 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
1918 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
1919 IDirect3DViewport_Release(d3d_viewport
);
1921 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1922 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
1923 vp
.dwSize
= sizeof(vp
);
1924 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
1925 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
1926 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
1927 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
1928 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
1929 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
1930 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
1931 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
1932 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
1933 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
1934 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
1935 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
1936 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
1937 IDirect3DViewport_Release(d3d_viewport
);
1939 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMObject
, (void**)&obj
);
1940 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1941 ok((IDirect3DRMObject
*)viewport
== obj
, "got object pointer %p, expected %p\n", obj
, viewport
);
1943 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMViewport2
, (void**)&viewport2
);
1944 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1946 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IDirect3DRMObject
, (void**)&obj2
);
1947 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1948 ok(obj
== obj2
, "got object pointer %p, expected %p\n", obj2
, obj
);
1949 ok((IUnknown
*)viewport
!= (IUnknown
*)viewport2
, "got viewport1 %p, viewport2 %p\n", viewport
, viewport2
);
1951 IDirect3DRMViewport2_Release(viewport2
);
1952 IDirect3DRMObject_Release(obj
);
1953 IDirect3DRMObject_Release(obj2
);
1955 test_class_name((IDirect3DRMObject
*)viewport
, "Viewport");
1956 test_object_name((IDirect3DRMObject
*)viewport
);
1959 hr
= IDirect3DRMViewport_SetAppData(viewport
, 0);
1960 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1962 hr
= IDirect3DRMViewport_SetAppData(viewport
, 0);
1963 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1965 hr
= IDirect3DRMViewport_SetAppData(viewport
, 1);
1966 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1968 hr
= IDirect3DRMViewport_SetAppData(viewport
, 1);
1969 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1971 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMViewport2
, (void**)&viewport2
);
1972 ok(hr
== D3DRM_OK
, "expected D3DRM_OK (hr = %x)\n", hr
);
1974 data
= IDirect3DRMViewport2_GetAppData(viewport2
);
1975 ok(data
== 1, "got %x\n", data
);
1976 IDirect3DRMViewport2_Release(viewport2
);
1977 IDirect3DRMViewport_Release(viewport
);
1979 /* IDirect3DRMViewport*::Init tests */
1980 ref1
= get_refcount((IUnknown
*)d3drm1
);
1981 ref2
= get_refcount((IUnknown
*)d3drm2
);
1982 ref3
= get_refcount((IUnknown
*)d3drm3
);
1983 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMViewport
, NULL
, &IID_IDirect3DRMViewport
,
1984 (void **)&viewport
);
1985 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x).\n", hr
);
1986 ref4
= get_refcount((IUnknown
*)d3drm1
);
1987 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
1988 ref4
= get_refcount((IUnknown
*)d3drm2
);
1989 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
1990 ref4
= get_refcount((IUnknown
*)d3drm3
);
1991 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
1993 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
1994 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1995 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1996 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
1998 /* Test all failures together */
1999 hr
= IDirect3DRMViewport_Init(viewport
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2000 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2001 hr
= IDirect3DRMViewport_Init(viewport
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2002 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2003 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
2004 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2005 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
);
2006 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2007 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1);
2008 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2010 device_ref
= get_refcount((IUnknown
*)device1
);
2011 frame_ref
= get_refcount((IUnknown
*)frame
);
2012 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2013 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMViewport interface (hr = %#x).\n", hr
);
2014 ref4
= get_refcount((IUnknown
*)d3drm1
);
2015 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2016 ref4
= get_refcount((IUnknown
*)d3drm2
);
2017 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
2018 ref4
= get_refcount((IUnknown
*)d3drm3
);
2019 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
2020 ref4
= get_refcount((IUnknown
*)device1
);
2021 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
2022 ref4
= get_refcount((IUnknown
*)frame
);
2023 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
2025 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
2026 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
2027 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
2028 IDirect3DRMDevice_Release(d3drm_device1
);
2030 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2031 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2032 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2033 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2034 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2035 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2036 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
2037 IDirect3DViewport_Release(d3d_viewport
);
2038 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2039 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
2040 IDirect3DViewport_Release(d3d_viewport
);
2042 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2043 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2044 vp
.dwSize
= sizeof(vp
);
2045 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2046 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
2047 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
2048 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
2049 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
2050 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
2051 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2052 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2053 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2054 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2055 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2056 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2057 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2058 IDirect3DViewport_Release(d3d_viewport
);
2060 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2061 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2063 IDirect3DRMViewport_Release(viewport
);
2064 ref4
= get_refcount((IUnknown
*)d3drm1
);
2065 todo_wine
ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2066 ref4
= get_refcount((IUnknown
*)d3drm2
);
2067 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
2068 ref4
= get_refcount((IUnknown
*)d3drm3
);
2069 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
2070 ref4
= get_refcount((IUnknown
*)device1
);
2071 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
2072 ref4
= get_refcount((IUnknown
*)frame
);
2073 todo_wine
ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
2075 ref1
= get_refcount((IUnknown
*)d3drm1
);
2076 ref2
= get_refcount((IUnknown
*)d3drm2
);
2077 ref3
= get_refcount((IUnknown
*)d3drm3
);
2078 hr
= IDirect3DRM3_CreateObject(d3drm2
, &CLSID_CDirect3DRMViewport
, NULL
, &IID_IDirect3DRMViewport2
,
2079 (void **)&viewport2
);
2080 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x).\n", hr
);
2081 ref4
= get_refcount((IUnknown
*)d3drm1
);
2082 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2083 ref4
= get_refcount((IUnknown
*)d3drm2
);
2084 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
2085 ref4
= get_refcount((IUnknown
*)d3drm3
);
2086 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
2088 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2089 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2090 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
2091 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2093 hr
= IDirect3DRMViewport2_Init(viewport2
, NULL
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2094 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2095 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2096 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2097 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
2098 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2099 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
);
2100 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2101 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1);
2102 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2104 device_ref
= get_refcount((IUnknown
*)device3
);
2105 frame_ref2
= get_refcount((IUnknown
*)frame3
);
2106 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2107 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMViewport2 interface (hr = %#x).\n", hr
);
2108 ref4
= get_refcount((IUnknown
*)device3
);
2109 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
2110 ref4
= get_refcount((IUnknown
*)frame3
);
2111 ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
2113 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
2114 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
2115 ok(device3
== d3drm_device3
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
2116 IDirect3DRMDevice3_Release(d3drm_device3
);
2118 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2119 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2120 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2121 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2122 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2123 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2124 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
2125 IDirect3DViewport_Release(d3d_viewport
);
2126 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2127 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4
, viewport_ref
);
2128 IDirect3DViewport_Release(d3d_viewport
);
2130 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2131 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
2132 vp
.dwSize
= sizeof(vp
);
2133 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2134 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr
);
2135 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %u, got %u.\n", rc
.right
, vp
.dwWidth
);
2136 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %u, got %u.\n", rc
.bottom
, vp
.dwHeight
);
2137 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %u, got %u.\n", rc
.left
, vp
.dwX
);
2138 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %u, got %u.\n", rc
.top
, vp
.dwY
);
2139 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2140 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2141 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2142 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2143 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2144 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2145 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2146 IDirect3DViewport_Release(d3d_viewport
);
2148 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2149 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2151 IDirect3DRMViewport2_Release(viewport2
);
2152 ref4
= get_refcount((IUnknown
*)d3drm1
);
2153 todo_wine
ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2154 ref4
= get_refcount((IUnknown
*)d3drm2
);
2155 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2
, ref4
);
2156 ref4
= get_refcount((IUnknown
*)d3drm3
);
2157 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3
, ref4
);
2158 ref4
= get_refcount((IUnknown
*)device3
);
2159 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref
, ref4
);
2160 ref4
= get_refcount((IUnknown
*)frame3
);
2161 todo_wine
ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
2163 IDirect3DRMDevice3_Release(device3
);
2164 IDirect3DRMDevice_Release(device1
);
2165 ref4
= get_refcount((IUnknown
*)d3drm1
);
2166 ok(ref4
> initial_ref1
, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1
, ref4
);
2167 ref4
= get_refcount((IUnknown
*)d3drm2
);
2168 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2
, ref4
);
2169 ref4
= get_refcount((IUnknown
*)d3drm3
);
2170 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3
, ref4
);
2171 ref4
= get_refcount((IUnknown
*)frame
);
2172 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref
, ref4
);
2173 ref4
= get_refcount((IUnknown
*)frame3
);
2174 ok(ref4
== frame_ref2
, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2
, ref4
);
2176 IDirect3DRMFrame3_Release(frame3
);
2177 ref4
= get_refcount((IUnknown
*)d3drm1
);
2178 ok(ref4
> initial_ref1
, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1
, ref4
);
2179 ref4
= get_refcount((IUnknown
*)d3drm2
);
2180 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2
, ref4
);
2181 ref4
= get_refcount((IUnknown
*)d3drm3
);
2182 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3
, ref4
);
2184 IDirect3DRMFrame_Release(frame
);
2185 ref4
= get_refcount((IUnknown
*)d3drm1
);
2186 ok(ref4
== initial_ref1
, "Expected ref4 == initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1
, ref4
);
2187 ref4
= get_refcount((IUnknown
*)d3drm2
);
2188 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2
, ref4
);
2189 ref4
= get_refcount((IUnknown
*)d3drm3
);
2190 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3
, ref4
);
2191 IDirectDrawClipper_Release(clipper
);
2193 IDirect3DRM3_Release(d3drm3
);
2194 IDirect3DRM2_Release(d3drm2
);
2195 IDirect3DRM_Release(d3drm1
);
2196 DestroyWindow(window
);
2199 static void test_Light(void)
2201 IDirect3DRMObject
*object
;
2204 IDirect3DRMLight
*light
;
2205 D3DRMLIGHTTYPE type
;
2208 hr
= Direct3DRMCreate(&d3drm
);
2209 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2211 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.5, 0.5, 0.5, &light
);
2212 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr
);
2214 hr
= IDirect3DRMLight_QueryInterface(light
, &IID_IDirect3DRMObject
, (void **)&object
);
2215 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr %#x.\n", hr
);
2216 IDirect3DRMObject_Release(object
);
2218 test_class_name((IDirect3DRMObject
*)light
, "Light");
2219 test_object_name((IDirect3DRMObject
*)light
);
2221 type
= IDirect3DRMLight_GetType(light
);
2222 ok(type
== D3DRMLIGHT_SPOT
, "wrong type (%u)\n", type
);
2224 color
= IDirect3DRMLight_GetColor(light
);
2225 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
2227 hr
= IDirect3DRMLight_SetType(light
, D3DRMLIGHT_POINT
);
2228 ok(hr
== D3DRM_OK
, "Cannot set type (hr = %x)\n", hr
);
2229 type
= IDirect3DRMLight_GetType(light
);
2230 ok(type
== D3DRMLIGHT_POINT
, "wrong type (%u)\n", type
);
2232 hr
= IDirect3DRMLight_SetColor(light
, 0xff180587);
2233 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
2234 color
= IDirect3DRMLight_GetColor(light
);
2235 ok(color
== 0xff180587, "wrong color (%x)\n", color
);
2237 hr
= IDirect3DRMLight_SetColorRGB(light
, 0.5, 0.5, 0.5);
2238 ok(hr
== D3DRM_OK
, "Cannot set color (hr = %x)\n", hr
);
2239 color
= IDirect3DRMLight_GetColor(light
);
2240 ok(color
== 0xff7f7f7f, "wrong color (%x)\n", color
);
2242 IDirect3DRMLight_Release(light
);
2244 IDirect3DRM_Release(d3drm
);
2247 static void test_Material2(void)
2251 IDirect3DRM3
*d3drm3
;
2252 IDirect3DRMMaterial2
*material2
;
2255 hr
= Direct3DRMCreate(&d3drm
);
2256 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2258 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
2260 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr
);
2261 IDirect3DRM_Release(d3drm
);
2265 hr
= IDirect3DRM3_CreateMaterial(d3drm3
, 18.5f
, &material2
);
2266 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr
);
2268 test_class_name((IDirect3DRMObject
*)material2
, "Material");
2269 test_object_name((IDirect3DRMObject
*)material2
);
2271 r
= IDirect3DRMMaterial2_GetPower(material2
);
2272 ok(r
== 18.5f
, "wrong power (%f)\n", r
);
2274 hr
= IDirect3DRMMaterial2_GetEmissive(material2
, &r
, &g
, &b
);
2275 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2276 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
);
2278 hr
= IDirect3DRMMaterial2_GetSpecular(material2
, &r
, &g
, &b
);
2279 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2280 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
);
2282 hr
= IDirect3DRMMaterial2_GetAmbient(material2
, &r
, &g
, &b
);
2283 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2284 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
);
2286 hr
= IDirect3DRMMaterial2_SetPower(material2
, 5.87f
);
2287 ok(hr
== D3DRM_OK
, "Cannot set power (hr = %x)\n", hr
);
2288 r
= IDirect3DRMMaterial2_GetPower(material2
);
2289 ok(r
== 5.87f
, "wrong power (%f)\n", r
);
2291 hr
= IDirect3DRMMaterial2_SetEmissive(material2
, 0.5f
, 0.5f
, 0.5f
);
2292 ok(hr
== D3DRM_OK
, "Cannot set emissive (hr = %x)\n", hr
);
2293 hr
= IDirect3DRMMaterial2_GetEmissive(material2
, &r
, &g
, &b
);
2294 ok(hr
== D3DRM_OK
, "Cannot get emissive (hr = %x)\n", hr
);
2295 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
);
2297 hr
= IDirect3DRMMaterial2_SetSpecular(material2
, 0.6f
, 0.6f
, 0.6f
);
2298 ok(hr
== D3DRM_OK
, "Cannot set specular (hr = %x)\n", hr
);
2299 hr
= IDirect3DRMMaterial2_GetSpecular(material2
, &r
, &g
, &b
);
2300 ok(hr
== D3DRM_OK
, "Cannot get specular (hr = %x)\n", hr
);
2301 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
);
2303 hr
= IDirect3DRMMaterial2_SetAmbient(material2
, 0.7f
, 0.7f
, 0.7f
);
2304 ok(hr
== D3DRM_OK
, "Cannot set ambient (hr = %x)\n", hr
);
2305 hr
= IDirect3DRMMaterial2_GetAmbient(material2
, &r
, &g
, &b
);
2306 ok(hr
== D3DRM_OK
, "Cannot get ambient (hr = %x)\n", hr
);
2307 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
);
2309 IDirect3DRMMaterial2_Release(material2
);
2311 IDirect3DRM3_Release(d3drm3
);
2312 IDirect3DRM_Release(d3drm
);
2315 static void test_Texture(void)
2318 IDirect3DRM
*d3drm1
;
2319 IDirect3DRM2
*d3drm2
;
2320 IDirect3DRM3
*d3drm3
;
2321 IDirect3DRMTexture
*texture1
;
2322 IDirect3DRMTexture2
*texture2
;
2323 IDirect3DRMTexture3
*texture3
;
2324 IDirectDrawSurface
*surface
;
2326 D3DRMIMAGE initimg
=
2329 TRUE
, 2 * sizeof(DWORD
), NULL
, NULL
,
2330 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
2335 TRUE
, 0, (void *)0xcafebabe, NULL
,
2336 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
2340 DWORD pixel
[4] = { 20000, 30000, 10000, 0 };
2341 ULONG ref1
, ref2
, ref3
, ref4
;
2343 hr
= Direct3DRMCreate(&d3drm1
);
2344 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2345 ref1
= get_refcount((IUnknown
*)d3drm1
);
2347 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
2348 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
2350 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
2351 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
2353 /* Test NULL params */
2354 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
2355 hr
= IDirect3DRM_CreateTexture(d3drm1
, NULL
, &texture1
);
2356 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2357 ok(!texture1
, "Expected texture returned == NULL, got %p.\n", texture1
);
2358 hr
= IDirect3DRM_CreateTexture(d3drm1
, NULL
, NULL
);
2359 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2361 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
2362 hr
= IDirect3DRM2_CreateTexture(d3drm2
, NULL
, &texture2
);
2363 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2364 ok(!texture2
, "Expected texture returned == NULL, got %p.\n", texture2
);
2365 hr
= IDirect3DRM2_CreateTexture(d3drm2
, NULL
, NULL
);
2366 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2368 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
2369 hr
= IDirect3DRM3_CreateTexture(d3drm3
, NULL
, &texture3
);
2370 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2371 ok(!texture3
, "Expected texture returned == NULL, got %p.\n", texture3
);
2372 hr
= IDirect3DRM3_CreateTexture(d3drm3
, NULL
, NULL
);
2373 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2375 /* Tests for validation of D3DRMIMAGE struct */
2376 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg
, &texture1
);
2377 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
2378 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg
, &texture2
);
2379 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2380 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
2381 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2382 IDirect3DRMTexture_Release(texture1
);
2383 IDirect3DRMTexture2_Release(texture2
);
2384 IDirect3DRMTexture3_Release(texture3
);
2387 testimg
.palette
= (void *)0xdeadbeef;
2388 testimg
.palette_size
= 0x39;
2389 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg
, &texture1
);
2390 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
2391 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg
, &texture2
);
2392 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2393 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
2394 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2395 IDirect3DRMTexture_Release(texture1
);
2396 IDirect3DRMTexture2_Release(texture2
);
2397 IDirect3DRMTexture3_Release(texture3
);
2400 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
2401 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2402 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2403 ok(!texture1
, "Expected texture == NULL, got %p.\n", texture1
);
2404 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
2405 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2406 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2407 ok(!texture2
, "Expected texture == NULL, got %p.\n", texture2
);
2408 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
2409 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2410 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2411 ok(!texture3
, "Expected texture == NULL, got %p.\n", texture3
);
2413 initimg
.red_mask
= 0;
2414 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2415 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2416 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2417 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2418 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2419 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2420 initimg
.red_mask
= 0x000000ff;
2421 initimg
.green_mask
= 0;
2422 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2423 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2424 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2425 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2426 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2427 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2428 initimg
.green_mask
= 0x0000ff00;
2429 initimg
.blue_mask
= 0;
2430 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2431 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2432 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2433 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2434 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2435 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2436 initimg
.blue_mask
= 0x00ff0000;
2437 initimg
.buffer1
= NULL
;
2438 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2439 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2440 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2441 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2442 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2443 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
2445 initimg
.buffer1
= &pixel
;
2446 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2447 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
2448 ref2
= get_refcount((IUnknown
*)d3drm1
);
2449 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2450 ref3
= get_refcount((IUnknown
*)d3drm2
);
2451 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2452 ref4
= get_refcount((IUnknown
*)d3drm3
);
2453 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2454 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2455 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2456 ref2
= get_refcount((IUnknown
*)d3drm1
);
2457 ok(ref2
> ref1
+ 1, "expected ref2 > (ref1 + 1), got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2458 ref3
= get_refcount((IUnknown
*)d3drm2
);
2459 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2460 ref4
= get_refcount((IUnknown
*)d3drm3
);
2461 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2462 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2463 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2464 ref2
= get_refcount((IUnknown
*)d3drm1
);
2465 ok(ref2
> ref1
+ 2, "expected ref2 > (ref1 + 2), got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2466 ref3
= get_refcount((IUnknown
*)d3drm2
);
2467 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2468 ref4
= get_refcount((IUnknown
*)d3drm3
);
2469 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2471 /* Created from image, GetSurface() does not work. */
2472 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, NULL
);
2473 ok(hr
== D3DRMERR_BADVALUE
, "GetSurface() expected to fail, %#x\n", hr
);
2475 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &surface
);
2476 ok(hr
== D3DRMERR_NOTCREATEDFROMDDS
, "GetSurface() expected to fail, %#x\n", hr
);
2478 /* Test all failures together */
2479 test_class_name((IDirect3DRMObject
*)texture1
, "Texture");
2480 test_class_name((IDirect3DRMObject
*)texture2
, "Texture");
2481 test_class_name((IDirect3DRMObject
*)texture3
, "Texture");
2482 test_object_name((IDirect3DRMObject
*)texture1
);
2483 test_object_name((IDirect3DRMObject
*)texture2
);
2484 test_object_name((IDirect3DRMObject
*)texture3
);
2486 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
2487 ok(!!d3drm_img
, "Failed to get image.\n");
2488 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2490 IDirect3DRMTexture_Release(texture1
);
2491 ref2
= get_refcount((IUnknown
*)d3drm1
);
2492 ok(ref2
- 2 == ref1
, "expected (ref2 - 2) == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2493 ref3
= get_refcount((IUnknown
*)d3drm2
);
2494 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2495 ref4
= get_refcount((IUnknown
*)d3drm3
);
2496 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2499 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
2500 ok(!!d3drm_img
, "Failed to get image.\n");
2501 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2503 IDirect3DRMTexture2_Release(texture2
);
2504 ref2
= get_refcount((IUnknown
*)d3drm1
);
2505 ok(ref2
- 1 == ref1
, "expected (ref2 - 1) == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2506 ref3
= get_refcount((IUnknown
*)d3drm2
);
2507 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2508 ref4
= get_refcount((IUnknown
*)d3drm3
);
2509 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2512 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
2513 ok(!!d3drm_img
, "Failed to get image.\n");
2514 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2516 IDirect3DRMTexture3_Release(texture3
);
2517 ref2
= get_refcount((IUnknown
*)d3drm1
);
2518 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2519 ref3
= get_refcount((IUnknown
*)d3drm2
);
2520 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2521 ref4
= get_refcount((IUnknown
*)d3drm3
);
2522 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2524 /* InitFromImage tests */
2525 /* Tests for validation of D3DRMIMAGE struct */
2527 testimg
.palette
= NULL
;
2528 testimg
.palette_size
= 0;
2529 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
2530 (void **)&texture2
);
2531 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr
);
2532 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
2533 (void **)&texture3
);
2534 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr
);
2535 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &testimg
);
2536 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2537 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
2538 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2539 IDirect3DRMTexture2_Release(texture2
);
2540 IDirect3DRMTexture3_Release(texture3
);
2543 testimg
.palette
= (void *)0xdeadbeef;
2544 testimg
.palette_size
= 0x39;
2545 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
2546 (void **)&texture2
);
2547 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr
);
2548 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
2549 (void **)&texture3
);
2550 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr
);
2551 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &testimg
);
2552 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 interface (hr = %#x)\n", hr
);
2553 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
2554 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
2555 IDirect3DRMTexture2_Release(texture2
);
2556 IDirect3DRMTexture3_Release(texture3
);
2558 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
2559 (void **)&texture2
);
2560 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr
);
2561 ref2
= get_refcount((IUnknown
*)texture2
);
2562 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, NULL
);
2563 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2564 ref3
= get_refcount((IUnknown
*)texture2
);
2565 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
2567 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
2568 (void **)&texture3
);
2569 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr
);
2570 ref2
= get_refcount((IUnknown
*)texture3
);
2571 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, NULL
);
2572 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2573 ref3
= get_refcount((IUnknown
*)texture3
);
2574 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
2577 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2578 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2579 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2580 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2582 initimg
.red_mask
= 0;
2583 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2584 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2585 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2586 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2587 initimg
.red_mask
= 0x000000ff;
2588 initimg
.green_mask
= 0;
2589 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2590 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2591 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2592 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2593 initimg
.green_mask
= 0x0000ff00;
2594 initimg
.blue_mask
= 0;
2595 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2596 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2597 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2598 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2599 initimg
.blue_mask
= 0x00ff0000;
2600 initimg
.buffer1
= NULL
;
2601 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2602 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2603 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2604 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2605 initimg
.buffer1
= &pixel
;
2608 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2609 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 from image (hr = %#x).\n", hr
);
2610 ref2
= get_refcount((IUnknown
*)d3drm1
);
2611 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2612 ref3
= get_refcount((IUnknown
*)d3drm2
);
2613 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2614 ref4
= get_refcount((IUnknown
*)d3drm3
);
2615 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2617 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
2618 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2619 /* Release leaked reference to d3drm1 */
2620 IDirect3DRM_Release(d3drm1
);
2622 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
2623 ok(!!d3drm_img
, "Failed to get image.\n");
2624 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2625 IDirect3DRMTexture2_Release(texture2
);
2626 ref2
= get_refcount((IUnknown
*)d3drm1
);
2627 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2628 ref3
= get_refcount((IUnknown
*)d3drm2
);
2629 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2630 ref4
= get_refcount((IUnknown
*)d3drm3
);
2631 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2634 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2635 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 from image (hr = %#x).\n", hr
);
2636 ref2
= get_refcount((IUnknown
*)d3drm1
);
2637 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
2638 ref3
= get_refcount((IUnknown
*)d3drm2
);
2639 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
2640 ref4
= get_refcount((IUnknown
*)d3drm3
);
2641 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
2643 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
2644 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
2645 IDirect3DRM_Release(d3drm1
);
2647 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
2648 ok(!!d3drm_img
, "Failed to get image.\n");
2649 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2650 IDirect3DRMTexture3_Release(texture3
);
2651 ref2
= get_refcount((IUnknown
*)d3drm1
);
2652 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
2653 ref3
= get_refcount((IUnknown
*)d3drm2
);
2654 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
2655 ref4
= get_refcount((IUnknown
*)d3drm3
);
2656 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1
, ref4
);
2658 IDirect3DRM3_Release(d3drm3
);
2659 IDirect3DRM2_Release(d3drm2
);
2660 IDirect3DRM_Release(d3drm1
);
2663 static void test_Device(void)
2665 IDirectDrawClipper
*pClipper
;
2668 IDirect3DRMDevice
*device
;
2669 IDirect3DRMWinDevice
*win_device
;
2674 window
= create_window();
2675 GetClientRect(window
, &rc
);
2677 hr
= Direct3DRMCreate(&d3drm
);
2678 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2680 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
2681 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
2683 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
2684 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
2686 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
2687 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &device
);
2688 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
2690 test_class_name((IDirect3DRMObject
*)device
, "Device");
2691 test_object_name((IDirect3DRMObject
*)device
);
2694 if (FAILED(hr
= IDirect3DRMDevice_QueryInterface(device
, &IID_IDirect3DRMWinDevice
, (void **)&win_device
)))
2696 win_skip("Cannot get IDirect3DRMWinDevice interface (hr = %x), skipping tests\n", hr
);
2700 test_class_name((IDirect3DRMObject
*)win_device
, "Device");
2701 test_object_name((IDirect3DRMObject
*)win_device
);
2702 IDirect3DRMWinDevice_Release(win_device
);
2705 IDirect3DRMDevice_Release(device
);
2706 IDirectDrawClipper_Release(pClipper
);
2708 IDirect3DRM_Release(d3drm
);
2709 DestroyWindow(window
);
2712 static void test_frame_transform(void)
2716 IDirect3DRMFrame
*frame
;
2717 D3DRMMATRIX4D matrix
;
2719 hr
= Direct3DRMCreate(&d3drm
);
2720 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2722 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &frame
);
2723 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr
);
2725 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
2726 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr
);
2727 ok(!memcmp(matrix
, identity
, sizeof(D3DRMMATRIX4D
)), "Returned matrix is not identity\n");
2729 IDirect3DRMFrame_Release(frame
);
2730 IDirect3DRM_Release(d3drm
);
2733 static int nb_objects
= 0;
2734 static const GUID
* refiids
[] =
2736 &IID_IDirect3DRMMeshBuilder
,
2737 &IID_IDirect3DRMMeshBuilder
,
2738 &IID_IDirect3DRMFrame
,
2739 &IID_IDirect3DRMMaterial
/* Not taken into account and not notified */
2742 static void __cdecl
object_load_callback(IDirect3DRMObject
*object
, REFIID objectguid
, void *arg
)
2744 ok(object
!= NULL
, "Arg 1 should not be null\n");
2745 ok(IsEqualGUID(objectguid
, refiids
[nb_objects
]), "Arg 2 is incorrect\n");
2746 ok(arg
== (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg
);
2750 static void test_d3drm_load(void)
2754 D3DRMLOADMEMORY info
;
2755 const GUID
* req_refiids
[] = { &IID_IDirect3DRMMeshBuilder
, &IID_IDirect3DRMFrame
, &IID_IDirect3DRMMaterial
};
2757 hr
= Direct3DRMCreate(&d3drm
);
2758 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
2760 info
.lpMemory
= data_d3drm_load
;
2761 info
.dSize
= strlen(data_d3drm_load
);
2762 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 3, D3DRMLOAD_FROMMEMORY
,
2763 object_load_callback
, (void *)0xdeadbeef, NULL
, NULL
, NULL
);
2764 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
2765 ok(nb_objects
== 3, "Should have loaded 3 objects (got %d)\n", nb_objects
);
2767 IDirect3DRM_Release(d3drm
);
2770 IDirect3DRMMeshBuilder
*mesh_builder
= NULL
;
2772 static void __cdecl
object_load_callback_frame(IDirect3DRMObject
*object
, REFIID object_guid
, void *arg
)
2775 IDirect3DRMFrame
*frame
;
2776 IDirect3DRMVisualArray
*array
;
2777 IDirect3DRMVisual
*visual
;
2781 hr
= IDirect3DRMObject_QueryInterface(object
, &IID_IDirect3DRMFrame
, (void**)&frame
);
2782 ok(hr
== D3DRM_OK
, "IDirect3DRMObject_QueryInterface returned %x\n", hr
);
2784 hr
= IDirect3DRMFrame_GetVisuals(frame
, &array
);
2785 ok(hr
== D3DRM_OK
, "IDirect3DRMFrame_GetVisuals returned %x\n", hr
);
2787 size
= IDirect3DRMVisualArray_GetSize(array
);
2788 ok(size
== 1, "Wrong size %u returned, expected 1\n", size
);
2790 hr
= IDirect3DRMVisualArray_GetElement(array
, 0, &visual
);
2791 ok(hr
== D3DRM_OK
, "IDirect3DRMVisualArray_GetElement returned %x\n", hr
);
2793 hr
= IDirect3DRMVisual_QueryInterface(visual
, &IID_IDirect3DRMMeshBuilder
, (void**)&mesh_builder
);
2794 ok(hr
== D3DRM_OK
, "IDirect3DRMVisualArray_GetSize returned %x\n", hr
);
2796 size
= sizeof(name
);
2797 hr
= IDirect3DRMMeshBuilder_GetName(mesh_builder
, &size
, name
);
2798 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr
);
2799 ok(!strcmp(name
, "mesh1"), "Wrong name %s, expected mesh1\n", name
);
2801 IDirect3DRMVisual_Release(visual
);
2802 IDirect3DRMVisualArray_Release(array
);
2803 IDirect3DRMFrame_Release(frame
);
2809 int vertex_per_face
;
2816 { 4, 3, 3, 9, 0x4c0000ff, 30.0f
, { 0.31f
, 0.32f
, 0.33f
}, { 0.34f
, 0.35f
, 0.36f
} },
2817 { 4, 2, 3, 6, 0x3300ff00, 20.0f
, { 0.21f
, 0.22f
, 0.23f
}, { 0.24f
, 0.25f
, 0.26f
} },
2818 { 3, 1, 3, 3, 0x19ff0000, 10.0f
, { 0.11f
, 0.12f
, 0.13f
}, { 0.14f
, 0.15f
, 0.16f
} }
2821 static void test_frame_mesh_materials(void)
2825 D3DRMLOADMEMORY info
;
2826 const GUID
*req_refiids
[] = { &IID_IDirect3DRMFrame
};
2827 IDirect3DRMMesh
*mesh
;
2829 IDirect3DRMMaterial
*material
;
2830 IDirect3DRMTexture
*texture
;
2833 hr
= Direct3DRMCreate(&d3drm
);
2834 ok(hr
== D3DRM_OK
, "Direct3DRMCreate returned %x\n", hr
);
2836 info
.lpMemory
= data_frame_mesh_materials
;
2837 info
.dSize
= strlen(data_frame_mesh_materials
);
2838 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 1, D3DRMLOAD_FROMMEMORY
, object_load_callback_frame
, (void*)0xdeadbeef, NULL
, NULL
, NULL
);
2839 ok(hr
== D3DRM_OK
, "Cannot load data (hr = %x)\n", hr
);
2841 hr
= IDirect3DRMMeshBuilder_CreateMesh(mesh_builder
, &mesh
);
2842 ok(hr
== D3DRM_OK
, "IDirect3DRMMeshBuilder_CreateMesh returned %x\n", hr
);
2844 size
= IDirect3DRMMesh_GetGroupCount(mesh
);
2845 ok(size
== 3, "Wrong size %u returned, expected 3\n", size
);
2847 for (i
= 0; i
< size
; i
++)
2849 D3DVALUE red
, green
, blue
, power
;
2851 unsigned vertex_count
, face_count
, vertex_per_face
;
2852 DWORD face_data_size
;
2854 hr
= IDirect3DRMMesh_GetGroup(mesh
, i
, &vertex_count
, &face_count
, &vertex_per_face
, &face_data_size
, NULL
);
2855 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroup returned %x\n", i
, hr
);
2856 ok(vertex_count
== groups
[i
].vertex_count
, "Group %d: Wrong vertex count %d, expected %d\n", i
, vertex_count
, groups
[i
].vertex_count
);
2857 ok(face_count
== groups
[i
].face_count
, "Group %d: Wrong face count %d; expected %d\n", i
, face_count
, groups
[i
].face_count
);
2858 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
);
2859 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
);
2861 color
= IDirect3DRMMesh_GetGroupColor(mesh
, i
);
2862 ok(color
== groups
[i
].color
, "Group %d: Wrong color %x, expected %x\n", i
, color
, groups
[i
].color
);
2864 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, i
, &material
);
2865 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroupMaterial returned %x\n", i
, hr
);
2866 ok(material
!= NULL
, "Group %d: No material\n", i
);
2867 power
= IDirect3DRMMaterial_GetPower(material
);
2868 ok(power
== groups
[i
].power
, "Group %d: Wrong power %f, expected %f\n", i
, power
, groups
[i
].power
);
2869 hr
= IDirect3DRMMaterial_GetSpecular(material
, &red
, &green
, &blue
);
2870 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMaterial_GetSpecular returned %x\n", i
, hr
);
2871 ok(red
== groups
[i
].specular
[0], "Group %d: Wrong specular red %f, expected %f\n", i
, red
, groups
[i
].specular
[0]);
2872 ok(green
== groups
[i
].specular
[1], "Group %d: Wrong specular green %f, pD3DRMexpected %f\n", i
, green
, groups
[i
].specular
[1]);
2873 ok(blue
== groups
[i
].specular
[2], "Group %d: Wrong specular blue %f, expected %f\n", i
, blue
, groups
[i
].specular
[2]);
2874 hr
= IDirect3DRMMaterial_GetEmissive(material
, &red
, &green
, &blue
);
2875 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMaterial_GetEmissive returned %x\n", i
, hr
);
2876 ok(red
== groups
[i
].emissive
[0], "Group %d: Wrong emissive red %f, expected %f\n", i
, red
, groups
[i
].emissive
[0]);
2877 ok(green
== groups
[i
].emissive
[1], "Group %d: Wrong emissive green %f, expected %f\n", i
, green
, groups
[i
].emissive
[1]);
2878 ok(blue
== groups
[i
].emissive
[2], "Group %d: Wrong emissive blue %f, expected %f\n", i
, blue
, groups
[i
].emissive
[2]);
2880 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, i
, &texture
);
2881 ok(hr
== D3DRM_OK
, "Group %d: IDirect3DRMMesh_GetGroupTexture returned %x\n", i
, hr
);
2882 ok(!texture
, "Group %d: Unexpected texture\n", i
);
2885 IDirect3DRMMaterial_Release(material
);
2887 IDirect3DRMTexture_Release(texture
);
2890 IDirect3DRMMesh_Release(mesh
);
2891 IDirect3DRMMeshBuilder_Release(mesh_builder
);
2892 IDirect3DRM_Release(d3drm
);
2898 REFIID refcount_iid
;
2903 static void test_qi(const char *test_name
, IUnknown
*base_iface
,
2904 REFIID refcount_iid
, const struct qi_test
*tests
, UINT entry_count
)
2906 ULONG refcount
, expected_refcount
;
2907 IUnknown
*iface1
, *iface2
;
2911 for (i
= 0; i
< entry_count
; ++i
)
2913 hr
= IUnknown_QueryInterface(base_iface
, tests
[i
].iid
, (void **)&iface1
);
2914 ok(hr
== tests
[i
].hr
, "Got hr %#x for test \"%s\" %u.\n", hr
, test_name
, i
);
2917 for (j
= 0; j
< entry_count
; ++j
)
2919 hr
= IUnknown_QueryInterface(iface1
, tests
[j
].iid
, (void **)&iface2
);
2920 ok(hr
== tests
[j
].hr
, "Got hr %#x for test \"%s\" %u, %u.\n", hr
, test_name
, i
, j
);
2923 expected_refcount
= 0;
2924 if (IsEqualGUID(refcount_iid
, tests
[j
].refcount_iid
))
2925 ++expected_refcount
;
2926 if (IsEqualGUID(tests
[i
].refcount_iid
, tests
[j
].refcount_iid
))
2927 ++expected_refcount
;
2928 refcount
= IUnknown_Release(iface2
);
2929 ok(refcount
== expected_refcount
, "Got refcount %u for test \"%s\" %u, %u, expected %u.\n",
2930 refcount
, test_name
, i
, j
, expected_refcount
);
2931 if (tests
[i
].vtable_iid
&& tests
[j
].vtable_iid
&& IsEqualGUID(tests
[i
].vtable_iid
, tests
[j
].vtable_iid
))
2932 ok(iface1
== iface2
,
2933 "Expected iface1 == iface2 for test \"%s\" %u, %u. Got iface1 = %p, iface 2 = %p.\n",
2934 test_name
, i
, j
, iface1
, iface2
);
2935 else if (tests
[i
].vtable_iid
&& tests
[j
].vtable_iid
)
2936 ok(iface1
!= iface2
,
2937 "Expected iface1 != iface2 for test \"%s\" %u, %u. Got iface1 == iface2 == %p.\n",
2938 test_name
, i
, j
, iface1
);
2942 expected_refcount
= 0;
2943 if (IsEqualGUID(refcount_iid
, tests
[i
].refcount_iid
))
2944 ++expected_refcount
;
2945 refcount
= IUnknown_Release(iface1
);
2946 ok(refcount
== expected_refcount
, "Got refcount %u for test \"%s\" %u, expected %u.\n",
2947 refcount
, test_name
, i
, expected_refcount
);
2952 static void test_d3drm_qi(void)
2954 static const struct qi_test tests
[] =
2956 { &IID_IDirect3DRM3
, &IID_IDirect3DRM3
, &IID_IDirect3DRM3
, S_OK
},
2957 { &IID_IDirect3DRM2
, &IID_IDirect3DRM2
, &IID_IDirect3DRM2
, S_OK
},
2958 { &IID_IDirect3DRM
, &IID_IDirect3DRM
, &IID_IDirect3DRM
, S_OK
},
2959 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2960 { &IID_IDirect3DRMObject
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2961 { &IID_IDirect3DRMObject2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2962 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2963 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2964 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2965 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2966 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2967 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2968 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2969 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2970 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2971 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2972 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2973 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2974 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2975 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2976 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2977 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2978 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2979 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2980 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2981 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2982 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2983 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2984 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2985 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2986 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2987 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2988 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2989 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2990 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2991 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2992 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2993 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2994 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2995 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2996 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2997 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2998 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
2999 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3000 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3001 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3002 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3003 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3004 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3005 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3006 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3007 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3008 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3009 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3010 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3011 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3012 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3013 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3014 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3015 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3016 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3017 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3018 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3019 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3020 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3021 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3022 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3023 { &IID_IUnknown
, &IID_IDirect3DRM
, &IID_IDirect3DRM
, S_OK
},
3028 hr
= Direct3DRMCreate(&d3drm
);
3029 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
3031 test_qi("d3drm_qi", (IUnknown
*)d3drm
, &IID_IDirect3DRM
, tests
, ARRAY_SIZE(tests
));
3033 IDirect3DRM_Release(d3drm
);
3036 static void test_frame_qi(void)
3038 static const struct qi_test tests
[] =
3040 { &IID_IDirect3DRMFrame3
, &IID_IUnknown
, &IID_IDirect3DRMFrame3
, S_OK
},
3041 { &IID_IDirect3DRMFrame2
, &IID_IUnknown
, &IID_IDirect3DRMFrame2
, S_OK
},
3042 { &IID_IDirect3DRMFrame
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
3043 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3044 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3045 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
3046 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3047 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3048 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3049 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3050 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3051 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3052 { &IID_IDirect3DRMVisual
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
3053 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3054 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3055 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3056 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3057 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3058 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3059 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3060 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3061 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3062 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3063 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3064 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3065 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3066 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3067 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3068 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3069 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3070 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3071 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3072 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3073 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3074 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3075 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3076 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3077 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3078 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3079 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3080 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3081 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3082 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3083 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3084 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3085 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3086 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3087 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3088 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3089 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3090 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3091 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3092 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3093 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3094 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3095 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3096 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3097 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3098 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3099 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3100 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3101 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3102 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3103 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3104 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3105 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3106 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
3109 IDirect3DRM
*d3drm1
;
3110 IDirect3DRM2
*d3drm2
;
3111 IDirect3DRM3
*d3drm3
;
3112 IDirect3DRMFrame
*frame1
;
3113 IDirect3DRMFrame2
*frame2
;
3114 IDirect3DRMFrame3
*frame3
;
3117 hr
= Direct3DRMCreate(&d3drm1
);
3118 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
3120 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
3121 ok(hr
== D3DRM_OK
, "Failed to create frame1 (hr = %x)\n", hr
);
3122 hr
= IDirect3DRMFrame_QueryInterface(frame1
, &IID_IUnknown
, (void **)&unknown
);
3123 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame1 (hr = %x)\n", hr
);
3124 IDirect3DRMFrame_Release(frame1
);
3125 test_qi("frame1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3126 IUnknown_Release(unknown
);
3128 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3129 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
3130 hr
= IDirect3DRM2_CreateFrame(d3drm2
, NULL
, &frame2
);
3131 ok(hr
== D3DRM_OK
, "Failed to create frame2 (hr = %x)\n", hr
);
3132 hr
= IDirect3DRMFrame2_QueryInterface(frame2
, &IID_IUnknown
, (void **)&unknown
);
3133 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame2 (hr = %x)\n", hr
);
3134 IDirect3DRMFrame2_Release(frame2
);
3135 test_qi("frame2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3136 IUnknown_Release(unknown
);
3138 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3139 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
3140 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
3141 ok(hr
== D3DRM_OK
, "Failed to create frame3 (hr = %x)\n", hr
);
3142 hr
= IDirect3DRMFrame3_QueryInterface(frame3
, &IID_IUnknown
, (void **)&unknown
);
3143 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame3 (hr = %x)\n", hr
);
3144 IDirect3DRMFrame3_Release(frame3
);
3145 test_qi("frame3_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3146 IUnknown_Release(unknown
);
3148 IDirect3DRM3_Release(d3drm3
);
3149 IDirect3DRM2_Release(d3drm2
);
3150 IDirect3DRM_Release(d3drm1
);
3153 static void test_device_qi(void)
3155 static const struct qi_test tests
[] =
3157 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3158 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3159 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3160 { &IID_IDirect3DRMDevice
, &IID_IUnknown
, &IID_IDirect3DRMDevice
, S_OK
, },
3161 { &IID_IDirect3DRMDevice2
, &IID_IUnknown
, &IID_IDirect3DRMDevice2
, S_OK
, },
3162 { &IID_IDirect3DRMDevice3
, &IID_IUnknown
, &IID_IDirect3DRMDevice3
, S_OK
, },
3163 { &IID_IDirect3DRMWinDevice
, &IID_IUnknown
, &IID_IDirect3DRMWinDevice
, S_OK
, },
3164 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMDevice
, S_OK
, },
3165 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3166 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3167 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3168 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3169 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3170 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3171 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3172 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3173 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3174 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3175 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3176 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3177 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3178 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3179 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3180 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3181 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3182 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3183 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3184 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3185 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3186 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3187 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3188 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3189 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3190 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3191 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3192 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3193 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3194 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3195 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3196 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3197 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3198 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3199 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3200 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3201 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3202 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3203 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3204 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3205 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3206 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3207 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3208 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3209 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3210 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3211 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3212 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3213 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3214 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3215 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3216 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3217 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3218 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3219 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3220 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3221 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3222 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3223 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3224 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
3227 IDirect3DRM
*d3drm1
;
3228 IDirect3DRM2
*d3drm2
;
3229 IDirect3DRM3
*d3drm3
;
3230 IDirectDrawClipper
*clipper
;
3231 IDirect3DRMDevice
*device1
;
3232 IDirect3DRMDevice2
*device2
;
3233 IDirect3DRMDevice3
*device3
;
3239 window
= create_window();
3240 GetClientRect(window
, &rc
);
3241 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3242 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr
);
3243 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3244 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x)\n", hr
);
3246 hr
= Direct3DRMCreate(&d3drm1
);
3247 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %x)\n", hr
);
3248 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
3249 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
3250 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr
);
3251 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IUnknown
, (void **)&unknown
);
3252 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice (hr = %x)\n", hr
);
3253 IDirect3DRMDevice_Release(device1
);
3254 test_qi("device1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3255 IUnknown_Release(unknown
);
3257 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3258 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
3259 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device2
);
3260 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface (hr = %x)\n", hr
);
3261 hr
= IDirect3DRMDevice2_QueryInterface(device2
, &IID_IUnknown
, (void **)&unknown
);
3262 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice2 (hr = %x)\n", hr
);
3263 IDirect3DRMDevice2_Release(device2
);
3264 test_qi("device2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3265 IUnknown_Release(unknown
);
3267 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3268 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
3269 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
3270 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
3271 IDirect3DRMDevice3_QueryInterface(device3
, &IID_IUnknown
, (void **)&unknown
);
3272 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice3 (hr = %x)\n", hr
);
3273 IDirect3DRMDevice3_Release(device3
);
3274 test_qi("device3_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3275 IUnknown_Release(unknown
);
3277 IDirectDrawClipper_Release(clipper
);
3278 IDirect3DRM3_Release(d3drm3
);
3279 IDirect3DRM2_Release(d3drm2
);
3280 IDirect3DRM_Release(d3drm1
);
3281 DestroyWindow(window
);
3285 static HRESULT CALLBACK
surface_callback(IDirectDrawSurface
*surface
, DDSURFACEDESC
*desc
, void *context
)
3287 IDirectDrawSurface
**primary
= context
;
3289 if (desc
->ddsCaps
.dwCaps
& DDSCAPS_PRIMARYSURFACE
)
3292 return DDENUMRET_CANCEL
;
3294 IDirectDrawSurface_Release(surface
);
3296 return DDENUMRET_OK
;
3299 static void test_create_device_from_clipper1(void)
3301 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3302 IDirect3DRM
*d3drm1
= NULL
;
3303 IDirectDraw
*ddraw
= NULL
;
3304 IUnknown
*unknown
= NULL
;
3305 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
3306 IDirect3DDevice
*d3ddevice1
= NULL
;
3307 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
3308 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
3309 IDirectDrawSurface7
*surface7
= NULL
;
3310 DDSURFACEDESC desc
, surface_desc
;
3311 DWORD expected_flags
, ret_val
;
3313 GUID driver
= IID_IDirect3DRGBDevice
;
3315 ULONG ref1
, ref2
, cref1
, cref2
;
3318 window
= create_window();
3319 GetClientRect(window
, &rc
);
3320 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3321 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr
);
3322 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3323 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x).\n", hr
);
3325 hr
= Direct3DRMCreate(&d3drm1
);
3326 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3327 ref1
= get_refcount((IUnknown
*)d3drm1
);
3328 cref1
= get_refcount((IUnknown
*)clipper
);
3330 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 0, 0, &device1
);
3331 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3332 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
3334 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3335 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, NULL
, &driver
, 300, 200, &device1
);
3336 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3338 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 300, 200, NULL
);
3339 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3341 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 300, 200, &device1
);
3342 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3343 ref2
= get_refcount((IUnknown
*)d3drm1
);
3344 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
3345 cref2
= get_refcount((IUnknown
*)clipper
);
3346 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1
, cref2
);
3347 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
3348 ok(ret_val
== 300, "Expected device width = 300, got %u.\n", ret_val
);
3349 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
3350 ok(ret_val
== 200, "Expected device height == 200, got %u.\n", ret_val
);
3352 /* Fetch immediate mode device in order to access render target */
3353 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
3354 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3356 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
3357 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3359 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
3360 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr
);
3362 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3363 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
3364 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr
);
3365 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
3366 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
3367 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3368 IUnknown_Release(unknown
);
3369 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3370 NULL
, &d3drm_primary
, surface_callback
);
3371 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3372 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
3373 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
3374 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface (hr = %x).\n", hr
);
3375 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
3377 IDirectDrawClipper_Release(d3drm_clipper
);
3378 IDirectDrawSurface_Release(d3drm_primary
);
3379 IDirectDrawSurface7_Release(surface7
);
3380 IDirectDraw_Release(ddraw
);
3382 /* Check properties of render target and depth surface */
3383 surface_desc
.dwSize
= sizeof(surface_desc
);
3384 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3385 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3387 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3388 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
3389 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
3390 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, surface_desc
.ddsCaps
.dwCaps
);
3391 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3392 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, surface_desc
.dwFlags
);
3394 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3395 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3396 desc
.dwSize
= sizeof(desc
);
3397 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3398 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3399 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %u bpp, got %u bpp.\n",
3400 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
3402 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3403 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3405 desc
.dwSize
= sizeof(desc
);
3406 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3407 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3409 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3410 desc
.dwWidth
, desc
.dwHeight
);
3411 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3412 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3413 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3414 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc
.dwZBufferBitDepth
);
3415 ok(desc
.ddpfPixelFormat
.dwStencilBitMask
== 0, "Expected 0 stencil bits, got %x.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
3417 /* Release old objects and check refcount of device and clipper */
3418 IDirectDrawSurface_Release(ds
);
3420 IDirectDrawSurface_Release(surface
);
3422 IDirect3DDevice_Release(d3ddevice1
);
3424 IDirect3DRMDevice_Release(device1
);
3425 ref2
= get_refcount((IUnknown
*)d3drm1
);
3426 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
3427 cref2
= get_refcount((IUnknown
*)clipper
);
3428 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1
, cref2
);
3430 /* Test if render target format follows the screen format */
3431 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3432 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3433 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
3434 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp (hr = %x).\n", hr
);
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
== 16, "Expected 16 bpp, got %u.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
3440 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
3441 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3443 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
3444 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3446 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
3447 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3449 surface_desc
.dwSize
= sizeof(surface_desc
);
3450 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3451 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3452 todo_wine
ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %ubpp.\n",
3453 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
3455 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
3456 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#x.\n", hr
);
3459 IDirectDrawSurface_Release(ds
);
3460 IDirectDrawSurface_Release(surface
);
3461 IDirect3DDevice_Release(d3ddevice1
);
3462 IDirect3DRMDevice_Release(device1
);
3463 IDirect3DRM_Release(d3drm1
);
3464 IDirectDrawClipper_Release(clipper
);
3465 IDirectDraw_Release(ddraw
);
3466 DestroyWindow(window
);
3469 static void test_create_device_from_clipper2(void)
3471 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3472 IDirect3DRM
*d3drm1
= NULL
;
3473 IDirect3DRM2
*d3drm2
= NULL
;
3474 IDirectDraw
*ddraw
= NULL
;
3475 IUnknown
*unknown
= NULL
;
3476 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
3477 IDirect3DDevice2
*d3ddevice2
= NULL
;
3478 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
3479 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
3480 IDirectDrawSurface7
*surface7
= NULL
;
3481 DDSURFACEDESC desc
, surface_desc
;
3482 DWORD expected_flags
, ret_val
;
3484 GUID driver
= IID_IDirect3DRGBDevice
;
3486 ULONG ref1
, ref2
, ref3
, cref1
, cref2
;
3489 window
= create_window();
3490 GetClientRect(window
, &rc
);
3491 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3492 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr
);
3493 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3494 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x).\n", hr
);
3496 hr
= Direct3DRMCreate(&d3drm1
);
3497 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3498 ref1
= get_refcount((IUnknown
*)d3drm1
);
3499 cref1
= get_refcount((IUnknown
*)clipper
);
3501 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3502 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
3503 ref2
= get_refcount((IUnknown
*)d3drm2
);
3505 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 0, 0, &device2
);
3506 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3507 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
3509 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3510 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, NULL
, &driver
, 300, 200, &device2
);
3511 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3513 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 300, 200, NULL
);
3514 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3516 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 300, 200, &device2
);
3517 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
3518 ref3
= get_refcount((IUnknown
*)d3drm1
);
3519 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
3520 ref3
= get_refcount((IUnknown
*)d3drm2
);
3521 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3522 cref2
= get_refcount((IUnknown
*)clipper
);
3523 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1
, cref2
);
3524 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
3525 ok(ret_val
== 300, "Expected device width = 300, got %u.\n", ret_val
);
3526 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
3527 ok(ret_val
== 200, "Expected device height == 200, got %u.\n", ret_val
);
3529 /* Fetch immediate mode device in order to access render target */
3530 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
3531 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3533 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3534 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3536 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
3537 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr
);
3539 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3540 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
3541 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr
);
3542 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
3543 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
3544 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3545 IUnknown_Release(unknown
);
3546 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3547 NULL
, &d3drm_primary
, surface_callback
);
3548 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3549 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
3550 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
3551 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface (hr = %x).\n", hr
);
3552 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
3554 IDirectDrawClipper_Release(d3drm_clipper
);
3555 IDirectDrawSurface_Release(d3drm_primary
);
3556 IDirectDrawSurface7_Release(surface7
);
3557 IDirectDraw_Release(ddraw
);
3559 /* Check properties of render target and depth surface */
3560 surface_desc
.dwSize
= sizeof(surface_desc
);
3561 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3562 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3564 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3565 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
3566 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
3567 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, surface_desc
.ddsCaps
.dwCaps
);
3568 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3569 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, surface_desc
.dwFlags
);
3571 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3572 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3573 desc
.dwSize
= sizeof(desc
);
3574 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3575 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3576 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %u bpp, got %u bpp.\n",
3577 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
3579 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3580 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3582 desc
.dwSize
= sizeof(desc
);
3583 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3584 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3586 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3587 desc
.dwWidth
, desc
.dwHeight
);
3588 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3589 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3590 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3591 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc
.dwZBufferBitDepth
);
3592 ok(desc
.ddpfPixelFormat
.dwStencilBitMask
== 0, "Expected 0 stencil bits, got %x.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
3594 /* Release old objects and check refcount of device and clipper */
3595 IDirectDrawSurface_Release(ds
);
3597 IDirectDrawSurface_Release(surface
);
3599 IDirect3DDevice2_Release(d3ddevice2
);
3601 IDirect3DRMDevice2_Release(device2
);
3602 ref3
= get_refcount((IUnknown
*)d3drm1
);
3603 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
3604 ref3
= get_refcount((IUnknown
*)d3drm2
);
3605 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3606 cref2
= get_refcount((IUnknown
*)clipper
);
3607 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1
, cref2
);
3609 /* Test if render target format follows the screen format */
3610 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3611 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3612 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
3613 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp (hr = %x).\n", hr
);
3615 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3616 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3617 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %u.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
3619 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device2
);
3620 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
3622 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
3623 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3625 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3626 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3628 surface_desc
.dwSize
= sizeof(surface_desc
);
3629 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3630 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3631 todo_wine
ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %ubpp.\n",
3632 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
3634 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
3635 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#x.\n", hr
);
3637 IDirectDrawSurface_Release(surface
);
3638 IDirect3DDevice2_Release(d3ddevice2
);
3639 IDirect3DRMDevice2_Release(device2
);
3640 IDirect3DRM2_Release(d3drm2
);
3641 IDirect3DRM_Release(d3drm1
);
3642 IDirectDrawClipper_Release(clipper
);
3643 IDirectDraw_Release(ddraw
);
3644 DestroyWindow(window
);
3647 static void test_create_device_from_clipper3(void)
3649 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3650 IDirect3DRM
*d3drm1
= NULL
;
3651 IDirect3DRM3
*d3drm3
= NULL
;
3652 IDirectDraw
*ddraw
= NULL
;
3653 IUnknown
*unknown
= NULL
;
3654 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
3655 IDirect3DDevice2
*d3ddevice2
= NULL
;
3656 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
3657 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
3658 IDirectDrawSurface7
*surface7
= NULL
;
3659 DDSURFACEDESC desc
, surface_desc
;
3660 DWORD expected_flags
, ret_val
;
3662 GUID driver
= IID_IDirect3DRGBDevice
;
3664 ULONG ref1
, ref2
, ref3
, cref1
, cref2
;
3667 window
= create_window();
3668 GetClientRect(window
, &rc
);
3669 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3670 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface (hr = %x).\n", hr
);
3671 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3672 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper (hr = %x).\n", hr
);
3674 hr
= Direct3DRMCreate(&d3drm1
);
3675 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3676 ref1
= get_refcount((IUnknown
*)d3drm1
);
3677 cref1
= get_refcount((IUnknown
*)clipper
);
3679 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3680 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
3681 ref2
= get_refcount((IUnknown
*)d3drm3
);
3683 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 0, 0, &device3
);
3684 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3685 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
3687 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
3688 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, NULL
, &driver
, 300, 200, &device3
);
3689 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3691 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 300, 200, NULL
);
3692 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
3694 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 300, 200, &device3
);
3695 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
3696 ref3
= get_refcount((IUnknown
*)d3drm1
);
3697 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
3698 ref3
= get_refcount((IUnknown
*)d3drm3
);
3699 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3700 cref2
= get_refcount((IUnknown
*)clipper
);
3701 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %u , cref2 = %u.\n", cref1
, cref2
);
3702 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
3703 ok(ret_val
== 300, "Expected device width = 300, got %u.\n", ret_val
);
3704 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
3705 ok(ret_val
== 200, "Expected device height == 200, got %u.\n", ret_val
);
3707 /* Fetch immediate mode device in order to access render target */
3708 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
3709 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3711 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3712 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3714 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
3715 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got %x.\n", hr
);
3717 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
3718 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
3719 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface (hr = %x).\n", hr
);
3720 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
3721 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
3722 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3723 IUnknown_Release(unknown
);
3724 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3725 NULL
, &d3drm_primary
, surface_callback
);
3726 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3727 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
3728 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
3729 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface (hr = %x).\n", hr
);
3730 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
3732 IDirectDrawClipper_Release(d3drm_clipper
);
3733 IDirectDrawSurface_Release(d3drm_primary
);
3734 IDirectDrawSurface7_Release(surface7
);
3735 IDirectDraw_Release(ddraw
);
3737 /* Check properties of render target and depth surface */
3738 surface_desc
.dwSize
= sizeof(surface_desc
);
3739 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3740 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3742 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3743 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
3744 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
3745 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, surface_desc
.ddsCaps
.dwCaps
);
3746 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3747 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, surface_desc
.dwFlags
);
3749 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3750 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3751 desc
.dwSize
= sizeof(desc
);
3752 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3753 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3754 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %u bpp, got %u bpp.\n",
3755 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
3757 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3758 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3760 desc
.dwSize
= sizeof(desc
);
3761 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3762 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3764 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %u, %u.\n",
3765 desc
.dwWidth
, desc
.dwHeight
);
3766 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3767 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3768 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3769 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %u.\n", desc
.dwZBufferBitDepth
);
3770 ok(desc
.ddpfPixelFormat
.dwStencilBitMask
== 0, "Expected 0 stencil bits, got %x.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
3772 /* Release old objects and check refcount of device and clipper */
3773 IDirectDrawSurface_Release(ds
);
3775 IDirectDrawSurface_Release(surface
);
3777 IDirect3DDevice2_Release(d3ddevice2
);
3779 IDirect3DRMDevice3_Release(device3
);
3780 ref3
= get_refcount((IUnknown
*)d3drm1
);
3781 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
3782 ref3
= get_refcount((IUnknown
*)d3drm3
);
3783 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
3784 cref2
= get_refcount((IUnknown
*)clipper
);
3785 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1
, cref2
);
3787 /* Test if render target format follows the screen format */
3788 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3789 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3790 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
3791 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp (hr = %x).\n", hr
);
3793 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
3794 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode (hr = %x)\n", hr
);
3795 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %u.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
3797 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
3798 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
3800 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
3801 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
3803 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
3804 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3806 surface_desc
.dwSize
= sizeof(surface_desc
);
3807 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
3808 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
3809 todo_wine
ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %ubpp.\n",
3810 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
3812 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
3813 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#x.\n", hr
);
3815 IDirectDrawSurface_Release(surface
);
3816 IDirect3DDevice2_Release(d3ddevice2
);
3817 IDirect3DRMDevice3_Release(device3
);
3818 IDirect3DRM3_Release(d3drm3
);
3819 IDirect3DRM_Release(d3drm1
);
3820 IDirectDrawClipper_Release(clipper
);
3821 IDirectDraw_Release(ddraw
);
3822 DestroyWindow(window
);
3825 static void test_create_device_from_surface1(void)
3827 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
3829 IDirectDraw
*ddraw
= NULL
;
3830 IDirect3DRM
*d3drm1
= NULL
;
3831 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
3832 IDirect3DDevice
*d3ddevice1
= NULL
;
3833 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
3834 DWORD expected_flags
, ret_val
;
3836 GUID driver
= IID_IDirect3DRGBDevice
;
3837 ULONG ref1
, ref2
, surface_ref1
, surface_ref2
;
3839 BOOL use_sysmem_zbuffer
= FALSE
;
3842 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
3843 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
3845 window
= create_window();
3846 GetClientRect(window
, &rc
);
3848 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
3849 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
3851 hr
= Direct3DRMCreate(&d3drm1
);
3852 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
3853 ref1
= get_refcount((IUnknown
*)d3drm1
);
3855 /* Create a surface and use it to create the retained mode device. */
3856 memset(&desc
, 0, sizeof(desc
));
3857 desc
.dwSize
= sizeof(desc
);
3858 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
3859 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
3860 desc
.dwWidth
= rc
.right
;
3861 desc
.dwHeight
= rc
.bottom
;
3863 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3864 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3866 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
3867 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr
);
3868 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
3869 IDirectDrawSurface_Release(surface
);
3871 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
3872 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3873 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3874 surface_ref1
= get_refcount((IUnknown
*)surface
);
3876 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, NULL
);
3877 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got %x.\n", hr
);
3878 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, NULL
, &device1
);
3879 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
3880 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, NULL
, surface
, &device1
);
3881 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
3883 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
3884 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3885 ref2
= get_refcount((IUnknown
*)d3drm1
);
3886 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
3887 surface_ref2
= get_refcount((IUnknown
*)surface
);
3888 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n", surface_ref1
, surface_ref2
);
3889 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
3890 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
3891 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
3892 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
3894 /* Check if CreateDeviceFromSurface creates a primary surface */
3895 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
3896 NULL
, &d3drm_surface
, surface_callback
);
3897 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
3898 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
3900 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
3901 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3903 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&d3drm_surface
);
3904 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3905 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
3907 /* Check properties of attached depth surface */
3908 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
3909 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3911 memset(&desc
, 0, sizeof(desc
));
3912 desc
.dwSize
= sizeof(desc
);
3913 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
3914 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
3916 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
3917 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
3918 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
3919 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
3920 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
3921 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
3923 IDirectDrawSurface_Release(ds
);
3924 IDirect3DDevice_Release(d3ddevice1
);
3925 IDirectDrawSurface_Release(d3drm_surface
);
3927 IDirect3DRMDevice_Release(device1
);
3928 ref2
= get_refcount((IUnknown
*)d3drm1
);
3929 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
3930 surface_ref2
= get_refcount((IUnknown
*)surface
);
3931 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n",
3932 surface_ref1
, surface_ref2
);
3933 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3934 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3935 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
3936 ref1
= IDirectDrawSurface_Release(ds
);
3937 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
3938 ref1
= IDirectDrawSurface_Release(surface
);
3939 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
3941 memset(&desc
, 0, sizeof(desc
));
3942 desc
.dwSize
= sizeof(desc
);
3943 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
3944 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
3945 desc
.dwWidth
= rc
.right
;
3946 desc
.dwHeight
= rc
.bottom
;
3948 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
3949 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
3951 memset(&desc
, 0, sizeof(desc
));
3952 desc
.dwSize
= sizeof(desc
);
3953 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
3954 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
3955 desc
.dwZBufferBitDepth
= 16;
3956 desc
.dwWidth
= rc
.right
;
3957 desc
.dwHeight
= rc
.bottom
;
3958 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
3959 ok(hr
== DD_OK
, "Cannot create depth surface (hr = %x).\n", hr
);
3960 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
3961 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
3963 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
3964 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr
);
3966 hr
= IDirect3DRMDevice2_GetDirect3DDevice(device1
, &d3ddevice1
);
3967 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
3969 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&d3drm_surface
);
3970 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
3971 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
3973 /* Check if depth surface matches the one we created */
3974 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
3975 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3976 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
3978 IDirectDrawSurface_Release(d3drm_ds
);
3979 IDirectDrawSurface_Release(d3drm_surface
);
3980 IDirectDrawSurface_Release(ds
);
3982 IDirect3DDevice_Release(d3ddevice1
);
3983 IDirect3DRMDevice_Release(device1
);
3984 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
3985 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
3986 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
3987 ref1
= IDirectDrawSurface_Release(ds
);
3988 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
3989 ref1
= IDirectDrawSurface_Release(surface
);
3990 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
3991 IDirect3DRM_Release(d3drm1
);
3992 IDirectDraw_Release(ddraw
);
3993 DestroyWindow(window
);
3996 static void test_create_device_from_surface2(void)
3998 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4000 IDirectDraw
*ddraw
= NULL
;
4001 IDirect3DRM
*d3drm1
= NULL
;
4002 IDirect3DRM2
*d3drm2
= NULL
;
4003 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
4004 IDirect3DDevice2
*d3ddevice2
= NULL
;
4005 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
4006 DWORD expected_flags
, ret_val
;
4008 GUID driver
= IID_IDirect3DRGBDevice
;
4009 ULONG ref1
, ref2
, ref3
, surface_ref1
, surface_ref2
;
4011 BOOL use_sysmem_zbuffer
= FALSE
;
4014 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4015 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4017 window
= create_window();
4018 GetClientRect(window
, &rc
);
4020 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4021 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4023 hr
= Direct3DRMCreate(&d3drm1
);
4024 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4025 ref1
= get_refcount((IUnknown
*)d3drm1
);
4027 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
4028 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
4029 ref2
= get_refcount((IUnknown
*)d3drm2
);
4031 /* Create a surface and use it to create the retained mode device. */
4032 memset(&desc
, 0, sizeof(desc
));
4033 desc
.dwSize
= sizeof(desc
);
4034 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4035 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
4036 desc
.dwWidth
= rc
.right
;
4037 desc
.dwHeight
= rc
.bottom
;
4039 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4040 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4042 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4043 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr
);
4044 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
4045 IDirectDrawSurface_Release(surface
);
4047 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
4048 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4049 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4050 surface_ref1
= get_refcount((IUnknown
*)surface
);
4052 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, NULL
);
4053 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got %x.\n", hr
);
4054 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, NULL
, &device2
);
4055 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
4056 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, NULL
, surface
, &device2
);
4057 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
4059 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4060 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
4061 ref3
= get_refcount((IUnknown
*)d3drm1
);
4062 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4063 ref3
= get_refcount((IUnknown
*)d3drm2
);
4064 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4065 surface_ref2
= get_refcount((IUnknown
*)surface
);
4066 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n", surface_ref1
, surface_ref2
);
4067 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4068 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4069 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4070 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4072 /* Check if CreateDeviceFromSurface creates a primary surface */
4073 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4074 NULL
, &d3drm_surface
, surface_callback
);
4075 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4076 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
4078 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4079 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4081 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4082 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4083 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4085 /* Check properties of attached depth surface */
4086 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
4087 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4089 memset(&desc
, 0, sizeof(desc
));
4090 desc
.dwSize
= sizeof(desc
);
4091 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4092 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4094 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
4095 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4096 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4097 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4098 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4099 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4101 IDirectDrawSurface_Release(ds
);
4102 IDirect3DDevice2_Release(d3ddevice2
);
4103 IDirectDrawSurface_Release(d3drm_surface
);
4105 IDirect3DRMDevice2_Release(device2
);
4106 ref3
= get_refcount((IUnknown
*)d3drm1
);
4107 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
4108 ref3
= get_refcount((IUnknown
*)d3drm2
);
4109 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4110 surface_ref2
= get_refcount((IUnknown
*)surface
);
4111 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n",
4112 surface_ref1
, surface_ref2
);
4113 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4114 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4115 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4116 ref1
= IDirectDrawSurface_Release(ds
);
4117 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4119 ref1
= IDirectDrawSurface_Release(surface
);
4120 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4122 memset(&desc
, 0, sizeof(desc
));
4123 desc
.dwSize
= sizeof(desc
);
4124 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4125 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4126 desc
.dwWidth
= rc
.right
;
4127 desc
.dwHeight
= rc
.bottom
;
4129 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4130 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4132 memset(&desc
, 0, sizeof(desc
));
4133 desc
.dwSize
= sizeof(desc
);
4134 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4135 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
4136 desc
.dwZBufferBitDepth
= 16;
4137 desc
.dwWidth
= rc
.right
;
4138 desc
.dwHeight
= rc
.bottom
;
4139 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
4140 ok(hr
== DD_OK
, "Cannot create depth surface (hr = %x).\n", hr
);
4141 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
4142 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4144 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4145 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr
);
4147 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4148 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4150 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4151 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4152 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4154 /* Check if depth surface matches the one we created */
4155 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4156 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4157 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4159 IDirectDrawSurface_Release(d3drm_ds
);
4160 IDirectDrawSurface_Release(d3drm_surface
);
4161 IDirectDrawSurface_Release(ds
);
4163 IDirect3DDevice2_Release(d3ddevice2
);
4164 IDirect3DRMDevice2_Release(device2
);
4165 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4166 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4167 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4168 ref1
= IDirectDrawSurface_Release(ds
);
4169 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4170 ref1
= IDirectDrawSurface_Release(surface
);
4171 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4172 IDirect3DRM2_Release(d3drm2
);
4173 IDirect3DRM_Release(d3drm1
);
4174 IDirectDraw_Release(ddraw
);
4175 DestroyWindow(window
);
4178 static void test_create_device_from_surface3(void)
4180 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4182 IDirectDraw
*ddraw
= NULL
;
4183 IDirect3DRM
*d3drm1
= NULL
;
4184 IDirect3DRM3
*d3drm3
= NULL
;
4185 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
4186 IDirect3DDevice2
*d3ddevice2
= NULL
;
4187 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
4188 DWORD expected_flags
, ret_val
;
4190 GUID driver
= IID_IDirect3DRGBDevice
;
4191 ULONG ref1
, ref2
, ref3
, surface_ref1
, surface_ref2
;
4193 BOOL use_sysmem_zbuffer
= FALSE
;
4196 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4197 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4199 window
= create_window();
4200 GetClientRect(window
, &rc
);
4202 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4203 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4205 hr
= Direct3DRMCreate(&d3drm1
);
4206 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4207 ref1
= get_refcount((IUnknown
*)d3drm1
);
4209 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
4210 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
4211 ref2
= get_refcount((IUnknown
*)d3drm3
);
4213 /* Create a surface and use it to create the retained mode device. */
4214 memset(&desc
, 0, sizeof(desc
));
4215 desc
.dwSize
= sizeof(desc
);
4216 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4217 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
4218 desc
.dwWidth
= rc
.right
;
4219 desc
.dwHeight
= rc
.bottom
;
4221 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4222 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4224 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4225 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr
);
4226 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
4227 IDirectDrawSurface_Release(surface
);
4229 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
4230 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4231 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4232 surface_ref1
= get_refcount((IUnknown
*)surface
);
4234 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, NULL
);
4235 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got %x.\n", hr
);
4236 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, NULL
, 0, &device3
);
4237 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
4238 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, NULL
, surface
, 0, &device3
);
4239 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got %x.\n", hr
);
4241 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4242 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4243 ref3
= get_refcount((IUnknown
*)d3drm1
);
4244 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4245 ref3
= get_refcount((IUnknown
*)d3drm3
);
4246 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4247 surface_ref2
= get_refcount((IUnknown
*)surface
);
4248 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n", surface_ref1
, surface_ref2
);
4249 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
4250 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4251 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
4252 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4254 /* Check if CreateDeviceFromSurface creates a primary surface */
4255 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4256 NULL
, &d3drm_surface
, surface_callback
);
4257 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4258 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
4260 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4261 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4263 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4264 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4265 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4267 /* Check properties of attached depth surface */
4268 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
4269 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4271 memset(&desc
, 0, sizeof(desc
));
4272 desc
.dwSize
= sizeof(desc
);
4273 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4274 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4276 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
4277 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4278 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4279 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4280 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4281 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4283 IDirectDrawSurface_Release(ds
);
4284 IDirect3DDevice2_Release(d3ddevice2
);
4285 IDirectDrawSurface_Release(d3drm_surface
);
4286 IDirect3DRMDevice3_Release(device3
);
4288 ref3
= get_refcount((IUnknown
*)d3drm1
);
4289 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
4290 ref3
= get_refcount((IUnknown
*)d3drm3
);
4291 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4292 surface_ref2
= get_refcount((IUnknown
*)surface
);
4293 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %u, surface_ref2 = %u.\n",
4294 surface_ref1
, surface_ref2
);
4295 /* In version 3, d3drm will destroy all references of the depth surface it created internally. */
4296 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4297 todo_wine
ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %x.\n", hr
);
4299 IDirectDrawSurface_Release(ds
);
4300 ref1
= IDirectDrawSurface_Release(surface
);
4301 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4303 memset(&desc
, 0, sizeof(desc
));
4304 desc
.dwSize
= sizeof(desc
);
4305 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4306 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4307 desc
.dwWidth
= rc
.right
;
4308 desc
.dwHeight
= rc
.bottom
;
4310 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4311 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4313 memset(&desc
, 0, sizeof(desc
));
4314 desc
.dwSize
= sizeof(desc
);
4315 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4316 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
4317 desc
.dwZBufferBitDepth
= 16;
4318 desc
.dwWidth
= rc
.right
;
4319 desc
.dwHeight
= rc
.bottom
;
4320 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
4321 ok(hr
== DD_OK
, "Cannot create depth surface (hr = %x).\n", hr
);
4322 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
4323 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4325 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, D3DRMDEVICE_NOZBUFFER
, &device3
);
4326 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4328 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4329 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4331 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4332 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4333 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4335 /* Check if depth surface matches the one we created */
4336 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4337 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4338 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4340 IDirectDrawSurface_Release(d3drm_ds
);
4341 IDirectDrawSurface_Release(d3drm_surface
);
4342 IDirectDrawSurface_Release(ds
);
4343 IDirect3DDevice2_Release(d3ddevice2
);
4344 IDirect3DRMDevice3_Release(device3
);
4345 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4346 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4347 /* The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4348 ref1
= IDirectDrawSurface_Release(ds
);
4349 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4351 /* What happens if we pass no flags and still attach our own depth surface? */
4352 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4353 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4355 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4356 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4358 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4359 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4360 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4362 /* Check if depth surface matches the one we created */
4363 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4364 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4365 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4367 IDirectDrawSurface_Release(d3drm_ds
);
4368 IDirectDrawSurface_Release(d3drm_surface
);
4369 IDirect3DDevice2_Release(d3ddevice2
);
4370 IDirect3DRMDevice3_Release(device3
);
4371 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4372 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4373 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4374 ref1
= IDirectDrawSurface_Release(ds
);
4375 ok(ref1
== 1, "Expected ref1 == 1, got %u.\n", ref1
);
4376 ref1
= IDirectDrawSurface_Release(surface
);
4377 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4379 memset(&desc
, 0, sizeof(desc
));
4380 desc
.dwSize
= sizeof(desc
);
4381 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4382 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4383 desc
.dwWidth
= rc
.right
;
4384 desc
.dwHeight
= rc
.bottom
;
4386 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4387 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4389 /* What happens if we don't pass D3DRMDEVICE_NOZBUFFER and still not attach our own depth surface? */
4390 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, D3DRMDEVICE_NOZBUFFER
, &device3
);
4391 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface (hr = %x).\n", hr
);
4393 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4394 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4396 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4397 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4398 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4400 /* Check if depth surface matches the one we created */
4401 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4402 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %x).\n", hr
);
4403 IDirectDrawSurface_Release(d3drm_surface
);
4405 IDirect3DDevice2_Release(d3ddevice2
);
4406 IDirect3DRMDevice3_Release(device3
);
4407 ref1
= IDirectDrawSurface_Release(surface
);
4408 ok(ref1
== 0, "Expected Render target refcount == 0, got %u.\n", ref1
);
4409 IDirect3DRM3_Release(d3drm3
);
4410 IDirect3DRM_Release(d3drm1
);
4411 IDirectDraw_Release(ddraw
);
4412 DestroyWindow(window
);
4415 static IDirect3DDevice
*create_device1(IDirectDraw
*ddraw
, HWND window
, IDirectDrawSurface
**ds
)
4417 static const DWORD z_depths
[] = { 32, 24, 16 };
4418 IDirectDrawSurface
*surface
;
4419 IDirect3DDevice
*device
= NULL
;
4420 DDSURFACEDESC surface_desc
;
4425 GetClientRect(window
, &rc
);
4426 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4427 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4429 memset(&surface_desc
, 0, sizeof(surface_desc
));
4430 surface_desc
.dwSize
= sizeof(surface_desc
);
4431 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4432 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4433 surface_desc
.dwWidth
= rc
.right
;
4434 surface_desc
.dwHeight
= rc
.bottom
;
4436 hr
= IDirectDraw_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
4437 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4439 /* We used to use EnumDevices() for this, but it seems
4440 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
4441 * relationship with reality. */
4442 for (i
= 0; i
< ARRAY_SIZE(z_depths
); ++i
)
4444 memset(&surface_desc
, 0, sizeof(surface_desc
));
4445 surface_desc
.dwSize
= sizeof(surface_desc
);
4446 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4447 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
4448 U2(surface_desc
).dwZBufferBitDepth
= z_depths
[i
];
4449 surface_desc
.dwWidth
= rc
.right
;
4450 surface_desc
.dwHeight
= rc
.bottom
;
4451 if (FAILED(IDirectDraw_CreateSurface(ddraw
, &surface_desc
, ds
, NULL
)))
4454 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, *ds
);
4455 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4458 IDirectDrawSurface_Release(*ds
);
4462 if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface
, &IID_IDirect3DHALDevice
, (void **)&device
)))
4465 IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, *ds
);
4466 IDirectDrawSurface_Release(*ds
);
4470 IDirectDrawSurface_Release(surface
);
4474 static void test_create_device_from_d3d1(void)
4476 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
4477 IDirect3D
*d3d1
= NULL
, *temp_d3d1
;
4478 IDirect3DRM
*d3drm1
= NULL
;
4479 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
4480 IDirect3DRMDevice2
*device2
;
4481 IDirect3DRMDevice3
*device3
;
4482 IDirect3DDevice
*d3ddevice1
= NULL
, *d3drm_d3ddevice1
= NULL
, *temp_d3ddevice1
;
4483 IDirect3DDevice2
*d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4484 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
4485 DWORD expected_flags
, ret_val
;
4486 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4490 ULONG ref1
, ref2
, ref3
, ref4
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
4493 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
4494 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4496 window
= create_window();
4497 GetClientRect(window
, &rc
);
4499 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
4500 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
4501 d3d_ref1
= get_refcount((IUnknown
*)d3d1
);
4503 /* Create the immediate mode device */
4504 d3ddevice1
= create_device1(ddraw1
, window
, &ds
);
4505 if (d3ddevice1
== NULL
)
4507 win_skip("Cannot create IM device, skipping tests.\n");
4508 IDirect3D_Release(d3d1
);
4509 IDirectDraw_Release(ddraw1
);
4512 device_ref1
= get_refcount((IUnknown
*)d3ddevice1
);
4514 hr
= Direct3DRMCreate(&d3drm1
);
4515 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4516 ref1
= get_refcount((IUnknown
*)d3drm1
);
4518 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, NULL
, d3ddevice1
, &device1
);
4519 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4520 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
4521 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, NULL
, &device1
);
4522 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4523 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, d3ddevice1
, NULL
);
4524 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4526 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, d3ddevice1
, &device1
);
4527 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice interface (hr = %x)\n", hr
);
4528 ref2
= get_refcount((IUnknown
*)d3drm1
);
4529 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
4530 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4531 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4532 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
4533 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4534 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
4535 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4536 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
4537 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4539 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
4540 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr
);
4541 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4542 ok(SUCCEEDED(hr
), "Expected hr == D3DRM_OK, got %#x.\n", hr
);
4543 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4544 IDirect3DRMDevice2_Release(device2
);
4546 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4547 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
4548 ok(hr
== DD_OK
, "Cannot get IDirect3DRMDevice3 Interface (hr = %x).\n", hr
);
4549 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4550 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4551 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4552 IDirect3DRMDevice3_Release(device3
);
4554 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4555 NULL
, &surface
, surface_callback
);
4556 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4557 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4559 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3drm_d3ddevice1
);
4560 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr
);
4561 ok(d3ddevice1
== d3drm_d3ddevice1
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice1
, d3drm_d3ddevice1
);
4563 /* Check properties of render target and depth surfaces */
4564 hr
= IDirect3DDevice_QueryInterface(d3drm_d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
4565 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4567 memset(&desc
, 0, sizeof(desc
));
4568 desc
.dwSize
= sizeof(desc
);
4569 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4570 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
4572 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4573 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4574 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4575 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4576 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4577 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4579 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4580 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4581 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4583 desc
.dwSize
= sizeof(desc
);
4584 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4585 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4587 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4588 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4589 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4590 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4591 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4593 IDirectDrawSurface_Release(d3drm_ds
);
4594 IDirectDrawSurface_Release(ds
);
4595 IDirectDrawSurface_Release(surface
);
4596 IDirect3DDevice_Release(d3drm_d3ddevice1
);
4597 IDirect3DRMDevice_Release(device1
);
4598 ref2
= get_refcount((IUnknown
*)d3drm1
);
4599 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
4600 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4601 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4603 /* InitFromD3D tests */
4604 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice
, (void **)&device1
);
4605 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr
);
4607 hr
= IDirect3DRMDevice_InitFromD3D(device1
, NULL
, d3ddevice1
);
4608 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4609 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, NULL
);
4610 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4612 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
4613 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice interface (hr = %#x)\n", hr
);
4614 ref2
= get_refcount((IUnknown
*)d3drm1
);
4615 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1
, ref2
);
4616 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4617 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4618 device_ref1
, device_ref2
);
4619 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
4620 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4621 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
4622 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4623 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
4624 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4626 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
4627 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4628 ref3
= get_refcount((IUnknown
*)d3drm1
);
4629 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4630 ref3
= get_refcount((IUnknown
*)d3ddevice1
);
4631 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4632 ref3
= get_refcount((IUnknown
*)d3d1
);
4633 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4634 /* Release leaked references */
4635 while (IDirect3DRM_Release(d3drm1
) > ref2
);
4636 while (IDirect3DDevice_Release(d3ddevice1
) > device_ref2
);
4637 while (IDirect3D_Release(d3d1
) > d3d_ref2
);
4639 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
4640 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface (hr = %#x).\n", hr
);
4641 ref4
= get_refcount((IUnknown
*)temp_ddraw1
);
4643 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D
, (void **)&temp_d3d1
);
4644 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr
);
4645 temp_d3ddevice1
= create_device1(temp_ddraw1
, window
, &surface
);
4646 hr
= IDirect3DRMDevice_InitFromD3D(device1
, temp_d3d1
, temp_d3ddevice1
);
4647 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4648 ref3
= get_refcount((IUnknown
*)d3drm1
);
4649 ok(ref3
> ref2
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4650 ref3
= get_refcount((IUnknown
*)temp_d3ddevice1
);
4651 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4652 ref3
= get_refcount((IUnknown
*)temp_d3d1
);
4653 todo_wine
ok(ref3
< d3d_ref2
, "Expected ref3 < d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4654 /* Release leaked references */
4655 while (IDirect3DRM_Release(d3drm1
) > ref2
);
4656 while (IDirect3DDevice_Release(temp_d3ddevice1
) > 0);
4657 while (IDirect3D_Release(temp_d3d1
) > ref4
);
4658 IDirectDrawSurface_Release(surface
);
4659 IDirectDraw_Release(temp_ddraw1
);
4661 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4662 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
4663 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 Interface (hr = %x).\n", hr
);
4664 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4665 ok(SUCCEEDED(hr
), "Expected hr == D3DRM_OK, got %#x.\n", hr
);
4666 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4667 IDirect3DRMDevice2_Release(device2
);
4669 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
4670 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
4671 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 Interface (hr = %#x).\n", hr
);
4672 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4673 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4674 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
4675 IDirect3DRMDevice3_Release(device3
);
4678 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4679 NULL
, &surface
, surface_callback
);
4680 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces (hr = %#x).\n", hr
);
4681 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4683 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3drm_d3ddevice1
);
4684 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice interface (hr = %#x).\n", hr
);
4685 ok(d3ddevice1
== d3drm_d3ddevice1
, "Expected Immediate Mode device created == %p, got %p.\n",
4686 d3ddevice1
, d3drm_d3ddevice1
);
4688 /* Check properties of render target and depth surfaces */
4689 hr
= IDirect3DDevice_QueryInterface(d3drm_d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
4690 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
4692 memset(&desc
, 0, sizeof(desc
));
4693 desc
.dwSize
= sizeof(desc
);
4694 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4695 ok(SUCCEEDED(hr
), "Cannot get surface desc structure (hr = %#x).\n", hr
);
4697 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4698 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4699 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
4700 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4701 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4702 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4704 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4705 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
4706 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4708 desc
.dwSize
= sizeof(desc
);
4709 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4710 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure (hr = %#x).\n", hr
);
4712 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4713 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4714 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %#x, got %#x.\n",
4715 DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4716 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4717 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
4719 IDirectDrawSurface_Release(d3drm_ds
);
4720 IDirectDrawSurface_Release(ds
);
4721 IDirectDrawSurface_Release(surface
);
4722 IDirect3DDevice_Release(d3drm_d3ddevice1
);
4723 IDirect3DRMDevice_Release(device1
);
4724 ref2
= get_refcount((IUnknown
*)d3drm1
);
4725 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1
, ref2
);
4726 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
4727 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4728 device_ref1
, device_ref2
);
4729 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
4730 todo_wine
ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
,
4733 IDirect3DRM_Release(d3drm1
);
4734 IDirect3DDevice_Release(d3ddevice1
);
4735 IDirect3D_Release(d3d1
);
4736 IDirectDraw_Release(ddraw1
);
4737 DestroyWindow(window
);
4740 static IDirect3DDevice2
*create_device2(IDirectDraw2
*ddraw
, HWND window
, IDirectDrawSurface
**ds
)
4742 static const DWORD z_depths
[] = { 32, 24, 16 };
4743 IDirectDrawSurface
*surface
;
4744 IDirect3DDevice2
*device
= NULL
;
4745 DDSURFACEDESC surface_desc
;
4751 GetClientRect(window
, &rc
);
4752 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4753 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
4755 memset(&surface_desc
, 0, sizeof(surface_desc
));
4756 surface_desc
.dwSize
= sizeof(surface_desc
);
4757 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4758 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4759 surface_desc
.dwWidth
= rc
.right
;
4760 surface_desc
.dwHeight
= rc
.bottom
;
4762 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
4763 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
4765 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
4768 IDirectDrawSurface_Release(surface
);
4773 /* We used to use EnumDevices() for this, but it seems
4774 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
4775 * relationship with reality. */
4776 for (i
= 0; i
< ARRAY_SIZE(z_depths
); ++i
)
4778 memset(&surface_desc
, 0, sizeof(surface_desc
));
4779 surface_desc
.dwSize
= sizeof(surface_desc
);
4780 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4781 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
4782 U2(surface_desc
).dwZBufferBitDepth
= z_depths
[i
];
4783 surface_desc
.dwWidth
= rc
.right
;
4784 surface_desc
.dwHeight
= rc
.bottom
;
4785 if (FAILED(IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, ds
, NULL
)))
4788 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, *ds
);
4789 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
4792 IDirectDrawSurface_Release(*ds
);
4796 if (SUCCEEDED(IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
)))
4799 IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, *ds
);
4800 IDirectDrawSurface_Release(*ds
);
4804 IDirect3D2_Release(d3d
);
4805 IDirectDrawSurface_Release(surface
);
4809 static void test_create_device_from_d3d2(void)
4811 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
4812 IDirectDraw2
*ddraw2
= NULL
, *temp_ddraw2
;
4814 IDirect3D2
*d3d2
= NULL
, *temp_d3d2
;
4815 IDirect3DRM
*d3drm1
= NULL
;
4816 IDirect3DRM2
*d3drm2
= NULL
;
4817 IDirect3DRMDevice
*device1
;
4818 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
4819 IDirect3DDevice
*d3ddevice1
;
4820 IDirect3DDevice2
*d3ddevice2
= NULL
, *d3drm_d3ddevice2
= NULL
, *temp_d3ddevice2
;
4821 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
4822 DWORD expected_flags
, ret_val
;
4823 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4827 ULONG ref1
, ref2
, ref3
, ref4
, ref5
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
4830 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
4831 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
4833 window
= create_window();
4834 GetClientRect(window
, &rc
);
4836 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
4837 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
4838 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
4839 ok(hr
== DD_OK
, "Cannot get IDirectDraw2 interface (hr = %x).\n", hr
);
4840 d3d_ref1
= get_refcount((IUnknown
*)d3d2
);
4842 /* Create the immediate mode device */
4843 d3ddevice2
= create_device2(ddraw2
, window
, &ds
);
4844 if (d3ddevice2
== NULL
)
4846 win_skip("Cannot create IM device, skipping tests.\n");
4847 IDirect3D2_Release(d3d2
);
4848 IDirectDraw2_Release(ddraw2
);
4849 IDirectDraw_Release(ddraw1
);
4852 device_ref1
= get_refcount((IUnknown
*)d3ddevice2
);
4854 hr
= Direct3DRMCreate(&d3drm1
);
4855 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
4856 ref1
= get_refcount((IUnknown
*)d3drm1
);
4858 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
4859 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
4860 ref2
= get_refcount((IUnknown
*)d3drm2
);
4862 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, NULL
, d3ddevice2
, &device2
);
4863 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4864 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
4865 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, NULL
, &device2
);
4866 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4867 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, d3ddevice2
, NULL
);
4868 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
4870 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, d3ddevice2
, &device2
);
4871 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice2 interface (hr = %x)\n", hr
);
4872 ref3
= get_refcount((IUnknown
*)d3drm1
);
4873 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4874 ref3
= get_refcount((IUnknown
*)d3drm2
);
4875 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4876 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4877 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4878 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4879 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4880 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4881 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4882 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4883 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4885 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4886 NULL
, &surface
, surface_callback
);
4887 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
4888 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
4890 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3drm_d3ddevice2
);
4891 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
4892 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
, d3drm_d3ddevice2
);
4894 /* Check properties of render target and depth surfaces */
4895 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
4896 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
4898 memset(&desc
, 0, sizeof(desc
));
4899 desc
.dwSize
= sizeof(desc
);
4900 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
4901 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
4903 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4904 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4905 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4906 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
4907 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4908 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4910 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
4911 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
4912 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4914 desc
.dwSize
= sizeof(desc
);
4915 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4916 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
4918 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
4919 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4920 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
4921 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4922 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
4924 IDirectDrawSurface_Release(d3drm_ds
);
4925 IDirectDrawSurface_Release(ds
);
4926 IDirectDrawSurface_Release(surface
);
4927 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
4928 IDirect3DRMDevice2_Release(device2
);
4929 ref3
= get_refcount((IUnknown
*)d3drm1
);
4930 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
4931 ref3
= get_refcount((IUnknown
*)d3drm2
);
4932 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
4933 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4934 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
4935 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4936 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4938 /* InitFromD3D tests */
4939 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
4940 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface (hr = %#x).\n", hr
);
4942 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
4943 ok(SUCCEEDED(hr
), "Cannot get IDirect3D interface (hr = %x).\n", hr
);
4944 if (SUCCEEDED(hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice
, (void **)&d3ddevice1
)))
4946 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, d3d1
, d3ddevice1
);
4947 ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
4948 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, NULL
, d3ddevice1
);
4949 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4950 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, d3d1
, NULL
);
4951 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4952 hr
= IDirect3DRMDevice2_QueryInterface(device2
, &IID_IDirect3DRMDevice
, (void **)&device1
);
4953 ok(SUCCEEDED(hr
), "Cannot obtain IDirect3DRMDevice interface (hr = %#x).\n", hr
);
4954 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
4955 todo_wine
ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
4956 IDirect3DRMDevice_Release(device1
);
4959 IDirect3DRMDevice_Release(device1
);
4960 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice2
,
4962 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface (hr = %#x).\n", hr
);
4965 IDirect3D_Release(d3d1
);
4966 IDirect3DDevice_Release(d3ddevice1
);
4968 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, NULL
, d3ddevice2
);
4969 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4970 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, NULL
);
4971 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
4973 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, d3ddevice2
);
4974 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice2 interface (hr = %#x)\n", hr
);
4975 ref4
= get_refcount((IUnknown
*)d3drm1
);
4976 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
4977 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
4978 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
4979 device_ref1
, device_ref2
);
4980 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
4981 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
4982 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4983 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
4984 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4985 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
4987 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, d3ddevice2
);
4988 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
4989 ref3
= get_refcount((IUnknown
*)d3drm1
);
4990 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
4991 ref3
= get_refcount((IUnknown
*)d3ddevice2
);
4992 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
4993 ref3
= get_refcount((IUnknown
*)d3d2
);
4994 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
4995 /* Release leaked references */
4996 while (IDirect3DRM_Release(d3drm1
) > ref4
);
4997 while (IDirect3DDevice2_Release(d3ddevice2
) > device_ref2
);
4998 while (IDirect3D2_Release(d3d2
) > d3d_ref2
);
5000 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
5001 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface (hr = %#x).\n", hr
);
5002 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D2
, (void **)&temp_d3d2
);
5003 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr
);
5004 ref5
= get_refcount((IUnknown
*)temp_d3d2
);
5006 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirectDraw2
, (void **)&temp_ddraw2
);
5007 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface (hr = %#x).\n", hr
);
5009 temp_d3ddevice2
= create_device2(temp_ddraw2
, window
, &surface
);
5010 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, temp_d3d2
, temp_d3ddevice2
);
5011 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
5012 ref3
= get_refcount((IUnknown
*)d3drm1
);
5013 ok(ref3
> ref4
, "expected ref3 > ref4, got ref3 = %u , ref4 = %u.\n", ref3
, ref4
);
5014 ref3
= get_refcount((IUnknown
*)temp_d3ddevice2
);
5015 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
5016 ref3
= get_refcount((IUnknown
*)temp_d3d2
);
5017 ok(ref3
== d3d_ref2
, "Expected ref3 == d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
5018 /* Release leaked references */
5019 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5020 while (IDirect3DDevice2_Release(temp_d3ddevice2
) > 0);
5021 while (IDirect3D2_Release(temp_d3d2
) >= ref5
);
5022 IDirectDrawSurface_Release(surface
);
5023 IDirectDraw2_Release(temp_ddraw2
);
5024 IDirectDraw_Release(temp_ddraw1
);
5027 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5028 NULL
, &surface
, surface_callback
);
5029 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces (hr = %#x).\n", hr
);
5030 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5032 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3drm_d3ddevice2
);
5033 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface (hr = %#x).\n", hr
);
5034 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
,
5037 /* Check properties of render target and depth surfaces */
5038 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5039 ok(SUCCEEDED(hr
), "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(SUCCEEDED(hr
), "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(SUCCEEDED(hr
), "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(SUCCEEDED(hr
), "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",
5064 DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
5065 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5066 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
5068 IDirectDrawSurface_Release(d3drm_ds
);
5069 IDirectDrawSurface_Release(ds
);
5070 IDirectDrawSurface_Release(surface
);
5071 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5072 IDirect3DRMDevice2_Release(device2
);
5073 ref3
= get_refcount((IUnknown
*)d3drm1
);
5074 ok(ref1
== ref3
, "Expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
5075 ref3
= get_refcount((IUnknown
*)d3drm2
);
5076 ok(ref3
== ref2
, "Expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5077 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5078 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5079 device_ref1
, device_ref2
);
5080 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5081 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5083 IDirect3DRM2_Release(d3drm2
);
5084 IDirect3DRM_Release(d3drm1
);
5085 IDirect3DDevice2_Release(d3ddevice2
);
5086 IDirect3D2_Release(d3d2
);
5087 IDirectDraw2_Release(ddraw2
);
5088 IDirectDraw_Release(ddraw1
);
5089 DestroyWindow(window
);
5092 static void test_create_device_from_d3d3(void)
5094 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
5095 IDirectDraw2
*ddraw2
= NULL
, *temp_ddraw2
;
5097 IDirect3D2
*d3d2
= NULL
, *temp_d3d2
;
5098 IDirect3DRM
*d3drm1
= NULL
;
5099 IDirect3DRM3
*d3drm3
= NULL
;
5100 IDirect3DRMDevice
*device1
;
5101 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
5102 IDirect3DDevice
*d3ddevice1
;
5103 IDirect3DDevice2
*d3ddevice2
= NULL
, *d3drm_d3ddevice2
= NULL
, *temp_d3ddevice2
;
5104 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
5105 DWORD expected_flags
, ret_val
;
5106 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
5110 ULONG ref1
, ref2
, ref3
, ref4
, ref5
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
5113 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
5114 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
5116 window
= create_window();
5117 GetClientRect(window
, &rc
);
5119 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
5120 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
5121 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
5122 ok(hr
== DD_OK
, "Cannot get IDirectDraw2 interface (hr = %x).\n", hr
);
5123 d3d_ref1
= get_refcount((IUnknown
*)d3d2
);
5125 /* Create the immediate mode device */
5126 d3ddevice2
= create_device2(ddraw2
, window
, &ds
);
5127 if (d3ddevice2
== NULL
)
5129 win_skip("Cannot create IM device, skipping tests.\n");
5130 IDirect3D2_Release(d3d2
);
5131 IDirectDraw2_Release(ddraw2
);
5132 IDirectDraw_Release(ddraw1
);
5135 device_ref1
= get_refcount((IUnknown
*)d3ddevice2
);
5137 hr
= Direct3DRMCreate(&d3drm1
);
5138 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
5139 ref1
= get_refcount((IUnknown
*)d3drm1
);
5141 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5142 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
5143 ref2
= get_refcount((IUnknown
*)d3drm3
);
5145 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, NULL
, d3ddevice2
, &device3
);
5146 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
5147 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
5148 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, NULL
, &device3
);
5149 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
5150 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3ddevice2
, NULL
);
5151 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr
);
5153 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3ddevice2
, &device3
);
5154 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice3 interface (hr = %x)\n", hr
);
5155 ref3
= get_refcount((IUnknown
*)d3drm1
);
5156 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
5157 ref3
= get_refcount((IUnknown
*)d3drm3
);
5158 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5159 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5160 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
5161 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
5162 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
5163 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
5164 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
5166 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5167 NULL
, &surface
, surface_callback
);
5168 ok(hr
== DD_OK
, "Failed to enumerate surfaces (hr = %x).\n", hr
);
5169 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5171 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3drm_d3ddevice2
);
5172 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr
);
5173 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
, d3drm_d3ddevice2
);
5175 /* Check properties of render target and depth surfaces */
5176 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5177 ok(hr
== DD_OK
, "Cannot get surface to the render target (hr = %x).\n", hr
);
5179 memset(&desc
, 0, sizeof(desc
));
5180 desc
.dwSize
= sizeof(desc
);
5181 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5182 ok(hr
== DD_OK
, "Cannot get surface desc structure (hr = %x).\n", hr
);
5184 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5185 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5186 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
5187 "Expected caps containing %x, got %x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
5188 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5189 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
5191 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5192 ok(hr
== DD_OK
, "Cannot get attached depth surface (hr = %x).\n", hr
);
5193 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5195 desc
.dwSize
= sizeof(desc
);
5196 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5197 ok(hr
== DD_OK
, "Cannot get z surface desc structure (hr = %x).\n", hr
);
5199 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5200 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5201 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
5202 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5203 ok(desc
.dwFlags
== expected_flags
, "Expected %x for flags, got %x.\n", expected_flags
, desc
.dwFlags
);
5205 IDirectDrawSurface_Release(d3drm_ds
);
5206 IDirectDrawSurface_Release(ds
);
5207 IDirectDrawSurface_Release(surface
);
5208 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5209 IDirect3DRMDevice3_Release(device3
);
5210 ref3
= get_refcount((IUnknown
*)d3drm1
);
5211 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
5212 ref3
= get_refcount((IUnknown
*)d3drm3
);
5213 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5214 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5215 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1
, device_ref2
);
5216 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5217 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5219 /* InitFromD3D tests */
5220 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
5221 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %#x).\n", hr
);
5223 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
5224 ok(SUCCEEDED(hr
), "Cannot get IDirect3D interface (hr = %#x).\n", hr
);
5225 if (SUCCEEDED(hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice
, (void **)&d3ddevice1
)))
5227 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, d3d1
, d3ddevice1
);
5228 ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
5229 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, NULL
, d3ddevice1
);
5230 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5231 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, d3d1
, NULL
);
5232 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5233 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice
, (void **)&device1
);
5234 ok(SUCCEEDED(hr
), "Cannot obtain IDirect3DRMDevice interface (hr = %#x).\n", hr
);
5235 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
5236 todo_wine
ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got %#x.\n", hr
);
5237 IDirect3DRMDevice_Release(device1
);
5240 IDirect3DRMDevice_Release(device1
);
5241 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice3
,
5243 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %#x).\n", hr
);
5246 IDirect3D_Release(d3d1
);
5247 IDirect3DDevice_Release(d3ddevice1
);
5249 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, NULL
, d3ddevice2
);
5250 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5251 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, NULL
);
5252 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
5254 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, d3ddevice2
);
5255 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice2 interface (hr = %#x)\n", hr
);
5256 ref4
= get_refcount((IUnknown
*)d3drm1
);
5257 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %u , ref4 = %u.\n", ref1
, ref4
);
5258 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5259 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5260 device_ref1
, device_ref2
);
5261 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5262 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5263 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
5264 ok(ret_val
== rc
.right
, "Expected device width = 300, got %u.\n", ret_val
);
5265 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
5266 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %u.\n", ret_val
);
5268 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, d3ddevice2
);
5269 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
5270 ref3
= get_refcount((IUnknown
*)d3drm1
);
5271 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %u , ref3 = %u.\n", ref1
, ref3
);
5272 ref3
= get_refcount((IUnknown
*)d3ddevice2
);
5273 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
5274 ref3
= get_refcount((IUnknown
*)d3d2
);
5275 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
5276 /* Release leaked references */
5277 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5278 while (IDirect3DDevice2_Release(d3ddevice2
) > device_ref2
);
5279 while (IDirect3D2_Release(d3d2
) > d3d_ref2
);
5281 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
5282 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface (hr = %#x).\n", hr
);
5283 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D2
, (void **)&temp_d3d2
);
5284 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %#x).\n", hr
);
5285 ref5
= get_refcount((IUnknown
*)temp_d3d2
);
5287 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirectDraw2
, (void **)&temp_ddraw2
);
5288 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface (hr = %#x).\n", hr
);
5290 temp_d3ddevice2
= create_device2(temp_ddraw2
, window
, &surface
);
5291 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, temp_d3d2
, temp_d3ddevice2
);
5292 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
5293 ref3
= get_refcount((IUnknown
*)d3drm1
);
5294 ok(ref3
> ref4
, "expected ref3 > ref4, got ref3 = %u , ref4 = %u.\n", ref3
, ref4
);
5295 ref3
= get_refcount((IUnknown
*)temp_d3ddevice2
);
5296 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %u, device_ref2 = %u.\n", ref3
, device_ref2
);
5297 ref3
= get_refcount((IUnknown
*)temp_d3d2
);
5298 ok(ref3
== d3d_ref2
, "Expected ref3 == d3d_ref2, got ref3 = %u, d3d_ref2 = %u.\n", ref3
, d3d_ref2
);
5299 /* Release leaked references */
5300 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5301 while (IDirect3DDevice2_Release(temp_d3ddevice2
) > 0);
5302 while (IDirect3D2_Release(temp_d3d2
) >= ref5
);
5303 IDirectDrawSurface_Release(surface
);
5304 IDirectDraw2_Release(temp_ddraw2
);
5305 IDirectDraw_Release(temp_ddraw1
);
5308 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5309 NULL
, &surface
, surface_callback
);
5310 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces (hr = %#x).\n", hr
);
5311 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5313 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3drm_d3ddevice2
);
5314 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface (hr = %#x).\n", hr
);
5315 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
,
5318 /* Check properties of render target and depth surfaces */
5319 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5320 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
5322 memset(&desc
, 0, sizeof(desc
));
5323 desc
.dwSize
= sizeof(desc
);
5324 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5325 ok(SUCCEEDED(hr
), "Cannot get surface desc structure (hr = %x).\n", hr
);
5327 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5328 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5329 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
5330 "Expected caps containing %#x, got %#x.\n", DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
, desc
.ddsCaps
.dwCaps
);
5331 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5332 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
5334 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5335 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
5336 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5338 desc
.dwSize
= sizeof(desc
);
5339 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5340 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure (hr = %x).\n", hr
);
5342 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %u, %u, got %u, %u.\n",
5343 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5344 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Expected caps containing %x, got %#x.\n",
5345 DDSCAPS_ZBUFFER
, desc
.ddsCaps
.dwCaps
);
5346 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5347 ok(desc
.dwFlags
== expected_flags
, "Expected %#x for flags, got %#x.\n", expected_flags
, desc
.dwFlags
);
5349 IDirectDrawSurface_Release(d3drm_ds
);
5350 IDirectDrawSurface_Release(ds
);
5351 IDirectDrawSurface_Release(surface
);
5352 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5353 IDirect3DRMDevice3_Release(device3
);
5354 ref3
= get_refcount((IUnknown
*)d3drm1
);
5355 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %u, ref3 = %u.\n", ref1
, ref3
);
5356 ref3
= get_refcount((IUnknown
*)d3drm3
);
5357 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2
, ref3
);
5358 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5359 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %u, device_ref2 = %u.\n",
5360 device_ref1
, device_ref2
);
5361 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5362 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %u, d3d_ref2 = %u.\n", d3d_ref1
, d3d_ref2
);
5364 IDirect3DRM3_Release(d3drm3
);
5365 IDirect3DRM_Release(d3drm1
);
5366 IDirect3DDevice2_Release(d3ddevice2
);
5367 IDirect3D2_Release(d3d2
);
5368 IDirectDraw2_Release(ddraw2
);
5369 IDirectDraw_Release(ddraw1
);
5370 DestroyWindow(window
);
5373 static char *create_bitmap(unsigned int w
, unsigned int h
, BOOL palettized
)
5375 unsigned int bpp
= palettized
? 8 : 24;
5376 BITMAPFILEHEADER file_header
;
5377 DWORD written
, size
, ret
;
5378 unsigned char *buffer
;
5379 char path
[MAX_PATH
];
5385 ret
= GetTempPathA(MAX_PATH
, path
);
5386 ok(ret
, "Failed to get temporary file path.\n");
5387 filename
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
);
5388 ret
= GetTempFileNameA(path
, "d3d", 0, filename
);
5389 ok(ret
, "Failed to get filename.\n");
5390 file
= CreateFileA(filename
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
5391 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to open temporary file \"%s\".\n", filename
);
5393 size
= FIELD_OFFSET(BITMAPINFO
, bmiColors
[palettized
? 256 : 0]);
5395 memset(&file_header
, 0, sizeof(file_header
));
5396 file_header
.bfType
= 0x4d42; /* BM */
5397 file_header
.bfOffBits
= sizeof(file_header
) + size
;
5398 file_header
.bfSize
= file_header
.bfOffBits
+ w
* h
* (bpp
/ 8);
5399 ret
= WriteFile(file
, &file_header
, sizeof(file_header
), &written
, NULL
);
5400 ok(ret
&& written
== sizeof(file_header
), "Failed to write file header.\n");
5402 info
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
5403 info
->bmiHeader
.biSize
= sizeof(info
->bmiHeader
);
5404 info
->bmiHeader
.biBitCount
= bpp
;
5405 info
->bmiHeader
.biPlanes
= 1;
5406 info
->bmiHeader
.biWidth
= w
;
5407 info
->bmiHeader
.biHeight
= h
;
5408 info
->bmiHeader
.biCompression
= BI_RGB
;
5411 for (i
= 0; i
< 256; ++i
)
5413 info
->bmiColors
[i
].rgbBlue
= i
;
5414 info
->bmiColors
[i
].rgbGreen
= i
;
5415 info
->bmiColors
[i
].rgbRed
= i
;
5418 ret
= WriteFile(file
, info
, size
, &written
, NULL
);
5419 ok(ret
&& written
== size
, "Failed to write bitmap info.\n");
5420 HeapFree(GetProcessHeap(), 0, info
);
5422 size
= w
* h
* (bpp
/ 8);
5423 buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
5424 for (i
= 0, j
= 0; i
< size
;)
5433 buffer
[i
++] = j
% 251;
5434 buffer
[i
++] = j
% 239;
5435 buffer
[i
++] = j
++ % 247;
5438 ret
= WriteFile(file
, buffer
, size
, &written
, NULL
);
5439 ok(ret
&& written
== size
, "Failed to write bitmap data.\n");
5440 HeapFree(GetProcessHeap(), 0, buffer
);
5447 static void test_bitmap_data(unsigned int test_idx
, const D3DRMIMAGE
*img
,
5448 BOOL upside_down
, unsigned int w
, unsigned int h
, BOOL palettized
)
5450 const unsigned char *data
= img
->buffer1
;
5453 ok(img
->width
== w
, "Test %u: Got unexpected image width %u, expected %u.\n", test_idx
, img
->width
, w
);
5454 ok(img
->height
== h
, "Test %u: Got unexpected image height %u, expected %u.\n", test_idx
, img
->height
, h
);
5455 ok(img
->aspectx
== 1, "Test %u: Got unexpected image aspectx %u.\n", test_idx
, img
->aspectx
);
5456 ok(img
->aspecty
== 1, "Test %u: Got unexpected image aspecty %u.\n", test_idx
, img
->aspecty
);
5457 ok(!img
->buffer2
, "Test %u: Got unexpected image buffer2 %p.\n", test_idx
, img
->buffer2
);
5459 /* The image is palettized if the total number of colors used is <= 256. */
5460 if (w
* h
> 256 && !palettized
)
5462 /* D3drm aligns the 24bpp texture to 4 bytes in the buffer, with one
5463 * byte padding from 24bpp texture. */
5464 ok(img
->depth
== 32, "Test %u: Got unexpected image depth %u.\n", test_idx
, img
->depth
);
5465 ok(img
->rgb
== TRUE
, "Test %u: Got unexpected image rgb %#x.\n", test_idx
, img
->rgb
);
5466 ok(img
->bytes_per_line
== w
* 4, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5467 test_idx
, img
->bytes_per_line
, w
* 4);
5468 ok(img
->red_mask
== 0xff0000, "Test %u: Got unexpected image red mask %#x.\n", test_idx
, img
->red_mask
);
5469 ok(img
->green_mask
== 0x00ff00, "Test %u: Got unexpected image green mask %#x.\n", test_idx
, img
->green_mask
);
5470 ok(img
->blue_mask
== 0x0000ff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx
, img
->blue_mask
);
5471 ok(!img
->alpha_mask
, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx
, img
->alpha_mask
);
5472 ok(!img
->palette_size
, "Test %u: Got unexpected palette size %u.\n", test_idx
, img
->palette_size
);
5473 ok(!img
->palette
, "Test %u: Got unexpected image palette %p.\n", test_idx
, img
->palette
);
5474 for (i
= 0; i
< h
; ++i
)
5476 for (j
= 0; j
< w
; ++j
)
5478 const unsigned char *ptr
= &data
[i
* img
->bytes_per_line
+ j
* 4];
5479 unsigned int idx
= upside_down
? (h
- 1 - i
) * w
+ j
: i
* w
+ j
;
5481 if (ptr
[0] != idx
% 251 || ptr
[1] != idx
% 239 || ptr
[2] != idx
% 247 || ptr
[3] != 0xff)
5483 ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
5484 "expected 0x%02x%02x%02x%02x.\n", test_idx
, ptr
[0], ptr
[1], ptr
[2], ptr
[3],
5485 j
, i
, idx
% 251, idx
% 239, idx
% 247, 0xff);
5493 ok(img
->depth
== 8, "Test %u: Got unexpected image depth %u.\n", test_idx
, img
->depth
);
5494 ok(!img
->rgb
, "Test %u: Got unexpected image rgb %#x.\n", test_idx
, img
->rgb
);
5495 ok(img
->red_mask
== 0xff, "Test %u: Got unexpected image red mask %#x.\n", test_idx
, img
->red_mask
);
5496 ok(img
->green_mask
== 0xff, "Test %u: Got unexpected image green mask %#x.\n", test_idx
, img
->green_mask
);
5497 ok(img
->blue_mask
== 0xff, "Test %u: Got unexpected image blue mask %#x.\n", test_idx
, img
->blue_mask
);
5498 ok(!img
->alpha_mask
, "Test %u: Got unexpected image alpha mask %#x.\n", test_idx
, img
->alpha_mask
);
5499 ok(!!img
->palette
, "Test %u: Got unexpected image palette %p.\n", test_idx
, img
->palette
);
5502 /* In this case, bytes_per_line is aligned to the next multiple of
5504 ok(img
->bytes_per_line
== ((w
+ 3) & ~3), "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5505 test_idx
, img
->bytes_per_line
, (w
+ 3) & ~3);
5506 ok(img
->palette_size
== w
* h
, "Test %u: Got unexpected palette size %u, expected %u.\n",
5507 test_idx
, img
->palette_size
, w
* h
);
5508 for (i
= 0; i
< img
->palette_size
; ++i
)
5510 unsigned int idx
= upside_down
? (h
- 1) * w
- i
+ (i
% w
) * 2 : i
;
5511 ok(img
->palette
[i
].red
== idx
% 251
5512 && img
->palette
[i
].green
== idx
% 239 && img
->palette
[i
].blue
== idx
% 247,
5513 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
5514 test_idx
, i
, img
->palette
[i
].red
, img
->palette
[i
].green
, img
->palette
[i
].blue
);
5515 ok(img
->palette
[i
].flags
== D3DRMPALETTE_READONLY
,
5516 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
5517 test_idx
, i
, img
->palette
[i
].flags
);
5519 for (i
= 0; i
< h
; ++i
)
5521 for (j
= 0; j
< w
; ++j
)
5523 if (data
[i
* img
->bytes_per_line
+ j
] != i
* w
+ j
)
5525 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
5526 test_idx
, data
[i
* img
->bytes_per_line
+ j
], j
, i
, i
* w
+ j
);
5534 /* bytes_per_line is not always aligned by d3drm depending on the
5536 ok(img
->bytes_per_line
== w
, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
5537 test_idx
, img
->bytes_per_line
, w
);
5538 ok(img
->palette_size
== 256, "Test %u: Got unexpected palette size %u.\n", test_idx
, img
->palette_size
);
5539 for (i
= 0; i
< 256; ++i
)
5541 ok(img
->palette
[i
].red
== i
&& img
->palette
[i
].green
== i
&& img
->palette
[i
].blue
== i
,
5542 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
5543 test_idx
, i
, img
->palette
[i
].red
, img
->palette
[i
].green
, img
->palette
[i
].blue
);
5544 ok(img
->palette
[i
].flags
== D3DRMPALETTE_READONLY
,
5545 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
5546 test_idx
, i
, img
->palette
[i
].flags
);
5548 for (i
= 0; i
< h
; ++i
)
5550 for (j
= 0; j
< w
; ++j
)
5552 unsigned int idx
= upside_down
? (h
- 1 - i
) * w
+ j
: i
* w
+ j
;
5553 if (data
[i
* img
->bytes_per_line
+ j
] != idx
% 256)
5555 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
5556 test_idx
, data
[i
* img
->bytes_per_line
+ j
], j
, i
, idx
% 256);
5563 static void test_load_texture(void)
5565 IDirect3DRMTexture3
*texture3
;
5566 IDirect3DRMTexture2
*texture2
;
5567 IDirect3DRMTexture
*texture1
;
5568 D3DRMIMAGE
*d3drm_img
;
5569 IDirect3DRM3
*d3drm3
;
5570 IDirect3DRM2
*d3drm2
;
5571 IDirect3DRM
*d3drm1
;
5593 hr
= Direct3DRMCreate(&d3drm1
);
5594 ok(hr
== D3DRM_OK
, "Failed to create IDirect3DRM object, hr %#x.\n", hr
);
5595 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5596 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM2 interface, hr %#x.\n", hr
);
5597 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5598 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM3 interface, hr %#x.\n", hr
);
5599 ref1
= get_refcount((IUnknown
*)d3drm1
);
5601 /* Test all failures together. */
5602 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
5603 hr
= IDirect3DRM_LoadTexture(d3drm1
, NULL
, &texture1
);
5604 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#x.\n", hr
);
5605 ok(!texture1
, "Got unexpected texture %p.\n", texture1
);
5606 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
5607 hr
= IDirect3DRM_LoadTexture(d3drm1
, "", &texture1
);
5608 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#x.\n", hr
);
5609 ok(!texture1
, "Got unexpected texture %p.\n", texture1
);
5610 hr
= IDirect3DRM_LoadTexture(d3drm1
, NULL
, NULL
);
5611 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#x.\n", hr
);
5613 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
5614 hr
= IDirect3DRM2_LoadTexture(d3drm2
, NULL
, &texture2
);
5615 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#x.\n", hr
);
5616 ok(!texture2
, "Got unexpected texture %p.\n", texture2
);
5617 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
5618 hr
= IDirect3DRM2_LoadTexture(d3drm2
, "", &texture2
);
5619 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#x.\n", hr
);
5620 ok(!texture2
, "Got unexpected texture %p.\n", texture2
);
5621 hr
= IDirect3DRM2_LoadTexture(d3drm2
, NULL
, NULL
);
5622 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#x.\n", hr
);
5624 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
5625 hr
= IDirect3DRM3_LoadTexture(d3drm3
, NULL
, &texture3
);
5626 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#x.\n", hr
);
5627 ok(!texture3
, "Got unexpected texture %p.\n", texture3
);
5628 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
5629 hr
= IDirect3DRM_LoadTexture(d3drm3
, "", &texture3
);
5630 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#x.\n", hr
);
5631 ok(!texture3
, "Got unexpected texture %p.\n", texture3
);
5632 hr
= IDirect3DRM3_LoadTexture(d3drm3
, NULL
, NULL
);
5633 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#x.\n", hr
);
5635 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
5637 filename
= create_bitmap(tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5639 hr
= IDirect3DRM_LoadTexture(d3drm1
, filename
, &texture1
);
5640 ok(SUCCEEDED(hr
), "Test %u: Failed to load texture, hr %#x.\n", i
, hr
);
5641 ref2
= get_refcount((IUnknown
*)d3drm1
);
5642 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 %u, ref2 %u.\n", i
, ref1
, ref2
);
5644 hr
= IDirect3DRMTexture_InitFromFile(texture1
, filename
);
5645 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5646 /* InitFromFile() seems to AddRef() IDirect3DRM even if it fails. */
5647 IDirect3DRM_Release(d3drm1
);
5648 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
5649 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5650 test_bitmap_data(i
* 7, d3drm_img
, FALSE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5651 IDirect3DRMTexture_Release(texture1
);
5652 ref2
= get_refcount((IUnknown
*)d3drm1
);
5653 ok(ref1
== ref2
, "Test %u: expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
5654 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMTexture
,
5655 NULL
, &IID_IDirect3DRMTexture
, (void **)&texture1
);
5656 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
5657 hr
= IDirect3DRMTexture_InitFromFile(texture1
, NULL
);
5658 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5659 hr
= IDirect3DRMTexture_InitFromFile(texture1
, "");
5660 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5661 hr
= IDirect3DRMTexture_InitFromFile(texture1
, filename
);
5662 ok(SUCCEEDED(hr
), "Test %u: Failed to initialise texture from file, hr %#x.\n", i
, hr
);
5663 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
5664 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5665 test_bitmap_data(i
* 7 + 1, d3drm_img
, FALSE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5666 IDirect3DRMTexture_Release(texture1
);
5668 hr
= IDirect3DRM2_LoadTexture(d3drm2
, filename
, &texture2
);
5669 ok(SUCCEEDED(hr
), "Test %u: Failed to load texture, hr %#x.\n", i
, hr
);
5670 ref2
= get_refcount((IUnknown
*)d3drm1
);
5671 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 %u, ref2 %u.\n", i
, ref1
, ref2
);
5673 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, filename
);
5674 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5675 IDirect3DRM_Release(d3drm1
);
5676 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
5677 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5678 test_bitmap_data(i
* 7 + 2, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5679 IDirect3DRMTexture2_Release(texture2
);
5680 ref2
= get_refcount((IUnknown
*)d3drm1
);
5681 ok(ref1
== ref2
, "Test %u: expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
5682 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
,
5683 NULL
, &IID_IDirect3DRMTexture2
, (void **)&texture2
);
5684 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
5685 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, NULL
);
5686 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5687 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, "");
5688 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5689 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, filename
);
5690 ok(SUCCEEDED(hr
), "Test %u: Failed to initialise texture from file, hr %#x.\n", i
, hr
);
5691 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
5692 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5693 test_bitmap_data(i
* 7 + 3, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5694 IDirect3DRMTexture2_Release(texture2
);
5696 hr
= IDirect3DRM3_LoadTexture(d3drm3
, filename
, &texture3
);
5697 ok(SUCCEEDED(hr
), "Test %u: Failed to load texture, hr %#x.\n", i
, hr
);
5698 ref2
= get_refcount((IUnknown
*)d3drm1
);
5699 ok(ref2
> ref1
, "Test %u: expected ref2 > ref1, got ref1 %u, ref2 %u.\n", i
, ref1
, ref2
);
5701 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, filename
);
5702 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5703 IDirect3DRM_Release(d3drm1
);
5704 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
5705 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5706 test_bitmap_data(i
* 7 + 4, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5707 /* Test whether querying a version 1 texture from version 3 causes a
5708 * change in the loading behavior. */
5709 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture
, (void **)&texture1
);
5710 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMTexture interface, hr %#x.\n", hr
);
5711 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
5712 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5713 test_bitmap_data(i
* 7 + 5, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5714 IDirect3DRMTexture_Release(texture1
);
5715 IDirect3DRMTexture3_Release(texture3
);
5716 ref2
= get_refcount((IUnknown
*)d3drm1
);
5717 ok(ref1
== ref2
, "Test %u: expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", i
, ref1
, ref2
);
5719 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
,
5720 NULL
, &IID_IDirect3DRMTexture3
, (void **)&texture3
);
5721 ok(SUCCEEDED(hr
), "Test %u: Failed to create texture, hr %#x.\n", i
, hr
);
5722 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, NULL
);
5723 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5724 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, "");
5725 ok(hr
== D3DRMERR_BADOBJECT
, "Test %u: Got unexpected hr %#x.\n", i
, hr
);
5726 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, filename
);
5727 ok(SUCCEEDED(hr
), "Test %u: Failed to initialize texture from file, hr %#x.\n", i
, hr
);
5728 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
5729 ok(!!d3drm_img
, "Test %u: Failed to get image.\n", i
);
5730 test_bitmap_data(i
* 7 + 6, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
5731 IDirect3DRMTexture3_Release(texture3
);
5733 ret
= DeleteFileA(filename
);
5734 ok(ret
, "Test %u: Failed to delete bitmap \"%s\".\n", i
, filename
);
5735 HeapFree(GetProcessHeap(), 0, filename
);
5738 IDirect3DRM3_Release(d3drm3
);
5739 IDirect3DRM2_Release(d3drm2
);
5740 IDirect3DRM_Release(d3drm1
);
5743 static void test_texture_qi(void)
5745 static const struct qi_test tests
[] =
5747 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5748 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5749 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5750 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5751 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5752 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5753 { &IID_IDirect3DRMWinDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5754 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
5755 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5756 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5757 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5758 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5759 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5760 { &IID_IDirect3DRMVisual
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
5761 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5762 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5763 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5764 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5765 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5766 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5767 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5768 { &IID_IDirect3DRMTexture
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
5769 { &IID_IDirect3DRMTexture2
, &IID_IUnknown
, &IID_IDirect3DRMTexture2
, S_OK
},
5770 { &IID_IDirect3DRMTexture3
, &IID_IUnknown
, &IID_IDirect3DRMTexture3
, S_OK
},
5771 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5772 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5773 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5774 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5775 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5776 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5777 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5778 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5779 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5780 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5781 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5782 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5783 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5784 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5785 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5786 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5787 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5788 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5789 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5790 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5791 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5792 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5793 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5794 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5795 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5796 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5797 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5798 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5799 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5800 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5801 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5802 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5803 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5804 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5805 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5806 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5807 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5808 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5809 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5810 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5811 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5812 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5813 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5814 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
5817 IDirect3DRM
*d3drm1
;
5818 IDirect3DRM2
*d3drm2
;
5819 IDirect3DRM3
*d3drm3
;
5820 IDirect3DRMTexture
*texture1
;
5821 IDirect3DRMTexture2
*texture2
;
5822 IDirect3DRMTexture3
*texture3
;
5827 hr
= Direct3DRMCreate(&d3drm1
);
5828 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x)\n", hr
);
5829 filename
= create_bitmap(1, 1, TRUE
);
5830 hr
= IDirect3DRM_LoadTexture(d3drm1
, filename
, &texture1
);
5831 ok(SUCCEEDED(hr
), "Failed to load texture (hr = %#x).\n", hr
);
5832 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr
);
5833 hr
= IDirect3DRMTexture_QueryInterface(texture1
, &IID_IUnknown
, (void **)&unknown
);
5834 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture (hr = %#x)\n", hr
);
5835 IDirect3DRMTexture_Release(texture1
);
5836 test_qi("texture1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
5837 IUnknown_Release(unknown
);
5839 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5840 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
5841 hr
= IDirect3DRM2_LoadTexture(d3drm2
, filename
, &texture2
);
5842 ok(SUCCEEDED(hr
), "Failed to load texture (hr = %#x).\n", hr
);
5843 hr
= IDirect3DRMTexture2_QueryInterface(texture2
, &IID_IUnknown
, (void **)&unknown
);
5844 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture2 (hr = %#x)\n", hr
);
5845 IDirect3DRMTexture2_Release(texture2
);
5846 test_qi("texture2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
5847 IUnknown_Release(unknown
);
5849 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5850 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
5851 hr
= IDirect3DRM3_LoadTexture(d3drm3
, filename
, &texture3
);
5852 ok(SUCCEEDED(hr
), "Failed to load texture (hr = %#x).\n", hr
);
5853 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
5854 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IUnknown
, (void **)&unknown
);
5855 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture3 (hr = %#x)\n", hr
);
5856 IDirect3DRMTexture3_Release(texture3
);
5857 test_qi("texture3_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
5858 IUnknown_Release(unknown
);
5860 IDirect3DRM3_Release(d3drm3
);
5861 IDirect3DRM2_Release(d3drm2
);
5862 IDirect3DRM_Release(d3drm1
);
5863 check
= DeleteFileA(filename
);
5864 ok(check
, "Cannot delete image stored in %s (error = %d).\n", filename
, GetLastError());
5865 HeapFree(GetProcessHeap(), 0, filename
);
5868 static void test_viewport_qi(void)
5870 IDirect3DRM
*d3drm1
;
5871 IDirect3DRM2
*d3drm2
;
5872 IDirect3DRM3
*d3drm3
;
5873 IDirect3DRMFrame
*frame1
, *camera1
;
5874 IDirect3DRMFrame3
*frame3
, *camera3
;
5875 IDirect3DRMDevice
*device1
;
5876 IDirect3DRMDevice3
*device3
;
5877 IDirectDrawClipper
*clipper
;
5878 IDirect3DRMViewport
*viewport1
;
5879 IDirect3DRMViewport2
*viewport2
;
5881 GUID driver
= IID_IDirect3DRGBDevice
;
5884 static const struct qi_test tests
[] =
5886 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5887 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5888 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5889 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5890 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5891 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5892 { &IID_IDirect3DRMWinDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5893 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMViewport
, S_OK
},
5894 { &IID_IDirect3DRMViewport
, &IID_IUnknown
, &IID_IDirect3DRMViewport
, S_OK
},
5895 { &IID_IDirect3DRMViewport2
, &IID_IUnknown
, &IID_IDirect3DRMViewport2
, S_OK
},
5896 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5897 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5898 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5899 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5900 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5901 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5902 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5903 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5904 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5905 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5906 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5907 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5908 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5909 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5910 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5911 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5912 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5913 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5914 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5915 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5916 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5917 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5918 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5919 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5920 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5921 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5922 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5923 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5924 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5925 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5926 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5927 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5928 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5929 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5930 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5931 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5932 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5933 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5934 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5935 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5936 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5937 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5938 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5939 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5940 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5941 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5942 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5943 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5944 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5945 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5946 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5947 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5948 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5949 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5950 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5951 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5952 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
5953 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
5956 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
5957 ok(SUCCEEDED(hr
), "Cannot get IDirectDrawClipper interface (hr = %#x).\n", hr
);
5959 hr
= Direct3DRMCreate(&d3drm1
);
5960 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
5962 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 640, 480, &device1
);
5963 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr
);
5964 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
5965 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
5966 hr
= IDirect3DRM_CreateFrame(d3drm1
, frame1
, &camera1
);
5967 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
5968 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, camera1
, 0, 0, 640, 480, &viewport1
);
5969 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
5970 hr
= IDirect3DRMViewport_QueryInterface(viewport1
, &IID_IUnknown
, (void **)&unknown
);
5971 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface (hr = %#x).\n", hr
);
5972 IDirect3DRMViewport_Release(viewport1
);
5973 test_qi("viewport1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
5974 IUnknown_Release(unknown
);
5976 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5977 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr
);
5978 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, camera1
, 0, 0, 640, 480, &viewport1
);
5979 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr
);
5980 hr
= IDirect3DRMViewport_QueryInterface(viewport1
, &IID_IUnknown
, (void **)&unknown
);
5981 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface (hr = %#x).\n", hr
);
5982 IDirect3DRMViewport_Release(viewport1
);
5983 test_qi("viewport1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
5984 IUnknown_Release(unknown
);
5985 IDirect3DRMDevice_Release(device1
);
5986 IDirect3DRMFrame_Release(camera1
);
5987 IDirect3DRMFrame_Release(frame1
);
5989 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5990 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
5991 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 640, 480, &device3
);
5992 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface (hr = %#x).\n", hr
);
5993 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
5994 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
5995 hr
= IDirect3DRM3_CreateFrame(d3drm3
, frame3
, &camera3
);
5996 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
5997 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, 640, 480, &viewport2
);
5998 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
5999 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IUnknown
, (void **)&unknown
);
6000 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface (hr = %#x).\n", hr
);
6001 IDirect3DRMViewport_Release(viewport2
);
6002 test_qi("viewport2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6003 IUnknown_Release(unknown
);
6004 IDirect3DRMDevice3_Release(device3
);
6005 IDirect3DRMFrame3_Release(camera3
);
6006 IDirect3DRMFrame3_Release(frame3
);
6008 IDirectDrawClipper_Release(clipper
);
6009 IDirect3DRM3_Release(d3drm3
);
6010 IDirect3DRM2_Release(d3drm2
);
6011 IDirect3DRM_Release(d3drm1
);
6014 static D3DCOLOR
get_surface_color(IDirectDrawSurface
*surface
, UINT x
, UINT y
)
6016 RECT rect
= { x
, y
, x
+ 1, y
+ 1 };
6017 DDSURFACEDESC surface_desc
;
6021 memset(&surface_desc
, 0, sizeof(surface_desc
));
6022 surface_desc
.dwSize
= sizeof(surface_desc
);
6024 hr
= IDirectDrawSurface_Lock(surface
, &rect
, &surface_desc
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
6025 ok(SUCCEEDED(hr
), "Failed to lock surface, hr %#x.\n", hr
);
6029 color
= *((DWORD
*)surface_desc
.lpSurface
) & 0x00ffffff;
6031 hr
= IDirectDrawSurface_Unlock(surface
, NULL
);
6032 ok(SUCCEEDED(hr
), "Failed to unlock surface, hr %#x.\n", hr
);
6037 static IDirect3DDevice2
*create_device2_without_ds(IDirectDraw2
*ddraw
, HWND window
)
6039 IDirectDrawSurface
*surface
;
6040 IDirect3DDevice2
*device
= NULL
;
6041 DDSURFACEDESC surface_desc
;
6046 GetClientRect(window
, &rc
);
6047 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
6048 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
6050 memset(&surface_desc
, 0, sizeof(surface_desc
));
6051 surface_desc
.dwSize
= sizeof(surface_desc
);
6052 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
6053 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
6054 surface_desc
.dwWidth
= rc
.right
;
6055 surface_desc
.dwHeight
= rc
.bottom
;
6057 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
6058 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
6060 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
6063 IDirectDrawSurface_Release(surface
);
6067 IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
);
6069 IDirect3D2_Release(d3d
);
6070 IDirectDrawSurface_Release(surface
);
6074 static BOOL
compare_color(D3DCOLOR c1
, D3DCOLOR c2
, BYTE max_diff
)
6076 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
6078 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
6080 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
6082 if ((c1
& 0xff) - (c2
& 0xff) > max_diff
) return FALSE
;
6086 static void clear_depth_surface(IDirectDrawSurface
*surface
, DWORD value
)
6091 memset(&fx
, 0, sizeof(fx
));
6092 fx
.dwSize
= sizeof(fx
);
6093 U5(fx
).dwFillDepth
= value
;
6095 hr
= IDirectDrawSurface_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_DEPTHFILL
| DDBLT_WAIT
, &fx
);
6096 ok(SUCCEEDED(hr
), "Got unexpected hr %#x.\n", hr
);
6099 static void set_execute_data(IDirect3DExecuteBuffer
*execute_buffer
, UINT vertex_count
, UINT offset
, UINT len
)
6101 D3DEXECUTEDATA exec_data
;
6104 memset(&exec_data
, 0, sizeof(exec_data
));
6105 exec_data
.dwSize
= sizeof(exec_data
);
6106 exec_data
.dwVertexCount
= vertex_count
;
6107 exec_data
.dwInstructionOffset
= offset
;
6108 exec_data
.dwInstructionLength
= len
;
6109 hr
= IDirect3DExecuteBuffer_SetExecuteData(execute_buffer
, &exec_data
);
6110 ok(SUCCEEDED(hr
), "Failed to set execute data, hr %#x.\n", hr
);
6113 static void emit_set_ts(void **ptr
, D3DTRANSFORMSTATETYPE state
, DWORD value
)
6115 D3DINSTRUCTION
*inst
= *ptr
;
6116 D3DSTATE
*ts
= (D3DSTATE
*)(inst
+ 1);
6118 inst
->bOpcode
= D3DOP_STATETRANSFORM
;
6119 inst
->bSize
= sizeof(*ts
);
6122 U1(*ts
).dtstTransformStateType
= state
;
6123 U2(*ts
).dwArg
[0] = value
;
6128 static void emit_set_rs(void **ptr
, D3DRENDERSTATETYPE state
, DWORD value
)
6130 D3DINSTRUCTION
*inst
= *ptr
;
6131 D3DSTATE
*rs
= (D3DSTATE
*)(inst
+ 1);
6133 inst
->bOpcode
= D3DOP_STATERENDER
;
6134 inst
->bSize
= sizeof(*rs
);
6137 U1(*rs
).drstRenderStateType
= state
;
6138 U2(*rs
).dwArg
[0] = value
;
6143 static void emit_process_vertices(void **ptr
, DWORD flags
, WORD base_idx
, DWORD vertex_count
)
6145 D3DINSTRUCTION
*inst
= *ptr
;
6146 D3DPROCESSVERTICES
*pv
= (D3DPROCESSVERTICES
*)(inst
+ 1);
6148 inst
->bOpcode
= D3DOP_PROCESSVERTICES
;
6149 inst
->bSize
= sizeof(*pv
);
6152 pv
->dwFlags
= flags
;
6153 pv
->wStart
= base_idx
;
6155 pv
->dwCount
= vertex_count
;
6161 static void emit_tquad(void **ptr
, WORD base_idx
)
6163 D3DINSTRUCTION
*inst
= *ptr
;
6164 D3DTRIANGLE
*tri
= (D3DTRIANGLE
*)(inst
+ 1);
6166 inst
->bOpcode
= D3DOP_TRIANGLE
;
6167 inst
->bSize
= sizeof(*tri
);
6170 U1(*tri
).v1
= base_idx
;
6171 U2(*tri
).v2
= base_idx
+ 1;
6172 U3(*tri
).v3
= base_idx
+ 2;
6173 tri
->wFlags
= D3DTRIFLAG_START
;
6176 U1(*tri
).v1
= base_idx
+ 2;
6177 U2(*tri
).v2
= base_idx
+ 1;
6178 U3(*tri
).v3
= base_idx
+ 3;
6179 tri
->wFlags
= D3DTRIFLAG_ODD
;
6185 static void emit_end(void **ptr
)
6187 D3DINSTRUCTION
*inst
= *ptr
;
6189 inst
->bOpcode
= D3DOP_EXIT
;
6196 static void d3d_draw_quad1(IDirect3DDevice
*device
, IDirect3DViewport
*viewport
)
6198 IDirect3DExecuteBuffer
*execute_buffer
;
6199 D3DEXECUTEBUFFERDESC exec_desc
;
6203 D3DMATRIXHANDLE world_handle
, view_handle
, proj_handle
;
6204 static D3DMATRIX mat
=
6206 1.0f
, 0.0f
, 0.0f
, 0.0f
,
6207 0.0f
, 1.0f
, 0.0f
, 0.0f
,
6208 0.0f
, 0.0f
, 1.0f
, 0.0f
,
6209 0.0f
, 0.0f
, 0.0f
, 1.0f
,
6211 static const D3DLVERTEX quad_strip
[] =
6213 {{-1.0f
}, {-1.0f
}, {0.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
6214 {{-1.0f
}, { 1.0f
}, {0.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
6215 {{ 1.0f
}, {-1.0f
}, {1.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
6216 {{ 1.0f
}, { 1.0f
}, {1.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
6219 hr
= IDirect3DDevice_CreateMatrix(device
, &world_handle
);
6220 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#x.\n", hr
);
6221 hr
= IDirect3DDevice_SetMatrix(device
, world_handle
, &mat
);
6222 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#x.\n", hr
);
6223 hr
= IDirect3DDevice_CreateMatrix(device
, &view_handle
);
6224 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#x.\n", hr
);
6225 hr
= IDirect3DDevice_SetMatrix(device
, view_handle
, &mat
);
6226 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#x.\n", hr
);
6227 hr
= IDirect3DDevice_CreateMatrix(device
, &proj_handle
);
6228 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#x.\n", hr
);
6229 hr
= IDirect3DDevice_SetMatrix(device
, proj_handle
, &mat
);
6230 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#x.\n", hr
);
6232 memset(&exec_desc
, 0, sizeof(exec_desc
));
6233 exec_desc
.dwSize
= sizeof(exec_desc
);
6234 exec_desc
.dwFlags
= D3DDEB_BUFSIZE
| D3DDEB_CAPS
;
6235 exec_desc
.dwBufferSize
= 1024;
6236 exec_desc
.dwCaps
= D3DDEBCAPS_SYSTEMMEMORY
;
6238 hr
= IDirect3DDevice_CreateExecuteBuffer(device
, &exec_desc
, &execute_buffer
, NULL
);
6239 ok(SUCCEEDED(hr
), "Failed to create execute buffer, hr %#x.\n", hr
);
6241 hr
= IDirect3DExecuteBuffer_Lock(execute_buffer
, &exec_desc
);
6242 ok(SUCCEEDED(hr
), "Failed to lock execute buffer, hr %#x.\n", hr
);
6244 memcpy(exec_desc
.lpData
, quad_strip
, sizeof(quad_strip
));
6245 ptr
= ((BYTE
*)exec_desc
.lpData
) + sizeof(quad_strip
);
6246 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_WORLD
, world_handle
);
6247 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_VIEW
, view_handle
);
6248 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_PROJECTION
, proj_handle
);
6249 emit_set_rs(&ptr
, D3DRENDERSTATE_CLIPPING
, FALSE
);
6250 emit_set_rs(&ptr
, D3DRENDERSTATE_ZENABLE
, TRUE
);
6251 emit_set_rs(&ptr
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
6252 emit_set_rs(&ptr
, D3DRENDERSTATE_CULLMODE
, D3DCULL_NONE
);
6253 emit_set_rs(&ptr
, D3DRENDERSTATE_SHADEMODE
, D3DSHADE_FLAT
);
6255 emit_process_vertices(&ptr
, D3DPROCESSVERTICES_TRANSFORM
, 0, 4);
6256 emit_tquad(&ptr
, 0);
6259 inst_length
= (BYTE
*)ptr
- (BYTE
*)exec_desc
.lpData
;
6260 inst_length
-= sizeof(quad_strip
);
6262 hr
= IDirect3DExecuteBuffer_Unlock(execute_buffer
);
6263 ok(SUCCEEDED(hr
), "Failed to unlock execute buffer, hr %#x.\n", hr
);
6265 hr
= IDirect3DDevice_BeginScene(device
);
6266 set_execute_data(execute_buffer
, 4, sizeof(quad_strip
), inst_length
);
6267 hr
= IDirect3DDevice_Execute(device
, execute_buffer
, viewport
, D3DEXECUTE_CLIPPED
);
6268 ok(SUCCEEDED(hr
), "Failed to execute exec buffer, hr %#x.\n", hr
);
6269 hr
= IDirect3DDevice_EndScene(device
);
6270 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
6272 IDirect3DExecuteBuffer_Release(execute_buffer
);
6275 static void test_viewport_clear1(void)
6277 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
6279 IDirectDrawClipper
*clipper
;
6280 IDirect3DRM
*d3drm1
;
6281 IDirect3DRMFrame
*frame1
, *camera1
;
6282 IDirect3DRMDevice
*device1
;
6283 IDirect3DViewport
*d3d_viewport
;
6284 IDirect3DRMViewport
*viewport1
;
6285 IDirect3DDevice
*d3d_device1
;
6286 IDirectDrawSurface
*surface
, *ds
, *d3drm_ds
;
6288 GUID driver
= IID_IDirect3DRGBDevice
;
6293 window
= create_window();
6294 GetClientRect(window
, &rc
);
6296 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
6297 ok(SUCCEEDED(hr
), "Cannot create IDirectDraw interface (hr = %#x).\n", hr
);
6299 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
6300 ok(SUCCEEDED(hr
), "Failed to set cooperative level (hr = %#x).\n", hr
);
6302 hr
= IDirectDraw_CreateClipper(ddraw
, 0, &clipper
, NULL
);
6303 ok(SUCCEEDED(hr
), "Cannot create clipper (hr = %#x).\n", hr
);
6305 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
6306 ok(SUCCEEDED(hr
), "Cannot set HWnd to Clipper (hr = %#x)\n", hr
);
6308 hr
= Direct3DRMCreate(&d3drm1
);
6309 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
6311 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
6312 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface (hr = %#x)\n", hr
);
6314 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
6315 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
6316 hr
= IDirect3DRM_CreateFrame(d3drm1
, frame1
, &camera1
);
6317 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr
);
6319 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, camera1
, 0, 0, rc
.right
,
6320 rc
.bottom
, &viewport1
);
6321 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
6323 /* Fetch immediate mode device and viewport */
6324 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3d_device1
);
6325 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice interface (hr = %#x).\n", hr
);
6326 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport1
, &d3d_viewport
);
6327 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
6329 hr
= IDirect3DDevice_QueryInterface(d3d_device1
, &IID_IDirectDrawSurface
, (void **)&surface
);
6330 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
6332 ret_color
= get_surface_color(surface
, 320, 240);
6333 ok(compare_color(ret_color
, 0, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6335 /* Clear uses the scene frame's background color. */
6336 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 1.0f
, 1.0f
, 1.0f
);
6337 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6338 ret_color
= IDirect3DRMFrame_GetSceneBackground(frame1
);
6339 ok(ret_color
== 0xffffffff, "Expected scene color returned == 0xffffffff, got %#x.\n", ret_color
);
6340 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(camera1
, 0.0f
, 1.0f
, 0.0f
);
6341 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6342 ret_color
= IDirect3DRMFrame_GetSceneBackground(camera1
);
6343 ok(ret_color
== 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color
);
6345 hr
= IDirect3DRMViewport_Clear(viewport1
);
6346 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6347 ret_color
= get_surface_color(surface
, 320, 240);
6348 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6350 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 0.0f
, 0.0f
, 1.0f
);
6351 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6352 ret_color
= IDirect3DRMFrame_GetSceneBackground(frame1
);
6353 ok(ret_color
== 0xff0000ff, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color
);
6355 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
6356 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6357 hr
= IDirect3DRMViewport_Clear(viewport1
);
6358 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6359 ret_color
= get_surface_color(surface
, 100, 200);
6360 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6362 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
6364 ret_color
= get_surface_color(surface
, 100, 200);
6365 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6367 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
6368 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
6370 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
6371 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6372 hr
= IDirect3DRMViewport_Clear(viewport1
);
6373 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6374 ret_color
= get_surface_color(surface
, 100, 200);
6375 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6377 /* Fill the depth surface with a value lower than the quad's depth value. */
6378 clear_depth_surface(ds
, 0x7fff);
6380 /* Depth test passes here */
6381 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
6382 ret_color
= get_surface_color(surface
, 100, 200);
6383 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6384 /* Depth test fails here */
6385 ret_color
= get_surface_color(surface
, 500, 400);
6386 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6388 /* Check what happens if we release the depth surface that d3drm created, and clear the viewport */
6389 hr
= IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, ds
);
6390 ok(SUCCEEDED(hr
), "Cannot delete attached surface (hr = %#x).\n", hr
);
6391 d3drm_ds
= (IDirectDrawSurface
*)0xdeadbeef;
6392 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
6393 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#x.\n", hr
);
6394 ok(d3drm_ds
== NULL
, "Expected NULL z-surface, got %p.\n", d3drm_ds
);
6396 clear_depth_surface(ds
, 0x7fff);
6397 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
6398 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6399 hr
= IDirect3DRMViewport_Clear(viewport1
);
6400 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6402 ret_color
= get_surface_color(surface
, 100, 200);
6403 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6405 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
6406 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
6407 IDirectDrawSurface_Release(ds
);
6409 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
6411 ret_color
= get_surface_color(surface
, 100, 200);
6412 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6413 ret_color
= get_surface_color(surface
, 500, 400);
6414 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6416 IDirect3DViewport_Release(d3d_viewport
);
6417 IDirectDrawSurface_Release(surface
);
6418 IDirect3DDevice_Release(d3d_device1
);
6419 IDirect3DRMViewport_Release(viewport1
);
6420 IDirect3DRMFrame_Release(frame1
);
6421 IDirect3DRMFrame_Release(camera1
);
6422 IDirect3DRMDevice_Release(device1
);
6423 IDirect3DRM_Release(d3drm1
);
6424 IDirectDrawClipper_Release(clipper
);
6425 IDirectDraw_Release(ddraw
);
6426 DestroyWindow(window
);
6429 static void draw_quad2(IDirect3DDevice2
*device
, IDirect3DViewport
*viewport
)
6431 static D3DLVERTEX tquad
[] =
6433 {{-1.0f
}, {-1.0f
}, {0.0f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
6434 {{-1.0f
}, { 1.0f
}, {0.0f
}, 0, {0xffbada55}, {0}, {0.0f
}, {1.0f
}},
6435 {{ 1.0f
}, {-1.0f
}, {1.0f
}, 0, {0xffbada55}, {0}, {1.0f
}, {0.0f
}},
6436 {{ 1.0f
}, { 1.0f
}, {1.0f
}, 0, {0xffbada55}, {0}, {1.0f
}, {1.0f
}},
6438 static D3DMATRIX mat
=
6440 1.0f
, 0.0f
, 0.0f
, 0.0f
,
6441 0.0f
, 1.0f
, 0.0f
, 0.0f
,
6442 0.0f
, 0.0f
, 1.0f
, 0.0f
,
6443 0.0f
, 0.0f
, 0.0f
, 1.0f
,
6445 IDirect3DViewport2
*viewport2
;
6448 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, &mat
);
6449 ok(SUCCEEDED(hr
), "Failed to set world transform, hr %#x.\n", hr
);
6450 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_VIEW
, &mat
);
6451 ok(SUCCEEDED(hr
), "Failed to set view transform, hr %#x.\n", hr
);
6452 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_PROJECTION
, &mat
);
6453 ok(SUCCEEDED(hr
), "Failed to set projection transform, hr %#x.\n", hr
);
6455 hr
= IDirect3DViewport_QueryInterface(viewport
, &IID_IDirect3DViewport2
, (void **)&viewport2
);
6456 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport2 interface (hr = %#x).\n", hr
);
6457 hr
= IDirect3DDevice2_SetCurrentViewport(device
, viewport2
);
6458 ok(SUCCEEDED(hr
), "Failed to activate the viewport, hr %#x.\n", hr
);
6459 IDirect3DViewport2_Release(viewport2
);
6461 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, D3DZB_TRUE
);
6462 ok(SUCCEEDED(hr
), "Failed to enable z testing, hr %#x.\n", hr
);
6463 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZFUNC
, D3DCMP_LESSEQUAL
);
6464 ok(SUCCEEDED(hr
), "Failed to set the z function, hr %#x.\n", hr
);
6466 hr
= IDirect3DDevice2_BeginScene(device
);
6467 ok(SUCCEEDED(hr
), "Failed to begin scene, hr %#x.\n", hr
);
6468 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_LVERTEX
, tquad
, 4, 0);
6469 ok(SUCCEEDED(hr
), "Failed to draw, hr %#x.\n", hr
);
6470 hr
= IDirect3DDevice2_EndScene(device
);
6471 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
6474 static void test_viewport_clear2(void)
6476 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
6478 IDirectDraw
*ddraw1
;
6479 IDirectDraw2
*ddraw2
;
6480 IDirectDrawClipper
*clipper
;
6481 IDirect3DRM
*d3drm1
;
6482 IDirect3DRM3
*d3drm3
;
6483 IDirect3DRMFrame3
*frame3
, *camera3
;
6484 IDirect3DRMDevice3
*device3
;
6485 IDirect3DViewport
*d3d_viewport
;
6486 IDirect3DRMViewport2
*viewport2
;
6487 IDirect3DDevice2
*d3d_device2
;
6488 IDirectDrawSurface
*surface
, *ds
, *d3drm_ds
;
6490 GUID driver
= IID_IDirect3DRGBDevice
;
6495 window
= create_window();
6496 GetClientRect(window
, &rc
);
6498 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
6499 ok(SUCCEEDED(hr
), "Cannot create IDirectDraw interface (hr = %#x).\n", hr
);
6501 hr
= IDirectDraw_SetCooperativeLevel(ddraw1
, window
, DDSCL_NORMAL
);
6502 ok(SUCCEEDED(hr
), "Failed to set cooperative level (hr = %#x).\n", hr
);
6504 hr
= IDirectDraw_CreateClipper(ddraw1
, 0, &clipper
, NULL
);
6505 ok(SUCCEEDED(hr
), "Cannot create clipper (hr = %#x).\n", hr
);
6507 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
6508 ok(SUCCEEDED(hr
), "Cannot set HWnd to Clipper (hr = %#x)\n", hr
);
6510 hr
= Direct3DRMCreate(&d3drm1
);
6511 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr
);
6513 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6514 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr
);
6516 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
6517 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice3 interface (hr = %#x)\n", hr
);
6519 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
6520 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
6521 hr
= IDirect3DRM3_CreateFrame(d3drm3
, frame3
, &camera3
);
6522 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr
);
6524 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, rc
.right
,
6525 rc
.bottom
, &viewport2
);
6526 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
6528 /* Fetch immediate mode device in order to access render target and test its color. */
6529 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3d_device2
);
6530 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface (hr = %#x).\n", hr
);
6532 hr
= IDirect3DDevice2_GetRenderTarget(d3d_device2
, &surface
);
6533 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
6535 ret_color
= get_surface_color(surface
, 320, 240);
6536 ok(compare_color(ret_color
, 0, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6538 /* Clear uses the scene frame's background color. */
6539 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 1.0f
, 1.0f
, 1.0f
);
6540 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6541 ret_color
= IDirect3DRMFrame3_GetSceneBackground(frame3
);
6542 ok(ret_color
== 0xffffffff, "Expected scene color returned == 0xffffffff, got %#x.\n", ret_color
);
6543 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(camera3
, 0.0f
, 1.0f
, 0.0f
);
6544 ok(SUCCEEDED(hr
), "Cannot set scene background RGB (hr = %#x)\n", hr
);
6545 ret_color
= IDirect3DRMFrame3_GetSceneBackground(camera3
);
6546 ok(ret_color
== 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color
);
6548 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6549 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6550 ret_color
= get_surface_color(surface
, 320, 240);
6551 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6553 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
6554 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr
);
6556 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6557 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6559 /* d3drm seems to be calling BeginScene when Clear is called. */
6560 hr
= IDirect3DDevice2_BeginScene(d3d_device2
);
6561 todo_wine
ok(hr
== D3DERR_SCENE_IN_SCENE
, "Expected hr == D3DERR_SCENE_IN_SCENE, got %#x.\n", hr
);
6562 hr
= IDirect3DDevice2_EndScene(d3d_device2
);
6563 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#x.\n", hr
);
6565 ret_color
= get_surface_color(surface
, 320, 240);
6566 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6568 /* We're using d3d to draw using IDirect3DDevice2 created from d3drm. */
6569 draw_quad2(d3d_device2
, d3d_viewport
);
6570 ret_color
= get_surface_color(surface
, 320, 240);
6571 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6573 /* Without calling Configure, Clear doesn't work. */
6574 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6575 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6576 ret_color
= get_surface_color(surface
, 320, 240);
6577 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6579 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6580 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6581 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6582 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6584 ret_color
= get_surface_color(surface
, 320, 240);
6585 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6587 /* Fetch attached depth surface and see if viewport clears it if it's detached from the render target. */
6588 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
6589 ok(SUCCEEDED(hr
), "Cannot get attached depth surface (hr = %x).\n", hr
);
6591 clear_depth_surface(ds
, 0x39);
6592 draw_quad2(d3d_device2
, d3d_viewport
);
6594 ret_color
= get_surface_color(surface
, 320, 240);
6595 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6597 hr
= IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, ds
);
6598 ok(SUCCEEDED(hr
), "Cannot delete attached surface (hr = %#x).\n", hr
);
6599 d3drm_ds
= (IDirectDrawSurface
*)0xdeadbeef;
6600 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
6601 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#x.\n", hr
);
6602 ok(d3drm_ds
== NULL
, "Expected NULL z-surface, got %p.\n", d3drm_ds
);
6604 clear_depth_surface(ds
, 0x7fff);
6606 /* This version of Clear still clears the depth surface even if it's deleted from the render target. */
6607 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6608 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6609 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6610 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6612 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
6613 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#x.\n", hr
);
6614 ret_color
= get_surface_color(surface
, 320, 240);
6615 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6617 draw_quad2(d3d_device2
, d3d_viewport
);
6618 ret_color
= get_surface_color(surface
, 100, 200);
6619 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6620 ret_color
= get_surface_color(surface
, 500, 400);
6621 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6623 /* Clear with no flags */
6624 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6625 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6626 hr
= IDirect3DRMViewport2_Clear(viewport2
, 0);
6627 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6628 ret_color
= get_surface_color(surface
, 320, 240);
6629 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6631 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
6632 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport (hr = %#x).\n", hr
);
6633 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6634 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6635 ret_color
= get_surface_color(surface
, 320, 240);
6636 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6638 IDirect3DViewport_Release(d3d_viewport
);
6639 IDirectDrawSurface_Release(surface
);
6640 IDirectDrawSurface_Release(ds
);
6641 IDirect3DDevice2_Release(d3d_device2
);
6642 IDirect3DRMViewport2_Release(viewport2
);
6643 IDirect3DRMDevice3_Release(device3
);
6645 /* Create device without depth surface attached */
6646 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
6647 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface (hr = %#x).\n", hr
);
6648 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
6649 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface (hr = %x).\n", hr
);
6650 d3d_device2
= create_device2_without_ds(ddraw2
, window
);
6654 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3d_device2
, &device3
);
6655 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRMDevice interface (hr = %#x)\n", hr
);
6656 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, rc
.right
,
6657 rc
.bottom
, &viewport2
);
6658 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr
);
6659 hr
= IDirect3DDevice2_GetRenderTarget(d3d_device2
, &surface
);
6660 ok(SUCCEEDED(hr
), "Cannot get surface to the render target (hr = %#x).\n", hr
);
6662 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
6663 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6664 ret_color
= get_surface_color(surface
, 320, 240);
6665 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08x.\n", ret_color
);
6667 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ZBUFFER
);
6668 ok(SUCCEEDED(hr
), "Cannot clear viewport (hr = %#x).\n", hr
);
6670 IDirectDrawSurface_Release(surface
);
6671 IDirect3DRMViewport2_Release(viewport2
);
6672 IDirect3DRMDevice3_Release(device3
);
6673 IDirect3DDevice2_Release(d3d_device2
);
6676 IDirect3DRMFrame3_Release(camera3
);
6677 IDirect3DRMFrame3_Release(frame3
);
6678 IDirect3DRM3_Release(d3drm3
);
6679 IDirect3DRM_Release(d3drm1
);
6680 IDirectDrawClipper_Release(clipper
);
6681 IDirect3D2_Release(d3d2
);
6682 IDirectDraw2_Release(ddraw2
);
6683 IDirectDraw_Release(ddraw1
);
6684 DestroyWindow(window
);
6687 static void test_create_texture_from_surface(void)
6689 D3DRMIMAGE testimg
=
6692 TRUE
, 0, (void *)0xcafebabe, NULL
,
6693 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
6695 IDirectDrawSurface
*surface
= NULL
, *surface2
= NULL
, *ds
= NULL
;
6696 IDirect3DRMTexture
*texture1
;
6697 IDirect3DRMTexture2
*texture2
;
6698 IDirect3DRMTexture3
*texture3
;
6699 IDirectDraw
*ddraw
= NULL
;
6700 IDirect3DRM
*d3drm1
= NULL
;
6701 IDirect3DRM2
*d3drm2
= NULL
;
6702 IDirect3DRM3
*d3drm3
= NULL
;
6703 ULONG ref1
, ref2
, ref3
;
6710 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
6711 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface (hr = %x).\n", hr
);
6713 window
= create_window();
6714 GetClientRect(window
, &rc
);
6716 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
6717 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#x.\n", hr
);
6719 hr
= Direct3DRMCreate(&d3drm1
);
6720 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface (hr = %x).\n", hr
);
6722 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
6723 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr
);
6725 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6726 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr
);
6728 /* Create a surface and use it to create a texture. */
6729 memset(&desc
, 0, sizeof(desc
));
6730 desc
.dwSize
= sizeof(desc
);
6731 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
6732 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
6733 desc
.dwWidth
= rc
.right
;
6734 desc
.dwHeight
= rc
.bottom
;
6736 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
6737 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
6739 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface2
, NULL
);
6740 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#x.\n", hr
);
6742 /* Test NULL params */
6743 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
6744 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, NULL
, &texture1
);
6745 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6746 ok(!texture1
, "Expected texture returned == NULL, got %p.\n", texture1
);
6748 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, NULL
, NULL
);
6749 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6751 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
6752 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, NULL
, &texture2
);
6753 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6754 ok(!texture2
, "Expected texture returned == NULL, got %p.\n", texture2
);
6756 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, NULL
, NULL
);
6757 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6759 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
6760 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, NULL
, &texture3
);
6761 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6762 ok(!texture3
, "Expected texture returned == NULL, got %p.\n", texture3
);
6764 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, NULL
, NULL
);
6765 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6767 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
6768 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, surface
, &texture1
);
6769 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6771 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
6772 image
= IDirect3DRMTexture_GetImage(texture1
);
6773 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
6774 hr
= IDirect3DRMTexture_InitFromSurface(texture1
, NULL
);
6775 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
6776 IDirect3DRMTexture_Release(texture1
);
6778 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
6779 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, surface
, &texture2
);
6780 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6781 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
6782 image
= IDirect3DRMTexture2_GetImage(texture2
);
6783 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
6784 hr
= IDirect3DRMTexture2_InitFromSurface(texture2
, NULL
);
6785 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
6786 IDirect3DRMTexture_Release(texture2
);
6788 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
6789 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, surface
, &texture3
);
6790 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#x.\n", hr
);
6791 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
6792 image
= IDirect3DRMTexture3_GetImage(texture3
);
6793 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
6794 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, NULL
);
6795 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr
);
6796 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, NULL
);
6797 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr
);
6798 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &ds
);
6799 ok(SUCCEEDED(hr
), "Failed to get surface, hr %#x.\n", hr
);
6800 ok(ds
== surface
, "Expected same surface back.\n");
6801 IDirectDrawSurface_Release(ds
);
6803 /* Init already initialized texture with same surface. */
6804 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface
);
6805 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6807 /* Init already initialized texture with different surface. */
6808 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface2
);
6809 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6811 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &ds
);
6812 ok(SUCCEEDED(hr
), "Failed to get surface, hr %#x.\n", hr
);
6813 ok(ds
== surface
, "Expected same surface back.\n");
6814 IDirectDrawSurface_Release(ds
);
6816 ref1
= get_refcount((IUnknown
*)d3drm1
);
6817 ref2
= get_refcount((IUnknown
*)d3drm2
);
6818 ref3
= get_refcount((IUnknown
*)d3drm3
);
6819 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
6820 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6821 ok(ref1
< get_refcount((IUnknown
*)d3drm1
), "Expected d3drm1 reference taken.\n");
6822 ok(ref2
== get_refcount((IUnknown
*)d3drm2
), "Expected d3drm2 reference unchanged.\n");
6823 ok(ref3
== get_refcount((IUnknown
*)d3drm3
), "Expected d3drm3 reference unchanged.\n");
6824 /* Release leaked reference to d3drm1 */
6825 IDirect3DRM_Release(d3drm1
);
6827 IDirect3DRMTexture_Release(texture3
);
6829 /* Create from image, initialize from surface. */
6830 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
6831 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr
);
6833 ref1
= get_refcount((IUnknown
*)d3drm1
);
6834 ref2
= get_refcount((IUnknown
*)d3drm2
);
6835 ref3
= get_refcount((IUnknown
*)d3drm3
);
6836 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface
);
6837 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#x.\n", hr
);
6838 ok(ref1
< get_refcount((IUnknown
*)d3drm1
), "Expected d3drm1 reference taken.\n");
6839 ok(ref2
== get_refcount((IUnknown
*)d3drm2
), "Expected d3drm2 reference unchanged.\n");
6840 ok(ref3
== get_refcount((IUnknown
*)d3drm3
), "Expected d3drm3 reference unchanged.\n");
6841 /* Release leaked reference to d3drm1 */
6842 IDirect3DRM_Release(d3drm1
);
6843 IDirect3DRMTexture3_Release(texture3
);
6845 IDirectDrawSurface_Release(surface2
);
6846 IDirectDrawSurface_Release(surface
);
6847 IDirect3DRM3_Release(d3drm3
);
6848 IDirect3DRM2_Release(d3drm2
);
6849 IDirect3DRM_Release(d3drm1
);
6850 IDirectDraw_Release(ddraw
);
6853 static void test_animation(void)
6855 IDirect3DRMAnimation2
*animation2
;
6856 IDirect3DRMAnimation
*animation
;
6857 D3DRMANIMATIONOPTIONS options
;
6858 IDirect3DRMObject
*obj
, *obj2
;
6859 D3DRMANIMATIONKEY keys
[10];
6860 IDirect3DRMFrame3
*frame3
;
6861 IDirect3DRMFrame
*frame
;
6862 D3DRMANIMATIONKEY key
;
6863 IDirect3DRM
*d3drm1
;
6869 hr
= Direct3DRMCreate(&d3drm1
);
6870 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRM instance, hr 0x%08x.\n", hr
);
6872 hr
= IDirect3DRM_CreateAnimation(d3drm1
, NULL
);
6873 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr 0x%08x.\n", hr
);
6875 CHECK_REFCOUNT(d3drm1
, 1);
6876 hr
= IDirect3DRM_CreateAnimation(d3drm1
, &animation
);
6877 ok(SUCCEEDED(hr
), "Failed to create animation hr 0x%08x.\n", hr
);
6878 CHECK_REFCOUNT(d3drm1
, 2);
6880 test_class_name((IDirect3DRMObject
*)animation
, "Animation");
6882 hr
= IDirect3DRMAnimation_QueryInterface(animation
, &IID_IDirect3DRMAnimation2
, (void **)&animation2
);
6883 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMAnimation2, hr 0x%08x.\n", hr
);
6884 ok(animation
!= (void *)animation2
, "Expected different interface pointer.\n");
6886 hr
= IDirect3DRMAnimation_QueryInterface(animation
, &IID_IDirect3DRMObject
, (void **)&obj
);
6887 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr 0x%08x.\n", hr
);
6889 hr
= IDirect3DRMAnimation2_QueryInterface(animation2
, &IID_IDirect3DRMObject
, (void **)&obj2
);
6890 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr 0x%08x.\n", hr
);
6892 ok(obj
== obj2
&& obj
== (IDirect3DRMObject
*)animation
, "Unexpected object pointer.\n");
6894 IDirect3DRMObject_Release(obj
);
6895 IDirect3DRMObject_Release(obj2
);
6897 /* Set animated frame, get it back. */
6898 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame
);
6899 ok(SUCCEEDED(hr
), "Failed to create a frame, hr %#x.\n", hr
);
6901 hr
= IDirect3DRMAnimation_SetFrame(animation
, NULL
);
6902 ok(SUCCEEDED(hr
), "Failed to reset frame, hr %#x.\n", hr
);
6904 CHECK_REFCOUNT(frame
, 1);
6905 hr
= IDirect3DRMAnimation_SetFrame(animation
, frame
);
6906 ok(SUCCEEDED(hr
), "Failed to set a frame, hr %#x.\n", hr
);
6907 CHECK_REFCOUNT(frame
, 1);
6909 hr
= IDirect3DRMAnimation2_GetFrame(animation2
, NULL
);
6910 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
6912 hr
= IDirect3DRMAnimation2_GetFrame(animation2
, &frame3
);
6913 ok(SUCCEEDED(hr
), "Failed to get the frame, %#x.\n", hr
);
6914 ok(frame3
!= (void *)frame
, "Unexpected interface pointer.\n");
6915 CHECK_REFCOUNT(frame
, 2);
6917 IDirect3DRMFrame3_Release(frame3
);
6919 hr
= IDirect3DRMAnimation_SetFrame(animation
, NULL
);
6920 ok(SUCCEEDED(hr
), "Failed to reset frame, hr %#x.\n", hr
);
6922 hr
= IDirect3DRMFrame_QueryInterface(frame
, &IID_IDirect3DRMFrame3
, (void **)&frame3
);
6923 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMFrame3, hr %#x.\n", hr
);
6925 CHECK_REFCOUNT(frame3
, 2);
6926 hr
= IDirect3DRMAnimation2_SetFrame(animation2
, frame3
);
6927 ok(SUCCEEDED(hr
), "Failed to set a frame, hr %#x.\n", hr
);
6928 CHECK_REFCOUNT(frame3
, 2);
6930 IDirect3DRMFrame3_Release(frame3
);
6931 IDirect3DRMFrame_Release(frame
);
6933 /* Animation options. */
6934 options
= IDirect3DRMAnimation_GetOptions(animation
);
6935 ok(options
== (D3DRMANIMATION_CLOSED
| D3DRMANIMATION_LINEARPOSITION
),
6936 "Unexpected default options %#x.\n", options
);
6938 /* Undefined mask value */
6939 hr
= IDirect3DRMAnimation_SetOptions(animation
, 0xf0000000);
6940 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
6942 options
= IDirect3DRMAnimation_GetOptions(animation
);
6943 ok(options
== (D3DRMANIMATION_CLOSED
| D3DRMANIMATION_LINEARPOSITION
),
6944 "Unexpected default options %#x.\n", options
);
6946 /* Ambiguous mask */
6947 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_OPEN
| D3DRMANIMATION_CLOSED
);
6948 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
6950 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_LINEARPOSITION
| D3DRMANIMATION_SPLINEPOSITION
);
6951 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
6953 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_SCALEANDROTATION
| D3DRMANIMATION_POSITION
);
6954 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
6956 options
= IDirect3DRMAnimation_GetOptions(animation
);
6957 ok(options
== (D3DRMANIMATION_CLOSED
| D3DRMANIMATION_LINEARPOSITION
),
6958 "Unexpected default options %#x.\n", options
);
6960 /* Mask contains undefined bits together with valid one. */
6961 hr
= IDirect3DRMAnimation_SetOptions(animation
, 0xf0000000 | D3DRMANIMATION_OPEN
);
6962 ok(SUCCEEDED(hr
), "Failed to set animation options, hr %#x.\n", hr
);
6964 options
= IDirect3DRMAnimation_GetOptions(animation
);
6965 ok(options
== (0xf0000000 | D3DRMANIMATION_OPEN
), "Unexpected animation options %#x.\n", options
);
6967 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_SCALEANDROTATION
);
6968 ok(SUCCEEDED(hr
), "Failed to set animation options, hr %#x.\n", hr
);
6970 options
= IDirect3DRMAnimation_GetOptions(animation
);
6971 ok(options
== D3DRMANIMATION_SCALEANDROTATION
, "Unexpected options %#x.\n", options
);
6973 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_OPEN
);
6974 ok(SUCCEEDED(hr
), "Failed to set animation options, hr %#x.\n", hr
);
6976 options
= IDirect3DRMAnimation_GetOptions(animation
);
6977 ok(options
== D3DRMANIMATION_OPEN
, "Unexpected options %#x.\n", options
);
6979 hr
= IDirect3DRMAnimation_SetOptions(animation
, 0);
6980 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
6982 options
= IDirect3DRMAnimation_GetOptions(animation
);
6983 ok(options
== D3DRMANIMATION_OPEN
, "Unexpected options %#x.\n", options
);
6985 /* Key management. */
6986 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 0.0f
, 1.0f
, 0.0f
, 0.0f
);
6987 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#x.\n", hr
);
6989 hr
= IDirect3DRMAnimation_AddScaleKey(animation
, 0.0f
, 1.0f
, 2.0f
, 1.0f
);
6990 ok(SUCCEEDED(hr
), "Failed to add scale key, hr %#x.\n", hr
);
6992 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 0.0f
, 2.0f
, 0.0f
, 0.0f
);
6993 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#x.\n", hr
);
6995 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 99.0f
, 3.0f
, 1.0f
, 0.0f
);
6996 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#x.\n", hr
);
6998 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 80.0f
, 4.0f
, 1.0f
, 0.0f
);
6999 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#x.\n", hr
);
7004 D3DRMQuaternionFromRotation(&q
, &v
, 1.0f
);
7006 /* NULL quaternion pointer leads to a crash on Windows. */
7007 hr
= IDirect3DRMAnimation_AddRotateKey(animation
, 0.0f
, &q
);
7008 ok(SUCCEEDED(hr
), "Failed to add rotation key, hr %#.x\n", hr
);
7011 memset(keys
, 0, sizeof(keys
));
7012 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 99.0f
, &count
, keys
);
7013 ok(SUCCEEDED(hr
), "Failed to get animation keys, hr %#x.\n", hr
);
7014 ok(count
== 6, "Unexpected key count %u.\n", count
);
7016 ok(keys
[0].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %u.\n", keys
[0].dwKeyType
);
7017 ok(keys
[1].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[1].dwKeyType
);
7018 ok(keys
[2].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[2].dwKeyType
);
7019 ok(keys
[3].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[3].dwKeyType
);
7020 ok(keys
[4].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[4].dwKeyType
);
7021 ok(keys
[5].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %u.\n", keys
[5].dwKeyType
);
7023 /* Relative order, keys are returned sorted by time. */
7024 ok(keys
[1].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[1].dvTime
);
7025 ok(keys
[2].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[2].dvTime
);
7026 ok(keys
[3].dvTime
== 80.0f
, "Unexpected key time %.8e.\n", keys
[3].dvTime
);
7027 ok(keys
[4].dvTime
== 99.0f
, "Unexpected key time %.8e.\n", keys
[4].dvTime
);
7029 /* For keys with same time, order they were added in is kept. */
7030 ok(keys
[1].dvPositionKey
.x
== 1.0f
, "Unexpected key position x %.8e.\n", keys
[1].dvPositionKey
.x
);
7031 ok(keys
[2].dvPositionKey
.x
== 2.0f
, "Unexpected key position x %.8e.\n", keys
[2].dvPositionKey
.x
);
7032 ok(keys
[3].dvPositionKey
.x
== 4.0f
, "Unexpected key position x %.8e.\n", keys
[3].dvPositionKey
.x
);
7033 ok(keys
[4].dvPositionKey
.x
== 3.0f
, "Unexpected key position x %.8e.\n", keys
[4].dvPositionKey
.x
);
7035 for (i
= 0; i
< count
; i
++)
7037 ok(keys
[i
].dwSize
== sizeof(*keys
), "%u: unexpected dwSize value %u.\n", i
, keys
[i
].dwSize
);
7041 switch (keys
[i
].dwKeyType
)
7043 case D3DRMANIMATION_ROTATEKEY
:
7044 ok((keys
[i
].dwID
& 0xf0000000) == 0x40000000, "%u: unexpected id mask %#x.\n", i
, keys
[i
].dwID
);
7046 case D3DRMANIMATION_POSITIONKEY
:
7047 ok((keys
[i
].dwID
& 0xf0000000) == 0x80000000, "%u: unexpected id mask %#x.\n", i
, keys
[i
].dwID
);
7049 case D3DRMANIMATION_SCALEKEY
:
7050 ok((keys
[i
].dwID
& 0xf0000000) == 0xc0000000, "%u: unexpected id mask %#x.\n", i
, keys
[i
].dwID
);
7053 ok(0, "%u: unknown key type %d.\n", i
, keys
[i
].dwKeyType
);
7058 /* No keys in this range. */
7060 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 100.0f
, 200.0f
, &count
, NULL
);
7061 ok(hr
== D3DRMERR_NOSUCHKEY
, "Unexpected hr %#x.\n", hr
);
7062 ok(count
== 0, "Unexpected key count %u.\n", count
);
7065 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 100.0f
, 200.0f
, &count
, keys
);
7066 ok(hr
== D3DRMERR_NOSUCHKEY
, "Unexpected hr %#x.\n", hr
);
7067 ok(count
== 0, "Unexpected key count %u.\n", count
);
7070 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 0.0f
, &count
, NULL
);
7071 ok(SUCCEEDED(hr
), "Failed to get animation keys, hr %#x.\n", hr
);
7072 ok(count
== 4, "Unexpected key count %u.\n", count
);
7074 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 100.0f
, NULL
, NULL
);
7075 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
7077 /* Time is 0-based. */
7078 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -100.0f
, -50.0f
, NULL
, NULL
);
7079 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#x.\n", hr
);
7082 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -100.0f
, -50.0f
, &count
, NULL
);
7083 ok(hr
== D3DRMERR_NOSUCHKEY
, "Unexpected hr %#x.\n", hr
);
7084 ok(count
== 0, "Unexpected key count %u.\n", count
);
7087 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -100.0f
, 100.0f
, &count
, NULL
);
7088 ok(SUCCEEDED(hr
), "Failed to get animation keys, hr %#x.\n", hr
);
7089 ok(count
== 6, "Unexpected key count %u.\n", count
);
7091 /* AddKey() tests. */
7092 hr
= IDirect3DRMAnimation2_AddKey(animation2
, NULL
);
7093 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
7095 memset(&key
, 0, sizeof(key
));
7096 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7097 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7098 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
7100 memset(&key
, 0, sizeof(key
));
7101 key
.dwSize
= sizeof(key
) - 1;
7102 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7103 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7104 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
7106 memset(&key
, 0, sizeof(key
));
7107 key
.dwSize
= sizeof(key
) + 1;
7108 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7109 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7110 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
7112 memset(&key
, 0, sizeof(key
));
7113 key
.dwSize
= sizeof(key
);
7114 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7115 key
.dvPositionKey
.x
= 8.0f
;
7116 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7117 ok(SUCCEEDED(hr
), "Failed to add key, hr %#x.\n", hr
);
7120 hr
= IDirect3DRMAnimation_AddRotateKey(animation
, 0.0f
, &q
);
7121 ok(SUCCEEDED(hr
), "Failed to add rotation key, hr %#.x\n", hr
);
7123 hr
= IDirect3DRMAnimation_AddScaleKey(animation
, 0.0f
, 1.0f
, 2.0f
, 1.0f
);
7124 ok(SUCCEEDED(hr
), "Failed to add scale key, hr %#x.\n", hr
);
7127 memset(keys
, 0, sizeof(keys
));
7128 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -1000.0f
, 1000.0f
, &count
, keys
);
7129 ok(SUCCEEDED(hr
), "Failed to get key count, hr %#x.\n", hr
);
7130 ok(count
== 9, "Unexpected key count %u.\n", count
);
7132 ok(keys
[0].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %u.\n", keys
[0].dwKeyType
);
7133 ok(keys
[1].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %u.\n", keys
[1].dwKeyType
);
7134 ok(keys
[2].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[2].dwKeyType
);
7135 ok(keys
[3].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[3].dwKeyType
);
7136 ok(keys
[4].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[4].dwKeyType
);
7137 ok(keys
[5].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[5].dwKeyType
);
7138 ok(keys
[6].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[6].dwKeyType
);
7139 ok(keys
[7].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %u.\n", keys
[7].dwKeyType
);
7140 ok(keys
[8].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %u.\n", keys
[8].dwKeyType
);
7142 ok(keys
[0].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[0].dvTime
);
7143 ok(keys
[1].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[1].dvTime
);
7144 ok(keys
[2].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[2].dvTime
);
7145 ok(keys
[3].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[3].dvTime
);
7146 ok(keys
[4].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[4].dvTime
);
7147 ok(keys
[5].dvTime
== 80.0f
, "Unexpected key time %.8e.\n", keys
[5].dvTime
);
7148 ok(keys
[6].dvTime
== 99.0f
, "Unexpected key time %.8e.\n", keys
[6].dvTime
);
7149 ok(keys
[7].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[7].dvTime
);
7150 ok(keys
[8].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[8].dvTime
);
7152 hr
= IDirect3DRMAnimation_DeleteKey(animation
, -100.0f
);
7153 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#x.\n", hr
);
7155 hr
= IDirect3DRMAnimation_DeleteKey(animation
, 100.0f
);
7156 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#x.\n", hr
);
7158 /* Only first Position keys are not removed. */
7159 hr
= IDirect3DRMAnimation_DeleteKey(animation
, 0.0f
);
7160 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#x.\n", hr
);
7163 memset(keys
, 0, sizeof(keys
));
7164 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 100.0f
, &count
, keys
);
7165 ok(SUCCEEDED(hr
), "Failed to get key count, hr %#x.\n", hr
);
7166 ok(count
== 6, "Unexpected key count %u.\n", count
);
7168 ok(keys
[0].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %u.\n", keys
[0].dwKeyType
);
7169 ok(keys
[1].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[1].dwKeyType
);
7170 ok(keys
[2].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[2].dwKeyType
);
7171 ok(keys
[3].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[3].dwKeyType
);
7172 ok(keys
[4].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %u.\n", keys
[4].dwKeyType
);
7173 ok(keys
[5].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %u.\n", keys
[5].dwKeyType
);
7175 ok(keys
[0].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[0].dvTime
);
7176 ok(keys
[1].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[1].dvTime
);
7177 ok(keys
[2].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[2].dvTime
);
7178 ok(keys
[3].dvTime
== 80.0f
, "Unexpected key time %.8e.\n", keys
[3].dvTime
);
7179 ok(keys
[4].dvTime
== 99.0f
, "Unexpected key time %.8e.\n", keys
[4].dvTime
);
7180 ok(keys
[5].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[5].dvTime
);
7182 hr
= IDirect3DRMAnimation_DeleteKey(animation
, 0.0f
);
7183 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#x.\n", hr
);
7186 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 100.0f
, &count
, NULL
);
7187 ok(SUCCEEDED(hr
), "Failed to get key count, hr %#x.\n", hr
);
7188 ok(count
== 3, "Unexpected key count %u.\n", count
);
7190 IDirect3DRMAnimation2_Release(animation2
);
7191 IDirect3DRMAnimation_Release(animation
);
7193 IDirect3DRM_Release(d3drm1
);
7196 static void test_animation_qi(void)
7198 static const struct qi_test tests
[] =
7200 { &IID_IDirect3DRMAnimation2
, &IID_IUnknown
, &IID_IDirect3DRMAnimation2
, S_OK
},
7201 { &IID_IDirect3DRMAnimation
, &IID_IUnknown
, &IID_IDirect3DRMAnimation
, S_OK
},
7202 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7203 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7204 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMAnimation
, S_OK
},
7205 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7206 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7207 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7208 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7209 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7210 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7211 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7212 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7213 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7214 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7215 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7216 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7217 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7218 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7219 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7220 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7221 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7222 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7223 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7224 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7225 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7226 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7227 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7228 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7229 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7230 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7231 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7232 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7233 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7234 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7235 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7236 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7237 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7238 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7239 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7240 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7241 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7242 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7243 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7244 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7245 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7246 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7247 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7248 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7249 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7250 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7251 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7252 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7253 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7254 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7255 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7256 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7257 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7258 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7259 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7260 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7261 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7262 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
7264 IDirect3DRMAnimation2
*animation2
;
7265 IDirect3DRMAnimation
*animation
;
7266 IDirect3DRM3
*d3drm3
;
7267 IDirect3DRM
*d3drm1
;
7271 hr
= Direct3DRMCreate(&d3drm1
);
7272 ok(SUCCEEDED(hr
), "Failed to create d3drm instance, hr %#x.\n", hr
);
7274 hr
= IDirect3DRM_CreateAnimation(d3drm1
, &animation
);
7275 ok(SUCCEEDED(hr
), "Failed to create animation hr %#x.\n", hr
);
7277 hr
= IDirect3DRMAnimation_QueryInterface(animation
, &IID_IUnknown
, (void **)&unknown
);
7278 ok(SUCCEEDED(hr
), "Failed to get IUnknown from animation, hr %#x.\n", hr
);
7279 IDirect3DRMAnimation_Release(animation
);
7281 test_qi("animation_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
7282 IUnknown_Release(unknown
);
7284 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
7285 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM3, hr %#x.\n", hr
);
7287 hr
= IDirect3DRM3_CreateAnimation(d3drm3
, &animation2
);
7288 ok(SUCCEEDED(hr
), "Failed to create animation hr %#x.\n", hr
);
7290 hr
= IDirect3DRMAnimation2_QueryInterface(animation2
, &IID_IUnknown
, (void **)&unknown
);
7291 ok(SUCCEEDED(hr
), "Failed to get IUnknown from animation, hr %#x.\n", hr
);
7292 IDirect3DRMAnimation2_Release(animation2
);
7294 test_qi("animation2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
7295 IUnknown_Release(unknown
);
7297 IDirect3DRM3_Release(d3drm3
);
7298 IDirect3DRM_Release(d3drm1
);
7301 static void test_wrap(void)
7303 IDirect3DRMWrap
*wrap
;
7304 IDirect3DRM
*d3drm1
;
7307 hr
= Direct3DRMCreate(&d3drm1
);
7308 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRM instance, hr %#x.\n", hr
);
7310 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMWrap
, NULL
, &IID_IDirect3DRMWrap
, (void **)&wrap
);
7311 ok(SUCCEEDED(hr
), "Failed to create wrap instance, hr %#x.\n", hr
);
7313 test_class_name((IDirect3DRMObject
*)wrap
, "");
7315 IDirect3DRMWrap_Release(wrap
);
7316 IDirect3DRM_Release(d3drm1
);
7319 static void test_wrap_qi(void)
7321 static const struct qi_test tests
[] =
7323 { &IID_IDirect3DRMWrap
, &IID_IUnknown
, &IID_IDirect3DRMWrap
, S_OK
},
7324 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7325 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7326 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMWrap
, S_OK
},
7327 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7328 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7329 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7330 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7331 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7332 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7333 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7334 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7335 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7336 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7337 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7338 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7339 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7340 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7341 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7342 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7343 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7344 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7345 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7346 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7347 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7348 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7349 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7350 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7351 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7352 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7353 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7354 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7355 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7356 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7357 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7358 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7359 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7360 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7361 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7362 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7363 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7364 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7365 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7366 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7367 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7368 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7369 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7370 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7371 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7372 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7373 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7374 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7375 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7376 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7377 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7378 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7379 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7380 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7381 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7382 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7383 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7384 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7385 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
7386 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
7388 IDirect3DRMWrap
*wrap
;
7389 IDirect3DRM
*d3drm1
;
7393 hr
= Direct3DRMCreate(&d3drm1
);
7394 ok(SUCCEEDED(hr
), "Failed to create d3drm instance, hr %#x.\n", hr
);
7396 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMWrap
, NULL
, &IID_IDirect3DRMWrap
, (void **)&wrap
);
7397 ok(SUCCEEDED(hr
), "Failed to create wrap instance, hr %#x.\n", hr
);
7399 hr
= IDirect3DRMWrap_QueryInterface(wrap
, &IID_IUnknown
, (void **)&unknown
);
7400 ok(SUCCEEDED(hr
), "Failed to get IUnknown from wrap (hr = %#x)\n", hr
);
7401 IDirect3DRMWrap_Release(wrap
);
7402 test_qi("wrap_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
7403 IUnknown_Release(unknown
);
7405 IDirect3DRM_Release(d3drm1
);
7410 test_MeshBuilder3();
7420 test_frame_transform();
7422 test_frame_mesh_materials();
7426 test_create_device_from_clipper1();
7427 test_create_device_from_clipper2();
7428 test_create_device_from_clipper3();
7429 test_create_device_from_surface1();
7430 test_create_device_from_surface2();
7431 test_create_device_from_surface3();
7432 test_create_device_from_d3d1();
7433 test_create_device_from_d3d2();
7434 test_create_device_from_d3d3();
7435 test_load_texture();
7438 test_viewport_clear1();
7439 test_viewport_clear2();
7440 test_create_texture_from_surface();
7442 test_animation_qi();