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
25 #define _USE_MATH_DEFINES
32 #include "wine/test.h"
34 #define CHECK_REFCOUNT(obj,rc) \
37 int count = get_refcount( (IUnknown *)obj ); \
38 ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
41 static ULONG
get_refcount(IUnknown
*object
)
43 IUnknown_AddRef( object
);
44 return IUnknown_Release( object
);
47 static BOOL
compare_uint(unsigned int x
, unsigned int y
, unsigned int max_diff
)
49 unsigned int diff
= x
> y
? x
- y
: y
- x
;
51 return diff
<= max_diff
;
54 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
64 return compare_uint(x
, y
, ulps
);
67 #define expect_matrix(m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u) \
68 expect_matrix_(__LINE__, m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u)
69 static void expect_matrix_(unsigned int line
, D3DRMMATRIX4D m
,
70 float m11
, float m12
, float m13
, float m14
, float m21
, float m22
, float m23
, float m24
,
71 float m31
, float m32
, float m33
, float m34
, float m41
, float m42
, float m43
, float m44
,
74 BOOL equal
= compare_float(m
[0][0], m11
, ulps
) && compare_float(m
[0][1], m12
, ulps
)
75 && compare_float(m
[0][2], m13
, ulps
) && compare_float(m
[0][3], m14
, ulps
)
76 && compare_float(m
[1][0], m21
, ulps
) && compare_float(m
[1][1], m22
, ulps
)
77 && compare_float(m
[1][2], m23
, ulps
) && compare_float(m
[1][3], m24
, ulps
)
78 && compare_float(m
[2][0], m31
, ulps
) && compare_float(m
[2][1], m32
, ulps
)
79 && compare_float(m
[2][2], m33
, ulps
) && compare_float(m
[2][3], m34
, ulps
)
80 && compare_float(m
[3][0], m41
, ulps
) && compare_float(m
[3][1], m42
, ulps
)
81 && compare_float(m
[3][2], m43
, ulps
) && compare_float(m
[3][3], m44
, ulps
);
83 ok_(__FILE__
, line
)(equal
,
84 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
85 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
86 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
87 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
88 m
[0][0], m
[0][1], m
[0][2], m
[0][3], m
[1][0], m
[1][1], m
[1][2], m
[1][3],
89 m
[2][0], m
[2][1], m
[2][2], m
[2][3], m
[3][0], m
[3][1], m
[3][2], m
[3][3],
90 m11
, m12
, m13
, m14
, m21
, m22
, m23
, m24
, m31
, m32
, m33
, m34
, m41
, m42
, m43
, m44
);
93 #define expect_vector(v, x, y, z, u) expect_vector_(__LINE__, v, x, y, z, u)
94 static void expect_vector_(unsigned int line
, const D3DVECTOR
*v
, float x
, float y
, float z
, unsigned int ulps
)
96 BOOL equal
= compare_float(v
->x
, x
, ulps
)
97 && compare_float(v
->y
, y
, ulps
)
98 && compare_float(v
->z
, z
, ulps
);
100 ok_(__FILE__
, line
)(equal
, "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
101 v
->x
, v
->y
, v
->z
, x
, y
, z
);
104 #define vector_eq(a, b) vector_eq_(__LINE__, a, b)
105 static void vector_eq_(unsigned int line
, const D3DVECTOR
*left
, const D3DVECTOR
*right
)
107 expect_vector_(line
, left
, right
->x
, right
->y
, right
->z
, 0);
110 static BOOL
compare_color(D3DCOLOR c1
, D3DCOLOR c2
, BYTE max_diff
)
112 return compare_uint(c1
& 0xff, c2
& 0xff, max_diff
)
113 && compare_uint((c1
>> 8) & 0xff, (c2
>> 8) & 0xff, max_diff
)
114 && compare_uint((c1
>> 16) & 0xff, (c2
>> 16) & 0xff, max_diff
)
115 && compare_uint((c1
>> 24) & 0xff, (c2
>> 24) & 0xff, max_diff
);
118 static D3DRMMATRIX4D identity
= {
119 { 1.0f
, 0.0f
, 0.0f
, 0.0f
},
120 { 0.0f
, 1.0f
, 0.0f
, 0.0f
},
121 { 0.0f
, 0.0f
, 1.0f
, 0.0f
},
122 { 0.0f
, 0.0f
, 0.0f
, 1.0f
}
125 static void frame_set_transform(IDirect3DRMFrame
*frame
,
126 float m11
, float m12
, float m13
, float m14
, float m21
, float m22
, float m23
, float m24
,
127 float m31
, float m32
, float m33
, float m34
, float m41
, float m42
, float m43
, float m44
)
129 D3DRMMATRIX4D matrix
=
131 {m11
, m12
, m13
, m14
},
132 {m21
, m22
, m23
, m24
},
133 {m31
, m32
, m33
, m34
},
134 {m41
, m42
, m43
, m44
},
137 IDirect3DRMFrame_AddTransform(frame
, D3DRMCOMBINE_REPLACE
, matrix
);
140 static void set_vector(D3DVECTOR
*v
, float x
, float y
, float z
)
147 static void matrix_sanitise(D3DRMMATRIX4D m
)
151 for (i
= 0; i
< 4; ++i
)
153 for (j
= 0; j
< 4; ++j
)
155 if (m
[i
][j
] > -1e-7f
&& m
[i
][j
] < 1e-7f
)
161 static HWND
create_window(void)
163 RECT r
= {0, 0, 640, 480};
165 AdjustWindowRect(&r
, WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, FALSE
);
167 return CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
168 CW_USEDEFAULT
, CW_USEDEFAULT
, r
.right
- r
.left
, r
.bottom
- r
.top
, NULL
, NULL
, NULL
, NULL
);
171 #define test_class_name(a, b) test_class_name_(__LINE__, a, b)
172 static void test_class_name_(unsigned int line
, IDirect3DRMObject
*object
, const char *name
)
174 char cname
[64] = {0};
178 hr
= IDirect3DRMObject_GetClassName(object
, NULL
, cname
);
179 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
180 hr
= IDirect3DRMViewport_GetClassName(object
, NULL
, NULL
);
181 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
184 hr
= IDirect3DRMObject_GetClassName(object
, &size
, NULL
);
185 ok_(__FILE__
, line
)(hr
== D3DRM_OK
, "Failed to get classname size, hr %#lx.\n", hr
);
186 ok_(__FILE__
, line
)(size
== strlen(name
) + 1, "wrong size: %lu.\n", size
);
188 size
= size2
= !!*name
;
189 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
190 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
191 ok_(__FILE__
, line
)(size
== size2
, "Got size %lu.\n", size
);
193 size
= sizeof(cname
);
194 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
195 ok_(__FILE__
, line
)(hr
== D3DRM_OK
, "Failed to get classname, hr %#lx.\n", hr
);
196 ok_(__FILE__
, line
)(size
== strlen(name
) + 1, "wrong size: %lu.\n", size
);
197 ok_(__FILE__
, line
)(!strcmp(cname
, name
), "Expected cname to be \"%s\", but got \"%s\".\n", name
, cname
);
199 size
= strlen(name
) + 1;
200 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
201 ok_(__FILE__
, line
)(hr
== D3DRM_OK
, "Failed to get classname, hr %#lx.\n", hr
);
202 ok_(__FILE__
, line
)(size
== strlen(name
) + 1, "wrong size: %lu.\n", size
);
203 ok_(__FILE__
, line
)(!strcmp(cname
, name
), "Expected cname to be \"%s\", but got \"%s\".\n", name
, cname
);
206 strcpy(cname
, "XXX");
207 hr
= IDirect3DRMObject_GetClassName(object
, &size
, cname
);
208 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
209 ok_(__FILE__
, line
)(size
== strlen(name
), "Wrong classname size: %lu.\n", size
);
210 ok_(__FILE__
, line
)(!strcmp(cname
, "XXX"), "Expected unchanged buffer, but got \"%s\".\n", cname
);
213 #define test_object_name(a) test_object_name_(__LINE__, a)
214 static void test_object_name_(unsigned int line
, IDirect3DRMObject
*object
)
220 hr
= IDirect3DRMObject_GetName(object
, NULL
, NULL
);
221 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
224 hr
= IDirect3DRMObject_GetName(object
, NULL
, name
);
225 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Got unexpected hr %#lx.\n", hr
);
226 ok_(__FILE__
, line
)(name
[0] == 0x1f, "Unexpected buffer contents, %#x.\n", name
[0]);
228 /* Name is not set yet. */
230 hr
= IDirect3DRMObject_GetName(object
, &size
, NULL
);
231 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
232 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %lu.\n", size
);
236 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
237 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
238 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %lu.\n", size
);
239 ok_(__FILE__
, line
)(name
[0] == 0, "Unexpected name \"%s\".\n", name
);
243 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
244 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
245 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %lu.\n", size
);
246 ok_(__FILE__
, line
)(name
[0] == 0x1f, "Unexpected name \"%s\".\n", name
);
248 hr
= IDirect3DRMObject_SetName(object
, NULL
);
249 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Got unexpected hr %#lx.\n", hr
);
251 hr
= IDirect3DRMObject_SetName(object
, "name");
252 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to set a name, hr %#lx.\n", hr
);
255 hr
= IDirect3DRMObject_GetName(object
, &size
, NULL
);
256 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
257 ok_(__FILE__
, line
)(size
== strlen("name") + 1, "Unexpected size %lu.\n", size
);
259 size
= strlen("name") + 1;
260 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
261 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
262 ok_(__FILE__
, line
)(size
== strlen("name") + 1, "Unexpected size %lu.\n", size
);
263 ok_(__FILE__
, line
)(!strcmp(name
, "name"), "Unexpected name \"%s\".\n", name
);
267 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
268 ok_(__FILE__
, line
)(hr
== E_INVALIDARG
, "Failed to get object name, hr %#lx.\n", hr
);
269 ok_(__FILE__
, line
)(size
== 2, "Unexpected size %lu.\n", size
);
270 ok_(__FILE__
, line
)(name
[0] == 0x1f, "Got unexpected name \"%s\".\n", name
);
272 hr
= IDirect3DRMObject_SetName(object
, NULL
);
273 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to set object name, hr %#lx.\n", hr
);
276 hr
= IDirect3DRMObject_GetName(object
, &size
, NULL
);
277 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
278 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %lu.\n", size
);
282 hr
= IDirect3DRMObject_GetName(object
, &size
, name
);
283 ok_(__FILE__
, line
)(SUCCEEDED(hr
), "Failed to get name size, hr %#lx.\n", hr
);
284 ok_(__FILE__
, line
)(size
== 0, "Unexpected size %lu.\n", size
);
285 ok_(__FILE__
, line
)(name
[0] == 0, "Got unexpected name \"%s\".\n", name
);
288 static char data_bad_version
[] =
295 static char data_no_mesh
[] =
302 static char data_ok
[] =
321 static char data_full
[] =
323 "Header { 1; 0; 1; }\n"
331 " MeshMaterialList {\n"
334 " 0.0; 1.0; 0.0; 1.0;;\n"
338 " TextureFileName {\n"
339 " \"Texture.bmp\";\n"
351 " MeshTextureCoords {\n"
359 static char data_d3drm_load
[] =
386 " 0.1, 0.2, 0.3, 0.4;;\n"
392 static char data_frame_mesh_materials
[] =
394 "Header { 1; 0; 1; }\n"
410 " MeshMaterialList {\n"
411 " 3; 6; 0, 1, 1, 2, 2, 2;\n"
413 " 1.0; 0.0; 0.0; 0.1;;\n"
415 " 0.11; 0.12; 0.13;;\n"
416 " 0.14; 0.15; 0.16;;\n"
419 " 0.0; 1.0; 0.0; 0.2;;\n"
421 " 0.21; 0.22; 0.23;;\n"
422 " 0.24; 0.25; 0.26;;\n"
425 " 0.0; 0.0; 1.0; 0.3;;\n"
427 " 0.31; 0.32; 0.33;;\n"
428 " 0.34; 0.35; 0.36;;\n"
434 static void test_MeshBuilder(void)
438 IDirect3DRMMeshBuilder
*pMeshBuilder
;
439 IDirect3DRMMeshBuilder3
*meshbuilder3
;
440 IDirect3DRMMesh
*mesh
;
441 D3DRMLOADMEMORY info
;
443 DWORD val1
, val2
, val3
;
453 hr
= Direct3DRMCreate(&d3drm
);
454 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
456 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
457 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface, hr %#lx\n", hr
);
459 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMObject
, (void **)&unk
);
460 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
461 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
462 IUnknown_Release(unk
);
464 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMVisual
, (void **)&unk
);
465 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
466 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
467 IUnknown_Release(unk
);
469 hr
= IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder
, &IID_IDirect3DRMMeshBuilder3
, (void **)&meshbuilder3
);
470 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
472 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3
, &IID_IDirect3DRMObject
, (void **)&unk
);
473 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
474 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
475 IUnknown_Release(unk
);
477 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3
, &IID_IDirect3DRMVisual
, (void **)&unk
);
478 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
479 ok(unk
== (IUnknown
*)pMeshBuilder
, "Unexpected interface pointer.\n");
480 IUnknown_Release(unk
);
482 IDirect3DRMMeshBuilder3_Release(meshbuilder3
);
484 test_class_name((IDirect3DRMObject
*)pMeshBuilder
, "Builder");
485 test_object_name((IDirect3DRMObject
*)pMeshBuilder
);
487 info
.lpMemory
= data_bad_version
;
488 info
.dSize
= strlen(data_bad_version
);
489 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
490 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE, hr %#lx\n", hr
);
492 info
.lpMemory
= data_no_mesh
;
493 info
.dSize
= strlen(data_no_mesh
);
494 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
495 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND, hr %#lx\n", hr
);
497 info
.lpMemory
= data_ok
;
498 info
.dSize
= strlen(data_ok
);
499 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
500 ok(hr
== D3DRM_OK
, "Cannot load mesh data, hr %#lx\n", hr
);
503 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
504 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
505 ok(!strcmp(name
, "Object"), "Retrieved name '%s' instead of 'Object'\n", name
);
506 size
= strlen("Object"); /* No space for null character */
507 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
508 ok(hr
== E_INVALIDARG
, "Unexpected hr %#lx.\n", hr
);
509 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, NULL
);
510 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
512 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
513 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
514 ok(size
== 0, "Size should be 0 instead of %lu.\n", size
);
515 hr
= IDirect3DRMMeshBuilder_SetName(pMeshBuilder
, "");
516 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
518 hr
= IDirect3DRMMeshBuilder_GetName(pMeshBuilder
, &size
, name
);
519 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
520 ok(!strcmp(name
, ""), "Retrieved name '%s' instead of ''\n", name
);
522 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
523 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
525 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
526 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
528 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, NULL
, &val2
, NULL
, &val3
, NULL
);
529 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
530 ok(val1
== 4, "Wrong number of vertices %ld (must be 4)\n", val1
);
531 ok(val2
== 4, "Wrong number of normals %ld (must be 4)\n", val2
);
532 ok(val3
== 22, "Wrong number of face data bytes %ld (must be 22)\n", val3
);
534 /* Check that Load method generated default normals */
535 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, NULL
, &val2
, n
, NULL
, NULL
);
536 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
537 expect_vector(&n
[0], 0.577350f
, 0.577350f
, 0.577350f
, 32);
538 expect_vector(&n
[1], -0.229416f
, 0.688247f
, 0.688247f
, 32);
539 expect_vector(&n
[2], -0.229416f
, 0.688247f
, 0.688247f
, 32);
540 expect_vector(&n
[3], -0.577350f
, 0.577350f
, 0.577350f
, 32);
542 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
545 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
546 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
547 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
548 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
551 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 1, &valu
, &valv
);
552 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
553 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
554 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
557 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 2, &valu
, &valv
);
558 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
559 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
560 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
563 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 3, &valu
, &valv
);
564 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
565 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
566 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
567 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 4, &valu
, &valv
);
568 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr
);
572 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 0, valu
, valv
);
573 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates, hr %#lx\n", hr
);
574 hr
= IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder
, 4, valu
, valv
);
575 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr
);
579 hr
= IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder
, 0, &valu
, &valv
);
580 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
581 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
582 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
584 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
586 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &pMeshBuilder
);
587 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface, hr %#lx\n", hr
);
589 /* No group in mesh when mesh builder is not loaded */
590 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
591 ok(hr
== D3DRM_OK
, "CreateMesh failed returning hr %#lx.\n", hr
);
596 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
597 ok(nb_groups
== 0, "GetCroupCount returned %lu\n", nb_groups
);
599 IDirect3DRMMesh_Release(mesh
);
602 info
.lpMemory
= data_full
;
603 info
.dSize
= strlen(data_full
);
604 hr
= IDirect3DRMMeshBuilder_Load(pMeshBuilder
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
605 ok(hr
== D3DRM_OK
, "Cannot load mesh data, hr %#lx\n", hr
);
607 val
= IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder
);
608 ok(val
== 3, "Wrong number of vertices %d (must be 3)\n", val
);
610 val
= IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder
);
611 ok(val
== 1, "Wrong number of faces %d (must be 1)\n", val
);
613 /* Check no buffer size and too small buffer size errors */
614 val1
= 1; val2
= 3; val3
= 8;
615 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
616 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
617 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, NULL
, v
, &val2
, n
, &val3
, f
);
618 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
619 val1
= 3; val2
= 1; val3
= 8;
620 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
621 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
622 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, NULL
, n
, &val3
, f
);
623 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
624 val1
= 3; val2
= 3; val3
= 1;
625 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
626 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
627 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, NULL
, f
);
628 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
630 val1
= 3; val2
= 3; val3
= 8;
631 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
632 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
633 ok(val1
== 3, "Wrong number of vertices %ld (must be 3)\n", val1
);
634 ok(val2
== 3, "Wrong number of normals %ld (must be 3)\n", val2
);
635 ok(val3
== 8, "Wrong number of face data bytes %ld (must be 8)\n", val3
);
636 expect_vector(&v
[0], 0.1f
, 0.2f
, 0.3f
, 32);
637 expect_vector(&v
[1], 0.4f
, 0.5f
, 0.6f
, 32);
638 expect_vector(&v
[2], 0.7f
, 0.8f
, 0.9f
, 32);
639 expect_vector(&n
[0], 1.1f
, 1.2f
, 1.3f
, 32);
640 expect_vector(&n
[1], 1.4f
, 1.5f
, 1.6f
, 32);
641 expect_vector(&n
[2], 1.7f
, 1.8f
, 1.9f
, 32);
642 ok(f
[0] == 3 , "Wrong component f[0] = %ld (expected 3)\n", f
[0]);
643 ok(f
[1] == 0 , "Wrong component f[1] = %ld (expected 0)\n", f
[1]);
644 ok(f
[2] == 0 , "Wrong component f[2] = %ld (expected 0)\n", f
[2]);
645 ok(f
[3] == 1 , "Wrong component f[3] = %ld (expected 1)\n", f
[3]);
646 ok(f
[4] == 1 , "Wrong component f[4] = %ld (expected 1)\n", f
[4]);
647 ok(f
[5] == 2 , "Wrong component f[5] = %ld (expected 2)\n", f
[5]);
648 ok(f
[6] == 2 , "Wrong component f[6] = %ld (expected 2)\n", f
[6]);
649 ok(f
[7] == 0 , "Wrong component f[7] = %ld (expected 0)\n", f
[7]);
651 hr
= IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder
, &mesh
);
652 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
656 unsigned nb_vertices
, nb_faces
, nb_face_vertices
;
658 IDirect3DRMMaterial
*material
= (IDirect3DRMMaterial
*)0xdeadbeef;
659 IDirect3DRMTexture
*texture
= (IDirect3DRMTexture
*)0xdeadbeef;
662 nb_groups
= IDirect3DRMMesh_GetGroupCount(mesh
);
663 ok(nb_groups
== 1, "GetCroupCount returned %lu.\n", nb_groups
);
664 hr
= IDirect3DRMMesh_GetGroup(mesh
, 1, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
665 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
666 hr
= IDirect3DRMMesh_GetGroup(mesh
, 0, &nb_vertices
, &nb_faces
, &nb_face_vertices
, &data_size
, NULL
);
667 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
668 ok(nb_vertices
== 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices
);
669 ok(nb_faces
== 1, "Wrong number of faces %u (must be 1)\n", nb_faces
);
670 ok(nb_face_vertices
== 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices
);
671 ok(data_size
== 3, "Wrong number of face data bytes %lu (must be 3)\n", data_size
);
672 color
= IDirect3DRMMesh_GetGroupColor(mesh
, 0);
673 ok(color
== 0xff00ff00, "Wrong color returned %#lx instead of %#x\n", color
, 0xff00ff00);
674 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, 0, &texture
);
675 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
676 ok(texture
== NULL
, "No texture should be present\n");
677 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, 0, &material
);
678 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
679 ok(material
!= NULL
, "No material present\n");
680 hr
= IDirect3DRMMaterial_GetEmissive(material
, &values
[0], &values
[1], &values
[2]);
681 ok(hr
== D3DRM_OK
, "Failed to get emissive color, hr %#lx.\n", hr
);
682 ok(values
[0] == 0.5f
, "Got unexpected red component %.8e.\n", values
[0]);
683 ok(values
[1] == 0.5f
, "Got unexpected green component %.8e.\n", values
[1]);
684 ok(values
[2] == 0.5f
, "Got unexpected blue component %.8e.\n", values
[2]);
685 hr
= IDirect3DRMMaterial_GetSpecular(material
, &values
[0], &values
[1], &values
[2]);
686 ok(hr
== D3DRM_OK
, "Failed to get specular color, hr %#lx.\n", hr
);
687 ok(values
[0] == 1.0f
, "Got unexpected red component %.8e.\n", values
[0]);
688 ok(values
[1] == 0.0f
, "Got unexpected green component %.8e.\n", values
[1]);
689 ok(values
[2] == 0.0f
, "Got unexpected blue component %.8e.\n", values
[2]);
690 values
[0] = IDirect3DRMMaterial_GetPower(material
);
691 ok(values
[0] == 30.0f
, "Got unexpected power value %.8e.\n", values
[0]);
692 IDirect3DRMMaterial_Release(material
);
694 IDirect3DRMMesh_Release(mesh
);
697 hr
= IDirect3DRMMeshBuilder_Scale(pMeshBuilder
, 2, 3 ,4);
698 ok(hr
== D3DRM_OK
, "Scale failed returning hr %#lx.\n", hr
);
700 hr
= IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder
, &val1
, v
, &val2
, n
, &val3
, f
);
701 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
702 ok(val2
== 3, "Wrong number of normals %ld (must be 3)\n", val2
);
703 ok(val1
== 3, "Wrong number of vertices %ld (must be 3)\n", val1
);
705 expect_vector(&v
[0], 0.1f
* 2, 0.2f
* 3, 0.3f
* 4, 32);
706 expect_vector(&v
[1], 0.4f
* 2, 0.5f
* 3, 0.6f
* 4, 32);
707 expect_vector(&v
[2], 0.7f
* 2, 0.8f
* 3, 0.9f
* 4, 32);
708 /* Normals are not affected by Scale */
709 expect_vector(&n
[0], 1.1f
, 1.2f
, 1.3f
, 32);
710 expect_vector(&n
[1], 1.4f
, 1.5f
, 1.6f
, 32);
711 expect_vector(&n
[2], 1.7f
, 1.8f
, 1.9f
, 32);
713 IDirect3DRMMeshBuilder_Release(pMeshBuilder
);
715 IDirect3DRM_Release(d3drm
);
718 static void test_MeshBuilder3(void)
722 IDirect3DRM3
*d3drm3
;
723 IDirect3DRMMeshBuilder3
*pMeshBuilder3
;
724 D3DRMLOADMEMORY info
;
729 hr
= Direct3DRMCreate(&d3drm
);
730 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
732 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
734 win_skip("Cannot get IDirect3DRM3 interface, hr %#lx, skipping tests\n", hr
);
735 IDirect3DRM_Release(d3drm
);
739 hr
= IDirect3DRM3_CreateMeshBuilder(d3drm3
, &pMeshBuilder3
);
740 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder3 interface, hr %#lx\n", hr
);
742 test_class_name((IDirect3DRMObject
*)pMeshBuilder3
, "Builder");
743 test_object_name((IDirect3DRMObject
*)pMeshBuilder3
);
745 info
.lpMemory
= data_bad_version
;
746 info
.dSize
= strlen(data_bad_version
);
747 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
748 ok(hr
== D3DRMERR_BADFILE
, "Should have returned D3DRMERR_BADFILE, hr %#lx\n", hr
);
750 info
.lpMemory
= data_no_mesh
;
751 info
.dSize
= strlen(data_no_mesh
);
752 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
753 ok(hr
== D3DRMERR_NOTFOUND
, "Should have returned D3DRMERR_NOTFOUND, hr %#lx\n", hr
);
755 info
.lpMemory
= data_ok
;
756 info
.dSize
= strlen(data_ok
);
757 hr
= IDirect3DRMMeshBuilder3_Load(pMeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
758 ok(hr
== D3DRM_OK
, "Cannot load mesh data, hr %#lx\n", hr
);
760 val
= IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3
);
761 ok(val
== 4, "Wrong number of vertices %d (must be 4)\n", val
);
763 val
= IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3
);
764 ok(val
== 3, "Wrong number of faces %d (must be 3)\n", val
);
766 hr
= IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3
, 0, &val1
, NULL
);
767 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
768 ok(val1
== 4, "Wrong number of vertices %ld (must be 4)\n", val1
);
770 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
773 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
774 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
775 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
776 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
779 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 1, &valu
, &valv
);
780 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
781 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
782 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
785 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 2, &valu
, &valv
);
786 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
787 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
788 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
791 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 3, &valu
, &valv
);
792 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
793 ok(valu
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valu
);
794 ok(valv
== 0.0f
, "Wrong coordinate %f (must be 0.0)\n", valv
);
795 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 4, &valu
, &valv
);
796 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr
);
800 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 0, valu
, valv
);
801 ok(hr
== D3DRM_OK
, "Cannot set texture coordinates, hr %#lx\n", hr
);
802 hr
= IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3
, 4, valu
, valv
);
803 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr
);
807 hr
= IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3
, 0, &valu
, &valv
);
808 ok(hr
== D3DRM_OK
, "Cannot get texture coordinates, hr %#lx\n", hr
);
809 ok(valu
== 1.23f
, "Wrong coordinate %f (must be 1.23)\n", valu
);
810 ok(valv
== 3.21f
, "Wrong coordinate %f (must be 3.21)\n", valv
);
812 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3
);
813 IDirect3DRM3_Release(d3drm3
);
814 IDirect3DRM_Release(d3drm
);
817 static void test_Mesh(void)
821 IDirect3DRMMesh
*mesh
;
824 hr
= Direct3DRMCreate(&d3drm
);
825 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
827 hr
= IDirect3DRM_CreateMesh(d3drm
, &mesh
);
828 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMesh interface, hr %#lx\n", hr
);
830 test_class_name((IDirect3DRMObject
*)mesh
, "Mesh");
831 test_object_name((IDirect3DRMObject
*)mesh
);
833 hr
= IDirect3DRMMesh_QueryInterface(mesh
, &IID_IDirect3DRMObject
, (void **)&unk
);
834 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
835 IUnknown_Release(unk
);
837 hr
= IDirect3DRMMesh_QueryInterface(mesh
, &IID_IDirect3DRMVisual
, (void **)&unk
);
838 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
839 IUnknown_Release(unk
);
841 IDirect3DRMMesh_Release(mesh
);
843 IDirect3DRM_Release(d3drm
);
846 static void test_Face(void)
850 IDirect3DRM2
*d3drm2
;
851 IDirect3DRM3
*d3drm3
;
852 IDirect3DRMMeshBuilder2
*MeshBuilder2
;
853 IDirect3DRMMeshBuilder3
*MeshBuilder3
;
854 IDirect3DRMFace
*face1
;
855 IDirect3DRMObject
*obj
;
856 IDirect3DRMFace2
*face2
;
857 IDirect3DRMFaceArray
*array1
;
858 D3DRMLOADMEMORY info
;
859 D3DVECTOR v1
[4], n1
[4], v2
[4], n2
[4];
863 D3DRMRENDERQUALITY quality
;
865 hr
= Direct3DRMCreate(&d3drm
);
866 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
868 hr
= IDirect3DRM_CreateFace(d3drm
, &face1
);
869 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace interface, hr %#lx\n", hr
);
872 skip("Cannot get IDirect3DRMFace interface, hr %#lx, skipping tests\n", hr
);
873 IDirect3DRM_Release(d3drm
);
877 hr
= IDirect3DRMFace_QueryInterface(face1
, &IID_IDirect3DRMObject
, (void **)&obj
);
878 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
879 ok(obj
== (IDirect3DRMObject
*)face1
, "Unexpected interface pointer.\n");
880 IDirect3DRMObject_Release(obj
);
882 test_class_name((IDirect3DRMObject
*)face1
, "Face");
883 test_object_name((IDirect3DRMObject
*)face1
);
885 icount
= IDirect3DRMFace_GetVertexCount(face1
);
886 ok(!icount
, "wrong VertexCount: %i\n", icount
);
888 IDirect3DRMFace_Release(face1
);
890 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM2
, (void **)&d3drm2
)))
892 win_skip("Cannot get IDirect3DRM2 interface, hr %#lx, skipping tests\n", hr
);
893 IDirect3DRM_Release(d3drm
);
897 hr
= IDirect3DRM2_CreateMeshBuilder(d3drm2
, &MeshBuilder2
);
898 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder2 interface, hr %#lx\n", hr
);
900 icount
= IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2
);
901 ok(!icount
, "wrong FaceCount: %i\n", icount
);
904 hr
= IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2
, &array1
);
906 ok(hr
== D3DRM_OK
, "Cannot get FaceArray, hr %#lx\n", hr
);
908 hr
= IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2
, &face1
);
909 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFace interface, hr %#lx\n", hr
);
911 icount
= IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2
);
913 ok(icount
== 1, "wrong FaceCount: %i\n", icount
);
916 hr
= IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2
, &array1
);
918 ok(hr
== D3DRM_OK
, "Cannot get FaceArray, hr %#lx\n", hr
);
920 ok(array1
!= NULL
, "pArray = %p\n", array1
);
923 IDirect3DRMFace
*face
;
924 count
= IDirect3DRMFaceArray_GetSize(array1
);
925 ok(count
== 1, "count = %lu\n", count
);
926 hr
= IDirect3DRMFaceArray_GetElement(array1
, 0, &face
);
927 ok(hr
== D3DRM_OK
, "Cannot get face, hr %#lx\n", hr
);
928 IDirect3DRMFace_Release(face
);
929 IDirect3DRMFaceArray_Release(array1
);
932 icount
= IDirect3DRMFace_GetVertexCount(face1
);
933 ok(!icount
, "wrong VertexCount: %i\n", icount
);
935 quality
= IDirect3DRMMeshBuilder3_GetQuality(MeshBuilder2
);
936 ok(quality
== D3DRMRENDER_GOURAUD
, "Unexpected %lx.\n", quality
);
938 hr
= IDirect3DRMMeshBuilder3_SetQuality(MeshBuilder2
, D3DRMRENDER_PHONG
);
939 ok(hr
== S_OK
, "got %lx.\n", hr
);
941 quality
= IDirect3DRMMeshBuilder3_GetQuality(MeshBuilder2
);
942 ok(quality
== D3DRMRENDER_PHONG
, "got %lx.\n", quality
);
944 hr
= IDirect3DRMMeshBuilder3_SetQuality(MeshBuilder2
, D3DRMRENDER_GOURAUD
);
945 ok(hr
== S_OK
, "got %lx.\n", hr
);
947 IDirect3DRMFace_Release(face1
);
948 IDirect3DRMMeshBuilder2_Release(MeshBuilder2
);
950 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
952 win_skip("Cannot get IDirect3DRM3 interface, hr %#lx, skipping tests\n", hr
);
953 IDirect3DRM_Release(d3drm
);
957 hr
= IDirect3DRM3_CreateMeshBuilder(d3drm3
, &MeshBuilder3
);
958 ok(hr
== D3DRM_OK
, "Unexpected hr %lx.\n", hr
);
960 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
961 ok(!icount
, "wrong FaceCount: %i\n", icount
);
963 hr
= IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3
, &face2
);
964 ok(hr
== D3DRM_OK
, "Unexpected hr %lx.\n", hr
);
966 hr
= IDirect3DRMFace2_QueryInterface(face2
, &IID_IDirect3DRMObject
, (void **)&obj
);
967 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
969 hr
= IDirect3DRMFace2_QueryInterface(face2
, &IID_IDirect3DRMFace
, (void **)&face1
);
970 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
971 ok(obj
== (IDirect3DRMObject
*)face1
, "Unexpected interface pointer.\n");
973 IDirect3DRMFace_Release(face1
);
974 IDirect3DRMObject_Release(obj
);
976 test_class_name((IDirect3DRMObject
*)face2
, "Face");
977 test_object_name((IDirect3DRMObject
*)face2
);
979 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
981 ok(icount
== 1, "wrong FaceCount: %i\n", icount
);
984 hr
= IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3
, &array1
);
986 ok(hr
== D3DRM_OK
, "Cannot get FaceArray, hr %#lx\n", hr
);
988 ok(array1
!= NULL
, "pArray = %p\n", array1
);
991 IDirect3DRMFace
*face
;
992 count
= IDirect3DRMFaceArray_GetSize(array1
);
993 ok(count
== 1, "count = %lu\n", count
);
994 hr
= IDirect3DRMFaceArray_GetElement(array1
, 0, &face
);
995 ok(hr
== D3DRM_OK
, "Cannot get face, hr %#lx\n", hr
);
996 IDirect3DRMFace_Release(face
);
997 IDirect3DRMFaceArray_Release(array1
);
1000 icount
= IDirect3DRMFace2_GetVertexCount(face2
);
1001 ok(!icount
, "wrong VertexCount: %i\n", icount
);
1003 info
.lpMemory
= data_ok
;
1004 info
.dSize
= strlen(data_ok
);
1005 hr
= IDirect3DRMMeshBuilder3_Load(MeshBuilder3
, &info
, NULL
, D3DRMLOAD_FROMMEMORY
, NULL
, NULL
);
1006 ok(hr
== D3DRM_OK
, "Cannot load mesh data, hr %#lx\n", hr
);
1008 icount
= IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3
);
1009 ok(icount
== 4, "Wrong number of vertices %d (must be 4)\n", icount
);
1011 icount
= IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3
);
1012 ok(icount
== 4, "Wrong number of normals %d (must be 4)\n", icount
);
1014 icount
= IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3
);
1016 ok(icount
== 4, "Wrong number of faces %d (must be 4)\n", icount
);
1019 hr
= IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3
, 0, &count
, v1
);
1020 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
1021 ok(count
== 4, "Wrong number of vertices %ld (must be 4)\n", count
);
1023 hr
= IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3
, 0, &count
, n1
);
1024 ok(hr
== D3DRM_OK
, "Cannot get normals information, hr %#lx\n", hr
);
1025 ok(count
== 4, "Wrong number of normals %ld (must be 4)\n", count
);
1028 hr
= IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3
, &array1
);
1030 ok(hr
== D3DRM_OK
, "Cannot get FaceArray, hr %#lx\n", hr
);
1032 ok(array1
!= NULL
, "pArray = %p\n", array1
);
1035 IDirect3DRMFace
*face
;
1036 count
= IDirect3DRMFaceArray_GetSize(array1
);
1037 ok(count
== 4, "count = %lu\n", count
);
1038 hr
= IDirect3DRMFaceArray_GetElement(array1
, 1, &face
);
1039 ok(hr
== D3DRM_OK
, "Cannot get face, hr %#lx\n", hr
);
1040 hr
= IDirect3DRMFace_GetVertices(face
, &count
, v2
, n2
);
1041 ok(hr
== D3DRM_OK
, "Cannot get vertices information, hr %#lx\n", hr
);
1042 ok(count
== 3, "Wrong number of vertices %ld (must be 3)\n", count
);
1044 vector_eq(&v1
[0], &v2
[0]);
1045 vector_eq(&v1
[1], &v2
[1]);
1046 vector_eq(&v1
[2], &v2
[2]);
1048 vector_eq(&n1
[0], &n2
[0]);
1049 vector_eq(&n1
[1], &n2
[1]);
1050 vector_eq(&n1
[2], &n2
[2]);
1052 IDirect3DRMFace_Release(face
);
1053 IDirect3DRMFaceArray_Release(array1
);
1056 /* Setting face color. */
1057 hr
= IDirect3DRMFace2_SetColor(face2
, 0x1f180587);
1058 ok(SUCCEEDED(hr
), "Failed to set face color, hr %#lx.\n", hr
);
1059 color
= IDirect3DRMFace2_GetColor(face2
);
1060 ok(color
== 0x1f180587, "Unexpected color %8lx.\n", color
);
1062 hr
= IDirect3DRMFace2_SetColorRGB(face2
, 0.5f
, 0.5f
, 0.5f
);
1063 ok(SUCCEEDED(hr
), "Failed to set color, hr %#lx.\n", hr
);
1064 color
= IDirect3DRMFace2_GetColor(face2
);
1065 ok(color
== 0xff7f7f7f, "Unexpected color %8lx.\n", color
);
1067 IDirect3DRMFace2_Release(face2
);
1068 IDirect3DRMMeshBuilder3_Release(MeshBuilder3
);
1069 IDirect3DRM3_Release(d3drm3
);
1070 IDirect3DRM2_Release(d3drm2
);
1071 IDirect3DRM_Release(d3drm
);
1074 static void test_Frame(void)
1078 IDirect3DRMFrame
*pFrameC
;
1079 IDirect3DRMFrame
*pFrameP1
;
1080 IDirect3DRMFrame
*pFrameP2
;
1081 IDirect3DRMFrame
*pFrameTmp
;
1082 IDirect3DRMFrame
*scene_frame
;
1083 IDirect3DRMFrameArray
*frame_array
;
1084 IDirect3DRMMeshBuilder
*mesh_builder
;
1085 IDirect3DRMVisual
*visual1
;
1086 IDirect3DRMVisual
*visual_tmp
;
1087 IDirect3DRMVisualArray
*visual_array
;
1088 IDirect3DRMLight
*light1
;
1089 IDirect3DRMLight
*light_tmp
;
1090 IDirect3DRMLightArray
*light_array
;
1091 IDirect3DRMFrame3
*frame3
;
1092 DWORD count
, options
;
1096 hr
= Direct3DRMCreate(&d3drm
);
1097 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
1099 ref
= get_refcount((IUnknown
*)d3drm
);
1100 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameC
);
1101 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
1102 CHECK_REFCOUNT(pFrameC
, 1);
1103 ref2
= get_refcount((IUnknown
*)d3drm
);
1104 ok(ref2
> ref
, "Expected d3drm object to be referenced.\n");
1106 test_class_name((IDirect3DRMObject
*)pFrameC
, "Frame");
1107 test_object_name((IDirect3DRMObject
*)pFrameC
);
1109 hr
= IDirect3DRMFrame_GetParent(pFrameC
, NULL
);
1110 ok(hr
== D3DRMERR_BADVALUE
, "Should fail and return D3DRM_BADVALUE, hr %#lx\n", hr
);
1111 pFrameTmp
= (void*)0xdeadbeef;
1112 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1113 ok(hr
== D3DRM_OK
, "Cannot get parent frame, hr %#lx\n", hr
);
1114 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1115 CHECK_REFCOUNT(pFrameC
, 1);
1118 hr
= IDirect3DRMFrame_GetChildren(pFrameC
, &frame_array
);
1119 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1120 ok(!!frame_array
, "frame_array = %p\n", frame_array
);
1123 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1124 ok(count
== 0, "count = %lu\n", count
);
1125 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1126 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr
);
1127 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1128 IDirect3DRMFrameArray_Release(frame_array
);
1131 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP1
);
1132 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
1134 /* GetParent with NULL pointer */
1135 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, NULL
);
1136 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr
);
1137 CHECK_REFCOUNT(pFrameP1
, 1);
1139 /* [Add/Delete]Child with NULL pointer */
1140 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, NULL
);
1141 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr
);
1142 CHECK_REFCOUNT(pFrameP1
, 1);
1144 hr
= IDirect3DRMFrame_DeleteChild(pFrameP1
, NULL
);
1145 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr
);
1146 CHECK_REFCOUNT(pFrameP1
, 1);
1148 /* Add child to first parent */
1149 pFrameTmp
= (void*)0xdeadbeef;
1150 hr
= IDirect3DRMFrame_GetParent(pFrameP1
, &pFrameTmp
);
1151 ok(hr
== D3DRM_OK
, "Cannot get parent frame, hr %#lx\n", hr
);
1152 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1154 hr
= IDirect3DRMFrame_AddChild(pFrameP1
, pFrameC
);
1155 ok(hr
== D3DRM_OK
, "Cannot add child frame, hr %#lx\n", hr
);
1156 CHECK_REFCOUNT(pFrameP1
, 1);
1157 CHECK_REFCOUNT(pFrameC
, 2);
1159 hr
= IDirect3DRMFrame_GetScene(pFrameC
, NULL
);
1160 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1161 hr
= IDirect3DRMFrame_GetScene(pFrameC
, &scene_frame
);
1162 ok(SUCCEEDED(hr
), "Cannot get scene, hr %#lx.\n", hr
);
1163 ok(scene_frame
== pFrameP1
, "Expected scene frame == %p, got %p.\n", pFrameP1
, scene_frame
);
1164 CHECK_REFCOUNT(pFrameP1
, 2);
1165 IDirect3DRMFrame_Release(scene_frame
);
1166 hr
= IDirect3DRMFrame_GetScene(pFrameP1
, &scene_frame
);
1167 ok(SUCCEEDED(hr
), "Cannot get scene, hr %#lx.\n", hr
);
1168 ok(scene_frame
== pFrameP1
, "Expected scene frame == %p, got %p.\n", pFrameP1
, scene_frame
);
1169 CHECK_REFCOUNT(pFrameP1
, 2);
1170 IDirect3DRMFrame_Release(scene_frame
);
1173 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &frame_array
);
1174 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1175 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
1176 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
1177 "Invalid refcount. Expected 3 (or 2) got %ld\n", get_refcount((IUnknown
*)pFrameC
));
1180 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1181 ok(count
== 1, "count = %lu\n", count
);
1182 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1183 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1184 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1185 ok((get_refcount((IUnknown
*)pFrameC
) == 4) || broken(get_refcount((IUnknown
*)pFrameC
) == 3),
1186 "Invalid refcount. Expected 4 (or 3) got %ld\n", get_refcount((IUnknown
*)pFrameC
));
1187 IDirect3DRMFrame_Release(pFrameTmp
);
1188 ok((get_refcount((IUnknown
*)pFrameC
) == 3) || broken(get_refcount((IUnknown
*)pFrameC
) == 2),
1189 "Invalid refcount. Expected 3 (or 2) got %ld\n", get_refcount((IUnknown
*)pFrameC
));
1190 IDirect3DRMFrameArray_Release(frame_array
);
1191 CHECK_REFCOUNT(pFrameC
, 2);
1194 pFrameTmp
= (void*)0xdeadbeef;
1195 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1196 ok(hr
== D3DRM_OK
, "Cannot get parent frame, hr %#lx\n", hr
);
1197 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
1198 CHECK_REFCOUNT(pFrameP1
, 2);
1199 IDirect3DRMFrame_Release(pFrameTmp
);
1200 CHECK_REFCOUNT(pFrameP1
, 1);
1202 /* Add child to second parent */
1203 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &pFrameP2
);
1204 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
1206 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1207 ok(hr
== D3DRM_OK
, "Cannot add child frame, hr %#lx\n", hr
);
1208 CHECK_REFCOUNT(pFrameC
, 2);
1211 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1212 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1215 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1216 ok(count
== 1, "count = %lu\n", count
);
1217 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1218 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1219 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1220 IDirect3DRMFrame_Release(pFrameTmp
);
1221 IDirect3DRMFrameArray_Release(frame_array
);
1225 hr
= IDirect3DRMFrame_GetChildren(pFrameP1
, &frame_array
);
1226 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1229 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1230 ok(count
== 0, "count = %lu\n", count
);
1231 pFrameTmp
= (void*)0xdeadbeef;
1232 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1233 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr
);
1234 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1235 IDirect3DRMFrameArray_Release(frame_array
);
1237 hr
= IDirect3DRMFrame_GetScene(pFrameC
, &scene_frame
);
1238 ok(SUCCEEDED(hr
), "Cannot get scene, hr %#lx.\n", hr
);
1239 ok(scene_frame
== pFrameP2
, "Expected scene frame == %p, got %p.\n", pFrameP2
, scene_frame
);
1240 CHECK_REFCOUNT(pFrameP2
, 2);
1241 IDirect3DRMFrame_Release(scene_frame
);
1242 hr
= IDirect3DRMFrame_GetScene(pFrameP2
, &scene_frame
);
1243 ok(SUCCEEDED(hr
), "Cannot get scene, hr %#lx.\n", hr
);
1244 ok(scene_frame
== pFrameP2
, "Expected scene frame == %p, got %p.\n", pFrameP2
, scene_frame
);
1245 CHECK_REFCOUNT(pFrameP2
, 2);
1246 IDirect3DRMFrame_Release(scene_frame
);
1248 pFrameTmp
= (void*)0xdeadbeef;
1249 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1250 ok(hr
== D3DRM_OK
, "Cannot get parent frame, hr %#lx\n", hr
);
1251 ok(pFrameTmp
== pFrameP2
, "pFrameTmp = %p\n", pFrameTmp
);
1252 CHECK_REFCOUNT(pFrameP2
, 2);
1253 CHECK_REFCOUNT(pFrameC
, 2);
1254 IDirect3DRMFrame_Release(pFrameTmp
);
1255 CHECK_REFCOUNT(pFrameP2
, 1);
1257 /* Add child again */
1258 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1259 ok(hr
== D3DRM_OK
, "Cannot add child frame, hr %#lx\n", hr
);
1260 CHECK_REFCOUNT(pFrameC
, 2);
1263 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1264 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1267 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1268 ok(count
== 1, "count = %lu\n", count
);
1269 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1270 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1271 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1272 IDirect3DRMFrame_Release(pFrameTmp
);
1273 IDirect3DRMFrameArray_Release(frame_array
);
1277 hr
= IDirect3DRMFrame_DeleteChild(pFrameP2
, pFrameC
);
1278 ok(hr
== D3DRM_OK
, "Cannot delete child frame, hr %#lx\n", hr
);
1279 CHECK_REFCOUNT(pFrameC
, 1);
1282 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1283 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1286 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1287 ok(count
== 0, "count = %lu\n", count
);
1288 pFrameTmp
= (void*)0xdeadbeef;
1289 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1290 ok(hr
== D3DRMERR_BADVALUE
, "Should have returned D3DRMERR_BADVALUE, hr %#lx\n", hr
);
1291 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1292 IDirect3DRMFrameArray_Release(frame_array
);
1295 pFrameTmp
= (void*)0xdeadbeef;
1296 hr
= IDirect3DRMFrame_GetParent(pFrameC
, &pFrameTmp
);
1297 ok(hr
== D3DRM_OK
, "Cannot get parent frame, hr %#lx\n", hr
);
1298 ok(pFrameTmp
== NULL
, "pFrameTmp = %p\n", pFrameTmp
);
1300 /* Add two children */
1301 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameC
);
1302 ok(hr
== D3DRM_OK
, "Cannot add child frame, hr %#lx\n", hr
);
1303 CHECK_REFCOUNT(pFrameC
, 2);
1305 hr
= IDirect3DRMFrame_AddChild(pFrameP2
, pFrameP1
);
1306 ok(hr
== D3DRM_OK
, "Cannot add child frame, hr %#lx\n", hr
);
1307 CHECK_REFCOUNT(pFrameP1
, 2);
1310 hr
= IDirect3DRMFrame_GetChildren(pFrameP2
, &frame_array
);
1311 ok(hr
== D3DRM_OK
, "Cannot get children, hr %#lx\n", hr
);
1314 count
= IDirect3DRMFrameArray_GetSize(frame_array
);
1315 ok(count
== 2, "count = %lu\n", count
);
1316 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 0, &pFrameTmp
);
1317 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1318 ok(pFrameTmp
== pFrameC
, "pFrameTmp = %p\n", pFrameTmp
);
1319 IDirect3DRMFrame_Release(pFrameTmp
);
1320 hr
= IDirect3DRMFrameArray_GetElement(frame_array
, 1, &pFrameTmp
);
1321 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1322 ok(pFrameTmp
== pFrameP1
, "pFrameTmp = %p\n", pFrameTmp
);
1323 IDirect3DRMFrame_Release(pFrameTmp
);
1324 IDirect3DRMFrameArray_Release(frame_array
);
1327 /* [Add/Delete]Visual with NULL pointer */
1328 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, NULL
);
1329 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr
);
1330 CHECK_REFCOUNT(pFrameP1
, 2);
1332 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, NULL
);
1333 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr
);
1334 CHECK_REFCOUNT(pFrameP1
, 2);
1337 hr
= IDirect3DRM_CreateMeshBuilder(d3drm
, &mesh_builder
);
1338 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMeshBuilder interface, hr %#lx\n", hr
);
1339 visual1
= (IDirect3DRMVisual
*)mesh_builder
;
1341 /* Add Visual to first parent */
1342 hr
= IDirect3DRMFrame_AddVisual(pFrameP1
, visual1
);
1343 ok(hr
== D3DRM_OK
, "Cannot add visual, hr %#lx\n", hr
);
1344 CHECK_REFCOUNT(pFrameP1
, 2);
1345 CHECK_REFCOUNT(visual1
, 2);
1347 visual_array
= NULL
;
1348 hr
= IDirect3DRMFrame_GetVisuals(pFrameP1
, &visual_array
);
1349 ok(hr
== D3DRM_OK
, "Cannot get visuals, hr %#lx\n", hr
);
1352 count
= IDirect3DRMVisualArray_GetSize(visual_array
);
1353 ok(count
== 1, "count = %lu\n", count
);
1354 hr
= IDirect3DRMVisualArray_GetElement(visual_array
, 0, &visual_tmp
);
1355 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1356 ok(visual_tmp
== visual1
, "visual_tmp = %p\n", visual_tmp
);
1357 IDirect3DRMVisual_Release(visual_tmp
);
1358 IDirect3DRMVisualArray_Release(visual_array
);
1362 hr
= IDirect3DRMFrame_DeleteVisual(pFrameP1
, visual1
);
1363 ok(hr
== D3DRM_OK
, "Cannot delete visual, hr %#lx\n", hr
);
1364 CHECK_REFCOUNT(pFrameP1
, 2);
1365 IDirect3DRMMeshBuilder_Release(mesh_builder
);
1367 /* [Add/Delete]Light with NULL pointer */
1368 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, NULL
);
1369 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr
);
1370 CHECK_REFCOUNT(pFrameP1
, 2);
1372 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, NULL
);
1373 ok(hr
== D3DRMERR_BADOBJECT
, "Should have returned D3DRMERR_BADOBJECT, hr %#lx\n", hr
);
1374 CHECK_REFCOUNT(pFrameP1
, 2);
1377 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.1, 0.2, 0.3, &light1
);
1378 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface, hr %#lx\n", hr
);
1380 /* Add Light to first parent */
1381 hr
= IDirect3DRMFrame_AddLight(pFrameP1
, light1
);
1382 ok(hr
== D3DRM_OK
, "Cannot add light, hr %#lx\n", hr
);
1383 CHECK_REFCOUNT(pFrameP1
, 2);
1384 CHECK_REFCOUNT(light1
, 2);
1387 hr
= IDirect3DRMFrame_GetLights(pFrameP1
, &light_array
);
1388 ok(hr
== D3DRM_OK
, "Cannot get lights, hr %#lx\n", hr
);
1391 count
= IDirect3DRMLightArray_GetSize(light_array
);
1392 ok(count
== 1, "count = %lu\n", count
);
1393 hr
= IDirect3DRMLightArray_GetElement(light_array
, 0, &light_tmp
);
1394 ok(hr
== D3DRM_OK
, "Cannot get element, hr %#lx\n", hr
);
1395 ok(light_tmp
== light1
, "light_tmp = %p\n", light_tmp
);
1396 IDirect3DRMLight_Release(light_tmp
);
1397 IDirect3DRMLightArray_Release(light_array
);
1401 hr
= IDirect3DRMFrame_DeleteLight(pFrameP1
, light1
);
1402 ok(hr
== D3DRM_OK
, "Cannot delete light, hr %#lx\n", hr
);
1403 CHECK_REFCOUNT(pFrameP1
, 2);
1404 IDirect3DRMLight_Release(light1
);
1406 /* Test SceneBackground on first parent */
1407 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1408 ok(color
== 0xff000000, "wrong color %lx.\n", color
);
1410 hr
= IDirect3DRMFrame_SetSceneBackground(pFrameP1
, 0xff180587);
1411 ok(hr
== D3DRM_OK
, "Cannot set color, hr %#lx\n", hr
);
1412 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1413 ok(color
== 0xff180587, "wrong color %lx.\n", color
);
1415 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1
, 0.5, 0.5, 0.5);
1416 ok(hr
== D3DRM_OK
, "Cannot set color, hr %#lx\n", hr
);
1417 color
= IDirect3DRMFrame_GetSceneBackground(pFrameP1
);
1418 ok(color
== 0xff7f7f7f, "wrong color %lx.\n", color
);
1420 /* Traversal options. */
1421 hr
= IDirect3DRMFrame_QueryInterface(pFrameP2
, &IID_IDirect3DRMFrame3
, (void **)&frame3
);
1422 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMFrame3 interface, hr %#lx.\n", hr
);
1424 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, NULL
);
1425 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1428 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, &options
);
1429 ok(SUCCEEDED(hr
), "Failed to get traversal options, hr %#lx.\n", hr
);
1430 ok(options
== (D3DRMFRAME_RENDERENABLE
| D3DRMFRAME_PICKENABLE
), "Unexpected default options %#lx.\n", options
);
1432 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, 0);
1433 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
1435 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, 0xf0000000);
1436 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1438 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, 0xf0000000 | D3DRMFRAME_PICKENABLE
);
1439 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1442 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, &options
);
1443 ok(SUCCEEDED(hr
), "Failed to get traversal options, hr %#lx.\n", hr
);
1444 ok(options
== 0, "Unexpected traversal options %#lx.\n", options
);
1446 hr
= IDirect3DRMFrame3_SetTraversalOptions(frame3
, D3DRMFRAME_PICKENABLE
);
1447 ok(SUCCEEDED(hr
), "Failed to set traversal options, hr %#lx.\n", hr
);
1450 hr
= IDirect3DRMFrame3_GetTraversalOptions(frame3
, &options
);
1451 ok(SUCCEEDED(hr
), "Failed to get traversal options, hr %#lx.\n", hr
);
1452 ok(options
== D3DRMFRAME_PICKENABLE
, "Unexpected traversal options %#lx.\n", options
);
1454 IDirect3DRMFrame3_Release(frame3
);
1457 IDirect3DRMFrame_Release(pFrameP2
);
1458 CHECK_REFCOUNT(pFrameC
, 1);
1459 CHECK_REFCOUNT(pFrameP1
, 1);
1461 IDirect3DRMFrame_Release(pFrameC
);
1462 IDirect3DRMFrame_Release(pFrameP1
);
1464 IDirect3DRM_Release(d3drm
);
1467 struct destroy_context
1469 IDirect3DRMObject
*obj
;
1470 unsigned int test_idx
;
1474 struct callback_order
1478 } corder
[3], d3drm_corder
[3];
1480 static void CDECL
destroy_callback(IDirect3DRMObject
*obj
, void *arg
)
1482 struct destroy_context
*ctxt
= arg
;
1483 ok(ctxt
->called
== 1 || ctxt
->called
== 2, "got called counter %d\n", ctxt
->called
);
1484 ok(obj
== ctxt
->obj
, "called with %p, expected %p\n", obj
, ctxt
->obj
);
1485 d3drm_corder
[ctxt
->called
].callback
= &destroy_callback
;
1486 d3drm_corder
[ctxt
->called
++].context
= ctxt
;
1489 static void CDECL
destroy_callback1(IDirect3DRMObject
*obj
, void *arg
)
1491 struct destroy_context
*ctxt
= (struct destroy_context
*)arg
;
1492 ok(ctxt
->called
== 0, "got called counter %d\n", ctxt
->called
);
1493 ok(obj
== ctxt
->obj
, "called with %p, expected %p\n", obj
, ctxt
->obj
);
1494 d3drm_corder
[ctxt
->called
].callback
= &destroy_callback1
;
1495 d3drm_corder
[ctxt
->called
++].context
= ctxt
;
1498 static void test_destroy_callback(unsigned int test_idx
, REFCLSID clsid
, REFIID iid
)
1500 struct destroy_context context
;
1501 IDirect3DRMObject
*obj
;
1507 hr
= Direct3DRMCreate(&d3drm
);
1508 ok(SUCCEEDED(hr
), "Test %u: Cannot get IDirect3DRM interface, hr %#lx.\n", test_idx
, hr
);
1510 hr
= IDirect3DRM_CreateObject(d3drm
, clsid
, NULL
, iid
, (void **)&unknown
);
1511 ok(hr
== D3DRM_OK
, "Test %u: Cannot get IDirect3DRMObject interface, hr %#lx.\n", test_idx
, hr
);
1512 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirect3DRMObject
, (void**)&obj
);
1513 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1514 IUnknown_Release(unknown
);
1517 context
.test_idx
= test_idx
;
1520 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, NULL
, &context
);
1521 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected D3DRMERR_BADVALUE, hr %#lx.\n", test_idx
, hr
);
1523 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1524 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1525 corder
[2].callback
= &destroy_callback
;
1526 corder
[2].context
= &context
;
1528 /* same callback added twice */
1529 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1530 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1531 corder
[1].callback
= &destroy_callback
;
1532 corder
[1].context
= &context
;
1534 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback1
, NULL
);
1535 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1537 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback1
, &context
);
1538 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1541 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback1
, &context
);
1542 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1543 corder
[0].callback
= &destroy_callback1
;
1544 corder
[0].context
= &context
;
1546 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, NULL
, NULL
);
1547 ok(hr
== D3DRMERR_BADVALUE
, "Test %u: expected D3DRM_BADVALUE, hr %#lx.\n", test_idx
, hr
);
1550 IDirect3DRMObject_Release(obj
);
1551 ok(context
.called
== 3, "Test %u: got %d, expected 3.\n", test_idx
, context
.called
);
1552 for (i
= 0; i
< context
.called
; i
++)
1554 ok(corder
[i
].callback
== d3drm_corder
[i
].callback
1555 && corder
[i
].context
== d3drm_corder
[i
].context
,
1556 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder
[i
].callback
,
1557 d3drm_corder
[i
].context
, corder
[i
].callback
, corder
[i
].context
);
1560 /* test this pattern - add cb1, add cb2, add cb1, delete cb1 */
1561 hr
= IDirect3DRM_CreateObject(d3drm
, clsid
, NULL
, iid
, (void **)&unknown
);
1562 ok(hr
== D3DRM_OK
, "Test %u: Cannot get IDirect3DRMObject interface, hr %#lx.\n", test_idx
, hr
);
1563 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirect3DRMObject
, (void**)&obj
);
1564 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1565 IUnknown_Release(unknown
);
1567 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1568 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1569 corder
[1].callback
= &destroy_callback
;
1570 corder
[1].context
= &context
;
1572 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback1
, &context
);
1573 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1574 corder
[0].callback
= &destroy_callback1
;
1575 corder
[0].context
= &context
;
1577 hr
= IDirect3DRMObject_AddDestroyCallback(obj
, destroy_callback
, &context
);
1578 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1580 hr
= IDirect3DRMObject_DeleteDestroyCallback(obj
, destroy_callback
, &context
);
1581 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1584 hr
= IDirect3DRMObject_QueryInterface(obj
, &IID_IDirect3DRMObject
, (void**)&context
.obj
);
1585 ok(hr
== D3DRM_OK
, "Test %u: expected D3DRM_OK, hr %#lx.\n", test_idx
, hr
);
1586 IDirect3DRMObject_Release(context
.obj
);
1587 IUnknown_Release(unknown
);
1588 ok(context
.called
== 2, "Test %u: got %d, expected 2.\n", test_idx
, context
.called
);
1589 for (i
= 0; i
< context
.called
; i
++)
1591 ok(corder
[i
].callback
== d3drm_corder
[i
].callback
1592 && corder
[i
].context
== d3drm_corder
[i
].context
,
1593 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder
[i
].callback
,
1594 d3drm_corder
[i
].context
, corder
[i
].callback
, corder
[i
].context
);
1597 IDirect3DRM_Release(d3drm
);
1600 static void test_object(void)
1606 BOOL takes_d3drm_ref
;
1610 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice
},
1611 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice2
},
1612 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMDevice3
},
1613 { &CLSID_CDirect3DRMDevice
, &IID_IDirect3DRMWinDevice
},
1614 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture
},
1615 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture2
},
1616 { &CLSID_CDirect3DRMTexture
, &IID_IDirect3DRMTexture3
},
1617 { &CLSID_CDirect3DRMViewport
, &IID_IDirect3DRMViewport
},
1618 { &CLSID_CDirect3DRMViewport
, &IID_IDirect3DRMViewport2
},
1619 { &CLSID_CDirect3DRMFace
, &IID_IDirect3DRMFace
},
1620 { &CLSID_CDirect3DRMFace
, &IID_IDirect3DRMFace2
},
1621 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder
, TRUE
},
1622 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder2
, TRUE
},
1623 { &CLSID_CDirect3DRMMeshBuilder
, &IID_IDirect3DRMMeshBuilder3
, TRUE
},
1624 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame
, TRUE
},
1625 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame2
, TRUE
},
1626 { &CLSID_CDirect3DRMFrame
, &IID_IDirect3DRMFrame3
, TRUE
},
1627 { &CLSID_CDirect3DRMLight
, &IID_IDirect3DRMLight
, TRUE
},
1628 { &CLSID_CDirect3DRMMaterial
, &IID_IDirect3DRMMaterial
, TRUE
},
1629 { &CLSID_CDirect3DRMMaterial
, &IID_IDirect3DRMMaterial2
, TRUE
},
1630 { &CLSID_CDirect3DRMMesh
, &IID_IDirect3DRMMesh
, TRUE
},
1631 { &CLSID_CDirect3DRMAnimation
, &IID_IDirect3DRMAnimation
, TRUE
},
1632 { &CLSID_CDirect3DRMAnimation
, &IID_IDirect3DRMAnimation2
, TRUE
},
1633 { &CLSID_CDirect3DRMWrap
, &IID_IDirect3DRMWrap
},
1635 IDirect3DRM
*d3drm1
;
1636 IDirect3DRM2
*d3drm2
;
1637 IDirect3DRM3
*d3drm3
;
1638 IUnknown
*unknown
= (IUnknown
*)0xdeadbeef;
1640 ULONG ref1
, ref2
, ref3
, ref4
;
1643 hr
= Direct3DRMCreate(&d3drm1
);
1644 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
1645 ref1
= get_refcount((IUnknown
*)d3drm1
);
1646 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
1647 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
1648 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
1649 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
1651 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_DirectDraw
, NULL
, &IID_IDirectDraw
, (void **)&unknown
);
1652 ok(hr
== CLASSFACTORY_E_FIRST
, "Expected hr == CLASSFACTORY_E_FIRST, got %#lx.\n", hr
);
1653 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1655 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
1657 winetest_push_context("Test %u", i
);
1659 unknown
= (IUnknown
*)0xdeadbeef;
1660 hr
= IDirect3DRM_CreateObject(d3drm1
, NULL
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1661 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1662 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1663 unknown
= (IUnknown
*)0xdeadbeef;
1664 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, NULL
, (void **)&unknown
);
1665 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1666 ok(!unknown
, "Expected object returned == NULL, got %p.\n", unknown
);
1667 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, NULL
, NULL
);
1668 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1670 hr
= IDirect3DRM_CreateObject(d3drm1
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1671 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
1674 ref2
= get_refcount((IUnknown
*)d3drm1
);
1675 if (tests
[i
].takes_d3drm_ref
)
1676 ok(ref2
> ref1
, "Unexpected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1678 ok(ref2
== ref1
, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1680 ref3
= get_refcount((IUnknown
*)d3drm2
);
1681 ok(ref3
== ref1
, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
1682 ref4
= get_refcount((IUnknown
*)d3drm3
);
1683 ok(ref4
== ref1
, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1684 IUnknown_Release(unknown
);
1685 ref2
= get_refcount((IUnknown
*)d3drm1
);
1686 ok(ref2
== ref1
, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1687 ref3
= get_refcount((IUnknown
*)d3drm2
);
1688 ok(ref3
== ref1
, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
1689 ref4
= get_refcount((IUnknown
*)d3drm3
);
1690 ok(ref4
== ref1
, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1692 /* test Add/Destroy callbacks */
1693 test_destroy_callback(i
, tests
[i
].clsid
, tests
[i
].iid
);
1695 hr
= IDirect3DRM2_CreateObject(d3drm2
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1696 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
1697 ref2
= get_refcount((IUnknown
*)d3drm1
);
1698 if (tests
[i
].takes_d3drm_ref
)
1699 ok(ref2
> ref1
, "Unexpected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1701 ok(ref2
== ref1
, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1702 ref3
= get_refcount((IUnknown
*)d3drm2
);
1703 ok(ref3
== ref1
, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
1704 ref4
= get_refcount((IUnknown
*)d3drm3
);
1705 ok(ref4
== ref1
, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1706 IUnknown_Release(unknown
);
1707 ref2
= get_refcount((IUnknown
*)d3drm1
);
1708 ok(ref2
== ref1
, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1709 ref3
= get_refcount((IUnknown
*)d3drm2
);
1710 ok(ref3
== ref1
, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
1711 ref4
= get_refcount((IUnknown
*)d3drm3
);
1712 ok(ref4
== ref1
, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1714 hr
= IDirect3DRM3_CreateObject(d3drm3
, tests
[i
].clsid
, NULL
, tests
[i
].iid
, (void **)&unknown
);
1715 ok(SUCCEEDED(hr
), "Unexpected hr %#lx.\n", hr
);
1716 ref2
= get_refcount((IUnknown
*)d3drm1
);
1717 if (tests
[i
].takes_d3drm_ref
)
1718 ok(ref2
> ref1
, "Unexpected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1720 ok(ref2
== ref1
, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1721 ref3
= get_refcount((IUnknown
*)d3drm2
);
1722 ok(ref3
== ref1
, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
1723 ref4
= get_refcount((IUnknown
*)d3drm3
);
1724 ok(ref4
== ref1
, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1725 IUnknown_Release(unknown
);
1726 ref2
= get_refcount((IUnknown
*)d3drm1
);
1727 ok(ref2
== ref1
, "Unexpected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
1728 ref3
= get_refcount((IUnknown
*)d3drm2
);
1729 ok(ref3
== ref1
, "Unexpected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
1730 ref4
= get_refcount((IUnknown
*)d3drm3
);
1731 ok(ref4
== ref1
, "Unexpected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1734 winetest_pop_context();
1737 IDirect3DRM_Release(d3drm1
);
1738 IDirect3DRM2_Release(d3drm2
);
1739 IDirect3DRM3_Release(d3drm3
);
1742 static void test_Viewport(void)
1744 IDirect3DRMFrame3
*frame3
, *d3drm_frame3
, *tmp_frame3
;
1745 IDirect3DRMFrame
*frame
, *d3drm_frame
, *tmp_frame1
;
1746 float field
, left
, top
, right
, bottom
, front
, back
;
1747 D3DRMPROJECTIONTYPE projection
;
1748 IDirectDrawClipper
*clipper
;
1750 IDirect3DRM
*d3drm1
;
1751 IDirect3DRM2
*d3drm2
;
1752 IDirect3DRM3
*d3drm3
;
1753 IDirect3DRMDevice
*device1
, *d3drm_device1
;
1754 IDirect3DRMDevice3
*device3
, *d3drm_device3
;
1755 IDirect3DRMViewport
*viewport
;
1756 IDirect3DRMViewport2
*viewport2
;
1757 IDirect3DViewport
*d3d_viewport
;
1759 D3DVALUE expected_val
;
1760 IDirect3DRMObject
*obj
, *obj2
;
1764 DWORD data
, ref1
, ref2
, ref3
, ref4
;
1765 DWORD initial_ref1
, initial_ref2
, initial_ref3
, device_ref
, frame_ref
, frame_ref2
, viewport_ref
;
1767 window
= create_window();
1768 GetClientRect(window
, &rc
);
1770 hr
= Direct3DRMCreate(&d3drm1
);
1771 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
1772 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
1773 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
1774 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
1775 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
1776 initial_ref1
= get_refcount((IUnknown
*)d3drm1
);
1777 initial_ref2
= get_refcount((IUnknown
*)d3drm2
);
1778 initial_ref3
= get_refcount((IUnknown
*)d3drm3
);
1780 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
1781 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface, hr %#lx\n", hr
);
1783 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
1784 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper, hr %#lx\n", hr
);
1786 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
1787 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
1788 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr
);
1789 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice
, (void **)&device1
);
1790 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface, hr %#lx.\n", hr
);
1792 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame
);
1793 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
1794 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &tmp_frame1
);
1795 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1796 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
1797 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface, hr %#lx.\n", hr
);
1798 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &tmp_frame3
);
1799 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1801 ref1
= get_refcount((IUnknown
*)d3drm1
);
1802 ref2
= get_refcount((IUnknown
*)d3drm2
);
1803 ref3
= get_refcount((IUnknown
*)d3drm3
);
1804 device_ref
= get_refcount((IUnknown
*)device1
);
1805 frame_ref
= get_refcount((IUnknown
*)frame
);
1807 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, 0, 0, 0, 0, &viewport
);
1808 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr
);
1809 ref4
= get_refcount((IUnknown
*)d3drm1
);
1810 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1811 ref4
= get_refcount((IUnknown
*)d3drm2
);
1812 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
1813 ref4
= get_refcount((IUnknown
*)d3drm3
);
1814 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
1815 ref4
= get_refcount((IUnknown
*)device1
);
1816 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
1817 ref4
= get_refcount((IUnknown
*)frame
);
1818 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
1820 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1821 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr
);
1822 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device1
, d3drm_device1
);
1823 IDirect3DRMDevice_Release(d3drm_device1
);
1825 hr
= IDirect3DRMViewport_SetCamera(viewport
, NULL
);
1826 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
1827 hr
= IDirect3DRMViewport_GetCamera(viewport
, &d3drm_frame
);
1828 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1829 ok(frame
== d3drm_frame
, "Expected frame returned = %p, got %p.\n", frame
, d3drm_frame
);
1830 IDirect3DRMFrame_Release(d3drm_frame
);
1832 hr
= IDirect3DRMViewport_SetCamera(viewport
, tmp_frame1
);
1833 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1834 hr
= IDirect3DRMViewport_GetCamera(viewport
, &d3drm_frame
);
1835 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1836 ok(d3drm_frame
== tmp_frame1
, "Got unexpected frame %p, expected %p.\n", d3drm_frame
, tmp_frame1
);
1837 IDirect3DRMFrame_Release(d3drm_frame
);
1839 IDirect3DRMViewport_Release(viewport
);
1840 ref4
= get_refcount((IUnknown
*)d3drm1
);
1841 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1842 ref4
= get_refcount((IUnknown
*)d3drm2
);
1843 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
1844 ref4
= get_refcount((IUnknown
*)d3drm3
);
1845 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
1846 ref4
= get_refcount((IUnknown
*)device1
);
1847 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
1848 ref4
= get_refcount((IUnknown
*)frame
);
1849 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
1851 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, 0, 0, 0, 0, &viewport
);
1852 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr
);
1853 ref4
= get_refcount((IUnknown
*)d3drm1
);
1854 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1855 ref4
= get_refcount((IUnknown
*)d3drm2
);
1856 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
1857 ref4
= get_refcount((IUnknown
*)d3drm3
);
1858 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
1859 ref4
= get_refcount((IUnknown
*)device1
);
1860 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
1861 ref4
= get_refcount((IUnknown
*)frame
);
1862 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
1864 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
1865 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr
);
1866 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device1
, d3drm_device1
);
1867 IDirect3DRMDevice_Release(d3drm_device1
);
1869 hr
= IDirect3DRMViewport_SetCamera(viewport
, NULL
);
1870 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
1871 hr
= IDirect3DRMViewport_GetCamera(viewport
, &d3drm_frame
);
1872 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1873 ok(frame
== d3drm_frame
, "Expected frame returned = %p, got %p.\n", frame
, d3drm_frame
);
1874 IDirect3DRMFrame_Release(d3drm_frame
);
1876 hr
= IDirect3DRMViewport_SetCamera(viewport
, tmp_frame1
);
1877 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1878 hr
= IDirect3DRMViewport_GetCamera(viewport
, &d3drm_frame
);
1879 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1880 ok(d3drm_frame
== tmp_frame1
, "Got unexpected frame %p, expected %p.\n", d3drm_frame
, tmp_frame1
);
1881 IDirect3DRMFrame_Release(d3drm_frame
);
1883 IDirect3DRMViewport_Release(viewport
);
1884 ref4
= get_refcount((IUnknown
*)d3drm1
);
1885 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1886 ref4
= get_refcount((IUnknown
*)d3drm2
);
1887 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
1888 ref4
= get_refcount((IUnknown
*)d3drm3
);
1889 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
1890 ref4
= get_refcount((IUnknown
*)device1
);
1891 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
1892 ref4
= get_refcount((IUnknown
*)frame
);
1893 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
1895 device_ref
= get_refcount((IUnknown
*)device3
);
1896 frame_ref2
= get_refcount((IUnknown
*)frame3
);
1898 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, 0, 0, 0, 0, &viewport2
);
1899 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr
);
1900 ref4
= get_refcount((IUnknown
*)d3drm1
);
1901 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1902 ref4
= get_refcount((IUnknown
*)d3drm2
);
1903 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
1904 ref4
= get_refcount((IUnknown
*)d3drm3
);
1905 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
1906 ref4
= get_refcount((IUnknown
*)device3
);
1907 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
1908 ref4
= get_refcount((IUnknown
*)frame3
);
1909 ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2
, ref4
);
1911 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
1912 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr
);
1913 ok(device3
== d3drm_device3
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
1914 IDirect3DRMDevice3_Release(d3drm_device3
);
1916 hr
= IDirect3DRMViewport2_SetCamera(viewport2
, NULL
);
1917 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
1918 hr
= IDirect3DRMViewport2_GetCamera(viewport2
, &d3drm_frame3
);
1919 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1920 ok(frame3
== d3drm_frame3
, "Expected frame returned = %p, got %p.\n", frame3
, d3drm_frame3
);
1921 IDirect3DRMFrame3_Release(d3drm_frame3
);
1923 hr
= IDirect3DRMViewport2_SetCamera(viewport2
, tmp_frame3
);
1924 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1925 hr
= IDirect3DRMViewport2_GetCamera(viewport2
, &d3drm_frame3
);
1926 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
1927 ok(d3drm_frame3
== tmp_frame3
, "Got unexpected frame %p, expected %p.\n", d3drm_frame3
, tmp_frame3
);
1928 IDirect3DRMFrame3_Release(d3drm_frame3
);
1930 IDirect3DRMViewport2_Release(viewport2
);
1931 ref4
= get_refcount((IUnknown
*)d3drm1
);
1932 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
1933 ref4
= get_refcount((IUnknown
*)d3drm2
);
1934 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
1935 ref4
= get_refcount((IUnknown
*)d3drm3
);
1936 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
1937 ref4
= get_refcount((IUnknown
*)device3
);
1938 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
1939 ref4
= get_refcount((IUnknown
*)frame3
);
1940 ok(ref4
== frame_ref2
, "Expected ref4 == frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2
, ref4
);
1942 /* Test all failures together */
1943 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1944 hr
= IDirect3DRM_CreateViewport(d3drm1
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1945 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
1946 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1947 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1948 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1949 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
1950 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1951 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1952 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport
);
1953 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1954 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1955 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1956 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport
);
1957 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1958 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1959 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1960 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport
);
1961 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1962 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1963 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1964 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1966 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1967 hr
= IDirect3DRM2_CreateViewport(d3drm2
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1968 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
1969 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1970 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1971 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
1972 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
1973 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1974 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1975 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport
);
1976 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1977 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1978 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1979 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport
);
1980 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1981 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1982 viewport
= (IDirect3DRMViewport
*)0xdeadbeef;
1983 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport
);
1984 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1985 ok(!viewport
, "Expected viewport returned == NULL, got %p.\n", viewport
);
1986 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
1987 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
1989 viewport2
= (IDirect3DRMViewport2
*)0xdeadbeef;
1990 hr
= IDirect3DRM3_CreateViewport(d3drm3
, NULL
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1991 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
1992 ok(!viewport2
, "Expected viewport returned == NULL, got %p.\n", viewport2
);
1993 viewport2
= (IDirect3DRMViewport2
*)0xdeadbeef;
1994 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
1995 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
1996 ok(!viewport2
, "Expected viewport returned == NULL, got %p.\n", viewport2
);
1997 viewport2
= (IDirect3DRMViewport2
*)0xdeadbeef;
1998 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1, &viewport2
);
1999 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2000 ok(!viewport2
, "Expected viewport returned == NULL, got %p.\n", viewport2
);
2001 viewport2
= (IDirect3DRMViewport2
*)0xdeadbeef;
2002 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
, &viewport2
);
2003 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2004 ok(!viewport2
, "Expected viewport returned == NULL, got %p.\n", viewport2
);
2005 viewport2
= (IDirect3DRMViewport2
*)0xdeadbeef;
2006 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1, &viewport2
);
2007 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2008 ok(!viewport2
, "Expected viewport returned == NULL, got %p.\n", viewport2
);
2009 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, NULL
);
2010 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2012 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
2013 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr
);
2014 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2015 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2016 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2017 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2018 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2019 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2020 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2021 IDirect3DViewport_Release(d3d_viewport
);
2022 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2023 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2024 IDirect3DViewport_Release(d3d_viewport
);
2026 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2027 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2028 vp
.dwSize
= sizeof(vp
);
2029 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2030 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr
);
2031 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %lu, got %lu.\n", rc
.right
, vp
.dwWidth
);
2032 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %lu, got %lu.\n", rc
.bottom
, vp
.dwHeight
);
2033 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %lu, got %lu.\n", rc
.left
, vp
.dwX
);
2034 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %lu, got %lu.\n", rc
.top
, vp
.dwY
);
2035 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2036 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2037 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2038 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2039 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2040 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2041 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2042 IDirect3DViewport_Release(d3d_viewport
);
2043 IDirect3DRMViewport_Release(viewport
);
2045 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport2
);
2046 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr
);
2047 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2048 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2049 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2050 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2051 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2052 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2053 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2054 IDirect3DViewport_Release(d3d_viewport
);
2055 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2056 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2057 IDirect3DViewport_Release(d3d_viewport
);
2059 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2060 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2061 vp
.dwSize
= sizeof(vp
);
2062 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2063 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr
);
2064 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %lu, got %lu.\n", rc
.right
, vp
.dwWidth
);
2065 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %lu, got %lu.\n", rc
.bottom
, vp
.dwHeight
);
2066 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %lu, got %lu.\n", rc
.left
, vp
.dwX
);
2067 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %lu, got %lu.\n", rc
.top
, vp
.dwY
);
2068 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2069 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2070 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2071 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2072 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2073 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2074 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2075 IDirect3DViewport_Release(d3d_viewport
);
2076 IDirect3DRMViewport2_Release(viewport2
);
2078 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, &viewport
);
2079 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr
);
2080 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2081 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2082 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2083 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2084 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2085 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2086 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2087 IDirect3DViewport_Release(d3d_viewport
);
2088 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2089 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2090 IDirect3DViewport_Release(d3d_viewport
);
2092 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2093 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2094 vp
.dwSize
= sizeof(vp
);
2095 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2096 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr
);
2097 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %lu, got %lu.\n", rc
.right
, vp
.dwWidth
);
2098 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %lu, got %lu.\n", rc
.bottom
, vp
.dwHeight
);
2099 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %lu, got %lu.\n", rc
.left
, vp
.dwX
);
2100 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %lu, got %lu.\n", rc
.top
, vp
.dwY
);
2101 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2102 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2103 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2104 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2105 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2106 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2107 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2108 IDirect3DViewport_Release(d3d_viewport
);
2110 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMObject
, (void**)&obj
);
2111 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2112 ok((IDirect3DRMObject
*)viewport
== obj
, "got object pointer %p, expected %p\n", obj
, viewport
);
2114 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMViewport2
, (void**)&viewport2
);
2115 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2117 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IDirect3DRMObject
, (void**)&obj2
);
2118 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2119 ok(obj
== obj2
, "got object pointer %p, expected %p\n", obj2
, obj
);
2120 ok((IUnknown
*)viewport
!= (IUnknown
*)viewport2
, "got viewport1 %p, viewport2 %p\n", viewport
, viewport2
);
2122 IDirect3DRMViewport2_Release(viewport2
);
2123 IDirect3DRMObject_Release(obj
);
2124 IDirect3DRMObject_Release(obj2
);
2126 test_class_name((IDirect3DRMObject
*)viewport
, "Viewport");
2127 test_object_name((IDirect3DRMObject
*)viewport
);
2130 hr
= IDirect3DRMViewport_SetAppData(viewport
, 0);
2131 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2133 hr
= IDirect3DRMViewport_SetAppData(viewport
, 0);
2134 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2136 hr
= IDirect3DRMViewport_SetAppData(viewport
, 1);
2137 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2139 hr
= IDirect3DRMViewport_SetAppData(viewport
, 1);
2140 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2142 hr
= IDirect3DRMViewport_QueryInterface(viewport
, &IID_IDirect3DRMViewport2
, (void**)&viewport2
);
2143 ok(hr
== D3DRM_OK
, "expected D3DRM_OK, hr %#lx\n", hr
);
2145 data
= IDirect3DRMViewport2_GetAppData(viewport2
);
2146 ok(data
== 1, "got %lx\n", data
);
2147 IDirect3DRMViewport2_Release(viewport2
);
2148 IDirect3DRMViewport_Release(viewport
);
2150 /* IDirect3DRMViewport*::Init tests */
2151 ref1
= get_refcount((IUnknown
*)d3drm1
);
2152 ref2
= get_refcount((IUnknown
*)d3drm2
);
2153 ref3
= get_refcount((IUnknown
*)d3drm3
);
2154 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMViewport
, NULL
, &IID_IDirect3DRMViewport
,
2155 (void **)&viewport
);
2156 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface, hr %#lx.\n", hr
);
2157 ref4
= get_refcount((IUnknown
*)d3drm1
);
2158 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2159 ref4
= get_refcount((IUnknown
*)d3drm2
);
2160 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
2161 ref4
= get_refcount((IUnknown
*)d3drm3
);
2162 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
2164 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2165 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2166 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
2167 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2168 hr
= IDirect3DRMViewport_GetCamera(viewport
, &d3drm_frame
);
2169 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2170 field
= IDirect3DRMViewport_GetField(viewport
);
2171 ok(field
== -1.0f
, "Got unexpected field %.8e.\n", field
);
2172 left
= right
= bottom
= top
= 10.0f
;
2173 hr
= IDirect3DRMViewport_GetPlane(viewport
, &left
, &right
, &bottom
, &top
);
2174 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2175 ok(left
== 10.0f
, "Got unexpected left %.8e.\n", left
);
2176 ok(right
== 10.0f
, "Got unexpected right %.8e.\n", right
);
2177 ok(bottom
== 10.0f
, "Got unexpected bottom %.8e.\n", bottom
);
2178 ok(top
== 10.0f
, "Got unexpected top %.8e.\n", top
);
2179 front
= IDirect3DRMViewport_GetFront(viewport
);
2180 ok(front
== -1.0f
, "Got unexpected front %.8e\n", front
);
2181 back
= IDirect3DRMViewport_GetBack(viewport
);
2182 ok(back
== -1.0f
, "Got unexpected back %.8e\n", back
);
2183 projection
= IDirect3DRMViewport_GetProjection(viewport
);
2184 ok(projection
== ~0u, "Got unexpected projection type %#x.\n", projection
);
2186 hr
= IDirect3DRMViewport_SetCamera(viewport
, frame
);
2187 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2188 hr
= IDirect3DRMViewport_SetField(viewport
, 0.5f
);
2189 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2190 hr
= IDirect3DRMViewport_SetPlane(viewport
, -0.5f
, 0.5f
, -0.5f
, 0.5f
);
2191 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2192 hr
= IDirect3DRMViewport_SetFront(viewport
, 1.0f
);
2193 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2194 hr
= IDirect3DRMViewport_SetBack(viewport
, 100.0f
);
2195 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2196 hr
= IDirect3DRMViewport_SetProjection(viewport
, D3DRMPROJECT_PERSPECTIVE
);
2197 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2199 /* Test all failures together */
2200 hr
= IDirect3DRMViewport_Init(viewport
, NULL
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2201 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2202 hr
= IDirect3DRMViewport_Init(viewport
, device1
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2203 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2204 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
2205 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2206 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
);
2207 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2208 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1);
2209 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2211 device_ref
= get_refcount((IUnknown
*)device1
);
2212 frame_ref
= get_refcount((IUnknown
*)frame
);
2213 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2214 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMViewport interface, hr %#lx.\n", hr
);
2215 ref4
= get_refcount((IUnknown
*)d3drm1
);
2216 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2217 ref4
= get_refcount((IUnknown
*)d3drm2
);
2218 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
2219 ref4
= get_refcount((IUnknown
*)d3drm3
);
2220 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
2221 ref4
= get_refcount((IUnknown
*)device1
);
2222 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
2223 ref4
= get_refcount((IUnknown
*)frame
);
2224 ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
2226 hr
= IDirect3DRMViewport_GetDevice(viewport
, &d3drm_device1
);
2227 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr
);
2228 ok(device1
== d3drm_device1
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
2229 IDirect3DRMDevice_Release(d3drm_device1
);
2231 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2232 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2233 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2234 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2235 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2236 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2237 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2238 IDirect3DViewport_Release(d3d_viewport
);
2239 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2240 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2241 IDirect3DViewport_Release(d3d_viewport
);
2243 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, &d3d_viewport
);
2244 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2245 vp
.dwSize
= sizeof(vp
);
2246 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2247 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr
);
2248 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %lu, got %lu.\n", rc
.right
, vp
.dwWidth
);
2249 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %lu, got %lu.\n", rc
.bottom
, vp
.dwHeight
);
2250 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %lu, got %lu.\n", rc
.left
, vp
.dwX
);
2251 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %lu, got %lu.\n", rc
.top
, vp
.dwY
);
2252 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2253 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2254 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2255 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2256 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2257 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2258 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2259 IDirect3DViewport_Release(d3d_viewport
);
2261 field
= IDirect3DRMViewport_GetField(viewport
);
2262 ok(field
== 0.5f
, "Got unexpected field %.8e.\n", field
);
2263 hr
= IDirect3DRMViewport_GetPlane(viewport
, &left
, &right
, &bottom
, &top
);
2264 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2265 ok(left
== -0.5f
, "Got unexpected left %.8e.\n", left
);
2266 ok(right
== 0.5f
, "Got unexpected right %.8e.\n", right
);
2267 ok(bottom
== -0.5f
, "Got unexpected bottom %.8e.\n", bottom
);
2268 ok(top
== 0.5f
, "Got unexpected top %.8e.\n", top
);
2269 front
= IDirect3DRMViewport_GetFront(viewport
);
2270 ok(front
== 1.0f
, "Got unexpected front %.8e.\n", front
);
2271 back
= IDirect3DRMViewport_GetBack(viewport
);
2272 ok(back
== 100.0f
, "Got unexpected back %.8e.\n", back
);
2273 projection
= IDirect3DRMViewport_GetProjection(viewport
);
2274 ok(projection
== D3DRMPROJECT_PERSPECTIVE
, "Got unexpected projection type %#x.\n", projection
);
2276 hr
= IDirect3DRMViewport_SetField(viewport
, 1.0f
);
2277 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2278 field
= IDirect3DRMViewport_GetField(viewport
);
2279 ok(field
== 1.0f
, "Got unexpected field %.8e.\n", field
);
2280 hr
= IDirect3DRMViewport_GetPlane(viewport
, &left
, &right
, &bottom
, &top
);
2281 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2282 ok(left
== -1.0f
, "Got unexpected left %.8e.\n", left
);
2283 ok(right
== 1.0f
, "Got unexpected right %.8e.\n", right
);
2284 ok(bottom
== -1.0f
, "Got unexpected bottom %.8e.\n", bottom
);
2285 ok(top
== 1.0f
, "Got unexpected top %.8e.\n", top
);
2287 hr
= IDirect3DRMViewport_SetPlane(viewport
, 5.0f
, 3.0f
, 2.0f
, 0.0f
);
2288 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2289 field
= IDirect3DRMViewport_GetField(viewport
);
2290 ok(field
== -1.0f
, "Got unexpected field %.8e.\n", field
);
2291 hr
= IDirect3DRMViewport_GetPlane(viewport
, &left
, &right
, &bottom
, &top
);
2292 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2293 ok(left
== 5.0f
, "Got unexpected left %.8e.\n", left
);
2294 ok(right
== 3.0f
, "Got unexpected right %.8e.\n", right
);
2295 ok(bottom
== 2.0f
, "Got unexpected bottom %.8e.\n", bottom
);
2296 ok(top
== 0.0f
, "Got unexpected top %.8e.\n", top
);
2297 hr
= IDirect3DRMViewport_SetFront(viewport
, 2.0f
);
2298 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2299 front
= IDirect3DRMViewport_GetFront(viewport
);
2300 ok(front
== 2.0f
, "Got unexpected front %.8e.\n", front
);
2301 hr
= IDirect3DRMViewport_SetBack(viewport
, 200.0f
);
2302 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2303 back
= IDirect3DRMViewport_GetBack(viewport
);
2304 ok(back
== 200.0f
, "Got unexpected back %.8e.\n", back
);
2305 hr
= IDirect3DRMViewport_SetProjection(viewport
, D3DRMPROJECT_ORTHOGRAPHIC
);
2306 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2307 projection
= IDirect3DRMViewport_GetProjection(viewport
);
2308 ok(projection
== D3DRMPROJECT_ORTHOGRAPHIC
, "Got unexpected projection type %#x.\n", projection
);
2310 hr
= IDirect3DRMViewport_Init(viewport
, device1
, frame
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2311 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2312 hr
= IDirect3DRMViewport_GetDevice(viewport
, NULL
);
2313 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2314 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport
, NULL
);
2315 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2316 hr
= IDirect3DRMViewport_GetCamera(viewport
, NULL
);
2317 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2318 hr
= IDirect3DRMViewport_SetField(viewport
, 0.0f
);
2319 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2320 hr
= IDirect3DRMViewport_SetField(viewport
, -1.0f
);
2321 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2322 hr
= IDirect3DRMViewport_SetFront(viewport
, 0.0f
);
2323 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2324 hr
= IDirect3DRMViewport_SetFront(viewport
, -1.0f
);
2325 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2326 front
= IDirect3DRMViewport_GetFront(viewport
);
2327 hr
= IDirect3DRMViewport_SetBack(viewport
, front
);
2328 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2329 hr
= IDirect3DRMViewport_SetBack(viewport
, front
/ 2.0f
);
2330 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2332 IDirect3DRMViewport_Release(viewport
);
2333 ref4
= get_refcount((IUnknown
*)d3drm1
);
2334 todo_wine
ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2335 ref4
= get_refcount((IUnknown
*)d3drm2
);
2336 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
2337 ref4
= get_refcount((IUnknown
*)d3drm3
);
2338 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
2339 ref4
= get_refcount((IUnknown
*)device1
);
2340 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
2341 ref4
= get_refcount((IUnknown
*)frame
);
2342 todo_wine
ok(ref4
> frame_ref
, "Expected ref4 > frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
2344 ref1
= get_refcount((IUnknown
*)d3drm1
);
2345 ref2
= get_refcount((IUnknown
*)d3drm2
);
2346 ref3
= get_refcount((IUnknown
*)d3drm3
);
2347 hr
= IDirect3DRM3_CreateObject(d3drm2
, &CLSID_CDirect3DRMViewport
, NULL
, &IID_IDirect3DRMViewport2
,
2348 (void **)&viewport2
);
2349 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface, hr %#lx.\n", hr
);
2350 ref4
= get_refcount((IUnknown
*)d3drm1
);
2351 ok(ref4
== ref1
, "Expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2352 ref4
= get_refcount((IUnknown
*)d3drm2
);
2353 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
2354 ref4
= get_refcount((IUnknown
*)d3drm3
);
2355 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
2357 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2358 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2359 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
2360 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2361 hr
= IDirect3DRMViewport2_GetCamera(viewport2
, &d3drm_frame3
);
2362 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2363 field
= IDirect3DRMViewport2_GetField(viewport2
);
2364 ok(field
== -1.0f
, "Got unexpected field %.8e.\n", field
);
2365 left
= right
= bottom
= top
= 10.0f
;
2366 hr
= IDirect3DRMViewport2_GetPlane(viewport2
, &left
, &right
, &bottom
, &top
);
2367 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2368 ok(left
== 10.0f
, "Got unexpected left %.8e.\n", left
);
2369 ok(right
== 10.0f
, "Got unexpected right %.8e.\n", right
);
2370 ok(bottom
== 10.0f
, "Got unexpected bottom %.8e.\n", bottom
);
2371 ok(top
== 10.0f
, "Got unexpected top %.8e.\n", top
);
2372 front
= IDirect3DRMViewport2_GetFront(viewport2
);
2373 ok(front
== -1.0f
, "Got unexpected front %.8e\n", front
);
2374 back
= IDirect3DRMViewport2_GetBack(viewport2
);
2375 ok(back
== -1.0f
, "Got unexpected back %.8e\n", back
);
2376 projection
= IDirect3DRMViewport2_GetProjection(viewport2
);
2377 ok(projection
== ~0u, "Got unexpected projection type %#x.\n", projection
);
2379 hr
= IDirect3DRMViewport2_SetCamera(viewport2
, frame3
);
2380 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2381 hr
= IDirect3DRMViewport2_SetField(viewport2
, 0.5f
);
2382 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2383 hr
= IDirect3DRMViewport2_SetPlane(viewport2
, -0.5f
, 0.5f
, -0.5f
, 0.5f
);
2384 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2385 hr
= IDirect3DRMViewport2_SetFront(viewport2
, 1.0f
);
2386 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2387 hr
= IDirect3DRMViewport2_SetBack(viewport2
, 100.0f
);
2388 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2389 hr
= IDirect3DRMViewport2_SetProjection(viewport2
, D3DRMPROJECT_PERSPECTIVE
);
2390 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
2392 hr
= IDirect3DRMViewport2_Init(viewport2
, NULL
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2393 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2394 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, NULL
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2395 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2396 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
2397 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2398 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
);
2399 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2400 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
+ 1);
2401 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2403 device_ref
= get_refcount((IUnknown
*)device3
);
2404 frame_ref2
= get_refcount((IUnknown
*)frame3
);
2405 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2406 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMViewport2 interface, hr %#lx.\n", hr
);
2407 ref4
= get_refcount((IUnknown
*)device3
);
2408 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
2409 ref4
= get_refcount((IUnknown
*)frame3
);
2410 ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2
, ref4
);
2412 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, &d3drm_device3
);
2413 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr
);
2414 ok(device3
== d3drm_device3
, "Expected device returned = %p, got %p.\n", device3
, d3drm_device3
);
2415 IDirect3DRMDevice3_Release(d3drm_device3
);
2417 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2418 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2419 viewport_ref
= get_refcount((IUnknown
*)d3d_viewport
);
2420 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2421 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2422 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2423 ok(ref4
> viewport_ref
, "Expected ref4 > viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2424 IDirect3DViewport_Release(d3d_viewport
);
2425 ref4
= get_refcount((IUnknown
*)d3d_viewport
);
2426 ok(ref4
== viewport_ref
, "Expected ref4 == viewport_ref, got ref4 = %lu, viewport_ref = %lu.\n", ref4
, viewport_ref
);
2427 IDirect3DViewport_Release(d3d_viewport
);
2429 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
2430 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
2431 vp
.dwSize
= sizeof(vp
);
2432 hr
= IDirect3DViewport_GetViewport(d3d_viewport
, &vp
);
2433 ok(SUCCEEDED(hr
), "Cannot get D3DVIEWPORT struct, hr %#lx.\n", hr
);
2434 ok(vp
.dwWidth
== rc
.right
, "Expected viewport width = %lu, got %lu.\n", rc
.right
, vp
.dwWidth
);
2435 ok(vp
.dwHeight
== rc
.bottom
, "Expected viewport height = %lu, got %lu.\n", rc
.bottom
, vp
.dwHeight
);
2436 ok(vp
.dwX
== rc
.left
, "Expected viewport X position = %lu, got %lu.\n", rc
.left
, vp
.dwX
);
2437 ok(vp
.dwY
== rc
.top
, "Expected viewport Y position = %lu, got %lu.\n", rc
.top
, vp
.dwY
);
2438 expected_val
= (rc
.right
> rc
.bottom
) ? (rc
.right
/ 2.0f
) : (rc
.bottom
/ 2.0f
);
2439 ok(vp
.dvScaleX
== expected_val
, "Expected dvScaleX = %f, got %f.\n", expected_val
, vp
.dvScaleX
);
2440 ok(vp
.dvScaleY
== expected_val
, "Expected dvScaleY = %f, got %f.\n", expected_val
, vp
.dvScaleY
);
2441 expected_val
= vp
.dwWidth
/ (2.0f
* vp
.dvScaleX
);
2442 ok(vp
.dvMaxX
== expected_val
, "Expected dvMaxX = %f, got %f.\n", expected_val
, vp
.dvMaxX
);
2443 expected_val
= vp
.dwHeight
/ (2.0f
* vp
.dvScaleY
);
2444 ok(vp
.dvMaxY
== expected_val
, "Expected dvMaxY = %f, got %f.\n", expected_val
, vp
.dvMaxY
);
2445 IDirect3DViewport_Release(d3d_viewport
);
2447 field
= IDirect3DRMViewport2_GetField(viewport2
);
2448 ok(field
== 0.5f
, "Got unexpected field %.8e.\n", field
);
2449 hr
= IDirect3DRMViewport2_GetPlane(viewport2
, &left
, &right
, &bottom
, &top
);
2450 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2451 ok(left
== -0.5f
, "Got unexpected left %.8e.\n", left
);
2452 ok(right
== 0.5f
, "Got unexpected right %.8e.\n", right
);
2453 ok(bottom
== -0.5f
, "Got unexpected bottom %.8e.\n", bottom
);
2454 ok(top
== 0.5f
, "Got unexpected top %.8e.\n", top
);
2455 front
= IDirect3DRMViewport2_GetFront(viewport2
);
2456 ok(front
== 1.0f
, "Got unexpected front %.8e.\n", front
);
2457 back
= IDirect3DRMViewport2_GetBack(viewport2
);
2458 ok(back
== 100.0f
, "Got unexpected back %.8e.\n", back
);
2459 projection
= IDirect3DRMViewport2_GetProjection(viewport2
);
2460 ok(projection
== D3DRMPROJECT_PERSPECTIVE
, "Got unexpected projection type %#x.\n", projection
);
2462 hr
= IDirect3DRMViewport2_SetField(viewport2
, 1.0f
);
2463 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2464 field
= IDirect3DRMViewport2_GetField(viewport2
);
2465 ok(field
== 1.0f
, "Got unexpected field %.8e.\n", field
);
2466 hr
= IDirect3DRMViewport2_GetPlane(viewport2
, &left
, &right
, &bottom
, &top
);
2467 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2468 ok(left
== -1.0f
, "Got unexpected left %.8e.\n", left
);
2469 ok(right
== 1.0f
, "Got unexpected right %.8e.\n", right
);
2470 ok(bottom
== -1.0f
, "Got unexpected bottom %.8e.\n", bottom
);
2471 ok(top
== 1.0f
, "Got unexpected top %.8e.\n", top
);
2473 hr
= IDirect3DRMViewport2_SetPlane(viewport2
, 5.0f
, 3.0f
, 2.0f
, 0.0f
);
2474 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2475 field
= IDirect3DRMViewport2_GetField(viewport2
);
2476 ok(field
== -1.0f
, "Got unexpected field %.8e.\n", field
);
2477 hr
= IDirect3DRMViewport2_GetPlane(viewport2
, &left
, &right
, &bottom
, &top
);
2478 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2479 ok(left
== 5.0f
, "Got unexpected left %.8e.\n", left
);
2480 ok(right
== 3.0f
, "Got unexpected right %.8e.\n", right
);
2481 ok(bottom
== 2.0f
, "Got unexpected bottom %.8e.\n", bottom
);
2482 ok(top
== 0.0f
, "Got unexpected top %.8e.\n", top
);
2483 hr
= IDirect3DRMViewport2_SetFront(viewport2
, 2.0f
);
2484 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2485 front
= IDirect3DRMViewport2_GetFront(viewport2
);
2486 ok(front
== 2.0f
, "Got unexpected front %.8e.\n", front
);
2487 hr
= IDirect3DRMViewport2_SetBack(viewport2
, 200.0f
);
2488 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2489 back
= IDirect3DRMViewport2_GetBack(viewport2
);
2490 ok(back
== 200.0f
, "Got unexpected back %.8e.\n", back
);
2491 hr
= IDirect3DRMViewport2_SetProjection(viewport2
, D3DRMPROJECT_ORTHOGRAPHIC
);
2492 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2493 projection
= IDirect3DRMViewport2_GetProjection(viewport2
);
2494 ok(projection
== D3DRMPROJECT_ORTHOGRAPHIC
, "Got unexpected projection type %#x.\n", projection
);
2496 hr
= IDirect3DRMViewport2_Init(viewport2
, device3
, frame3
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2497 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
2498 hr
= IDirect3DRMViewport2_GetDevice(viewport2
, NULL
);
2499 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2500 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, NULL
);
2501 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2502 hr
= IDirect3DRMViewport2_GetCamera(viewport2
, NULL
);
2503 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2504 hr
= IDirect3DRMViewport2_SetField(viewport2
, 0.0f
);
2505 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2506 hr
= IDirect3DRMViewport2_SetField(viewport2
, -1.0f
);
2507 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2508 hr
= IDirect3DRMViewport2_SetFront(viewport2
, 0.0f
);
2509 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2510 hr
= IDirect3DRMViewport2_SetFront(viewport2
, -1.0f
);
2511 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2512 front
= IDirect3DRMViewport2_GetFront(viewport2
);
2513 hr
= IDirect3DRMViewport2_SetBack(viewport2
, front
);
2514 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2515 hr
= IDirect3DRMViewport2_SetBack(viewport2
, front
/ 2.0f
);
2516 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
2518 IDirect3DRMViewport2_Release(viewport2
);
2519 ref4
= get_refcount((IUnknown
*)d3drm1
);
2520 todo_wine
ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2521 ref4
= get_refcount((IUnknown
*)d3drm2
);
2522 ok(ref4
== ref2
, "Expected ref4 == ref2, got ref2 = %lu, ref4 = %lu.\n", ref2
, ref4
);
2523 ref4
= get_refcount((IUnknown
*)d3drm3
);
2524 ok(ref4
== ref3
, "Expected ref4 == ref3, got ref3 = %lu, ref4 = %lu.\n", ref3
, ref4
);
2525 ref4
= get_refcount((IUnknown
*)device3
);
2526 ok(ref4
== device_ref
, "Expected ref4 == device_ref, got device_ref = %lu, ref4 = %lu.\n", device_ref
, ref4
);
2527 ref4
= get_refcount((IUnknown
*)frame3
);
2528 todo_wine
ok(ref4
> frame_ref2
, "Expected ref4 > frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2
, ref4
);
2530 IDirect3DRMDevice3_Release(device3
);
2531 IDirect3DRMDevice_Release(device1
);
2532 ref4
= get_refcount((IUnknown
*)d3drm1
);
2533 ok(ref4
> initial_ref1
, "Expected ref4 > initial_ref1, got initial_ref1 = %lu, ref4 = %lu.\n", initial_ref1
, ref4
);
2534 ref4
= get_refcount((IUnknown
*)d3drm2
);
2535 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %lu, ref4 = %lu.\n", initial_ref2
, ref4
);
2536 ref4
= get_refcount((IUnknown
*)d3drm3
);
2537 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %lu, ref4 = %lu.\n", initial_ref3
, ref4
);
2538 ref4
= get_refcount((IUnknown
*)frame
);
2539 ok(ref4
== frame_ref
, "Expected ref4 == frame_ref, got frame_ref = %lu, ref4 = %lu.\n", frame_ref
, ref4
);
2540 ref4
= get_refcount((IUnknown
*)frame3
);
2541 ok(ref4
== frame_ref2
, "Expected ref4 == frame_ref2, got frame_ref2 = %lu, ref4 = %lu.\n", frame_ref2
, ref4
);
2543 IDirect3DRMFrame3_Release(tmp_frame3
);
2544 IDirect3DRMFrame3_Release(frame3
);
2545 ref4
= get_refcount((IUnknown
*)d3drm1
);
2546 ok(ref4
> initial_ref1
, "Expected ref4 > initial_ref1, got initial_ref1 = %lu, ref4 = %lu.\n", initial_ref1
, ref4
);
2547 ref4
= get_refcount((IUnknown
*)d3drm2
);
2548 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %lu, ref4 = %lu.\n", initial_ref2
, ref4
);
2549 ref4
= get_refcount((IUnknown
*)d3drm3
);
2550 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %lu, ref4 = %lu.\n", initial_ref3
, ref4
);
2552 IDirect3DRMFrame3_Release(tmp_frame1
);
2553 IDirect3DRMFrame_Release(frame
);
2554 ref4
= get_refcount((IUnknown
*)d3drm1
);
2555 ok(ref4
== initial_ref1
, "Expected ref4 == initial_ref1, got initial_ref1 = %lu, ref4 = %lu.\n", initial_ref1
, ref4
);
2556 ref4
= get_refcount((IUnknown
*)d3drm2
);
2557 ok(ref4
== initial_ref2
, "Expected ref4 == initial_ref2, got initial_ref2 = %lu, ref4 = %lu.\n", initial_ref2
, ref4
);
2558 ref4
= get_refcount((IUnknown
*)d3drm3
);
2559 ok(ref4
== initial_ref3
, "Expected ref4 == initial_ref3, got initial_ref3 = %lu, ref4 = %lu.\n", initial_ref3
, ref4
);
2560 IDirectDrawClipper_Release(clipper
);
2562 IDirect3DRM3_Release(d3drm3
);
2563 IDirect3DRM2_Release(d3drm2
);
2564 IDirect3DRM_Release(d3drm1
);
2565 DestroyWindow(window
);
2568 static void test_Light(void)
2570 IDirect3DRMObject
*object
;
2573 IDirect3DRMLight
*light
;
2574 D3DRMLIGHTTYPE type
;
2577 hr
= Direct3DRMCreate(&d3drm
);
2578 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
2580 hr
= IDirect3DRM_CreateLightRGB(d3drm
, D3DRMLIGHT_SPOT
, 0.5, 0.5, 0.5, &light
);
2581 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMLight interface, hr %#lx\n", hr
);
2583 hr
= IDirect3DRMLight_QueryInterface(light
, &IID_IDirect3DRMObject
, (void **)&object
);
2584 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr %#lx.\n", hr
);
2585 IDirect3DRMObject_Release(object
);
2587 test_class_name((IDirect3DRMObject
*)light
, "Light");
2588 test_object_name((IDirect3DRMObject
*)light
);
2590 type
= IDirect3DRMLight_GetType(light
);
2591 ok(type
== D3DRMLIGHT_SPOT
, "wrong type (%u)\n", type
);
2593 color
= IDirect3DRMLight_GetColor(light
);
2594 ok(color
== 0xff7f7f7f, "wrong color %lx.\n", color
);
2596 hr
= IDirect3DRMLight_SetType(light
, D3DRMLIGHT_POINT
);
2597 ok(hr
== D3DRM_OK
, "Cannot set type, hr %#lx\n", hr
);
2598 type
= IDirect3DRMLight_GetType(light
);
2599 ok(type
== D3DRMLIGHT_POINT
, "wrong type %u.\n", type
);
2601 hr
= IDirect3DRMLight_SetColor(light
, 0xff180587);
2602 ok(hr
== D3DRM_OK
, "Cannot set color, hr %#lx\n", hr
);
2603 color
= IDirect3DRMLight_GetColor(light
);
2604 ok(color
== 0xff180587, "wrong color %#lx.\n", color
);
2606 hr
= IDirect3DRMLight_SetColor(light
, 0x00c0c0c0);
2607 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2608 color
= IDirect3DRMLight_GetColor(light
);
2609 ok(color
== 0xffc0c0c0, "Got unexpected color 0x%08lx.\n", color
);
2611 hr
= IDirect3DRMLight_SetColorRGB(light
, 0.5, 0.5, 0.5);
2612 ok(hr
== D3DRM_OK
, "Cannot set color, hr %#lx\n", hr
);
2613 color
= IDirect3DRMLight_GetColor(light
);
2614 ok(color
== 0xff7f7f7f, "wrong color %#lx.\n", color
);
2616 IDirect3DRMLight_Release(light
);
2618 hr
= IDirect3DRM_CreateLight(d3drm
, D3DRMLIGHT_SPOT
, 0x00c0c0c0, &light
);
2619 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
2621 type
= IDirect3DRMLight_GetType(light
);
2622 ok(type
== D3DRMLIGHT_SPOT
, "Got unexpected type %#x.\n", type
);
2624 color
= IDirect3DRMLight_GetColor(light
);
2625 ok(color
== 0xffc0c0c0, "Got unexpected color 0x%08lx.\n", color
);
2627 IDirect3DRMLight_Release(light
);
2629 IDirect3DRM_Release(d3drm
);
2632 static void test_Material2(void)
2636 IDirect3DRM3
*d3drm3
;
2637 IDirect3DRMMaterial2
*material2
;
2640 hr
= Direct3DRMCreate(&d3drm
);
2641 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
2643 if (FAILED(hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
)))
2645 win_skip("Cannot get IDirect3DRM3 interface, hr %#lx, skipping tests\n", hr
);
2646 IDirect3DRM_Release(d3drm
);
2650 hr
= IDirect3DRM3_CreateMaterial(d3drm3
, 18.5f
, &material2
);
2651 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMMaterial2 interface, hr %#lx\n", hr
);
2653 test_class_name((IDirect3DRMObject
*)material2
, "Material");
2654 test_object_name((IDirect3DRMObject
*)material2
);
2656 r
= IDirect3DRMMaterial2_GetPower(material2
);
2657 ok(r
== 18.5f
, "wrong power (%f)\n", r
);
2659 hr
= IDirect3DRMMaterial2_GetEmissive(material2
, &r
, &g
, &b
);
2660 ok(hr
== D3DRM_OK
, "Cannot get emissive, hr %#lx\n", hr
);
2661 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
);
2663 hr
= IDirect3DRMMaterial2_GetSpecular(material2
, &r
, &g
, &b
);
2664 ok(hr
== D3DRM_OK
, "Cannot get emissive, hr %#lx\n", hr
);
2665 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
);
2667 hr
= IDirect3DRMMaterial2_GetAmbient(material2
, &r
, &g
, &b
);
2668 ok(hr
== D3DRM_OK
, "Cannot get emissive, hr %#lx\n", hr
);
2669 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
);
2671 hr
= IDirect3DRMMaterial2_SetPower(material2
, 5.87f
);
2672 ok(hr
== D3DRM_OK
, "Cannot set power, hr %#lx\n", hr
);
2673 r
= IDirect3DRMMaterial2_GetPower(material2
);
2674 ok(r
== 5.87f
, "wrong power (%f)\n", r
);
2676 hr
= IDirect3DRMMaterial2_SetEmissive(material2
, 0.5f
, 0.5f
, 0.5f
);
2677 ok(hr
== D3DRM_OK
, "Cannot set emissive, hr %#lx\n", hr
);
2678 hr
= IDirect3DRMMaterial2_GetEmissive(material2
, &r
, &g
, &b
);
2679 ok(hr
== D3DRM_OK
, "Cannot get emissive, hr %#lx\n", hr
);
2680 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
);
2682 hr
= IDirect3DRMMaterial2_SetSpecular(material2
, 0.6f
, 0.6f
, 0.6f
);
2683 ok(hr
== D3DRM_OK
, "Cannot set specular, hr %#lx\n", hr
);
2684 hr
= IDirect3DRMMaterial2_GetSpecular(material2
, &r
, &g
, &b
);
2685 ok(hr
== D3DRM_OK
, "Cannot get specular, hr %#lx\n", hr
);
2686 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
);
2688 hr
= IDirect3DRMMaterial2_SetAmbient(material2
, 0.7f
, 0.7f
, 0.7f
);
2689 ok(hr
== D3DRM_OK
, "Cannot set ambient, hr %#lx\n", hr
);
2690 hr
= IDirect3DRMMaterial2_GetAmbient(material2
, &r
, &g
, &b
);
2691 ok(hr
== D3DRM_OK
, "Cannot get ambient, hr %#lx\n", hr
);
2692 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
);
2694 IDirect3DRMMaterial2_Release(material2
);
2696 IDirect3DRM3_Release(d3drm3
);
2697 IDirect3DRM_Release(d3drm
);
2700 static void test_Texture(void)
2703 IDirect3DRM
*d3drm1
;
2704 IDirect3DRM2
*d3drm2
;
2705 IDirect3DRM3
*d3drm3
;
2706 IDirect3DRMTexture
*texture1
;
2707 IDirect3DRMTexture2
*texture2
;
2708 IDirect3DRMTexture3
*texture3
;
2709 IDirectDrawSurface
*surface
;
2710 LONG decalx
, decaly
;
2711 DWORD colors
, shades
;
2713 D3DVALUE width
, height
;
2715 D3DRMIMAGE initimg
=
2718 TRUE
, 2 * sizeof(DWORD
), NULL
, NULL
,
2719 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
2724 TRUE
, 0, (void *)0xcafebabe, NULL
,
2725 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
2730 FALSE
, 2 * sizeof(DWORD
), (void *)0xcafebabe, NULL
,
2731 0x00000000, 0x00000000, 0x00000000, 0, 2, (void *)0xcafebabe
2735 DWORD pixel
[4] = { 20000, 30000, 10000, 0 };
2736 ULONG ref1
, ref2
, ref3
, ref4
;
2738 hr
= Direct3DRMCreate(&d3drm1
);
2739 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
2740 ref1
= get_refcount((IUnknown
*)d3drm1
);
2742 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
2743 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
2745 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
2746 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
2748 /* Test NULL params */
2749 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
2750 hr
= IDirect3DRM_CreateTexture(d3drm1
, NULL
, &texture1
);
2751 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2752 ok(!texture1
, "Expected texture returned == NULL, got %p.\n", texture1
);
2753 hr
= IDirect3DRM_CreateTexture(d3drm1
, NULL
, NULL
);
2754 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2756 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
2757 hr
= IDirect3DRM2_CreateTexture(d3drm2
, NULL
, &texture2
);
2758 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2759 ok(!texture2
, "Expected texture returned == NULL, got %p.\n", texture2
);
2760 hr
= IDirect3DRM2_CreateTexture(d3drm2
, NULL
, NULL
);
2761 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2763 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
2764 hr
= IDirect3DRM3_CreateTexture(d3drm3
, NULL
, &texture3
);
2765 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2766 ok(!texture3
, "Expected texture returned == NULL, got %p.\n", texture3
);
2767 hr
= IDirect3DRM3_CreateTexture(d3drm3
, NULL
, NULL
);
2768 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2770 /* Tests for validation of D3DRMIMAGE struct */
2771 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg
, &texture1
);
2772 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr
);
2773 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg
, &texture2
);
2774 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr
);
2775 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
2776 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
2777 IDirect3DRMTexture_Release(texture1
);
2778 IDirect3DRMTexture2_Release(texture2
);
2779 IDirect3DRMTexture3_Release(texture3
);
2782 testimg
.palette
= (void *)0xdeadbeef;
2783 testimg
.palette_size
= 0x39;
2784 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg
, &texture1
);
2785 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr
);
2786 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg
, &texture2
);
2787 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr
);
2788 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
2789 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
2790 IDirect3DRMTexture_Release(texture1
);
2791 IDirect3DRMTexture2_Release(texture2
);
2792 IDirect3DRMTexture3_Release(texture3
);
2794 /* Just palette set */
2795 hr
= IDirect3DRM_CreateTexture(d3drm1
, &testimg_palette
, &texture1
);
2796 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr
);
2797 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &testimg_palette
, &texture2
);
2798 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr
);
2799 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg_palette
, &texture3
);
2800 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
2801 IDirect3DRMTexture_Release(texture1
);
2802 IDirect3DRMTexture2_Release(texture2
);
2803 IDirect3DRMTexture3_Release(texture3
);
2806 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
2807 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2808 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2809 ok(!texture1
, "Expected texture == NULL, got %p.\n", texture1
);
2810 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
2811 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2812 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2813 ok(!texture2
, "Expected texture == NULL, got %p.\n", texture2
);
2814 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
2815 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2816 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2817 ok(!texture3
, "Expected texture == NULL, got %p.\n", texture3
);
2819 initimg
.red_mask
= 0;
2820 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2821 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2822 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2823 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2824 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2825 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2826 initimg
.red_mask
= 0x000000ff;
2827 initimg
.green_mask
= 0;
2828 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2829 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2830 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2831 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2832 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2833 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2834 initimg
.green_mask
= 0x0000ff00;
2835 initimg
.blue_mask
= 0;
2836 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2837 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2838 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2839 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2840 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2841 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2842 initimg
.blue_mask
= 0x00ff0000;
2843 initimg
.buffer1
= NULL
;
2844 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2845 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2846 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2847 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2848 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2849 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2851 initimg
.buffer1
= &pixel
;
2852 hr
= IDirect3DRM_CreateTexture(d3drm1
, &initimg
, &texture1
);
2853 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr
);
2854 ref2
= get_refcount((IUnknown
*)d3drm1
);
2855 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
2856 ref3
= get_refcount((IUnknown
*)d3drm2
);
2857 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
2858 ref4
= get_refcount((IUnknown
*)d3drm3
);
2859 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
2860 hr
= IDirect3DRM2_CreateTexture(d3drm2
, &initimg
, &texture2
);
2861 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr
);
2862 ref2
= get_refcount((IUnknown
*)d3drm1
);
2863 ok(ref2
> ref1
+ 1, "expected ref2 > (ref1 + 1), got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
2864 ref3
= get_refcount((IUnknown
*)d3drm2
);
2865 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
2866 ref4
= get_refcount((IUnknown
*)d3drm3
);
2867 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
2868 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &initimg
, &texture3
);
2869 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
2870 ref2
= get_refcount((IUnknown
*)d3drm1
);
2871 ok(ref2
> ref1
+ 2, "expected ref2 > (ref1 + 2), got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
2872 ref3
= get_refcount((IUnknown
*)d3drm2
);
2873 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
2874 ref4
= get_refcount((IUnknown
*)d3drm3
);
2875 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
2877 /* Created from image, GetSurface() does not work. */
2878 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, NULL
);
2879 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
2881 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &surface
);
2882 ok(hr
== D3DRMERR_NOTCREATEDFROMDDS
, "Unexpected hr %#lx.\n", hr
);
2884 /* Test all failures together */
2885 test_class_name((IDirect3DRMObject
*)texture1
, "Texture");
2886 test_class_name((IDirect3DRMObject
*)texture2
, "Texture");
2887 test_class_name((IDirect3DRMObject
*)texture3
, "Texture");
2888 test_object_name((IDirect3DRMObject
*)texture1
);
2889 test_object_name((IDirect3DRMObject
*)texture2
);
2890 test_object_name((IDirect3DRMObject
*)texture3
);
2892 hr
= IDirect3DRMTexture_GetDecalOrigin(texture1
, &decalx
, &decaly
);
2893 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2894 ok(decalx
== 0, "got %ld.\n", decalx
);
2895 ok(decaly
== 0, "got %ld.\n", decaly
);
2897 hr
= IDirect3DRMTexture_SetDecalOrigin(texture1
, 1, 1);
2898 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2900 hr
= IDirect3DRMTexture_GetDecalOrigin(texture1
, &decalx
, &decaly
);
2901 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2902 ok(decalx
== 1, "got %ld.\n", decalx
);
2903 ok(decaly
== 1, "got %ld.\n", decaly
);
2905 hr
= IDirect3DRMTexture_SetDecalOrigin(texture1
, 0, 0);
2906 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2908 colors
= IDirect3DRMTexture_GetColors(texture1
);
2909 ok(colors
== 8, "got %ld.\n", colors
);
2911 hr
= IDirect3DRMTexture_SetColors(texture1
, 256);
2912 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2914 colors
= IDirect3DRMTexture_GetColors(texture1
);
2915 ok(colors
== 256, "got %ld.\n", colors
);
2917 hr
= IDirect3DRMTexture_SetColors(texture1
, 8);
2918 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2920 shades
= IDirect3DRMTexture_GetShades(texture1
);
2921 ok(shades
== 16, "got %ld.\n", shades
);
2923 hr
= IDirect3DRMTexture_SetShades(texture1
, 8);
2924 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2926 shades
= IDirect3DRMTexture_GetShades(texture1
);
2927 ok(shades
== 8, "got %ld.\n", shades
);
2929 hr
= IDirect3DRMTexture_SetShades(texture1
, 11);
2930 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2932 shades
= IDirect3DRMTexture_GetShades(texture1
);
2933 ok(shades
== 11, "got %ld.\n", shades
);
2935 hr
= IDirect3DRMTexture_SetShades(texture1
, 8);
2936 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2938 hr
= IDirect3DRMTexture_GetDecalSize(texture1
, &width
, &height
);
2939 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2940 ok(width
== 1.0f
, "Got %.8e.\n", width
);
2941 ok(height
== 1.0f
, "Got %.8e.\n", height
);
2943 hr
= IDirect3DRMTexture_SetDecalSize(texture1
, 8.0f
, 7.0f
);
2944 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2946 hr
= IDirect3DRMTexture_GetDecalSize(texture1
, &width
, &height
);
2947 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2948 ok(width
== 8.0f
, "Got %.8e.\n", width
);
2949 ok(height
== 7.0f
, "Got %.8e.\n", height
);
2951 hr
= IDirect3DRMTexture_SetDecalSize(texture1
, 1.0f
, 1.0f
);
2952 ok(hr
== S_OK
, "got %#lx.\n", hr
);
2954 transparency
= IDirect3DRMTexture_GetDecalTransparency(texture1
);
2955 ok(transparency
== FALSE
, "Got %d.\n", transparency
);
2957 hr
= IDirect3DRMTexture_SetDecalTransparency(texture1
, TRUE
);
2958 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2960 transparency
= IDirect3DRMTexture_GetDecalTransparency(texture1
);
2961 ok(transparency
== TRUE
, "Got %d.\n", transparency
);
2963 hr
= IDirect3DRMTexture_SetDecalTransparency(texture1
, FALSE
);
2964 ok(hr
== S_OK
, "Got hr %#lx.\n", hr
);
2966 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
2967 ok(!!d3drm_img
, "Failed to get image.\n");
2968 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2970 IDirect3DRMTexture_Release(texture1
);
2971 ref2
= get_refcount((IUnknown
*)d3drm1
);
2972 ok(ref2
- 2 == ref1
, "expected (ref2 - 2) == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
2973 ref3
= get_refcount((IUnknown
*)d3drm2
);
2974 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
2975 ref4
= get_refcount((IUnknown
*)d3drm3
);
2976 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2979 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
2980 ok(!!d3drm_img
, "Failed to get image.\n");
2981 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2983 IDirect3DRMTexture2_Release(texture2
);
2984 ref2
= get_refcount((IUnknown
*)d3drm1
);
2985 ok(ref2
- 1 == ref1
, "expected (ref2 - 1) == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
2986 ref3
= get_refcount((IUnknown
*)d3drm2
);
2987 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
2988 ref4
= get_refcount((IUnknown
*)d3drm3
);
2989 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
2992 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
2993 ok(!!d3drm_img
, "Failed to get image.\n");
2994 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
2996 IDirect3DRMTexture3_Release(texture3
);
2997 ref2
= get_refcount((IUnknown
*)d3drm1
);
2998 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
2999 ref3
= get_refcount((IUnknown
*)d3drm2
);
3000 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
3001 ref4
= get_refcount((IUnknown
*)d3drm3
);
3002 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
3004 /* InitFromImage tests */
3005 /* Tests for validation of D3DRMIMAGE struct */
3007 testimg
.palette
= NULL
;
3008 testimg
.palette_size
= 0;
3009 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
3010 (void **)&texture2
);
3011 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx.\n", hr
);
3012 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
3013 (void **)&texture3
);
3014 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr
);
3015 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &testimg
);
3016 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 interface, hr %#lx\n", hr
);
3017 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
3018 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
3019 IDirect3DRMTexture2_Release(texture2
);
3020 IDirect3DRMTexture3_Release(texture3
);
3023 testimg
.palette
= (void *)0xdeadbeef;
3024 testimg
.palette_size
= 0x39;
3025 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
3026 (void **)&texture2
);
3027 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx.\n", hr
);
3028 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
3029 (void **)&texture3
);
3030 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr
);
3031 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &testimg
);
3032 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 interface, hr %#lx\n", hr
);
3033 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
3034 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
3035 IDirect3DRMTexture2_Release(texture2
);
3036 IDirect3DRMTexture3_Release(texture3
);
3038 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture2
,
3039 (void **)&texture2
);
3040 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture2 interface, hr %#lx.\n", hr
);
3041 ref2
= get_refcount((IUnknown
*)texture2
);
3042 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, NULL
);
3043 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3044 ref3
= get_refcount((IUnknown
*)texture2
);
3045 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
3047 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
, NULL
, &IID_IDirect3DRMTexture3
,
3048 (void **)&texture3
);
3049 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr
);
3050 ref2
= get_refcount((IUnknown
*)texture3
);
3051 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, NULL
);
3052 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3053 ref3
= get_refcount((IUnknown
*)texture3
);
3054 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
3057 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3058 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3059 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3060 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3062 initimg
.red_mask
= 0;
3063 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3064 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3065 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3066 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3067 initimg
.red_mask
= 0x000000ff;
3068 initimg
.green_mask
= 0;
3069 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3070 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3071 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3072 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3073 initimg
.green_mask
= 0x0000ff00;
3074 initimg
.blue_mask
= 0;
3075 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3076 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3077 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3078 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3079 initimg
.blue_mask
= 0x00ff0000;
3080 initimg
.buffer1
= NULL
;
3081 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3082 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3083 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3084 ok(hr
== D3DRMERR_BADOBJECT
, "Unexpected hr %#lx.\n", hr
);
3085 initimg
.buffer1
= &pixel
;
3088 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3089 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture2 from image, hr %#lx.\n", hr
);
3090 ref2
= get_refcount((IUnknown
*)d3drm1
);
3091 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
3092 ref3
= get_refcount((IUnknown
*)d3drm2
);
3093 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
3094 ref4
= get_refcount((IUnknown
*)d3drm3
);
3095 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
3097 hr
= IDirect3DRMTexture2_InitFromImage(texture2
, &initimg
);
3098 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
3099 /* Release leaked reference to d3drm1 */
3100 IDirect3DRM_Release(d3drm1
);
3102 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
3103 ok(!!d3drm_img
, "Failed to get image.\n");
3104 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
3105 IDirect3DRMTexture2_Release(texture2
);
3106 ref2
= get_refcount((IUnknown
*)d3drm1
);
3107 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
3108 ref3
= get_refcount((IUnknown
*)d3drm2
);
3109 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
3110 ref4
= get_refcount((IUnknown
*)d3drm3
);
3111 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
3114 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3115 ok(SUCCEEDED(hr
), "Cannot initialize IDirect3DRMTexture3 from image, hr %#lx.\n", hr
);
3116 ref2
= get_refcount((IUnknown
*)d3drm1
);
3117 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
3118 ref3
= get_refcount((IUnknown
*)d3drm2
);
3119 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
3120 ref4
= get_refcount((IUnknown
*)d3drm3
);
3121 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
3123 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &initimg
);
3124 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
3125 IDirect3DRM_Release(d3drm1
);
3127 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
3128 ok(!!d3drm_img
, "Failed to get image.\n");
3129 ok(d3drm_img
== &initimg
, "Expected image returned == %p, got %p.\n", &initimg
, d3drm_img
);
3130 IDirect3DRMTexture3_Release(texture3
);
3131 ref2
= get_refcount((IUnknown
*)d3drm1
);
3132 ok(ref2
== ref1
, "expected ref2 == ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
3133 ref3
= get_refcount((IUnknown
*)d3drm2
);
3134 ok(ref3
== ref1
, "expected ref3 == ref1, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
3135 ref4
= get_refcount((IUnknown
*)d3drm3
);
3136 ok(ref4
== ref1
, "expected ref4 == ref1, got ref1 = %lu, ref4 = %lu.\n", ref1
, ref4
);
3138 IDirect3DRM3_Release(d3drm3
);
3139 IDirect3DRM2_Release(d3drm2
);
3140 IDirect3DRM_Release(d3drm1
);
3143 static void test_Device(void)
3145 IDirectDrawClipper
*pClipper
;
3148 IDirect3DRMDevice
*device
;
3149 IDirect3DRMWinDevice
*win_device
;
3154 window
= create_window();
3155 GetClientRect(window
, &rc
);
3157 hr
= Direct3DRMCreate(&d3drm
);
3158 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
3160 hr
= DirectDrawCreateClipper(0, &pClipper
, NULL
);
3161 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface, hr %#lx\n", hr
);
3163 hr
= IDirectDrawClipper_SetHWnd(pClipper
, 0, window
);
3164 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper, hr %#lx\n", hr
);
3166 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
3167 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm
, pClipper
, &driver
, rc
.right
, rc
.bottom
, &device
);
3168 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr
);
3170 test_class_name((IDirect3DRMObject
*)device
, "Device");
3171 test_object_name((IDirect3DRMObject
*)device
);
3174 if (FAILED(hr
= IDirect3DRMDevice_QueryInterface(device
, &IID_IDirect3DRMWinDevice
, (void **)&win_device
)))
3176 win_skip("Cannot get IDirect3DRMWinDevice interface, hr %#lx, skipping tests\n", hr
);
3180 test_class_name((IDirect3DRMObject
*)win_device
, "Device");
3181 test_object_name((IDirect3DRMObject
*)win_device
);
3182 IDirect3DRMWinDevice_Release(win_device
);
3185 IDirect3DRMDevice_Release(device
);
3186 IDirectDrawClipper_Release(pClipper
);
3188 IDirect3DRM_Release(d3drm
);
3189 DestroyWindow(window
);
3192 static void test_frame_transform(void)
3194 IDirect3DRMFrame
*frame
, *subframe
;
3195 D3DRMMATRIX4D matrix
, add_matrix
;
3200 hr
= Direct3DRMCreate(&d3drm
);
3201 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3203 hr
= IDirect3DRM_CreateFrame(d3drm
, NULL
, &frame
);
3204 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3206 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3207 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3208 expect_matrix(matrix
,
3209 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3210 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3211 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3212 0.0f
, 0.0f
, 0.0f
, 1.0f
, 0);
3214 memcpy(add_matrix
, identity
, sizeof(add_matrix
));
3215 add_matrix
[3][0] = 3.0f
;
3216 add_matrix
[3][1] = 3.0f
;
3217 add_matrix
[3][2] = 3.0f
;
3219 frame_set_transform(frame
,
3220 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3221 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3222 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3223 0.0f
, 0.0f
, 0.0f
, 1.0f
);
3224 hr
= IDirect3DRMFrame_AddTransform(frame
, D3DRMCOMBINE_REPLACE
, add_matrix
);
3225 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3226 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3227 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3228 expect_matrix(matrix
,
3229 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3230 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3231 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3232 3.0f
, 3.0f
, 3.0f
, 1.0f
, 1);
3234 frame_set_transform(frame
,
3235 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3236 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3237 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3238 0.0f
, 0.0f
, 0.0f
, 1.0f
);
3239 hr
= IDirect3DRMFrame_AddTransform(frame
, D3DRMCOMBINE_BEFORE
, add_matrix
);
3240 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3241 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3242 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3243 expect_matrix(matrix
,
3244 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3245 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3246 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3247 6.0f
, 6.0f
, 6.0f
, 1.0f
, 1);
3249 frame_set_transform(frame
,
3250 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3251 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3252 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3253 0.0f
, 0.0f
, 0.0f
, 1.0f
);
3254 hr
= IDirect3DRMFrame_AddTransform(frame
, D3DRMCOMBINE_AFTER
, add_matrix
);
3255 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3256 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3257 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3258 expect_matrix(matrix
,
3259 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3260 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3261 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3262 3.0f
, 3.0f
, 3.0f
, 1.0f
, 1);
3264 add_matrix
[3][3] = 2.0f
;
3265 hr
= IDirect3DRMFrame_AddTransform(frame
, D3DRMCOMBINE_REPLACE
, add_matrix
);
3266 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
3268 frame_set_transform(frame
,
3269 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3270 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3271 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3272 0.0f
, 0.0f
, 0.0f
, 1.0f
);
3273 hr
= IDirect3DRMFrame_AddTranslation(frame
, D3DRMCOMBINE_REPLACE
, 3.0f
, 3.0f
, 3.0f
);
3274 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3275 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3276 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3277 expect_matrix(matrix
,
3278 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3279 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3280 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3281 3.0f
, 3.0f
, 3.0f
, 1.0f
, 1);
3283 frame_set_transform(frame
,
3284 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3285 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3286 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3287 0.0f
, 0.0f
, 0.0f
, 1.0f
);
3288 hr
= IDirect3DRMFrame_AddTranslation(frame
, D3DRMCOMBINE_BEFORE
, 3.0f
, 3.0f
, 3.0f
);
3289 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3290 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3291 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3292 expect_matrix(matrix
,
3293 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3294 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3295 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3296 6.0f
, 6.0f
, 6.0f
, 1.0f
, 1);
3298 frame_set_transform(frame
,
3299 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3300 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3301 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3302 0.0f
, 0.0f
, 0.0f
, 1.0f
);
3303 hr
= IDirect3DRMFrame_AddTranslation(frame
, D3DRMCOMBINE_AFTER
, 3.0f
, 3.0f
, 3.0f
);
3304 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3305 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3306 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3307 expect_matrix(matrix
,
3308 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3309 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3310 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3311 3.0f
, 3.0f
, 3.0f
, 1.0f
, 1);
3313 frame_set_transform(frame
,
3314 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3315 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3316 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3317 3.0f
, 3.0f
, 3.0f
, 1.0f
);
3318 hr
= IDirect3DRMFrame_AddScale(frame
, D3DRMCOMBINE_REPLACE
, 2.0f
, 2.0f
, 2.0f
);
3319 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3320 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3321 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3322 expect_matrix(matrix
,
3323 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3324 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3325 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3326 0.0f
, 0.0f
, 0.0f
, 1.0f
, 1);
3328 frame_set_transform(frame
,
3329 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3330 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3331 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3332 3.0f
, 3.0f
, 3.0f
, 1.0f
);
3333 hr
= IDirect3DRMFrame_AddScale(frame
, D3DRMCOMBINE_BEFORE
, 2.0f
, 2.0f
, 2.0f
);
3334 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3335 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3336 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3337 expect_matrix(matrix
,
3338 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3339 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3340 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3341 3.0f
, 3.0f
, 3.0f
, 1.0f
, 1);
3343 frame_set_transform(frame
,
3344 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3345 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3346 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3347 3.0f
, 3.0f
, 3.0f
, 1.0f
);
3348 hr
= IDirect3DRMFrame_AddScale(frame
, D3DRMCOMBINE_AFTER
, 2.0f
, 2.0f
, 2.0f
);
3349 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3350 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3351 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3352 expect_matrix(matrix
,
3353 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3354 0.0f
, 2.0f
, 0.0f
, 0.0f
,
3355 0.0f
, 0.0f
, 2.0f
, 0.0f
,
3356 6.0f
, 6.0f
, 6.0f
, 1.0f
, 1);
3358 frame_set_transform(frame
,
3359 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3360 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3361 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3362 3.0f
, 3.0f
, 3.0f
, 1.0f
);
3363 hr
= IDirect3DRMFrame_AddRotation(frame
, D3DRMCOMBINE_REPLACE
, 1.0f
, 0.0f
, 0.0f
, M_PI_2
);
3364 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3365 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3366 matrix_sanitise(matrix
);
3367 expect_matrix(matrix
,
3368 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3369 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3370 0.0f
, -1.0f
, 0.0f
, 0.0f
,
3371 0.0f
, 0.0f
, 0.0f
, 1.0f
, 1);
3373 frame_set_transform(frame
,
3374 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3375 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3376 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3377 3.0f
, 3.0f
, 3.0f
, 1.0f
);
3378 hr
= IDirect3DRMFrame_AddRotation(frame
, D3DRMCOMBINE_BEFORE
, 1.0f
, 0.0f
, 0.0f
, M_PI_2
);
3379 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3380 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3381 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3382 matrix_sanitise(matrix
);
3383 expect_matrix(matrix
,
3384 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3385 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3386 0.0f
, -1.0f
, 0.0f
, 0.0f
,
3387 3.0f
, 3.0f
, 3.0f
, 1.0f
, 1);
3389 frame_set_transform(frame
,
3390 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3391 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3392 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3393 3.0f
, 3.0f
, 3.0f
, 1.0f
);
3394 hr
= IDirect3DRMFrame_AddRotation(frame
, D3DRMCOMBINE_AFTER
, 1.0f
, 0.0f
, 0.0f
, M_PI_2
);
3395 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3396 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3397 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3398 matrix_sanitise(matrix
);
3399 expect_matrix(matrix
,
3400 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3401 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3402 0.0f
, -1.0f
, 0.0f
, 0.0f
,
3403 3.0f
, -3.0f
, 3.0f
, 1.0f
, 1);
3405 hr
= IDirect3DRMFrame_AddRotation(frame
, D3DRMCOMBINE_REPLACE
, 0.0f
, 0.0f
, 1.0f
, M_PI_2
);
3406 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3407 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3408 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3409 matrix_sanitise(matrix
);
3410 expect_matrix(matrix
,
3411 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3412 -1.0f
, 0.0f
, 0.0f
, 0.0f
,
3413 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3414 0.0f
, 0.0f
, 0.0f
, 1.0f
, 1);
3416 hr
= IDirect3DRMFrame_AddRotation(frame
, D3DRMCOMBINE_REPLACE
, 0.0f
, 0.0f
, 0.0f
, M_PI_2
);
3417 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3418 hr
= IDirect3DRMFrame_GetTransform(frame
, matrix
);
3419 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3420 matrix_sanitise(matrix
);
3421 expect_matrix(matrix
,
3422 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3423 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3424 0.0f
, -1.0f
, 0.0f
, 0.0f
,
3425 0.0f
, 0.0f
, 0.0f
, 1.0f
, 1);
3427 frame_set_transform(frame
,
3428 2.0f
, 0.0f
, 0.0f
, 0.0f
,
3429 0.0f
, 4.0f
, 0.0f
, 0.0f
,
3430 0.0f
, 0.0f
, 8.0f
, 0.0f
,
3431 64.0f
, 64.0f
, 64.0f
, 1.0f
);
3432 hr
= IDirect3DRM_CreateFrame(d3drm
, frame
, &subframe
);
3433 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3434 frame_set_transform(subframe
,
3435 1.0f
, 0.0f
, 0.0f
, 0.0f
,
3436 0.0f
, 1.0f
, 0.0f
, 0.0f
,
3437 0.0f
, 0.0f
, 1.0f
, 0.0f
,
3438 11.0f
, 11.0f
, 11.0f
, 1.0f
);
3439 set_vector(&v1
, 3.0f
, 5.0f
, 7.0f
);
3441 hr
= IDirect3DRMFrame_Transform(frame
, &v2
, &v1
);
3442 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3443 expect_vector(&v2
, 70.0f
, 84.0f
, 120.0f
, 1);
3445 hr
= IDirect3DRMFrame_Transform(subframe
, &v2
, &v1
);
3446 ok(hr
== D3DRM_OK
, "Got unexpected hr %#lx.\n", hr
);
3447 expect_vector(&v2
, 92.0f
, 128.0f
, 208.0f
, 1);
3449 IDirect3DRMFrame_Release(subframe
);
3450 IDirect3DRMFrame_Release(frame
);
3451 IDirect3DRM_Release(d3drm
);
3454 static int nb_objects
= 0;
3455 static const GUID
* refiids
[] =
3457 &IID_IDirect3DRMMeshBuilder
,
3458 &IID_IDirect3DRMMeshBuilder
,
3459 &IID_IDirect3DRMFrame
,
3460 &IID_IDirect3DRMMaterial
/* Not taken into account and not notified */
3463 static void __cdecl
object_load_callback(IDirect3DRMObject
*object
, REFIID objectguid
, void *arg
)
3465 ok(object
!= NULL
, "Arg 1 should not be null\n");
3466 ok(IsEqualGUID(objectguid
, refiids
[nb_objects
]), "Arg 2 is incorrect\n");
3467 ok(arg
== (void *)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg
);
3471 static void test_d3drm_load(void)
3475 D3DRMLOADMEMORY info
;
3476 const GUID
* req_refiids
[] = { &IID_IDirect3DRMMeshBuilder
, &IID_IDirect3DRMFrame
, &IID_IDirect3DRMMaterial
};
3478 hr
= Direct3DRMCreate(&d3drm
);
3479 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
3481 info
.lpMemory
= data_d3drm_load
;
3482 info
.dSize
= strlen(data_d3drm_load
);
3483 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 3, D3DRMLOAD_FROMMEMORY
,
3484 object_load_callback
, (void *)0xdeadbeef, NULL
, NULL
, NULL
);
3485 ok(hr
== D3DRM_OK
, "Cannot load data, hr %#lx\n", hr
);
3486 ok(nb_objects
== 3, "Should have loaded 3 objects (got %d)\n", nb_objects
);
3488 IDirect3DRM_Release(d3drm
);
3491 IDirect3DRMMeshBuilder
*mesh_builder
= NULL
;
3493 static void __cdecl
object_load_callback_frame(IDirect3DRMObject
*object
, REFIID object_guid
, void *arg
)
3496 IDirect3DRMFrame
*frame
;
3497 IDirect3DRMVisualArray
*array
;
3498 IDirect3DRMVisual
*visual
;
3502 hr
= IDirect3DRMObject_QueryInterface(object
, &IID_IDirect3DRMFrame
, (void**)&frame
);
3503 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3505 hr
= IDirect3DRMFrame_GetVisuals(frame
, &array
);
3506 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3508 size
= IDirect3DRMVisualArray_GetSize(array
);
3509 ok(size
== 1, "Wrong size %lu returned, expected 1\n", size
);
3511 hr
= IDirect3DRMVisualArray_GetElement(array
, 0, &visual
);
3512 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3514 hr
= IDirect3DRMVisual_QueryInterface(visual
, &IID_IDirect3DRMMeshBuilder
, (void**)&mesh_builder
);
3515 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3517 size
= sizeof(name
);
3518 hr
= IDirect3DRMMeshBuilder_GetName(mesh_builder
, &size
, name
);
3519 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3520 ok(!strcmp(name
, "mesh1"), "Wrong name %s, expected mesh1\n", name
);
3522 IDirect3DRMVisual_Release(visual
);
3523 IDirect3DRMVisualArray_Release(array
);
3524 IDirect3DRMFrame_Release(frame
);
3530 int vertex_per_face
;
3537 { 4, 3, 3, 9, 0x4c0000ff, 30.0f
, { 0.31f
, 0.32f
, 0.33f
}, { 0.34f
, 0.35f
, 0.36f
} },
3538 { 4, 2, 3, 6, 0x3300ff00, 20.0f
, { 0.21f
, 0.22f
, 0.23f
}, { 0.24f
, 0.25f
, 0.26f
} },
3539 { 3, 1, 3, 3, 0x19ff0000, 10.0f
, { 0.11f
, 0.12f
, 0.13f
}, { 0.14f
, 0.15f
, 0.16f
} }
3542 static void test_frame_mesh_materials(void)
3546 D3DRMLOADMEMORY info
;
3547 const GUID
*req_refiids
[] = { &IID_IDirect3DRMFrame
};
3548 IDirect3DRMMesh
*mesh
;
3550 IDirect3DRMMaterial
*material
;
3551 IDirect3DRMTexture
*texture
;
3554 hr
= Direct3DRMCreate(&d3drm
);
3555 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3557 info
.lpMemory
= data_frame_mesh_materials
;
3558 info
.dSize
= strlen(data_frame_mesh_materials
);
3559 hr
= IDirect3DRM_Load(d3drm
, &info
, NULL
, (GUID
**)req_refiids
, 1, D3DRMLOAD_FROMMEMORY
, object_load_callback_frame
, (void*)0xdeadbeef, NULL
, NULL
, NULL
);
3560 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3562 hr
= IDirect3DRMMeshBuilder_CreateMesh(mesh_builder
, &mesh
);
3563 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3565 size
= IDirect3DRMMesh_GetGroupCount(mesh
);
3566 ok(size
== 3, "Unexpected count %lu.\n", size
);
3568 for (i
= 0; i
< size
; i
++)
3570 D3DVALUE red
, green
, blue
, power
;
3572 unsigned vertex_count
, face_count
, vertex_per_face
;
3573 DWORD face_data_size
;
3575 winetest_push_context("Group %u", i
);
3577 hr
= IDirect3DRMMesh_GetGroup(mesh
, i
, &vertex_count
, &face_count
, &vertex_per_face
, &face_data_size
, NULL
);
3578 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3579 ok(vertex_count
== groups
[i
].vertex_count
, "Wrong vertex count %d, expected %d\n", vertex_count
, groups
[i
].vertex_count
);
3580 ok(face_count
== groups
[i
].face_count
, "Wrong face count %d; expected %d\n", face_count
, groups
[i
].face_count
);
3581 ok(vertex_per_face
== groups
[i
].vertex_per_face
, "Wrong vertex per face %d, expected %d\n", vertex_per_face
, groups
[i
].vertex_per_face
);
3582 ok(face_data_size
== groups
[i
].face_data_size
, "Wrong face data size %ld, expected %d\n", face_data_size
, groups
[i
].face_data_size
);
3584 color
= IDirect3DRMMesh_GetGroupColor(mesh
, i
);
3585 ok(color
== groups
[i
].color
, "Wrong color %lx, expected %lx.\n", color
, groups
[i
].color
);
3587 hr
= IDirect3DRMMesh_GetGroupMaterial(mesh
, i
, &material
);
3588 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3589 ok(material
!= NULL
, "No material.\n");
3590 power
= IDirect3DRMMaterial_GetPower(material
);
3591 ok(power
== groups
[i
].power
, "Wrong power %f, expected %f\n", power
, groups
[i
].power
);
3592 hr
= IDirect3DRMMaterial_GetSpecular(material
, &red
, &green
, &blue
);
3593 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3594 ok(red
== groups
[i
].specular
[0], "Wrong specular red %f, expected %f\n", red
, groups
[i
].specular
[0]);
3595 ok(green
== groups
[i
].specular
[1], "Wrong specular green %f, pD3DRMexpected %f\n", green
, groups
[i
].specular
[1]);
3596 ok(blue
== groups
[i
].specular
[2], "Wrong specular blue %f, expected %f\n", blue
, groups
[i
].specular
[2]);
3597 hr
= IDirect3DRMMaterial_GetEmissive(material
, &red
, &green
, &blue
);
3598 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3599 ok(red
== groups
[i
].emissive
[0], "Wrong emissive red %f, expected %f\n", red
, groups
[i
].emissive
[0]);
3600 ok(green
== groups
[i
].emissive
[1], "Wrong emissive green %f, expected %f\n", green
, groups
[i
].emissive
[1]);
3601 ok(blue
== groups
[i
].emissive
[2], "Wrong emissive blue %f, expected %f\n", blue
, groups
[i
].emissive
[2]);
3603 hr
= IDirect3DRMMesh_GetGroupTexture(mesh
, i
, &texture
);
3604 ok(hr
== D3DRM_OK
, "Unexpected hr %#lx.\n", hr
);
3605 ok(!texture
, "Unexpected texture\n");
3608 IDirect3DRMMaterial_Release(material
);
3610 IDirect3DRMTexture_Release(texture
);
3612 winetest_pop_context();
3615 IDirect3DRMMesh_Release(mesh
);
3616 IDirect3DRMMeshBuilder_Release(mesh_builder
);
3617 IDirect3DRM_Release(d3drm
);
3623 REFIID refcount_iid
;
3628 static void test_qi(const char *test_name
, IUnknown
*base_iface
,
3629 REFIID refcount_iid
, const struct qi_test
*tests
, UINT entry_count
)
3631 ULONG refcount
, expected_refcount
;
3632 IUnknown
*iface1
, *iface2
;
3636 for (i
= 0; i
< entry_count
; ++i
)
3638 hr
= IUnknown_QueryInterface(base_iface
, tests
[i
].iid
, (void **)&iface1
);
3639 ok(hr
== tests
[i
].hr
, "Got hr %#lx for test \"%s\" %u.\n", hr
, test_name
, i
);
3642 for (j
= 0; j
< entry_count
; ++j
)
3644 hr
= IUnknown_QueryInterface(iface1
, tests
[j
].iid
, (void **)&iface2
);
3645 ok(hr
== tests
[j
].hr
, "Got hr %#lx for test \"%s\" %u, %u.\n", hr
, test_name
, i
, j
);
3648 expected_refcount
= 0;
3649 if (IsEqualGUID(refcount_iid
, tests
[j
].refcount_iid
))
3650 ++expected_refcount
;
3651 if (IsEqualGUID(tests
[i
].refcount_iid
, tests
[j
].refcount_iid
))
3652 ++expected_refcount
;
3653 refcount
= IUnknown_Release(iface2
);
3654 ok(refcount
== expected_refcount
, "Got refcount %lu for test \"%s\" %u, %u, expected %lu.\n",
3655 refcount
, test_name
, i
, j
, expected_refcount
);
3656 if (tests
[i
].vtable_iid
&& tests
[j
].vtable_iid
&& IsEqualGUID(tests
[i
].vtable_iid
, tests
[j
].vtable_iid
))
3657 ok(iface1
== iface2
,
3658 "Expected iface1 == iface2 for test \"%s\" %u, %u. Got iface1 = %p, iface 2 = %p.\n",
3659 test_name
, i
, j
, iface1
, iface2
);
3660 else if (tests
[i
].vtable_iid
&& tests
[j
].vtable_iid
)
3661 ok(iface1
!= iface2
,
3662 "Expected iface1 != iface2 for test \"%s\" %u, %u. Got iface1 == iface2 == %p.\n",
3663 test_name
, i
, j
, iface1
);
3667 expected_refcount
= 0;
3668 if (IsEqualGUID(refcount_iid
, tests
[i
].refcount_iid
))
3669 ++expected_refcount
;
3670 refcount
= IUnknown_Release(iface1
);
3671 ok(refcount
== expected_refcount
, "Got refcount %lu for test \"%s\" %u, expected %lu.\n",
3672 refcount
, test_name
, i
, expected_refcount
);
3677 static void test_d3drm_qi(void)
3679 static const struct qi_test tests
[] =
3681 { &IID_IDirect3DRM3
, &IID_IDirect3DRM3
, &IID_IDirect3DRM3
, S_OK
},
3682 { &IID_IDirect3DRM2
, &IID_IDirect3DRM2
, &IID_IDirect3DRM2
, S_OK
},
3683 { &IID_IDirect3DRM
, &IID_IDirect3DRM
, &IID_IDirect3DRM
, S_OK
},
3684 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3685 { &IID_IDirect3DRMObject
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3686 { &IID_IDirect3DRMObject2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3687 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3688 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3689 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3690 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3691 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3692 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3693 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3694 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3695 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3696 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3697 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3698 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3699 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3700 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3701 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3702 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3703 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3704 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3705 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3706 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3707 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3708 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3709 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3710 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3711 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3712 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3713 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3714 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3715 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3716 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3717 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3718 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3719 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3720 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3721 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3722 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3723 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3724 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3725 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3726 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3727 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3728 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3729 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3730 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3731 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3732 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3733 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3734 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3735 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3736 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3737 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3738 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3739 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3740 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3741 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3742 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3743 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3744 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3745 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3746 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3747 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3748 { &IID_IUnknown
, &IID_IDirect3DRM
, &IID_IDirect3DRM
, S_OK
},
3753 hr
= Direct3DRMCreate(&d3drm
);
3754 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
3756 test_qi("d3drm_qi", (IUnknown
*)d3drm
, &IID_IDirect3DRM
, tests
, ARRAY_SIZE(tests
));
3758 IDirect3DRM_Release(d3drm
);
3761 static void test_frame_qi(void)
3763 static const struct qi_test tests
[] =
3765 { &IID_IDirect3DRMFrame3
, &IID_IUnknown
, &IID_IDirect3DRMFrame3
, S_OK
},
3766 { &IID_IDirect3DRMFrame2
, &IID_IUnknown
, &IID_IDirect3DRMFrame2
, S_OK
},
3767 { &IID_IDirect3DRMFrame
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
3768 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3769 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3770 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
3771 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3772 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3773 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3774 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3775 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3776 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3777 { &IID_IDirect3DRMVisual
, &IID_IUnknown
, &IID_IDirect3DRMFrame
, S_OK
},
3778 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3779 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3780 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3781 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3782 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3783 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3784 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3785 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3786 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3787 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3788 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3789 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3790 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3791 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3792 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3793 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3794 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3795 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3796 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3797 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3798 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3799 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3800 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3801 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3802 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3803 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3804 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3805 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3806 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3807 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3808 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3809 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3810 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3811 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3812 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3813 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3814 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3815 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3816 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3817 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3818 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3819 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3820 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3821 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3822 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3823 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3824 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3825 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3826 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3827 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3828 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3829 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3830 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3831 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
3834 IDirect3DRM
*d3drm1
;
3835 IDirect3DRM2
*d3drm2
;
3836 IDirect3DRM3
*d3drm3
;
3837 IDirect3DRMFrame
*frame1
;
3838 IDirect3DRMFrame2
*frame2
;
3839 IDirect3DRMFrame3
*frame3
;
3842 hr
= Direct3DRMCreate(&d3drm1
);
3843 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
3845 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
3846 ok(hr
== D3DRM_OK
, "Failed to create frame1, hr %#lx\n", hr
);
3847 hr
= IDirect3DRMFrame_QueryInterface(frame1
, &IID_IUnknown
, (void **)&unknown
);
3848 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame1, hr %#lx\n", hr
);
3849 IDirect3DRMFrame_Release(frame1
);
3850 test_qi("frame1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3851 IUnknown_Release(unknown
);
3853 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3854 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
3855 hr
= IDirect3DRM2_CreateFrame(d3drm2
, NULL
, &frame2
);
3856 ok(hr
== D3DRM_OK
, "Failed to create frame2, hr %#lx\n", hr
);
3857 hr
= IDirect3DRMFrame2_QueryInterface(frame2
, &IID_IUnknown
, (void **)&unknown
);
3858 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame2, hr %#lx\n", hr
);
3859 IDirect3DRMFrame2_Release(frame2
);
3860 test_qi("frame2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3861 IUnknown_Release(unknown
);
3863 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3864 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
3865 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
3866 ok(hr
== D3DRM_OK
, "Failed to create frame3, hr %#lx\n", hr
);
3867 hr
= IDirect3DRMFrame3_QueryInterface(frame3
, &IID_IUnknown
, (void **)&unknown
);
3868 ok(hr
== D3DRM_OK
, "Failed to create IUnknown from frame3, hr %#lx\n", hr
);
3869 IDirect3DRMFrame3_Release(frame3
);
3870 test_qi("frame3_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3871 IUnknown_Release(unknown
);
3873 IDirect3DRM3_Release(d3drm3
);
3874 IDirect3DRM2_Release(d3drm2
);
3875 IDirect3DRM_Release(d3drm1
);
3878 static void test_device_qi(void)
3880 static const struct qi_test tests
[] =
3882 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3883 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3884 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3885 { &IID_IDirect3DRMDevice
, &IID_IUnknown
, &IID_IDirect3DRMDevice
, S_OK
, },
3886 { &IID_IDirect3DRMDevice2
, &IID_IUnknown
, &IID_IDirect3DRMDevice2
, S_OK
, },
3887 { &IID_IDirect3DRMDevice3
, &IID_IUnknown
, &IID_IDirect3DRMDevice3
, S_OK
, },
3888 { &IID_IDirect3DRMWinDevice
, &IID_IUnknown
, &IID_IDirect3DRMWinDevice
, S_OK
, },
3889 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMDevice
, S_OK
, },
3890 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3891 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3892 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3893 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3894 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3895 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3896 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3897 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3898 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3899 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3900 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3901 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3902 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3903 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3904 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3905 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3906 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3907 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3908 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3909 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3910 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3911 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3912 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3913 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3914 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3915 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3916 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3917 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3918 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3919 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3920 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3921 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3922 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3923 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3924 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3925 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3926 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3927 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3928 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3929 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3930 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3931 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3932 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3933 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3934 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3935 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3936 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3937 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3938 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3939 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3940 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3941 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3942 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3943 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3944 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3945 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3946 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3947 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3948 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
3949 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
3952 IDirect3DRM
*d3drm1
;
3953 IDirect3DRM2
*d3drm2
;
3954 IDirect3DRM3
*d3drm3
;
3955 IDirectDrawClipper
*clipper
;
3956 IDirect3DRMDevice
*device1
;
3957 IDirect3DRMDevice2
*device2
;
3958 IDirect3DRMDevice3
*device3
;
3964 window
= create_window();
3965 GetClientRect(window
, &rc
);
3966 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
3967 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface, hr %#lx\n", hr
);
3968 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
3969 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper, hr %#lx\n", hr
);
3971 hr
= Direct3DRMCreate(&d3drm1
);
3972 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
3973 memcpy(&driver
, &IID_IDirect3DRGBDevice
, sizeof(GUID
));
3974 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
3975 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr
);
3976 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IUnknown
, (void **)&unknown
);
3977 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice, hr %#lx\n", hr
);
3978 IDirect3DRMDevice_Release(device1
);
3979 test_qi("device1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3980 IUnknown_Release(unknown
);
3982 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
3983 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
3984 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device2
);
3985 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface, hr %#lx\n", hr
);
3986 hr
= IDirect3DRMDevice2_QueryInterface(device2
, &IID_IUnknown
, (void **)&unknown
);
3987 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice2, hr %#lx\n", hr
);
3988 IDirect3DRMDevice2_Release(device2
);
3989 test_qi("device2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
3990 IUnknown_Release(unknown
);
3992 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
3993 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
3994 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
3995 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx\n", hr
);
3996 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IUnknown
, (void **)&unknown
);
3997 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMDevice3, hr %#lx\n", hr
);
3998 IDirect3DRMDevice3_Release(device3
);
3999 test_qi("device3_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
4000 IUnknown_Release(unknown
);
4002 IDirectDrawClipper_Release(clipper
);
4003 IDirect3DRM3_Release(d3drm3
);
4004 IDirect3DRM2_Release(d3drm2
);
4005 IDirect3DRM_Release(d3drm1
);
4006 DestroyWindow(window
);
4010 static HRESULT CALLBACK
surface_callback(IDirectDrawSurface
*surface
, DDSURFACEDESC
*desc
, void *context
)
4012 IDirectDrawSurface
**primary
= context
;
4014 if (desc
->ddsCaps
.dwCaps
& DDSCAPS_PRIMARYSURFACE
)
4017 return DDENUMRET_CANCEL
;
4019 IDirectDrawSurface_Release(surface
);
4021 return DDENUMRET_OK
;
4024 static void test_create_device_from_clipper1(void)
4026 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4027 IDirect3DRM
*d3drm1
= NULL
;
4028 IDirectDraw
*ddraw
= NULL
;
4029 IUnknown
*unknown
= NULL
;
4030 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
4031 IDirect3DDevice
*d3ddevice1
= NULL
;
4032 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
4033 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
4034 IDirectDrawSurface7
*surface7
= NULL
;
4035 DDSURFACEDESC desc
, surface_desc
;
4036 DWORD expected_flags
, ret_val
;
4038 GUID driver
= IID_IDirect3DRGBDevice
;
4040 ULONG ref1
, ref2
, cref1
, cref2
;
4043 window
= create_window();
4044 GetClientRect(window
, &rc
);
4045 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
4046 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr
);
4047 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
4048 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper, hr %#lx.\n", hr
);
4050 hr
= Direct3DRMCreate(&d3drm1
);
4051 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
4052 ref1
= get_refcount((IUnknown
*)d3drm1
);
4053 cref1
= get_refcount((IUnknown
*)clipper
);
4055 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 0, 0, &device1
);
4056 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
4057 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
4059 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4060 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, NULL
, &driver
, 300, 200, &device1
);
4061 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
4063 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 300, 200, NULL
);
4064 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
4066 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 300, 200, &device1
);
4067 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr
);
4068 ref2
= get_refcount((IUnknown
*)d3drm1
);
4069 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
4070 cref2
= get_refcount((IUnknown
*)clipper
);
4071 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %lu , cref2 = %lu.\n", cref1
, cref2
);
4072 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
4073 ok(ret_val
== 300, "Expected device width = 300, got %lu.\n", ret_val
);
4074 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
4075 ok(ret_val
== 200, "Expected device height == 200, got %lu.\n", ret_val
);
4077 /* Fetch immediate mode device in order to access render target */
4078 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
4079 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
4081 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
4082 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4084 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
4085 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got hr %#lx.\n", hr
);
4087 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4088 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
4089 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface, hr %#lx.\n", hr
);
4090 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
4091 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
4092 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4093 IUnknown_Release(unknown
);
4094 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4095 NULL
, &d3drm_primary
, surface_callback
);
4096 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
4097 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
4098 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
4099 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface, hr %#lx.\n", hr
);
4100 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
4102 IDirectDrawClipper_Release(d3drm_clipper
);
4103 IDirectDrawSurface_Release(d3drm_primary
);
4104 IDirectDrawSurface7_Release(surface7
);
4105 IDirectDraw_Release(ddraw
);
4107 /* Check properties of render target and depth surface */
4108 surface_desc
.dwSize
= sizeof(surface_desc
);
4109 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
4110 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
4112 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4113 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
4114 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4115 "Unexpected caps %#lx.\n", surface_desc
.ddsCaps
.dwCaps
);
4116 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4117 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, surface_desc
.dwFlags
);
4119 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4120 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4121 desc
.dwSize
= sizeof(desc
);
4122 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4123 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4124 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %lu bpp, got %lu bpp.\n",
4125 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
4127 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4128 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4130 desc
.dwSize
= sizeof(desc
);
4131 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4132 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
4134 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4135 desc
.dwWidth
, desc
.dwHeight
);
4136 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
4137 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4138 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
4139 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %lu.\n", desc
.dwZBufferBitDepth
);
4140 ok(!desc
.ddpfPixelFormat
.dwStencilBitMask
, "Unexpected stencil mask %#lx.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
4142 /* Release old objects and check refcount of device and clipper */
4143 IDirectDrawSurface_Release(ds
);
4145 IDirectDrawSurface_Release(surface
);
4147 IDirect3DDevice_Release(d3ddevice1
);
4149 IDirect3DRMDevice_Release(device1
);
4150 ref2
= get_refcount((IUnknown
*)d3drm1
);
4151 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
4152 cref2
= get_refcount((IUnknown
*)clipper
);
4153 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %lu, cref2 = %lu.\n", cref1
, cref2
);
4155 /* Test if render target format follows the screen format */
4156 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4157 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4158 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
4159 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp, hr %#lx.\n", hr
);
4161 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4162 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4163 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %lu.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
4165 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
4166 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr
);
4168 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
4169 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
4171 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
4172 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4174 surface_desc
.dwSize
= sizeof(surface_desc
);
4175 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
4176 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
4177 ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %lubpp.\n",
4178 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
4180 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
4181 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#lx.\n", hr
);
4184 IDirectDrawSurface_Release(ds
);
4185 IDirectDrawSurface_Release(surface
);
4186 IDirect3DDevice_Release(d3ddevice1
);
4187 IDirect3DRMDevice_Release(device1
);
4188 IDirect3DRM_Release(d3drm1
);
4189 IDirectDrawClipper_Release(clipper
);
4190 IDirectDraw_Release(ddraw
);
4191 DestroyWindow(window
);
4194 static void test_create_device_from_clipper2(void)
4196 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4197 IDirect3DRM
*d3drm1
= NULL
;
4198 IDirect3DRM2
*d3drm2
= NULL
;
4199 IDirectDraw
*ddraw
= NULL
;
4200 IUnknown
*unknown
= NULL
;
4201 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
4202 IDirect3DDevice2
*d3ddevice2
= NULL
;
4203 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
4204 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
4205 IDirectDrawSurface7
*surface7
= NULL
;
4206 DDSURFACEDESC desc
, surface_desc
;
4207 DWORD expected_flags
, ret_val
;
4209 GUID driver
= IID_IDirect3DRGBDevice
;
4211 ULONG ref1
, ref2
, ref3
, cref1
, cref2
;
4214 window
= create_window();
4215 GetClientRect(window
, &rc
);
4216 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
4217 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr
);
4218 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
4219 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper, hr %#lx.\n", hr
);
4221 hr
= Direct3DRMCreate(&d3drm1
);
4222 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
4223 ref1
= get_refcount((IUnknown
*)d3drm1
);
4224 cref1
= get_refcount((IUnknown
*)clipper
);
4226 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
4227 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
4228 ref2
= get_refcount((IUnknown
*)d3drm2
);
4230 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 0, 0, &device2
);
4231 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
4232 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
4234 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4235 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, NULL
, &driver
, 300, 200, &device2
);
4236 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
4238 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 300, 200, NULL
);
4239 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
4241 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, 300, 200, &device2
);
4242 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr
);
4243 ref3
= get_refcount((IUnknown
*)d3drm1
);
4244 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
4245 ref3
= get_refcount((IUnknown
*)d3drm2
);
4246 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4247 cref2
= get_refcount((IUnknown
*)clipper
);
4248 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %lu , cref2 = %lu.\n", cref1
, cref2
);
4249 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4250 ok(ret_val
== 300, "Expected device width = 300, got %lu.\n", ret_val
);
4251 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4252 ok(ret_val
== 200, "Expected device height == 200, got %lu.\n", ret_val
);
4254 /* Fetch immediate mode device in order to access render target */
4255 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4256 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4258 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
4259 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4261 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
4262 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got hr %#lx.\n", hr
);
4264 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4265 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
4266 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface, hr %#lx.\n", hr
);
4267 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
4268 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
4269 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4270 IUnknown_Release(unknown
);
4271 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4272 NULL
, &d3drm_primary
, surface_callback
);
4273 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
4274 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
4275 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
4276 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface, hr %#lx.\n", hr
);
4277 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
4279 IDirectDrawClipper_Release(d3drm_clipper
);
4280 IDirectDrawSurface_Release(d3drm_primary
);
4281 IDirectDrawSurface7_Release(surface7
);
4282 IDirectDraw_Release(ddraw
);
4284 /* Check properties of render target and depth surface */
4285 surface_desc
.dwSize
= sizeof(surface_desc
);
4286 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
4287 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
4289 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4290 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
4291 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4292 "Unexpected caps %#lx.\n", surface_desc
.ddsCaps
.dwCaps
);
4293 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4294 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, surface_desc
.dwFlags
);
4296 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4297 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4298 desc
.dwSize
= sizeof(desc
);
4299 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4300 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4301 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %lu bpp, got %lu bpp.\n",
4302 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
4304 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4305 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4307 desc
.dwSize
= sizeof(desc
);
4308 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4309 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
4311 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4312 desc
.dwWidth
, desc
.dwHeight
);
4313 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
4314 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4315 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
4316 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %lu.\n", desc
.dwZBufferBitDepth
);
4317 ok(!desc
.ddpfPixelFormat
.dwStencilBitMask
, "Expected stencil mask %#lx.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
4319 /* Release old objects and check refcount of device and clipper */
4320 IDirectDrawSurface_Release(ds
);
4322 IDirectDrawSurface_Release(surface
);
4324 IDirect3DDevice2_Release(d3ddevice2
);
4326 IDirect3DRMDevice2_Release(device2
);
4327 ref3
= get_refcount((IUnknown
*)d3drm1
);
4328 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
4329 ref3
= get_refcount((IUnknown
*)d3drm2
);
4330 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4331 cref2
= get_refcount((IUnknown
*)clipper
);
4332 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %lu, cref2 = %lu.\n", cref1
, cref2
);
4334 /* Test if render target format follows the screen format */
4335 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4336 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4337 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
4338 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp, hr %#lx.\n", hr
);
4340 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4341 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4342 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %lu.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
4344 hr
= IDirect3DRM2_CreateDeviceFromClipper(d3drm2
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device2
);
4345 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr
);
4347 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4348 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4350 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
4351 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4353 surface_desc
.dwSize
= sizeof(surface_desc
);
4354 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
4355 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
4356 ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %lubpp.\n",
4357 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
4359 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
4360 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#lx.\n", hr
);
4362 IDirectDrawSurface_Release(surface
);
4363 IDirect3DDevice2_Release(d3ddevice2
);
4364 IDirect3DRMDevice2_Release(device2
);
4365 IDirect3DRM2_Release(d3drm2
);
4366 IDirect3DRM_Release(d3drm1
);
4367 IDirectDrawClipper_Release(clipper
);
4368 IDirectDraw_Release(ddraw
);
4369 DestroyWindow(window
);
4372 static void test_create_device_from_clipper3(void)
4374 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4375 IDirect3DRM
*d3drm1
= NULL
;
4376 IDirect3DRM3
*d3drm3
= NULL
;
4377 IDirectDraw
*ddraw
= NULL
;
4378 IUnknown
*unknown
= NULL
;
4379 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
4380 IDirect3DDevice2
*d3ddevice2
= NULL
;
4381 IDirect3DDevice3
*d3ddevice3
= NULL
;
4382 IDirectDrawClipper
*clipper
= NULL
, *d3drm_clipper
= NULL
;
4383 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_primary
= NULL
;
4384 IDirectDrawSurface7
*surface7
= NULL
;
4385 DDSURFACEDESC desc
, surface_desc
;
4386 DWORD expected_flags
, ret_val
;
4388 GUID driver
= IID_IDirect3DRGBDevice
;
4390 ULONG ref1
, ref2
, ref3
, cref1
, cref2
;
4393 window
= create_window();
4394 GetClientRect(window
, &rc
);
4395 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
4396 ok(hr
== DD_OK
, "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr
);
4397 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
4398 ok(hr
== DD_OK
, "Cannot set HWnd to Clipper, hr %#lx.\n", hr
);
4400 hr
= Direct3DRMCreate(&d3drm1
);
4401 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
4402 ref1
= get_refcount((IUnknown
*)d3drm1
);
4403 cref1
= get_refcount((IUnknown
*)clipper
);
4405 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
4406 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
4407 ref2
= get_refcount((IUnknown
*)d3drm3
);
4409 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 0, 0, &device3
);
4410 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
4411 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
4413 /* If NULL is passed for clipper, CreateDeviceFromClipper returns D3DRMERR_BADVALUE */
4414 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, NULL
, &driver
, 300, 200, &device3
);
4415 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
4417 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 300, 200, NULL
);
4418 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
4420 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 300, 200, &device3
);
4421 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
4422 ref3
= get_refcount((IUnknown
*)d3drm1
);
4423 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
4424 ref3
= get_refcount((IUnknown
*)d3drm3
);
4425 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4426 cref2
= get_refcount((IUnknown
*)clipper
);
4427 ok(cref2
> cref1
, "expected cref2 > cref1, got cref1 = %lu , cref2 = %lu.\n", cref1
, cref2
);
4428 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
4429 ok(ret_val
== 300, "Expected device width = 300, got %lu.\n", ret_val
);
4430 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
4431 ok(ret_val
== 200, "Expected device height == 200, got %lu.\n", ret_val
);
4433 /* Fetch immediate mode device in order to access render target */
4434 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4435 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4437 hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice3
, (void**)&d3ddevice3
);
4438 ok(hr
== S_OK
, "Unexpected hr %#lx.\n", hr
);
4439 IDirect3DDevice3_Release(d3ddevice3
);
4441 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
4442 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4444 hr
= IDirectDrawSurface_GetClipper(surface
, &d3drm_clipper
);
4445 ok(hr
== DDERR_NOCLIPPERATTACHED
, "Expected hr == DDERR_NOCLIPPERATTACHED, got hr %#lx.\n", hr
);
4447 /* Check if CreateDeviceFromClipper creates a primary surface and attaches the clipper to it */
4448 hr
= IDirectDrawSurface_QueryInterface(surface
, &IID_IDirectDrawSurface7
, (void **)&surface7
);
4449 ok(hr
== DD_OK
, "Cannot get IDirectDrawSurface7 interface, hr %#lx.\n", hr
);
4450 IDirectDrawSurface7_GetDDInterface(surface7
, (void **)&unknown
);
4451 hr
= IUnknown_QueryInterface(unknown
, &IID_IDirectDraw
, (void **)&ddraw
);
4452 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4453 IUnknown_Release(unknown
);
4454 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4455 NULL
, &d3drm_primary
, surface_callback
);
4456 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
4457 ok(d3drm_primary
!= NULL
, "No primary surface was enumerated.\n");
4458 hr
= IDirectDrawSurface_GetClipper(d3drm_primary
, &d3drm_clipper
);
4459 ok(hr
== DD_OK
, "Cannot get attached clipper from primary surface, hr %#lx.\n", hr
);
4460 ok(d3drm_clipper
== clipper
, "Expected clipper returned == %p, got %p.\n", clipper
, d3drm_clipper
);
4462 IDirectDrawClipper_Release(d3drm_clipper
);
4463 IDirectDrawSurface_Release(d3drm_primary
);
4464 IDirectDrawSurface7_Release(surface7
);
4465 IDirectDraw_Release(ddraw
);
4467 /* Check properties of render target and depth surface */
4468 surface_desc
.dwSize
= sizeof(surface_desc
);
4469 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
4470 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
4472 ok((surface_desc
.dwWidth
== 300) && (surface_desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4473 surface_desc
.dwWidth
, surface_desc
.dwHeight
);
4474 ok((surface_desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
4475 "Unexpected caps %#lx.\n", surface_desc
.ddsCaps
.dwCaps
);
4476 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4477 ok(surface_desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, surface_desc
.dwFlags
);
4479 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4480 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4481 desc
.dwSize
= sizeof(desc
);
4482 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4483 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4484 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, "Expected %lu bpp, got %lu bpp.\n",
4485 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
, desc
.ddpfPixelFormat
.dwRGBBitCount
);
4487 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4488 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4490 desc
.dwSize
= sizeof(desc
);
4491 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4492 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
4494 ok((desc
.dwWidth
== 300) && (desc
.dwHeight
== 200), "Expected surface dimensions = 300, 200, got %lu, %lu.\n",
4495 desc
.dwWidth
, desc
.dwHeight
);
4496 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
4497 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4498 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
4499 ok(desc
.dwZBufferBitDepth
== 16, "Expected 16 for Z buffer bit depth, got %lu.\n", desc
.dwZBufferBitDepth
);
4500 ok(!desc
.ddpfPixelFormat
.dwStencilBitMask
, "Unexpected stencil mask %#lx.\n", desc
.ddpfPixelFormat
.dwStencilBitMask
);
4502 /* Release old objects and check refcount of device and clipper */
4503 IDirectDrawSurface_Release(ds
);
4505 IDirectDrawSurface_Release(surface
);
4507 IDirect3DDevice2_Release(d3ddevice2
);
4509 IDirect3DRMDevice3_Release(device3
);
4510 ref3
= get_refcount((IUnknown
*)d3drm1
);
4511 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
4512 ref3
= get_refcount((IUnknown
*)d3drm3
);
4513 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4514 cref2
= get_refcount((IUnknown
*)clipper
);
4515 ok(cref1
== cref2
, "expected cref1 == cref2, got cref1 = %lu, cref2 = %lu.\n", cref1
, cref2
);
4517 /* Test if render target format follows the screen format */
4518 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4519 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4520 hr
= IDirectDraw_SetDisplayMode(ddraw
, desc
.dwWidth
, desc
.dwHeight
, 16);
4521 ok(hr
== DD_OK
, "Cannot set display mode to 16bpp, hr %#lx.\n", hr
);
4523 hr
= IDirectDraw_GetDisplayMode(ddraw
, &desc
);
4524 ok(hr
== DD_OK
, "Cannot get IDirectDraw display mode, hr %#lx\n", hr
);
4525 ok(desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16 bpp, got %lu.\n", desc
.ddpfPixelFormat
.dwRGBBitCount
);
4527 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
4528 ok(hr
== D3DRM_OK
, "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
4530 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4531 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4533 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &surface
);
4534 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4536 surface_desc
.dwSize
= sizeof(surface_desc
);
4537 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &surface_desc
);
4538 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
4539 ok(surface_desc
.ddpfPixelFormat
.dwRGBBitCount
== 16, "Expected 16bpp, got %lubpp.\n",
4540 surface_desc
.ddpfPixelFormat
.dwRGBBitCount
);
4542 hr
= IDirectDraw2_RestoreDisplayMode(ddraw
);
4543 ok(SUCCEEDED(hr
), "RestoreDisplayMode failed, hr %#lx.\n", hr
);
4545 IDirectDrawSurface_Release(surface
);
4546 IDirect3DDevice2_Release(d3ddevice2
);
4547 IDirect3DRMDevice3_Release(device3
);
4548 IDirect3DRM3_Release(d3drm3
);
4549 IDirect3DRM_Release(d3drm1
);
4550 IDirectDrawClipper_Release(clipper
);
4551 IDirectDraw_Release(ddraw
);
4552 DestroyWindow(window
);
4555 static void test_create_device_from_surface1(void)
4557 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4559 IDirectDraw
*ddraw
= NULL
;
4560 IDirect3DRM
*d3drm1
= NULL
;
4561 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
4562 IDirect3DDevice
*d3ddevice1
= NULL
;
4563 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
4564 DWORD expected_flags
, ret_val
;
4566 GUID driver
= IID_IDirect3DRGBDevice
;
4567 ULONG ref1
, ref2
, surface_ref1
, surface_ref2
;
4569 BOOL use_sysmem_zbuffer
= FALSE
;
4572 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4573 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4575 window
= create_window();
4576 GetClientRect(window
, &rc
);
4578 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4579 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
4581 hr
= Direct3DRMCreate(&d3drm1
);
4582 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
4583 ref1
= get_refcount((IUnknown
*)d3drm1
);
4585 /* Create a surface and use it to create the retained mode device. */
4586 memset(&desc
, 0, sizeof(desc
));
4587 desc
.dwSize
= sizeof(desc
);
4588 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4589 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
4590 desc
.dwWidth
= rc
.right
;
4591 desc
.dwHeight
= rc
.bottom
;
4593 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4594 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4596 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
4597 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got hr %#lx.\n", hr
);
4598 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
4599 IDirectDrawSurface_Release(surface
);
4601 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
4602 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4603 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4604 surface_ref1
= get_refcount((IUnknown
*)surface
);
4606 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, NULL
);
4607 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got hr %#lx.\n", hr
);
4608 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, NULL
, &device1
);
4609 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr
);
4610 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, NULL
, surface
, &device1
);
4611 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr
);
4613 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
4614 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr
);
4615 ref2
= get_refcount((IUnknown
*)d3drm1
);
4616 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu , ref2 = %lu.\n", ref1
, ref2
);
4617 surface_ref2
= get_refcount((IUnknown
*)surface
);
4618 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n", surface_ref1
, surface_ref2
);
4619 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
4620 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
4621 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
4622 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
4624 /* Check if CreateDeviceFromSurface creates a primary surface */
4625 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4626 NULL
, &d3drm_surface
, surface_callback
);
4627 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
4628 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
4630 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3ddevice1
);
4631 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
4633 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&d3drm_surface
);
4634 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4635 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4637 /* Check properties of attached depth surface */
4638 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
4639 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4641 memset(&desc
, 0, sizeof(desc
));
4642 desc
.dwSize
= sizeof(desc
);
4643 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4644 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
4646 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
4647 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
4648 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4649 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
4650 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4651 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
4653 IDirectDrawSurface_Release(ds
);
4654 IDirect3DDevice_Release(d3ddevice1
);
4655 IDirectDrawSurface_Release(d3drm_surface
);
4657 IDirect3DRMDevice_Release(device1
);
4658 ref2
= get_refcount((IUnknown
*)d3drm1
);
4659 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
4660 surface_ref2
= get_refcount((IUnknown
*)surface
);
4661 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n",
4662 surface_ref1
, surface_ref2
);
4663 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4664 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4665 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4666 ref1
= IDirectDrawSurface_Release(ds
);
4667 ok(ref1
== 1, "Unexpected refcount %lu.\n", ref1
);
4668 ref1
= IDirectDrawSurface_Release(surface
);
4669 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
4671 memset(&desc
, 0, sizeof(desc
));
4672 desc
.dwSize
= sizeof(desc
);
4673 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4674 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4675 desc
.dwWidth
= rc
.right
;
4676 desc
.dwHeight
= rc
.bottom
;
4678 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4679 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4681 memset(&desc
, 0, sizeof(desc
));
4682 desc
.dwSize
= sizeof(desc
);
4683 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4684 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
4685 desc
.dwZBufferBitDepth
= 16;
4686 desc
.dwWidth
= rc
.right
;
4687 desc
.dwHeight
= rc
.bottom
;
4688 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
4689 ok(hr
== DD_OK
, "Cannot create depth surface, hr %#lx.\n", hr
);
4690 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
4691 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
4693 hr
= IDirect3DRM_CreateDeviceFromSurface(d3drm1
, &driver
, ddraw
, surface
, &device1
);
4694 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice interface, hr %#lx.\n", hr
);
4696 hr
= IDirect3DRMDevice2_GetDirect3DDevice(device1
, &d3ddevice1
);
4697 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
4699 hr
= IDirect3DDevice_QueryInterface(d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&d3drm_surface
);
4700 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4701 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4703 /* Check if depth surface matches the one we created */
4704 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4705 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4706 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4708 IDirectDrawSurface_Release(d3drm_ds
);
4709 IDirectDrawSurface_Release(d3drm_surface
);
4710 IDirectDrawSurface_Release(ds
);
4712 IDirect3DDevice_Release(d3ddevice1
);
4713 IDirect3DRMDevice_Release(device1
);
4714 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4715 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4716 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4717 ref1
= IDirectDrawSurface_Release(ds
);
4718 ok(ref1
== 1, "Unexpected refcount %lu.\n", ref1
);
4719 ref1
= IDirectDrawSurface_Release(surface
);
4720 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
4721 IDirect3DRM_Release(d3drm1
);
4722 IDirectDraw_Release(ddraw
);
4723 DestroyWindow(window
);
4726 static void test_create_device_from_surface2(void)
4728 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4730 IDirectDraw
*ddraw
= NULL
;
4731 IDirect3DRM
*d3drm1
= NULL
;
4732 IDirect3DRM2
*d3drm2
= NULL
;
4733 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
4734 IDirect3DDevice2
*d3ddevice2
= NULL
;
4735 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
4736 DWORD expected_flags
, ret_val
;
4738 GUID driver
= IID_IDirect3DRGBDevice
;
4739 ULONG ref1
, ref2
, ref3
, surface_ref1
, surface_ref2
;
4741 BOOL use_sysmem_zbuffer
= FALSE
;
4744 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4745 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4747 window
= create_window();
4748 GetClientRect(window
, &rc
);
4750 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4751 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
4753 hr
= Direct3DRMCreate(&d3drm1
);
4754 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
4755 ref1
= get_refcount((IUnknown
*)d3drm1
);
4757 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
4758 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
4759 ref2
= get_refcount((IUnknown
*)d3drm2
);
4761 /* Create a surface and use it to create the retained mode device. */
4762 memset(&desc
, 0, sizeof(desc
));
4763 desc
.dwSize
= sizeof(desc
);
4764 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4765 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
4766 desc
.dwWidth
= rc
.right
;
4767 desc
.dwHeight
= rc
.bottom
;
4769 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4770 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4772 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4773 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got hr %#lx.\n", hr
);
4774 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
4775 IDirectDrawSurface_Release(surface
);
4777 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
4778 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4779 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4780 surface_ref1
= get_refcount((IUnknown
*)surface
);
4782 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, NULL
);
4783 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got hr %#lx.\n", hr
);
4784 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, NULL
, &device2
);
4785 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr
);
4786 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, NULL
, surface
, &device2
);
4787 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr
);
4789 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4790 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr
);
4791 ref3
= get_refcount((IUnknown
*)d3drm1
);
4792 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
4793 ref3
= get_refcount((IUnknown
*)d3drm2
);
4794 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4795 surface_ref2
= get_refcount((IUnknown
*)surface
);
4796 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n", surface_ref1
, surface_ref2
);
4797 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
4798 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
4799 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
4800 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
4802 /* Check if CreateDeviceFromSurface creates a primary surface */
4803 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4804 NULL
, &d3drm_surface
, surface_callback
);
4805 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
4806 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
4808 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4809 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4811 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4812 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4813 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4815 /* Check properties of attached depth surface */
4816 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
4817 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4819 memset(&desc
, 0, sizeof(desc
));
4820 desc
.dwSize
= sizeof(desc
);
4821 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
4822 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
4824 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
4825 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
4826 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
4827 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
4828 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
4829 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
4831 IDirectDrawSurface_Release(ds
);
4832 IDirect3DDevice2_Release(d3ddevice2
);
4833 IDirectDrawSurface_Release(d3drm_surface
);
4835 IDirect3DRMDevice2_Release(device2
);
4836 ref3
= get_refcount((IUnknown
*)d3drm1
);
4837 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
4838 ref3
= get_refcount((IUnknown
*)d3drm2
);
4839 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4840 surface_ref2
= get_refcount((IUnknown
*)surface
);
4841 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n",
4842 surface_ref1
, surface_ref2
);
4843 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4844 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4845 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4846 ref1
= IDirectDrawSurface_Release(ds
);
4847 ok(ref1
== 1, "Unexpected refcount %lu.\n", ref1
);
4849 ref1
= IDirectDrawSurface_Release(surface
);
4850 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
4852 memset(&desc
, 0, sizeof(desc
));
4853 desc
.dwSize
= sizeof(desc
);
4854 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4855 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
4856 desc
.dwWidth
= rc
.right
;
4857 desc
.dwHeight
= rc
.bottom
;
4859 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4860 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4862 memset(&desc
, 0, sizeof(desc
));
4863 desc
.dwSize
= sizeof(desc
);
4864 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
4865 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
4866 desc
.dwZBufferBitDepth
= 16;
4867 desc
.dwWidth
= rc
.right
;
4868 desc
.dwHeight
= rc
.bottom
;
4869 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
4870 ok(hr
== DD_OK
, "Cannot create depth surface, hr %#lx.\n", hr
);
4871 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
4872 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
4874 hr
= IDirect3DRM2_CreateDeviceFromSurface(d3drm2
, &driver
, ddraw
, surface
, &device2
);
4875 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice2 interface, hr %#lx.\n", hr
);
4877 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
4878 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4880 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4881 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4882 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4884 /* Check if depth surface matches the one we created */
4885 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
4886 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4887 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
4889 IDirectDrawSurface_Release(d3drm_ds
);
4890 IDirectDrawSurface_Release(d3drm_surface
);
4891 IDirectDrawSurface_Release(ds
);
4893 IDirect3DDevice2_Release(d3ddevice2
);
4894 IDirect3DRMDevice2_Release(device2
);
4895 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
4896 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
4897 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
4898 ref1
= IDirectDrawSurface_Release(ds
);
4899 ok(ref1
== 1, "Unexpected refcount %lu.\n", ref1
);
4900 ref1
= IDirectDrawSurface_Release(surface
);
4901 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
4902 IDirect3DRM2_Release(d3drm2
);
4903 IDirect3DRM_Release(d3drm1
);
4904 IDirectDraw_Release(ddraw
);
4905 DestroyWindow(window
);
4908 static void test_create_device_from_surface3(void)
4910 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
4912 IDirectDraw
*ddraw
= NULL
;
4913 IDirect3DRM
*d3drm1
= NULL
;
4914 IDirect3DRM3
*d3drm3
= NULL
;
4915 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
4916 IDirect3DDevice2
*d3ddevice2
= NULL
;
4917 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_surface
= NULL
, *d3drm_ds
= NULL
;
4918 DWORD expected_flags
, ret_val
;
4920 GUID driver
= IID_IDirect3DRGBDevice
;
4921 ULONG ref1
, ref2
, ref3
, surface_ref1
, surface_ref2
;
4923 BOOL use_sysmem_zbuffer
= FALSE
;
4926 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
4927 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
4929 window
= create_window();
4930 GetClientRect(window
, &rc
);
4932 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
4933 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
4935 hr
= Direct3DRMCreate(&d3drm1
);
4936 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
4937 ref1
= get_refcount((IUnknown
*)d3drm1
);
4939 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
4940 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
4941 ref2
= get_refcount((IUnknown
*)d3drm3
);
4943 /* Create a surface and use it to create the retained mode device. */
4944 memset(&desc
, 0, sizeof(desc
));
4945 desc
.dwSize
= sizeof(desc
);
4946 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
4947 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
4948 desc
.dwWidth
= rc
.right
;
4949 desc
.dwHeight
= rc
.bottom
;
4951 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4952 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4954 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4955 ok(hr
== DDERR_INVALIDCAPS
, "Expected hr == DDERR_INVALIDCAPS, got hr %#lx.\n", hr
);
4956 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
4957 IDirectDrawSurface_Release(surface
);
4959 desc
.ddsCaps
.dwCaps
|= DDSCAPS_3DDEVICE
;
4960 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
4961 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
4962 surface_ref1
= get_refcount((IUnknown
*)surface
);
4964 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, NULL
);
4965 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == DDERR_BADVALUE, got hr %#lx.\n", hr
);
4966 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, NULL
, 0, &device3
);
4967 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr
);
4968 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, NULL
, surface
, 0, &device3
);
4969 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == DDERR_BADDEVICE, got hr %#lx.\n", hr
);
4971 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
4972 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
4973 ref3
= get_refcount((IUnknown
*)d3drm1
);
4974 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
4975 ref3
= get_refcount((IUnknown
*)d3drm3
);
4976 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
4977 surface_ref2
= get_refcount((IUnknown
*)surface
);
4978 ok(surface_ref2
> surface_ref1
, "Expected surface_ref2 > surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n", surface_ref1
, surface_ref2
);
4979 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
4980 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
4981 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
4982 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
4984 /* Check if CreateDeviceFromSurface creates a primary surface */
4985 hr
= IDirectDraw_EnumSurfaces(ddraw
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
4986 NULL
, &d3drm_surface
, surface_callback
);
4987 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
4988 ok(d3drm_surface
== NULL
, "No primary surface should have enumerated (%p).\n", d3drm_surface
);
4990 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
4991 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
4993 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
4994 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
4995 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
4997 /* Check properties of attached depth surface */
4998 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &ds
);
4999 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5001 memset(&desc
, 0, sizeof(desc
));
5002 desc
.dwSize
= sizeof(desc
);
5003 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5004 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
5006 use_sysmem_zbuffer
= desc
.ddsCaps
.dwCaps
& DDSCAPS_SYSTEMMEMORY
;
5007 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5008 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5009 ok(desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
, "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
5010 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5011 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5013 IDirectDrawSurface_Release(ds
);
5014 IDirect3DDevice2_Release(d3ddevice2
);
5015 IDirectDrawSurface_Release(d3drm_surface
);
5016 IDirect3DRMDevice3_Release(device3
);
5018 ref3
= get_refcount((IUnknown
*)d3drm1
);
5019 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
5020 ref3
= get_refcount((IUnknown
*)d3drm3
);
5021 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
5022 surface_ref2
= get_refcount((IUnknown
*)surface
);
5023 ok(surface_ref2
== surface_ref1
, "Expected surface_ref2 == surface_ref1, got surface_ref1 = %lu, surface_ref2 = %lu.\n",
5024 surface_ref1
, surface_ref2
);
5025 /* In version 3, d3drm will destroy all references of the depth surface it created internally. */
5026 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
5027 todo_wine
ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got hr %#lx.\n", hr
);
5029 IDirectDrawSurface_Release(ds
);
5030 ref1
= IDirectDrawSurface_Release(surface
);
5031 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
5033 memset(&desc
, 0, sizeof(desc
));
5034 desc
.dwSize
= sizeof(desc
);
5035 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
5036 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
5037 desc
.dwWidth
= rc
.right
;
5038 desc
.dwHeight
= rc
.bottom
;
5040 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
5041 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
5043 memset(&desc
, 0, sizeof(desc
));
5044 desc
.dwSize
= sizeof(desc
);
5045 desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
5046 desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
| (use_sysmem_zbuffer
? DDSCAPS_SYSTEMMEMORY
: 0);
5047 desc
.dwZBufferBitDepth
= 16;
5048 desc
.dwWidth
= rc
.right
;
5049 desc
.dwHeight
= rc
.bottom
;
5050 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &ds
, NULL
);
5051 ok(hr
== DD_OK
, "Cannot create depth surface, hr %#lx.\n", hr
);
5052 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
5053 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
5055 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, D3DRMDEVICE_NOZBUFFER
, &device3
);
5056 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
5058 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
5059 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
5061 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
5062 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
5063 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
5065 /* Check if depth surface matches the one we created */
5066 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
5067 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5068 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5070 IDirectDrawSurface_Release(d3drm_ds
);
5071 IDirectDrawSurface_Release(d3drm_surface
);
5072 IDirectDrawSurface_Release(ds
);
5073 IDirect3DDevice2_Release(d3ddevice2
);
5074 IDirect3DRMDevice3_Release(device3
);
5075 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
5076 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5077 /* The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
5078 ref1
= IDirectDrawSurface_Release(ds
);
5079 ok(ref1
== 1, "Unexpected refcount %lu.\n", ref1
);
5081 /* What happens if we pass no flags and still attach our own depth surface? */
5082 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, 0, &device3
);
5083 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
5085 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
5086 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
5088 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
5089 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
5090 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
5092 /* Check if depth surface matches the one we created */
5093 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
5094 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5095 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5097 IDirectDrawSurface_Release(d3drm_ds
);
5098 IDirectDrawSurface_Release(d3drm_surface
);
5099 IDirect3DDevice2_Release(d3ddevice2
);
5100 IDirect3DRMDevice3_Release(device3
);
5101 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
5102 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5103 /*The render target still holds a reference to ds as the depth surface remains attached to it, so refcount will be 1*/
5104 ref1
= IDirectDrawSurface_Release(ds
);
5105 ok(ref1
== 1, "Unexpected refcount %lu.\n", ref1
);
5106 ref1
= IDirectDrawSurface_Release(surface
);
5107 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
5109 memset(&desc
, 0, sizeof(desc
));
5110 desc
.dwSize
= sizeof(desc
);
5111 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
5112 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
5113 desc
.dwWidth
= rc
.right
;
5114 desc
.dwHeight
= rc
.bottom
;
5116 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
5117 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
5119 /* What happens if we don't pass D3DRMDEVICE_NOZBUFFER and still not attach our own depth surface? */
5120 hr
= IDirect3DRM3_CreateDeviceFromSurface(d3drm3
, &driver
, ddraw
, surface
, D3DRMDEVICE_NOZBUFFER
, &device3
);
5121 ok(SUCCEEDED(hr
), "Cannot create IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
5123 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
5124 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
5126 hr
= IDirect3DDevice2_GetRenderTarget(d3ddevice2
, &d3drm_surface
);
5127 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
5128 ok(surface
== d3drm_surface
, "Expected surface returned == %p, got %p.\n", surface
, d3drm_surface
);
5130 /* Check if depth surface matches the one we created */
5131 hr
= IDirectDrawSurface_GetAttachedSurface(d3drm_surface
, &caps
, &d3drm_ds
);
5132 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#lx.\n", hr
);
5133 IDirectDrawSurface_Release(d3drm_surface
);
5135 IDirect3DDevice2_Release(d3ddevice2
);
5136 IDirect3DRMDevice3_Release(device3
);
5137 ref1
= IDirectDrawSurface_Release(surface
);
5138 ok(!ref1
, "Unexpected refcount %lu.\n", ref1
);
5139 IDirect3DRM3_Release(d3drm3
);
5140 IDirect3DRM_Release(d3drm1
);
5141 IDirectDraw_Release(ddraw
);
5142 DestroyWindow(window
);
5145 static IDirect3DDevice
*create_device1(IDirectDraw
*ddraw
, HWND window
, IDirectDrawSurface
**ds
)
5147 static const DWORD z_depths
[] = { 32, 24, 16 };
5148 IDirectDrawSurface
*surface
;
5149 IDirect3DDevice
*device
= NULL
;
5150 DDSURFACEDESC surface_desc
;
5155 GetClientRect(window
, &rc
);
5156 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
5157 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
5159 memset(&surface_desc
, 0, sizeof(surface_desc
));
5160 surface_desc
.dwSize
= sizeof(surface_desc
);
5161 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
5162 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
5163 surface_desc
.dwWidth
= rc
.right
;
5164 surface_desc
.dwHeight
= rc
.bottom
;
5166 hr
= IDirectDraw_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
5167 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
5169 /* We used to use EnumDevices() for this, but it seems
5170 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
5171 * relationship with reality. */
5172 for (i
= 0; i
< ARRAY_SIZE(z_depths
); ++i
)
5174 memset(&surface_desc
, 0, sizeof(surface_desc
));
5175 surface_desc
.dwSize
= sizeof(surface_desc
);
5176 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
5177 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
5178 surface_desc
.dwZBufferBitDepth
= z_depths
[i
];
5179 surface_desc
.dwWidth
= rc
.right
;
5180 surface_desc
.dwHeight
= rc
.bottom
;
5181 if (FAILED(IDirectDraw_CreateSurface(ddraw
, &surface_desc
, ds
, NULL
)))
5184 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, *ds
);
5185 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
5188 IDirectDrawSurface_Release(*ds
);
5192 if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface
, &IID_IDirect3DHALDevice
, (void **)&device
)))
5195 IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, *ds
);
5196 IDirectDrawSurface_Release(*ds
);
5200 IDirectDrawSurface_Release(surface
);
5204 static void test_create_device_from_d3d1(void)
5206 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
5207 IDirect3D
*d3d1
= NULL
, *temp_d3d1
;
5208 IDirect3DRM
*d3drm1
= NULL
;
5209 IDirect3DRMDevice
*device1
= (IDirect3DRMDevice
*)0xdeadbeef;
5210 IDirect3DRMDevice2
*device2
;
5211 IDirect3DRMDevice3
*device3
;
5212 IDirect3DDevice
*d3ddevice1
= NULL
, *d3drm_d3ddevice1
= NULL
, *temp_d3ddevice1
;
5213 IDirect3DDevice2
*d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
5214 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
5215 DWORD expected_flags
, ret_val
;
5216 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
5220 ULONG ref1
, ref2
, ref3
, ref4
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
5223 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
5224 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
5226 window
= create_window();
5227 GetClientRect(window
, &rc
);
5229 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
5230 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
5231 d3d_ref1
= get_refcount((IUnknown
*)d3d1
);
5233 /* Create the immediate mode device */
5234 d3ddevice1
= create_device1(ddraw1
, window
, &ds
);
5235 if (d3ddevice1
== NULL
)
5237 win_skip("Cannot create IM device, skipping tests.\n");
5238 IDirect3D_Release(d3d1
);
5239 IDirectDraw_Release(ddraw1
);
5242 device_ref1
= get_refcount((IUnknown
*)d3ddevice1
);
5244 hr
= Direct3DRMCreate(&d3drm1
);
5245 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
5246 ref1
= get_refcount((IUnknown
*)d3drm1
);
5248 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, NULL
, d3ddevice1
, &device1
);
5249 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
5250 ok(device1
== NULL
, "Expected device returned == NULL, got %p.\n", device1
);
5251 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, NULL
, &device1
);
5252 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5253 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, d3ddevice1
, NULL
);
5254 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5256 hr
= IDirect3DRM_CreateDeviceFromD3D(d3drm1
, d3d1
, d3ddevice1
, &device1
);
5257 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice interface, hr %#lx\n", hr
);
5258 ref2
= get_refcount((IUnknown
*)d3drm1
);
5259 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
5260 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
5261 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1
, device_ref2
);
5262 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
5263 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5264 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
5265 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
5266 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
5267 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
5269 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
5270 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 Interface, hr %#lx.\n", hr
);
5271 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
5272 ok(SUCCEEDED(hr
), "Expected hr == D3DRM_OK, got hr %#lx.\n", hr
);
5273 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
5274 IDirect3DRMDevice2_Release(device2
);
5276 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
5277 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
5278 ok(hr
== DD_OK
, "Cannot get IDirect3DRMDevice3 Interface, hr %#lx.\n", hr
);
5279 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
5280 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5281 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
5282 IDirect3DRMDevice3_Release(device3
);
5284 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5285 NULL
, &surface
, surface_callback
);
5286 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
5287 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5289 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3drm_d3ddevice1
);
5290 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
5291 ok(d3ddevice1
== d3drm_d3ddevice1
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice1
, d3drm_d3ddevice1
);
5293 /* Check properties of render target and depth surfaces */
5294 hr
= IDirect3DDevice_QueryInterface(d3drm_d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
5295 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
5297 memset(&desc
, 0, sizeof(desc
));
5298 desc
.dwSize
= sizeof(desc
);
5299 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5300 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
5302 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5303 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5304 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
5305 "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
5306 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5307 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5309 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5310 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5311 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5313 desc
.dwSize
= sizeof(desc
);
5314 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5315 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
5317 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5318 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5319 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
5320 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5321 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5323 IDirectDrawSurface_Release(d3drm_ds
);
5324 IDirectDrawSurface_Release(ds
);
5325 IDirectDrawSurface_Release(surface
);
5326 IDirect3DDevice_Release(d3drm_d3ddevice1
);
5327 IDirect3DRMDevice_Release(device1
);
5328 ref2
= get_refcount((IUnknown
*)d3drm1
);
5329 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
5330 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
5331 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1
, device_ref2
);
5333 /* InitFromD3D tests */
5334 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice
, (void **)&device1
);
5335 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface, hr %#lx.\n", hr
);
5337 hr
= IDirect3DRMDevice_InitFromD3D(device1
, NULL
, d3ddevice1
);
5338 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5339 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, NULL
);
5340 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5342 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
5343 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice interface, hr %#lx\n", hr
);
5344 ref2
= get_refcount((IUnknown
*)d3drm1
);
5345 ok(ref2
> ref1
, "expected ref2 > ref1, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
5346 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
5347 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5348 device_ref1
, device_ref2
);
5349 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
5350 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5351 ret_val
= IDirect3DRMDevice_GetWidth(device1
);
5352 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
5353 ret_val
= IDirect3DRMDevice_GetHeight(device1
);
5354 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
5356 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
5357 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5358 ref3
= get_refcount((IUnknown
*)d3drm1
);
5359 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
5360 ref3
= get_refcount((IUnknown
*)d3ddevice1
);
5361 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3
, device_ref2
);
5362 ref3
= get_refcount((IUnknown
*)d3d1
);
5363 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3
, d3d_ref2
);
5364 /* Release leaked references */
5365 while (IDirect3DRM_Release(d3drm1
) > ref2
);
5366 while (IDirect3DDevice_Release(d3ddevice1
) > device_ref2
);
5367 while (IDirect3D_Release(d3d1
) > d3d_ref2
);
5369 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
5370 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
5371 ref4
= get_refcount((IUnknown
*)temp_ddraw1
);
5373 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D
, (void **)&temp_d3d1
);
5374 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
5375 temp_d3ddevice1
= create_device1(temp_ddraw1
, window
, &surface
);
5376 hr
= IDirect3DRMDevice_InitFromD3D(device1
, temp_d3d1
, temp_d3ddevice1
);
5377 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5378 ref3
= get_refcount((IUnknown
*)d3drm1
);
5379 ok(ref3
> ref2
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
5380 ref3
= get_refcount((IUnknown
*)temp_d3ddevice1
);
5381 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3
, device_ref2
);
5382 ref3
= get_refcount((IUnknown
*)temp_d3d1
);
5383 todo_wine
ok(ref3
< d3d_ref2
, "Expected ref3 < d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3
, d3d_ref2
);
5384 /* Release leaked references */
5385 while (IDirect3DRM_Release(d3drm1
) > ref2
);
5386 while (IDirect3DDevice_Release(temp_d3ddevice1
) > 0);
5387 while (IDirect3D_Release(temp_d3d1
) > ref4
);
5388 IDirectDrawSurface_Release(surface
);
5389 IDirectDraw_Release(temp_ddraw1
);
5391 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
5392 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
5393 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 Interface, hr %#lx.\n", hr
);
5394 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3ddevice2
);
5395 ok(SUCCEEDED(hr
), "Expected hr == D3DRM_OK, got hr %#lx.\n", hr
);
5396 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
5397 IDirect3DRMDevice2_Release(device2
);
5399 d3ddevice2
= (IDirect3DDevice2
*)0xdeadbeef;
5400 hr
= IDirect3DRMDevice_QueryInterface(device1
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
5401 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 Interface, hr %#lx.\n", hr
);
5402 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3ddevice2
);
5403 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5404 ok(d3ddevice2
== NULL
, "Expected d3ddevice2 == NULL, got %p.\n", d3ddevice2
);
5405 IDirect3DRMDevice3_Release(device3
);
5408 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5409 NULL
, &surface
, surface_callback
);
5410 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces, hr %#lx.\n", hr
);
5411 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5413 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3drm_d3ddevice1
);
5414 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
5415 ok(d3ddevice1
== d3drm_d3ddevice1
, "Expected Immediate Mode device created == %p, got %p.\n",
5416 d3ddevice1
, d3drm_d3ddevice1
);
5418 /* Check properties of render target and depth surfaces */
5419 hr
= IDirect3DDevice_QueryInterface(d3drm_d3ddevice1
, &IID_IDirectDrawSurface
, (void **)&surface
);
5420 ok(SUCCEEDED(hr
), "Cannot get surface to the render target, hr %#lx.\n", hr
);
5422 memset(&desc
, 0, sizeof(desc
));
5423 desc
.dwSize
= sizeof(desc
);
5424 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5425 ok(SUCCEEDED(hr
), "Cannot get surface desc structure, hr %#lx.\n", hr
);
5427 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5428 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5429 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
5430 "Unexpected caps got %lx.\n", desc
.ddsCaps
.dwCaps
);
5431 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5432 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5434 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5435 ok(SUCCEEDED(hr
), "Cannot get attached depth surface, hr %#lx.\n", hr
);
5436 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5438 desc
.dwSize
= sizeof(desc
);
5439 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5440 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure, hr %#lx.\n", hr
);
5442 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5443 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5444 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
5445 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5446 ok(desc
.dwFlags
== expected_flags
, "Expected %#lx for flags, got %#lx.\n", expected_flags
, desc
.dwFlags
);
5448 IDirectDrawSurface_Release(d3drm_ds
);
5449 IDirectDrawSurface_Release(ds
);
5450 IDirectDrawSurface_Release(surface
);
5451 IDirect3DDevice_Release(d3drm_d3ddevice1
);
5452 IDirect3DRMDevice_Release(device1
);
5453 ref2
= get_refcount((IUnknown
*)d3drm1
);
5454 ok(ref1
== ref2
, "expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
5455 device_ref2
= get_refcount((IUnknown
*)d3ddevice1
);
5456 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5457 device_ref1
, device_ref2
);
5458 d3d_ref2
= get_refcount((IUnknown
*)d3d1
);
5459 todo_wine
ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
,
5462 IDirect3DRM_Release(d3drm1
);
5463 IDirect3DDevice_Release(d3ddevice1
);
5464 IDirect3D_Release(d3d1
);
5465 IDirectDraw_Release(ddraw1
);
5466 DestroyWindow(window
);
5469 static IDirect3DDevice2
*create_device2(IDirectDraw2
*ddraw
, HWND window
, IDirectDrawSurface
**ds
)
5471 static const DWORD z_depths
[] = { 32, 24, 16 };
5472 IDirectDrawSurface
*surface
;
5473 IDirect3DDevice2
*device
= NULL
;
5474 DDSURFACEDESC surface_desc
;
5480 GetClientRect(window
, &rc
);
5481 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
5482 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
5484 memset(&surface_desc
, 0, sizeof(surface_desc
));
5485 surface_desc
.dwSize
= sizeof(surface_desc
);
5486 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
5487 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
5488 surface_desc
.dwWidth
= rc
.right
;
5489 surface_desc
.dwHeight
= rc
.bottom
;
5491 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
5492 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
5494 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
5497 IDirectDrawSurface_Release(surface
);
5502 /* We used to use EnumDevices() for this, but it seems
5503 * D3DDEVICEDESC.dwDeviceZBufferBitDepth only has a very casual
5504 * relationship with reality. */
5505 for (i
= 0; i
< ARRAY_SIZE(z_depths
); ++i
)
5507 memset(&surface_desc
, 0, sizeof(surface_desc
));
5508 surface_desc
.dwSize
= sizeof(surface_desc
);
5509 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_ZBUFFERBITDEPTH
| DDSD_WIDTH
| DDSD_HEIGHT
;
5510 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_ZBUFFER
;
5511 surface_desc
.dwZBufferBitDepth
= z_depths
[i
];
5512 surface_desc
.dwWidth
= rc
.right
;
5513 surface_desc
.dwHeight
= rc
.bottom
;
5514 if (FAILED(IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, ds
, NULL
)))
5517 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, *ds
);
5518 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
5521 IDirectDrawSurface_Release(*ds
);
5525 if (SUCCEEDED(IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
)))
5528 IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, *ds
);
5529 IDirectDrawSurface_Release(*ds
);
5533 IDirect3D2_Release(d3d
);
5534 IDirectDrawSurface_Release(surface
);
5538 static void test_create_device_from_d3d2(void)
5540 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
5541 IDirectDraw2
*ddraw2
= NULL
, *temp_ddraw2
;
5543 IDirect3D2
*d3d2
= NULL
, *temp_d3d2
;
5544 IDirect3DRM
*d3drm1
= NULL
;
5545 IDirect3DRM2
*d3drm2
= NULL
;
5546 IDirect3DRMDevice
*device1
;
5547 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
5548 IDirect3DDevice
*d3ddevice1
;
5549 IDirect3DDevice2
*d3ddevice2
= NULL
, *d3drm_d3ddevice2
= NULL
, *temp_d3ddevice2
;
5550 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
5551 DWORD expected_flags
, ret_val
;
5552 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
5556 ULONG ref1
, ref2
, ref3
, ref4
, ref5
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
5559 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
5560 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
5562 window
= create_window();
5563 GetClientRect(window
, &rc
);
5565 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
5566 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
5567 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
5568 ok(hr
== DD_OK
, "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr
);
5569 d3d_ref1
= get_refcount((IUnknown
*)d3d2
);
5571 /* Create the immediate mode device */
5572 d3ddevice2
= create_device2(ddraw2
, window
, &ds
);
5573 if (d3ddevice2
== NULL
)
5575 win_skip("Cannot create IM device, skipping tests.\n");
5576 IDirect3D2_Release(d3d2
);
5577 IDirectDraw2_Release(ddraw2
);
5578 IDirectDraw_Release(ddraw1
);
5581 device_ref1
= get_refcount((IUnknown
*)d3ddevice2
);
5583 hr
= Direct3DRMCreate(&d3drm1
);
5584 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
5585 ref1
= get_refcount((IUnknown
*)d3drm1
);
5587 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
5588 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
5589 ref2
= get_refcount((IUnknown
*)d3drm2
);
5591 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, NULL
, d3ddevice2
, &device2
);
5592 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
5593 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
5594 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, NULL
, &device2
);
5595 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
5596 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, d3ddevice2
, NULL
);
5597 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5599 hr
= IDirect3DRM2_CreateDeviceFromD3D(d3drm2
, d3d2
, d3ddevice2
, &device2
);
5600 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice2 interface, hr %#lx\n", hr
);
5601 ref3
= get_refcount((IUnknown
*)d3drm1
);
5602 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
5603 ref3
= get_refcount((IUnknown
*)d3drm2
);
5604 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
5605 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5606 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1
, device_ref2
);
5607 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5608 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5609 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
5610 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
5611 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
5612 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
5614 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5615 NULL
, &surface
, surface_callback
);
5616 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
5617 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5619 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3drm_d3ddevice2
);
5620 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
5621 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
, d3drm_d3ddevice2
);
5623 /* Check properties of render target and depth surfaces */
5624 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5625 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
5627 memset(&desc
, 0, sizeof(desc
));
5628 desc
.dwSize
= sizeof(desc
);
5629 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5630 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
5632 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5633 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5634 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
5635 "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
5636 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5637 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5639 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5640 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5641 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5643 desc
.dwSize
= sizeof(desc
);
5644 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5645 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
5647 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5648 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5649 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
5650 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5651 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5653 IDirectDrawSurface_Release(d3drm_ds
);
5654 IDirectDrawSurface_Release(ds
);
5655 IDirectDrawSurface_Release(surface
);
5656 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5657 IDirect3DRMDevice2_Release(device2
);
5658 ref3
= get_refcount((IUnknown
*)d3drm1
);
5659 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
5660 ref3
= get_refcount((IUnknown
*)d3drm2
);
5661 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
5662 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5663 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1
, device_ref2
);
5664 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5665 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5667 /* InitFromD3D tests */
5668 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice2
, (void **)&device2
);
5669 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface, hr %#lx.\n", hr
);
5671 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
5672 ok(SUCCEEDED(hr
), "Cannot get IDirect3D interface, hr %#lx.\n", hr
);
5673 if (SUCCEEDED(hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice
, (void **)&d3ddevice1
)))
5675 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, d3d1
, d3ddevice1
);
5676 ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got hr %#lx.\n", hr
);
5677 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, NULL
, d3ddevice1
);
5678 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5679 hr
= IDirect3DRMDevice2_InitFromD3D(device2
, d3d1
, NULL
);
5680 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5681 hr
= IDirect3DRMDevice2_QueryInterface(device2
, &IID_IDirect3DRMDevice
, (void **)&device1
);
5682 ok(SUCCEEDED(hr
), "Cannot obtain IDirect3DRMDevice interface, hr %#lx.\n", hr
);
5683 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
5684 todo_wine
ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got hr %#lx.\n", hr
);
5685 IDirect3DRMDevice_Release(device1
);
5688 IDirect3DRMDevice_Release(device1
);
5689 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice2
,
5691 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice2 interface, hr %#lx.\n", hr
);
5694 IDirect3D_Release(d3d1
);
5695 IDirect3DDevice_Release(d3ddevice1
);
5697 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, NULL
, d3ddevice2
);
5698 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5699 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, NULL
);
5700 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5702 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, d3ddevice2
);
5703 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice2 interface, hr %#lx\n", hr
);
5704 ref4
= get_refcount((IUnknown
*)d3drm1
);
5705 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
5706 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5707 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5708 device_ref1
, device_ref2
);
5709 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5710 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5711 ret_val
= IDirect3DRMDevice2_GetWidth(device2
);
5712 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
5713 ret_val
= IDirect3DRMDevice2_GetHeight(device2
);
5714 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
5716 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, d3d2
, d3ddevice2
);
5717 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5718 ref3
= get_refcount((IUnknown
*)d3drm1
);
5719 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
5720 ref3
= get_refcount((IUnknown
*)d3ddevice2
);
5721 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3
, device_ref2
);
5722 ref3
= get_refcount((IUnknown
*)d3d2
);
5723 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3
, d3d_ref2
);
5724 /* Release leaked references */
5725 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5726 while (IDirect3DDevice2_Release(d3ddevice2
) > device_ref2
);
5727 while (IDirect3D2_Release(d3d2
) > d3d_ref2
);
5729 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
5730 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
5731 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D2
, (void **)&temp_d3d2
);
5732 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
5733 ref5
= get_refcount((IUnknown
*)temp_d3d2
);
5735 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirectDraw2
, (void **)&temp_ddraw2
);
5736 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr
);
5738 temp_d3ddevice2
= create_device2(temp_ddraw2
, window
, &surface
);
5739 hr
= IDirect3DRMDevice2_InitFromD3D2(device2
, temp_d3d2
, temp_d3ddevice2
);
5740 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5741 ref3
= get_refcount((IUnknown
*)d3drm1
);
5742 ok(ref3
> ref4
, "expected ref3 > ref4, got ref3 = %lu , ref4 = %lu.\n", ref3
, ref4
);
5743 ref3
= get_refcount((IUnknown
*)temp_d3ddevice2
);
5744 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3
, device_ref2
);
5745 ref3
= get_refcount((IUnknown
*)temp_d3d2
);
5746 ok(ref3
== d3d_ref2
, "Expected ref3 == d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3
, d3d_ref2
);
5747 /* Release leaked references */
5748 while (IDirect3DRM_Release(d3drm1
) > ref4
);
5749 while (IDirect3DDevice2_Release(temp_d3ddevice2
) > 0);
5750 while (IDirect3D2_Release(temp_d3d2
) >= ref5
);
5751 IDirectDrawSurface_Release(surface
);
5752 IDirectDraw2_Release(temp_ddraw2
);
5753 IDirectDraw_Release(temp_ddraw1
);
5756 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5757 NULL
, &surface
, surface_callback
);
5758 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces, hr %#lx.\n", hr
);
5759 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5761 hr
= IDirect3DRMDevice2_GetDirect3DDevice2(device2
, &d3drm_d3ddevice2
);
5762 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
5763 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
,
5766 /* Check properties of render target and depth surfaces */
5767 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5768 ok(SUCCEEDED(hr
), "Cannot get surface to the render target, hr %#lx.\n", hr
);
5770 memset(&desc
, 0, sizeof(desc
));
5771 desc
.dwSize
= sizeof(desc
);
5772 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5773 ok(SUCCEEDED(hr
), "Cannot get surface desc structure, hr %#lx.\n", hr
);
5775 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5776 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5777 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
5778 "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
5779 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5780 ok(desc
.dwFlags
== expected_flags
, "Expected %#lx for flags, got %#lx.\n", expected_flags
, desc
.dwFlags
);
5782 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5783 ok(SUCCEEDED(hr
), "Cannot get attached depth surface, hr %#lx.\n", hr
);
5784 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5786 desc
.dwSize
= sizeof(desc
);
5787 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5788 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure, hr %#lx.\n", hr
);
5790 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5791 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5792 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
5793 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5794 ok(desc
.dwFlags
== expected_flags
, "Expected %#lx for flags, got %#lx.\n", expected_flags
, desc
.dwFlags
);
5796 IDirectDrawSurface_Release(d3drm_ds
);
5797 IDirectDrawSurface_Release(ds
);
5798 IDirectDrawSurface_Release(surface
);
5799 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5800 IDirect3DRMDevice2_Release(device2
);
5801 ref3
= get_refcount((IUnknown
*)d3drm1
);
5802 ok(ref1
== ref3
, "Expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
5803 ref3
= get_refcount((IUnknown
*)d3drm2
);
5804 ok(ref3
== ref2
, "Expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
5805 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5806 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5807 device_ref1
, device_ref2
);
5808 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5809 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5811 IDirect3DRM2_Release(d3drm2
);
5812 IDirect3DRM_Release(d3drm1
);
5813 IDirect3DDevice2_Release(d3ddevice2
);
5814 IDirect3D2_Release(d3d2
);
5815 IDirectDraw2_Release(ddraw2
);
5816 IDirectDraw_Release(ddraw1
);
5817 DestroyWindow(window
);
5820 static void test_create_device_from_d3d3(void)
5822 IDirectDraw
*ddraw1
= NULL
, *temp_ddraw1
;
5823 IDirectDraw2
*ddraw2
= NULL
, *temp_ddraw2
;
5825 IDirect3D2
*d3d2
= NULL
, *temp_d3d2
;
5826 IDirect3DRM
*d3drm1
= NULL
;
5827 IDirect3DRM3
*d3drm3
= NULL
;
5828 IDirect3DRMDevice
*device1
;
5829 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
5830 IDirect3DDevice
*d3ddevice1
;
5831 IDirect3DDevice2
*d3ddevice2
= NULL
, *d3drm_d3ddevice2
= NULL
, *temp_d3ddevice2
;
5832 IDirectDrawSurface
*surface
= NULL
, *ds
= NULL
, *d3drm_ds
= NULL
;
5833 DWORD expected_flags
, ret_val
;
5834 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
5838 ULONG ref1
, ref2
, ref3
, ref4
, ref5
, device_ref1
, device_ref2
, d3d_ref1
, d3d_ref2
;
5841 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
5842 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
5844 window
= create_window();
5845 GetClientRect(window
, &rc
);
5847 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
5848 ok(hr
== DD_OK
, "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
5849 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
5850 ok(hr
== DD_OK
, "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr
);
5851 d3d_ref1
= get_refcount((IUnknown
*)d3d2
);
5853 /* Create the immediate mode device */
5854 d3ddevice2
= create_device2(ddraw2
, window
, &ds
);
5855 if (d3ddevice2
== NULL
)
5857 win_skip("Cannot create IM device, skipping tests.\n");
5858 IDirect3D2_Release(d3d2
);
5859 IDirectDraw2_Release(ddraw2
);
5860 IDirectDraw_Release(ddraw1
);
5863 device_ref1
= get_refcount((IUnknown
*)d3ddevice2
);
5865 hr
= Direct3DRMCreate(&d3drm1
);
5866 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
5867 ref1
= get_refcount((IUnknown
*)d3drm1
);
5869 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
5870 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
5871 ref2
= get_refcount((IUnknown
*)d3drm3
);
5873 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, NULL
, d3ddevice2
, &device3
);
5874 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
5875 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
5876 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, NULL
, &device3
);
5877 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5878 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3ddevice2
, NULL
);
5879 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5881 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3ddevice2
, &device3
);
5882 ok(hr
== DD_OK
, "Failed to create IDirect3DRMDevice3 interface, hr %#lx\n", hr
);
5883 ref3
= get_refcount((IUnknown
*)d3drm1
);
5884 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
5885 ref3
= get_refcount((IUnknown
*)d3drm3
);
5886 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
5887 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5888 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1
, device_ref2
);
5889 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
5890 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
5891 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
5892 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
5894 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
5895 NULL
, &surface
, surface_callback
);
5896 ok(hr
== DD_OK
, "Failed to enumerate surfaces, hr %#lx.\n", hr
);
5897 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
5899 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3drm_d3ddevice2
);
5900 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
5901 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
, d3drm_d3ddevice2
);
5903 /* Check properties of render target and depth surfaces */
5904 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
5905 ok(hr
== DD_OK
, "Cannot get surface to the render target, hr %#lx.\n", hr
);
5907 memset(&desc
, 0, sizeof(desc
));
5908 desc
.dwSize
= sizeof(desc
);
5909 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
5910 ok(hr
== DD_OK
, "Cannot get surface desc structure, hr %#lx.\n", hr
);
5912 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5913 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5914 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
),
5915 "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
5916 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5917 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5919 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
5920 ok(hr
== DD_OK
, "Cannot get attached depth surface, hr %#lx.\n", hr
);
5921 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
5923 desc
.dwSize
= sizeof(desc
);
5924 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
5925 ok(hr
== DD_OK
, "Cannot get z surface desc structure, hr %#lx.\n", hr
);
5927 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
5928 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
5929 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %lx.\n", desc
.ddsCaps
.dwCaps
);
5930 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
5931 ok(desc
.dwFlags
== expected_flags
, "Expected %lx for flags, got %lx.\n", expected_flags
, desc
.dwFlags
);
5933 IDirectDrawSurface_Release(d3drm_ds
);
5934 IDirectDrawSurface_Release(ds
);
5935 IDirectDrawSurface_Release(surface
);
5936 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
5937 IDirect3DRMDevice3_Release(device3
);
5938 ref3
= get_refcount((IUnknown
*)d3drm1
);
5939 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
5940 ref3
= get_refcount((IUnknown
*)d3drm3
);
5941 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
5942 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5943 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n", device_ref1
, device_ref2
);
5944 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5945 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5947 /* InitFromD3D tests */
5948 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice3
, (void **)&device3
);
5949 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
5951 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D
, (void **)&d3d1
);
5952 ok(SUCCEEDED(hr
), "Cannot get IDirect3D interface, hr %#lx.\n", hr
);
5953 if (SUCCEEDED(hr
= IDirect3DDevice2_QueryInterface(d3ddevice2
, &IID_IDirect3DDevice
, (void **)&d3ddevice1
)))
5955 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, d3d1
, d3ddevice1
);
5956 ok(hr
== E_NOINTERFACE
, "Expected hr == E_NOINTERFACE, got hr %#lx.\n", hr
);
5957 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, NULL
, d3ddevice1
);
5958 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5959 hr
= IDirect3DRMDevice3_InitFromD3D(device3
, d3d1
, NULL
);
5960 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5961 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice
, (void **)&device1
);
5962 ok(SUCCEEDED(hr
), "Cannot obtain IDirect3DRMDevice interface, hr %#lx.\n", hr
);
5963 hr
= IDirect3DRMDevice_InitFromD3D(device1
, d3d1
, d3ddevice1
);
5964 todo_wine
ok(hr
== E_NOINTERFACE
, "Unexpected hr %#lx.\n", hr
);
5965 IDirect3DRMDevice_Release(device1
);
5968 IDirect3DRMDevice_Release(device1
);
5969 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMDevice
, NULL
, &IID_IDirect3DRMDevice3
,
5971 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
5974 IDirect3D_Release(d3d1
);
5975 IDirect3DDevice_Release(d3ddevice1
);
5977 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, NULL
, d3ddevice2
);
5978 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5979 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, NULL
);
5980 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
5982 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, d3ddevice2
);
5983 ok(SUCCEEDED(hr
), "Failed to initialise IDirect3DRMDevice2 interface, hr %#lx\n", hr
);
5984 ref4
= get_refcount((IUnknown
*)d3drm1
);
5985 ok(ref4
> ref1
, "Expected ref4 > ref1, got ref1 = %lu , ref4 = %lu.\n", ref1
, ref4
);
5986 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
5987 ok(device_ref2
> device_ref1
, "Expected device_ref2 > device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
5988 device_ref1
, device_ref2
);
5989 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
5990 ok(d3d_ref2
> d3d_ref1
, "Expected d3d_ref2 > d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
5991 ret_val
= IDirect3DRMDevice3_GetWidth(device3
);
5992 ok(ret_val
== rc
.right
, "Expected device width = 300, got %lu.\n", ret_val
);
5993 ret_val
= IDirect3DRMDevice3_GetHeight(device3
);
5994 ok(ret_val
== rc
.bottom
, "Expected device height == 200, got %lu.\n", ret_val
);
5996 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, d3d2
, d3ddevice2
);
5997 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
5998 ref3
= get_refcount((IUnknown
*)d3drm1
);
5999 ok(ref3
> ref1
, "expected ref3 > ref1, got ref1 = %lu , ref3 = %lu.\n", ref1
, ref3
);
6000 ref3
= get_refcount((IUnknown
*)d3ddevice2
);
6001 ok(ref3
> device_ref2
, "Expected ref3 > device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3
, device_ref2
);
6002 ref3
= get_refcount((IUnknown
*)d3d2
);
6003 ok(ref3
> d3d_ref2
, "Expected ref3 > d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3
, d3d_ref2
);
6004 /* Release leaked references */
6005 while (IDirect3DRM_Release(d3drm1
) > ref4
);
6006 while (IDirect3DDevice2_Release(d3ddevice2
) > device_ref2
);
6007 while (IDirect3D2_Release(d3d2
) > d3d_ref2
);
6009 hr
= DirectDrawCreate(NULL
, &temp_ddraw1
, NULL
);
6010 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
6011 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirect3D2
, (void **)&temp_d3d2
);
6012 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
6013 ref5
= get_refcount((IUnknown
*)temp_d3d2
);
6015 hr
= IDirectDraw_QueryInterface(temp_ddraw1
, &IID_IDirectDraw2
, (void **)&temp_ddraw2
);
6016 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr
);
6018 temp_d3ddevice2
= create_device2(temp_ddraw2
, window
, &surface
);
6019 hr
= IDirect3DRMDevice3_InitFromD3D2(device3
, temp_d3d2
, temp_d3ddevice2
);
6020 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
6021 ref3
= get_refcount((IUnknown
*)d3drm1
);
6022 ok(ref3
> ref4
, "expected ref3 > ref4, got ref3 = %lu , ref4 = %lu.\n", ref3
, ref4
);
6023 ref3
= get_refcount((IUnknown
*)temp_d3ddevice2
);
6024 ok(ref3
== device_ref2
, "Expected ref3 == device_ref2, got ref3 = %lu, device_ref2 = %lu.\n", ref3
, device_ref2
);
6025 ref3
= get_refcount((IUnknown
*)temp_d3d2
);
6026 ok(ref3
== d3d_ref2
, "Expected ref3 == d3d_ref2, got ref3 = %lu, d3d_ref2 = %lu.\n", ref3
, d3d_ref2
);
6027 /* Release leaked references */
6028 while (IDirect3DRM_Release(d3drm1
) > ref4
);
6029 while (IDirect3DDevice2_Release(temp_d3ddevice2
) > 0);
6030 while (IDirect3D2_Release(temp_d3d2
) >= ref5
);
6031 IDirectDrawSurface_Release(surface
);
6032 IDirectDraw2_Release(temp_ddraw2
);
6033 IDirectDraw_Release(temp_ddraw1
);
6036 hr
= IDirectDraw_EnumSurfaces(ddraw1
, DDENUMSURFACES_ALL
| DDENUMSURFACES_DOESEXIST
,
6037 NULL
, &surface
, surface_callback
);
6038 ok(SUCCEEDED(hr
), "Failed to enumerate surfaces, hr %#lx.\n", hr
);
6039 ok(surface
== NULL
, "No primary surface should have enumerated (%p).\n", surface
);
6041 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3drm_d3ddevice2
);
6042 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
6043 ok(d3ddevice2
== d3drm_d3ddevice2
, "Expected Immediate Mode device created == %p, got %p.\n", d3ddevice2
,
6046 /* Check properties of render target and depth surfaces */
6047 hr
= IDirect3DDevice2_GetRenderTarget(d3drm_d3ddevice2
, &surface
);
6048 ok(SUCCEEDED(hr
), "Cannot get surface to the render target, hr %#lx.\n", hr
);
6050 memset(&desc
, 0, sizeof(desc
));
6051 desc
.dwSize
= sizeof(desc
);
6052 hr
= IDirectDrawSurface_GetSurfaceDesc(surface
, &desc
);
6053 ok(SUCCEEDED(hr
), "Cannot get surface desc structure, hr %#lx.\n", hr
);
6055 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
6056 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
6057 ok((desc
.ddsCaps
.dwCaps
& (DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
)) == (DDSCAPS_OFFSCREENPLAIN
|DDSCAPS_3DDEVICE
),
6058 "Unexpected caps %#lx.\n", desc
.ddsCaps
.dwCaps
);
6059 expected_flags
= DDSD_PIXELFORMAT
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
6060 ok(desc
.dwFlags
== expected_flags
, "Expected %#lx for flags, got %#lx.\n", expected_flags
, desc
.dwFlags
);
6062 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
6063 ok(SUCCEEDED(hr
), "Cannot get attached depth surface, hr %#lx.\n", hr
);
6064 ok(ds
== d3drm_ds
, "Expected depth surface (%p) == surface created internally (%p).\n", ds
, d3drm_ds
);
6066 desc
.dwSize
= sizeof(desc
);
6067 hr
= IDirectDrawSurface_GetSurfaceDesc(ds
, &desc
);
6068 ok(SUCCEEDED(hr
), "Cannot get z surface desc structure, hr %#lx.\n", hr
);
6070 ok((desc
.dwWidth
== rc
.right
) && (desc
.dwHeight
== rc
.bottom
), "Expected surface dimensions = %lu, %lu, got %lu, %lu.\n",
6071 rc
.right
, rc
.bottom
, desc
.dwWidth
, desc
.dwHeight
);
6072 ok((desc
.ddsCaps
.dwCaps
& DDSCAPS_ZBUFFER
) == DDSCAPS_ZBUFFER
, "Unexpected caps %#lx.\n",desc
.ddsCaps
.dwCaps
);
6073 expected_flags
= DDSD_ZBUFFERBITDEPTH
| DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
| DDSD_PITCH
;
6074 ok(desc
.dwFlags
== expected_flags
, "Expected %#lx for flags, got %#lx.\n", expected_flags
, desc
.dwFlags
);
6076 IDirectDrawSurface_Release(d3drm_ds
);
6077 IDirectDrawSurface_Release(ds
);
6078 IDirectDrawSurface_Release(surface
);
6079 IDirect3DDevice2_Release(d3drm_d3ddevice2
);
6080 IDirect3DRMDevice3_Release(device3
);
6081 ref3
= get_refcount((IUnknown
*)d3drm1
);
6082 ok(ref1
== ref3
, "expected ref1 == ref3, got ref1 = %lu, ref3 = %lu.\n", ref1
, ref3
);
6083 ref3
= get_refcount((IUnknown
*)d3drm3
);
6084 ok(ref3
== ref2
, "expected ref3 == ref2, got ref2 = %lu , ref3 = %lu.\n", ref2
, ref3
);
6085 device_ref2
= get_refcount((IUnknown
*)d3ddevice2
);
6086 ok(device_ref2
== device_ref1
, "Expected device_ref2 == device_ref1, got device_ref1 = %lu, device_ref2 = %lu.\n",
6087 device_ref1
, device_ref2
);
6088 d3d_ref2
= get_refcount((IUnknown
*)d3d2
);
6089 ok(d3d_ref2
== d3d_ref1
, "Expected d3d_ref2 == d3d_ref1, got d3d_ref1 = %lu, d3d_ref2 = %lu.\n", d3d_ref1
, d3d_ref2
);
6091 IDirect3DRM3_Release(d3drm3
);
6092 IDirect3DRM_Release(d3drm1
);
6093 IDirect3DDevice2_Release(d3ddevice2
);
6094 IDirect3D2_Release(d3d2
);
6095 IDirectDraw2_Release(ddraw2
);
6096 IDirectDraw_Release(ddraw1
);
6097 DestroyWindow(window
);
6100 static void test_create_device_1(void)
6102 IDirect3DRM
*d3drm
= NULL
;
6103 IDirect3DRMDevice
*device
= (IDirect3DRMDevice
*)0xdeadbeef;
6106 hr
= Direct3DRMCreate(&d3drm
);
6107 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
6109 hr
= IDirect3DRM_CreateDevice(d3drm
, 640, 480, &device
);
6110 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == D3DRMERR_BADDEVICE, got hr %#lx.\n", hr
);
6111 ok(device
== NULL
, "Expected device returned == NULL, got %p.\n", device
);
6112 hr
= IDirect3DRM_CreateDevice(d3drm
, 640, 480, NULL
);
6113 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
6115 IDirect3DRM_Release(d3drm
);
6118 static void test_create_device_2(void)
6120 IDirect3DRM
*d3drm
= NULL
;
6121 IDirect3DRM2
*d3drm2
= NULL
;
6122 IDirect3DRMDevice2
*device2
= (IDirect3DRMDevice2
*)0xdeadbeef;
6125 hr
= Direct3DRMCreate(&d3drm
);
6126 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
6127 hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
6128 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
6130 hr
= IDirect3DRM2_CreateDevice(d3drm2
, 640, 480, &device2
);
6131 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == D3DRMERR_BADDEVICE, got %#lx.\n", hr
);
6132 ok(device2
== NULL
, "Expected device returned == NULL, got %p.\n", device2
);
6133 hr
= IDirect3DRM2_CreateDevice(d3drm2
, 640, 480, NULL
);
6134 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
6136 IDirect3DRM2_Release(d3drm2
);
6137 IDirect3DRM_Release(d3drm
);
6140 static void test_create_device_3(void)
6142 IDirect3DRM
*d3drm
= NULL
;
6143 IDirect3DRM3
*d3drm3
= NULL
;
6144 IDirect3DRMDevice3
*device3
= (IDirect3DRMDevice3
*)0xdeadbeef;
6147 hr
= Direct3DRMCreate(&d3drm
);
6148 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
6149 hr
= IDirect3DRM_QueryInterface(d3drm
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6150 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
6152 hr
= IDirect3DRM3_CreateDevice(d3drm3
, 640, 480, &device3
);
6153 ok(hr
== D3DRMERR_BADDEVICE
, "Expected hr == D3DRMERR_BADDEVICE, got %#lx.\n", hr
);
6154 ok(device3
== NULL
, "Expected device returned == NULL, got %p.\n", device3
);
6155 hr
= IDirect3DRM3_CreateDevice(d3drm3
, 640, 480, NULL
);
6156 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
6158 IDirect3DRM3_Release(d3drm3
);
6159 IDirect3DRM_Release(d3drm
);
6166 static char *create_bitmap(unsigned int w
, unsigned int h
, BOOL palettized
)
6168 unsigned int bpp
= palettized
? 8 : 24;
6169 BITMAPFILEHEADER file_header
;
6170 DWORD written
, size
, ret
;
6171 unsigned char *buffer
;
6172 char path
[MAX_PATH
];
6178 ret
= GetTempPathA(MAX_PATH
, path
);
6179 ok(ret
, "Failed to get temporary file path.\n");
6180 filename
= malloc(MAX_PATH
);
6181 ret
= GetTempFileNameA(path
, "d3d", 0, filename
);
6182 ok(ret
, "Failed to get filename.\n");
6183 file
= CreateFileA(filename
, GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
6184 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to open temporary file \"%s\".\n", filename
);
6186 size
= FIELD_OFFSET(BITMAPINFO
, bmiColors
[palettized
? 256 : 0]);
6188 memset(&file_header
, 0, sizeof(file_header
));
6189 file_header
.bfType
= 0x4d42; /* BM */
6190 file_header
.bfOffBits
= sizeof(file_header
) + size
;
6191 file_header
.bfSize
= file_header
.bfOffBits
+ w
* h
* (bpp
/ 8);
6192 ret
= WriteFile(file
, &file_header
, sizeof(file_header
), &written
, NULL
);
6193 ok(ret
&& written
== sizeof(file_header
), "Failed to write file header.\n");
6195 info
= calloc(1, size
);
6196 info
->bmiHeader
.biSize
= sizeof(info
->bmiHeader
);
6197 info
->bmiHeader
.biBitCount
= bpp
;
6198 info
->bmiHeader
.biPlanes
= 1;
6199 info
->bmiHeader
.biWidth
= w
;
6200 info
->bmiHeader
.biHeight
= h
;
6201 info
->bmiHeader
.biCompression
= BI_RGB
;
6204 for (i
= 0; i
< 256; ++i
)
6206 info
->bmiColors
[i
].rgbBlue
= i
% MOD_B
;
6207 info
->bmiColors
[i
].rgbGreen
= i
% MOD_G
;
6208 info
->bmiColors
[i
].rgbRed
= i
% MOD_R
;
6211 ret
= WriteFile(file
, info
, size
, &written
, NULL
);
6212 ok(ret
&& written
== size
, "Failed to write bitmap info.\n");
6215 size
= w
* h
* (bpp
/ 8);
6216 buffer
= calloc(1, size
);
6217 for (i
= 0, j
= 0; i
< size
;)
6226 buffer
[i
++] = j
% MOD_B
;
6227 buffer
[i
++] = j
% MOD_G
;
6228 buffer
[i
++] = j
++ % MOD_R
;
6231 ret
= WriteFile(file
, buffer
, size
, &written
, NULL
);
6232 ok(ret
&& written
== size
, "Failed to write bitmap data.\n");
6240 static void test_bitmap_data(unsigned int test_idx
, const D3DRMIMAGE
*img
,
6241 BOOL upside_down
, unsigned int w
, unsigned int h
, BOOL palettized
)
6243 const unsigned char *data
= img
->buffer1
;
6246 ok(img
->width
== w
, "Test %u: Got unexpected image width %u, expected %u.\n", test_idx
, img
->width
, w
);
6247 ok(img
->height
== h
, "Test %u: Got unexpected image height %u, expected %u.\n", test_idx
, img
->height
, h
);
6248 ok(img
->aspectx
== 1, "Test %u: Got unexpected image aspectx %u.\n", test_idx
, img
->aspectx
);
6249 ok(img
->aspecty
== 1, "Test %u: Got unexpected image aspecty %u.\n", test_idx
, img
->aspecty
);
6250 ok(!img
->buffer2
, "Test %u: Got unexpected image buffer2 %p.\n", test_idx
, img
->buffer2
);
6252 /* The image is palettized if the total number of colors used is <= 256. */
6253 if (w
* h
> 256 && !palettized
)
6255 /* D3drm aligns the 24bpp texture to 4 bytes in the buffer, with one
6256 * byte padding from 24bpp texture. */
6257 ok(img
->depth
== 32, "Test %u: Got unexpected image depth %u.\n", test_idx
, img
->depth
);
6258 ok(img
->rgb
== TRUE
, "Test %u: Got unexpected image rgb %#x.\n", test_idx
, img
->rgb
);
6259 ok(img
->bytes_per_line
== w
* 4, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6260 test_idx
, img
->bytes_per_line
, w
* 4);
6261 ok(img
->red_mask
== 0xff0000, "Test %u: Got unexpected image red mask %#lx.\n", test_idx
, img
->red_mask
);
6262 ok(img
->green_mask
== 0x00ff00, "Test %u: Got unexpected image green mask %#lx.\n", test_idx
, img
->green_mask
);
6263 ok(img
->blue_mask
== 0x0000ff, "Test %u: Got unexpected image blue mask %#lx.\n", test_idx
, img
->blue_mask
);
6264 ok(!img
->alpha_mask
, "Test %u: Got unexpected image alpha mask %#lx.\n", test_idx
, img
->alpha_mask
);
6265 ok(!img
->palette_size
, "Test %u: Got unexpected palette size %u.\n", test_idx
, img
->palette_size
);
6266 ok(!img
->palette
, "Test %u: Got unexpected image palette %p.\n", test_idx
, img
->palette
);
6267 for (i
= 0; i
< h
; ++i
)
6269 for (j
= 0; j
< w
; ++j
)
6271 const unsigned char *ptr
= &data
[i
* img
->bytes_per_line
+ j
* 4];
6272 unsigned int idx
= upside_down
? (h
- 1 - i
) * w
+ j
: i
* w
+ j
;
6274 if (ptr
[0] != idx
% MOD_B
|| ptr
[1] != idx
% MOD_G
|| ptr
[2] != idx
% MOD_R
|| ptr
[3] != 0xff)
6276 ok(0, "Test %u: Got unexpected color 0x%02x%02x%02x%02x at position %u, %u, "
6277 "expected 0x%02x%02x%02x%02x.\n", test_idx
, ptr
[0], ptr
[1], ptr
[2], ptr
[3],
6278 j
, i
, idx
% MOD_B
, idx
% MOD_G
, idx
% MOD_R
, 0xff);
6286 ok(img
->depth
== 8, "Test %u: Got unexpected image depth %u.\n", test_idx
, img
->depth
);
6287 ok(!img
->rgb
, "Test %u: Got unexpected image rgb %#x.\n", test_idx
, img
->rgb
);
6288 ok(img
->red_mask
== 0xff, "Test %u: Got unexpected image red mask %#lx.\n", test_idx
, img
->red_mask
);
6289 ok(img
->green_mask
== 0xff, "Test %u: Got unexpected image green mask %#lx.\n", test_idx
, img
->green_mask
);
6290 ok(img
->blue_mask
== 0xff, "Test %u: Got unexpected image blue mask %#lx.\n", test_idx
, img
->blue_mask
);
6291 ok(!img
->alpha_mask
, "Test %u: Got unexpected image alpha mask %#lx.\n", test_idx
, img
->alpha_mask
);
6292 ok(!!img
->palette
, "Test %u: Got unexpected image palette %p.\n", test_idx
, img
->palette
);
6295 /* In this case, bytes_per_line is aligned to the next multiple of
6297 ok(img
->bytes_per_line
== ((w
+ 3) & ~3), "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6298 test_idx
, img
->bytes_per_line
, (w
+ 3) & ~3);
6299 ok(img
->palette_size
== w
* h
, "Test %u: Got unexpected palette size %u, expected %u.\n",
6300 test_idx
, img
->palette_size
, w
* h
);
6301 for (i
= 0; i
< img
->palette_size
; ++i
)
6303 unsigned int idx
= upside_down
? (h
- 1) * w
- i
+ (i
% w
) * 2 : i
;
6304 ok(img
->palette
[i
].red
== idx
% MOD_R
6305 && img
->palette
[i
].green
== idx
% MOD_G
&& img
->palette
[i
].blue
== idx
% MOD_B
,
6306 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
6307 test_idx
, i
, img
->palette
[i
].red
, img
->palette
[i
].green
, img
->palette
[i
].blue
);
6308 ok(img
->palette
[i
].flags
== D3DRMPALETTE_READONLY
,
6309 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
6310 test_idx
, i
, img
->palette
[i
].flags
);
6312 for (i
= 0; i
< h
; ++i
)
6314 for (j
= 0; j
< w
; ++j
)
6316 if (data
[i
* img
->bytes_per_line
+ j
] != i
* w
+ j
)
6318 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
6319 test_idx
, data
[i
* img
->bytes_per_line
+ j
], j
, i
, i
* w
+ j
);
6327 /* bytes_per_line is not always aligned by d3drm depending on the
6329 ok(img
->bytes_per_line
== w
, "Test %u: Got unexpected image bytes per line %u, expected %u.\n",
6330 test_idx
, img
->bytes_per_line
, w
);
6331 ok(img
->palette_size
== 256, "Test %u: Got unexpected palette size %u.\n", test_idx
, img
->palette_size
);
6332 for (i
= 0; i
< 256; ++i
)
6334 ok(img
->palette
[i
].red
== i
% MOD_R
6335 && img
->palette
[i
].green
== i
% MOD_G
&& img
->palette
[i
].blue
== i
% MOD_B
,
6336 "Test %u: Got unexpected palette entry (%u) color 0x%02x%02x%02x.\n",
6337 test_idx
, i
, img
->palette
[i
].red
, img
->palette
[i
].green
, img
->palette
[i
].blue
);
6338 ok(img
->palette
[i
].flags
== D3DRMPALETTE_READONLY
,
6339 "Test %u: Got unexpected palette entry (%u) flags %#x.\n",
6340 test_idx
, i
, img
->palette
[i
].flags
);
6342 for (i
= 0; i
< h
; ++i
)
6344 for (j
= 0; j
< w
; ++j
)
6346 unsigned int idx
= upside_down
? (h
- 1 - i
) * w
+ j
: i
* w
+ j
;
6347 if (data
[i
* img
->bytes_per_line
+ j
] != idx
% 256)
6349 ok(0, "Test %u: Got unexpected color 0x%02x at position %u, %u, expected 0x%02x.\n",
6350 test_idx
, data
[i
* img
->bytes_per_line
+ j
], j
, i
, idx
% 256);
6357 static void test_load_texture(void)
6359 IDirect3DRMTexture3
*texture3
;
6360 IDirect3DRMTexture2
*texture2
;
6361 IDirect3DRMTexture
*texture1
;
6362 D3DRMIMAGE
*d3drm_img
;
6363 IDirect3DRM3
*d3drm3
;
6364 IDirect3DRM2
*d3drm2
;
6365 IDirect3DRM
*d3drm1
;
6388 hr
= Direct3DRMCreate(&d3drm1
);
6389 ok(hr
== D3DRM_OK
, "Failed to create IDirect3DRM object, hr %#lx.\n", hr
);
6390 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
6391 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM2 interface, hr %#lx.\n", hr
);
6392 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6393 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM3 interface, hr %#lx.\n", hr
);
6394 ref1
= get_refcount((IUnknown
*)d3drm1
);
6396 /* Test all failures together. */
6397 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
6398 hr
= IDirect3DRM_LoadTexture(d3drm1
, NULL
, &texture1
);
6399 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
6400 ok(!texture1
, "Got unexpected texture %p.\n", texture1
);
6401 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
6402 hr
= IDirect3DRM_LoadTexture(d3drm1
, "", &texture1
);
6403 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#lx.\n", hr
);
6404 ok(!texture1
, "Got unexpected texture %p.\n", texture1
);
6405 hr
= IDirect3DRM_LoadTexture(d3drm1
, NULL
, NULL
);
6406 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
6408 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
6409 hr
= IDirect3DRM2_LoadTexture(d3drm2
, NULL
, &texture2
);
6410 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#lx.\n", hr
);
6411 ok(!texture2
, "Got unexpected texture %p.\n", texture2
);
6412 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
6413 hr
= IDirect3DRM2_LoadTexture(d3drm2
, "", &texture2
);
6414 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#lx.\n", hr
);
6415 ok(!texture2
, "Got unexpected texture %p.\n", texture2
);
6416 hr
= IDirect3DRM2_LoadTexture(d3drm2
, NULL
, NULL
);
6417 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
6419 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
6420 hr
= IDirect3DRM3_LoadTexture(d3drm3
, NULL
, &texture3
);
6421 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#lx.\n", hr
);
6422 ok(!texture3
, "Got unexpected texture %p.\n", texture3
);
6423 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
6424 hr
= IDirect3DRM_LoadTexture(d3drm3
, "", &texture3
);
6425 ok(hr
== D3DRMERR_FILENOTFOUND
, "Got unexpected hr %#lx.\n", hr
);
6426 ok(!texture3
, "Got unexpected texture %p.\n", texture3
);
6427 hr
= IDirect3DRM3_LoadTexture(d3drm3
, NULL
, NULL
);
6428 ok(hr
== D3DRMERR_BADVALUE
, "Got unexpected hr %#lx.\n", hr
);
6430 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
6432 winetest_push_context("Test %u", i
);
6434 filename
= create_bitmap(tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6436 hr
= IDirect3DRM_LoadTexture(d3drm1
, filename
, &texture1
);
6437 ok(SUCCEEDED(hr
), "Failed to load texture, hr %#lx.\n", hr
);
6438 ref2
= get_refcount((IUnknown
*)d3drm1
);
6439 ok(ref2
> ref1
, "Expected ref2 > ref1, got ref1 %lu, ref2 %lu.\n", ref1
, ref2
);
6441 hr
= IDirect3DRMTexture_InitFromFile(texture1
, filename
);
6442 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6443 /* InitFromFile() seems to AddRef() IDirect3DRM even if it fails. */
6444 IDirect3DRM_Release(d3drm1
);
6445 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
6446 ok(!!d3drm_img
, "Failed to get image.\n");
6447 test_bitmap_data(i
* 7, d3drm_img
, FALSE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6448 IDirect3DRMTexture_Release(texture1
);
6449 ref2
= get_refcount((IUnknown
*)d3drm1
);
6450 ok(ref1
== ref2
, "Expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
6451 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMTexture
,
6452 NULL
, &IID_IDirect3DRMTexture
, (void **)&texture1
);
6453 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#lx.\n", hr
);
6454 hr
= IDirect3DRMTexture_InitFromFile(texture1
, NULL
);
6455 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6456 hr
= IDirect3DRMTexture_InitFromFile(texture1
, "");
6457 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6458 hr
= IDirect3DRMTexture_InitFromFile(texture1
, filename
);
6459 ok(SUCCEEDED(hr
), "Failed to initialise texture from file, hr %#lx.\n", hr
);
6460 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
6461 ok(!!d3drm_img
, "Failed to get image.\n");
6462 test_bitmap_data(i
* 7 + 1, d3drm_img
, FALSE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6463 IDirect3DRMTexture_Release(texture1
);
6465 hr
= IDirect3DRM2_LoadTexture(d3drm2
, filename
, &texture2
);
6466 ok(SUCCEEDED(hr
), "Failed to load texture, hr %#lx.\n", hr
);
6467 ref2
= get_refcount((IUnknown
*)d3drm1
);
6468 ok(ref2
> ref1
, "Expected ref2 > ref1, got ref1 %lu, ref2 %lu.\n", ref1
, ref2
);
6470 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, filename
);
6471 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6472 IDirect3DRM_Release(d3drm1
);
6473 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
6474 ok(!!d3drm_img
, "Failed to get image.\n");
6475 test_bitmap_data(i
* 7 + 2, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6476 IDirect3DRMTexture2_Release(texture2
);
6477 ref2
= get_refcount((IUnknown
*)d3drm1
);
6478 ok(ref1
== ref2
, "Expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
6479 hr
= IDirect3DRM2_CreateObject(d3drm2
, &CLSID_CDirect3DRMTexture
,
6480 NULL
, &IID_IDirect3DRMTexture2
, (void **)&texture2
);
6481 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#lx.\n", hr
);
6482 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, NULL
);
6483 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6484 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, "");
6485 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6486 hr
= IDirect3DRMTexture2_InitFromFile(texture2
, filename
);
6487 ok(SUCCEEDED(hr
), "Failed to initialise texture from file, hr %#lx.\n", hr
);
6488 d3drm_img
= IDirect3DRMTexture2_GetImage(texture2
);
6489 ok(!!d3drm_img
, "Failed to get image.\n");
6490 test_bitmap_data(i
* 7 + 3, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6491 IDirect3DRMTexture2_Release(texture2
);
6493 hr
= IDirect3DRM3_LoadTexture(d3drm3
, filename
, &texture3
);
6494 ok(SUCCEEDED(hr
), "Failed to load texture, hr %#lx.\n", hr
);
6495 ref2
= get_refcount((IUnknown
*)d3drm1
);
6496 ok(ref2
> ref1
, "Expected ref2 > ref1, got ref1 %lu, ref2 %lu.\n", ref1
, ref2
);
6498 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, filename
);
6499 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6500 IDirect3DRM_Release(d3drm1
);
6501 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
6502 ok(!!d3drm_img
, "Failed to get image.\n");
6503 test_bitmap_data(i
* 7 + 4, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6504 /* Test whether querying a version 1 texture from version 3 causes a
6505 * change in the loading behavior. */
6506 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture
, (void **)&texture1
);
6507 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMTexture interface, hr %#lx.\n", hr
);
6508 d3drm_img
= IDirect3DRMTexture_GetImage(texture1
);
6509 ok(!!d3drm_img
, "Failed to get image.\n");
6510 test_bitmap_data(i
* 7 + 5, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6511 IDirect3DRMTexture_Release(texture1
);
6512 IDirect3DRMTexture3_Release(texture3
);
6513 ref2
= get_refcount((IUnknown
*)d3drm1
);
6514 ok(ref1
== ref2
, "Expected ref1 == ref2, got ref1 = %lu, ref2 = %lu.\n", ref1
, ref2
);
6516 hr
= IDirect3DRM3_CreateObject(d3drm3
, &CLSID_CDirect3DRMTexture
,
6517 NULL
, &IID_IDirect3DRMTexture3
, (void **)&texture3
);
6518 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#lx.\n", hr
);
6519 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, NULL
);
6520 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6521 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, "");
6522 ok(hr
== D3DRMERR_BADOBJECT
, "Got unexpected hr %#lx.\n", hr
);
6523 hr
= IDirect3DRMTexture3_InitFromFile(texture3
, filename
);
6524 ok(SUCCEEDED(hr
), "Failed to initialize texture from file, hr %#lx.\n", hr
);
6525 d3drm_img
= IDirect3DRMTexture3_GetImage(texture3
);
6526 ok(!!d3drm_img
, "Failed to get image.\n");
6527 test_bitmap_data(i
* 7 + 6, d3drm_img
, TRUE
, tests
[i
].w
, tests
[i
].h
, tests
[i
].palettized
);
6528 IDirect3DRMTexture3_Release(texture3
);
6530 ret
= DeleteFileA(filename
);
6531 ok(ret
, "Failed to delete bitmap \"%s\".\n", filename
);
6534 winetest_pop_context();
6537 IDirect3DRM3_Release(d3drm3
);
6538 IDirect3DRM2_Release(d3drm2
);
6539 IDirect3DRM_Release(d3drm1
);
6542 static void test_texture_qi(void)
6544 static const struct qi_test tests
[] =
6546 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6547 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6548 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6549 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6550 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6551 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6552 { &IID_IDirect3DRMWinDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6553 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
6554 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6555 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6556 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6557 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6558 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6559 { &IID_IDirect3DRMVisual
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
6560 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6561 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6562 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6563 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6564 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6565 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6566 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6567 { &IID_IDirect3DRMTexture
, &IID_IUnknown
, &IID_IDirect3DRMTexture
, S_OK
},
6568 { &IID_IDirect3DRMTexture2
, &IID_IUnknown
, &IID_IDirect3DRMTexture2
, S_OK
},
6569 { &IID_IDirect3DRMTexture3
, &IID_IUnknown
, &IID_IDirect3DRMTexture3
, S_OK
},
6570 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6571 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6572 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6573 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6574 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6575 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6576 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6577 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6578 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6579 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6580 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6581 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6582 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6583 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6584 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6585 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6586 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6587 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6588 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6589 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6590 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6591 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6592 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6593 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6594 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6595 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6596 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6597 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6598 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6599 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6600 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6601 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6602 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6603 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6604 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6605 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6606 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6607 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6608 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6609 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6610 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6611 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6612 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6613 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
6616 IDirect3DRM
*d3drm1
;
6617 IDirect3DRM2
*d3drm2
;
6618 IDirect3DRM3
*d3drm3
;
6619 IDirect3DRMTexture
*texture1
;
6620 IDirect3DRMTexture2
*texture2
;
6621 IDirect3DRMTexture3
*texture3
;
6626 hr
= Direct3DRMCreate(&d3drm1
);
6627 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx\n", hr
);
6628 filename
= create_bitmap(1, 1, TRUE
);
6629 hr
= IDirect3DRM_LoadTexture(d3drm1
, filename
, &texture1
);
6630 ok(SUCCEEDED(hr
), "Failed to load texture, hr %#lx.\n", hr
);
6631 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr
);
6632 hr
= IDirect3DRMTexture_QueryInterface(texture1
, &IID_IUnknown
, (void **)&unknown
);
6633 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture, hr %#lx\n", hr
);
6634 IDirect3DRMTexture_Release(texture1
);
6635 test_qi("texture1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6636 IUnknown_Release(unknown
);
6638 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
6639 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
6640 hr
= IDirect3DRM2_LoadTexture(d3drm2
, filename
, &texture2
);
6641 ok(SUCCEEDED(hr
), "Failed to load texture, hr %#lx.\n", hr
);
6642 hr
= IDirect3DRMTexture2_QueryInterface(texture2
, &IID_IUnknown
, (void **)&unknown
);
6643 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture2, hr %#lx\n", hr
);
6644 IDirect3DRMTexture2_Release(texture2
);
6645 test_qi("texture2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6646 IUnknown_Release(unknown
);
6648 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6649 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
6650 hr
= IDirect3DRM3_LoadTexture(d3drm3
, filename
, &texture3
);
6651 ok(SUCCEEDED(hr
), "Failed to load texture, hr %#lx.\n", hr
);
6652 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr
);
6653 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IUnknown
, (void **)&unknown
);
6654 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface from IDirect3DRMTexture3, hr %#lx\n", hr
);
6655 IDirect3DRMTexture3_Release(texture3
);
6656 test_qi("texture3_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6657 IUnknown_Release(unknown
);
6659 IDirect3DRM3_Release(d3drm3
);
6660 IDirect3DRM2_Release(d3drm2
);
6661 IDirect3DRM_Release(d3drm1
);
6662 check
= DeleteFileA(filename
);
6663 ok(check
, "Cannot delete image stored in %s (error = %ld).\n", filename
, GetLastError());
6667 static void test_viewport_qi(void)
6669 IDirect3DRM
*d3drm1
;
6670 IDirect3DRM2
*d3drm2
;
6671 IDirect3DRM3
*d3drm3
;
6672 IDirect3DRMFrame
*frame1
, *camera1
;
6673 IDirect3DRMFrame3
*frame3
, *camera3
;
6674 IDirect3DRMDevice
*device1
;
6675 IDirect3DRMDevice3
*device3
;
6676 IDirectDrawClipper
*clipper
;
6677 IDirect3DRMViewport
*viewport1
;
6678 IDirect3DRMViewport2
*viewport2
;
6680 GUID driver
= IID_IDirect3DRGBDevice
;
6683 static const struct qi_test tests
[] =
6685 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6686 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6687 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6688 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6689 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6690 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6691 { &IID_IDirect3DRMWinDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6692 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMViewport
, S_OK
},
6693 { &IID_IDirect3DRMViewport
, &IID_IUnknown
, &IID_IDirect3DRMViewport
, S_OK
},
6694 { &IID_IDirect3DRMViewport2
, &IID_IUnknown
, &IID_IDirect3DRMViewport2
, S_OK
},
6695 { &IID_IDirect3DRMFrame
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6696 { &IID_IDirect3DRMFrame2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6697 { &IID_IDirect3DRMFrame3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6698 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6699 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6700 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6701 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6702 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6703 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6704 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6705 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6706 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6707 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6708 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6709 { &IID_IDirect3DRMWrap
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6710 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6711 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6712 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6713 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6714 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6715 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6716 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6717 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6718 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6719 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6720 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6721 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6722 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6723 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6724 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6725 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6726 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6727 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6728 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6729 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6730 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6731 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6732 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6733 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6734 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6735 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6736 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6737 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6738 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6739 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6740 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6741 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6742 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6743 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6744 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6745 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6746 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6747 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6748 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6749 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6750 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6751 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
6752 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
, },
6755 hr
= DirectDrawCreateClipper(0, &clipper
, NULL
);
6756 ok(SUCCEEDED(hr
), "Cannot get IDirectDrawClipper interface, hr %#lx.\n", hr
);
6758 hr
= Direct3DRMCreate(&d3drm1
);
6759 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
6761 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, 640, 480, &device1
);
6762 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice interface, hr %#lx.\n", hr
);
6763 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
6764 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
6765 hr
= IDirect3DRM_CreateFrame(d3drm1
, frame1
, &camera1
);
6766 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
6767 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, camera1
, 0, 0, 640, 480, &viewport1
);
6768 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr
);
6769 hr
= IDirect3DRMViewport_QueryInterface(viewport1
, &IID_IUnknown
, (void **)&unknown
);
6770 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface, hr %#lx.\n", hr
);
6771 IDirect3DRMViewport_Release(viewport1
);
6772 test_qi("viewport1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6773 IUnknown_Release(unknown
);
6775 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
6776 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
6777 hr
= IDirect3DRM2_CreateViewport(d3drm2
, device1
, camera1
, 0, 0, 640, 480, &viewport1
);
6778 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport interface, hr %#lx\n", hr
);
6779 hr
= IDirect3DRMViewport_QueryInterface(viewport1
, &IID_IUnknown
, (void **)&unknown
);
6780 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface, hr %#lx.\n", hr
);
6781 IDirect3DRMViewport_Release(viewport1
);
6782 test_qi("viewport1_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6783 IUnknown_Release(unknown
);
6784 IDirect3DRMDevice_Release(device1
);
6785 IDirect3DRMFrame_Release(camera1
);
6786 IDirect3DRMFrame_Release(frame1
);
6788 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
6789 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
6790 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, 640, 480, &device3
);
6791 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
6792 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
6793 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface, hr %#lx\n", hr
);
6794 hr
= IDirect3DRM3_CreateFrame(d3drm3
, frame3
, &camera3
);
6795 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface, hr %#lx\n", hr
);
6796 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, 640, 480, &viewport2
);
6797 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr
);
6798 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IUnknown
, (void **)&unknown
);
6799 ok(SUCCEEDED(hr
), "Cannot get IUnknown interface, hr %#lx.\n", hr
);
6800 IDirect3DRMViewport_Release(viewport2
);
6801 test_qi("viewport2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
6802 IUnknown_Release(unknown
);
6803 IDirect3DRMDevice3_Release(device3
);
6804 IDirect3DRMFrame3_Release(camera3
);
6805 IDirect3DRMFrame3_Release(frame3
);
6807 IDirectDrawClipper_Release(clipper
);
6808 IDirect3DRM3_Release(d3drm3
);
6809 IDirect3DRM2_Release(d3drm2
);
6810 IDirect3DRM_Release(d3drm1
);
6813 static D3DCOLOR
get_surface_color(IDirectDrawSurface
*surface
, UINT x
, UINT y
)
6815 RECT rect
= { x
, y
, x
+ 1, y
+ 1 };
6816 DDSURFACEDESC surface_desc
;
6820 memset(&surface_desc
, 0, sizeof(surface_desc
));
6821 surface_desc
.dwSize
= sizeof(surface_desc
);
6823 hr
= IDirectDrawSurface_Lock(surface
, &rect
, &surface_desc
, DDLOCK_READONLY
| DDLOCK_WAIT
, NULL
);
6824 ok(SUCCEEDED(hr
), "Failed to lock surface, hr %#lx.\n", hr
);
6828 color
= *((DWORD
*)surface_desc
.lpSurface
) & 0x00ffffff;
6830 hr
= IDirectDrawSurface_Unlock(surface
, NULL
);
6831 ok(SUCCEEDED(hr
), "Failed to unlock surface, hr %#lx.\n", hr
);
6836 static IDirect3DDevice2
*create_device2_without_ds(IDirectDraw2
*ddraw
, HWND window
)
6838 IDirectDrawSurface
*surface
;
6839 IDirect3DDevice2
*device
= NULL
;
6840 DDSURFACEDESC surface_desc
;
6845 GetClientRect(window
, &rc
);
6846 hr
= IDirectDraw2_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
6847 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
6849 memset(&surface_desc
, 0, sizeof(surface_desc
));
6850 surface_desc
.dwSize
= sizeof(surface_desc
);
6851 surface_desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
6852 surface_desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
| DDSCAPS_3DDEVICE
;
6853 surface_desc
.dwWidth
= rc
.right
;
6854 surface_desc
.dwHeight
= rc
.bottom
;
6856 hr
= IDirectDraw2_CreateSurface(ddraw
, &surface_desc
, &surface
, NULL
);
6857 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
6859 hr
= IDirectDraw2_QueryInterface(ddraw
, &IID_IDirect3D2
, (void **)&d3d
);
6862 IDirectDrawSurface_Release(surface
);
6866 IDirect3D2_CreateDevice(d3d
, &IID_IDirect3DHALDevice
, surface
, &device
);
6868 IDirect3D2_Release(d3d
);
6869 IDirectDrawSurface_Release(surface
);
6873 static void clear_depth_surface(IDirectDrawSurface
*surface
, DWORD value
)
6878 memset(&fx
, 0, sizeof(fx
));
6879 fx
.dwSize
= sizeof(fx
);
6880 fx
.dwFillDepth
= value
;
6882 hr
= IDirectDrawSurface_Blt(surface
, NULL
, NULL
, NULL
, DDBLT_DEPTHFILL
| DDBLT_WAIT
, &fx
);
6883 ok(SUCCEEDED(hr
), "Got unexpected hr %#lx.\n", hr
);
6886 static void set_execute_data(IDirect3DExecuteBuffer
*execute_buffer
, UINT vertex_count
, UINT offset
, UINT len
)
6888 D3DEXECUTEDATA exec_data
;
6891 memset(&exec_data
, 0, sizeof(exec_data
));
6892 exec_data
.dwSize
= sizeof(exec_data
);
6893 exec_data
.dwVertexCount
= vertex_count
;
6894 exec_data
.dwInstructionOffset
= offset
;
6895 exec_data
.dwInstructionLength
= len
;
6896 hr
= IDirect3DExecuteBuffer_SetExecuteData(execute_buffer
, &exec_data
);
6897 ok(SUCCEEDED(hr
), "Failed to set execute data, hr %#lx.\n", hr
);
6900 static void emit_set_ts(void **ptr
, D3DTRANSFORMSTATETYPE state
, DWORD value
)
6902 D3DINSTRUCTION
*inst
= *ptr
;
6903 D3DSTATE
*ts
= (D3DSTATE
*)(inst
+ 1);
6905 inst
->bOpcode
= D3DOP_STATETRANSFORM
;
6906 inst
->bSize
= sizeof(*ts
);
6909 ts
->dtstTransformStateType
= state
;
6910 ts
->dwArg
[0] = value
;
6915 static void emit_set_rs(void **ptr
, D3DRENDERSTATETYPE state
, DWORD value
)
6917 D3DINSTRUCTION
*inst
= *ptr
;
6918 D3DSTATE
*rs
= (D3DSTATE
*)(inst
+ 1);
6920 inst
->bOpcode
= D3DOP_STATERENDER
;
6921 inst
->bSize
= sizeof(*rs
);
6924 rs
->drstRenderStateType
= state
;
6925 rs
->dwArg
[0] = value
;
6930 static void emit_process_vertices(void **ptr
, DWORD flags
, WORD base_idx
, DWORD vertex_count
)
6932 D3DINSTRUCTION
*inst
= *ptr
;
6933 D3DPROCESSVERTICES
*pv
= (D3DPROCESSVERTICES
*)(inst
+ 1);
6935 inst
->bOpcode
= D3DOP_PROCESSVERTICES
;
6936 inst
->bSize
= sizeof(*pv
);
6939 pv
->dwFlags
= flags
;
6940 pv
->wStart
= base_idx
;
6942 pv
->dwCount
= vertex_count
;
6948 static void emit_tquad(void **ptr
, WORD base_idx
)
6950 D3DINSTRUCTION
*inst
= *ptr
;
6951 D3DTRIANGLE
*tri
= (D3DTRIANGLE
*)(inst
+ 1);
6953 inst
->bOpcode
= D3DOP_TRIANGLE
;
6954 inst
->bSize
= sizeof(*tri
);
6958 tri
->v2
= base_idx
+ 1;
6959 tri
->v3
= base_idx
+ 2;
6960 tri
->wFlags
= D3DTRIFLAG_START
;
6963 tri
->v1
= base_idx
+ 2;
6964 tri
->v2
= base_idx
+ 1;
6965 tri
->v3
= base_idx
+ 3;
6966 tri
->wFlags
= D3DTRIFLAG_ODD
;
6972 static void emit_end(void **ptr
)
6974 D3DINSTRUCTION
*inst
= *ptr
;
6976 inst
->bOpcode
= D3DOP_EXIT
;
6983 static void d3d_draw_quad1(IDirect3DDevice
*device
, IDirect3DViewport
*viewport
)
6985 IDirect3DExecuteBuffer
*execute_buffer
;
6986 D3DEXECUTEBUFFERDESC exec_desc
;
6990 D3DMATRIXHANDLE world_handle
, view_handle
, proj_handle
;
6991 static D3DMATRIX mat
=
6993 1.0f
, 0.0f
, 0.0f
, 0.0f
,
6994 0.0f
, 1.0f
, 0.0f
, 0.0f
,
6995 0.0f
, 0.0f
, 1.0f
, 0.0f
,
6996 0.0f
, 0.0f
, 0.0f
, 1.0f
,
6998 static const D3DLVERTEX quad_strip
[] =
7000 {{-1.0f
}, {-1.0f
}, {0.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
7001 {{-1.0f
}, { 1.0f
}, {0.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
7002 {{ 1.0f
}, {-1.0f
}, {1.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
7003 {{ 1.0f
}, { 1.0f
}, {1.00f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
7006 hr
= IDirect3DDevice_CreateMatrix(device
, &world_handle
);
7007 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#lx.\n", hr
);
7008 hr
= IDirect3DDevice_SetMatrix(device
, world_handle
, &mat
);
7009 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#lx.\n", hr
);
7010 hr
= IDirect3DDevice_CreateMatrix(device
, &view_handle
);
7011 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#lx.\n", hr
);
7012 hr
= IDirect3DDevice_SetMatrix(device
, view_handle
, &mat
);
7013 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#lx.\n", hr
);
7014 hr
= IDirect3DDevice_CreateMatrix(device
, &proj_handle
);
7015 ok(hr
== D3D_OK
, "Creating a matrix object failed, hr %#lx.\n", hr
);
7016 hr
= IDirect3DDevice_SetMatrix(device
, proj_handle
, &mat
);
7017 ok(hr
== D3D_OK
, "Setting a matrix object failed, hr %#lx.\n", hr
);
7019 memset(&exec_desc
, 0, sizeof(exec_desc
));
7020 exec_desc
.dwSize
= sizeof(exec_desc
);
7021 exec_desc
.dwFlags
= D3DDEB_BUFSIZE
| D3DDEB_CAPS
;
7022 exec_desc
.dwBufferSize
= 1024;
7023 exec_desc
.dwCaps
= D3DDEBCAPS_SYSTEMMEMORY
;
7025 hr
= IDirect3DDevice_CreateExecuteBuffer(device
, &exec_desc
, &execute_buffer
, NULL
);
7026 ok(SUCCEEDED(hr
), "Failed to create execute buffer, hr %#lx.\n", hr
);
7028 hr
= IDirect3DExecuteBuffer_Lock(execute_buffer
, &exec_desc
);
7029 ok(SUCCEEDED(hr
), "Failed to lock execute buffer, hr %#lx.\n", hr
);
7031 memcpy(exec_desc
.lpData
, quad_strip
, sizeof(quad_strip
));
7032 ptr
= ((BYTE
*)exec_desc
.lpData
) + sizeof(quad_strip
);
7033 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_WORLD
, world_handle
);
7034 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_VIEW
, view_handle
);
7035 emit_set_ts(&ptr
, D3DTRANSFORMSTATE_PROJECTION
, proj_handle
);
7036 emit_set_rs(&ptr
, D3DRENDERSTATE_CLIPPING
, FALSE
);
7037 emit_set_rs(&ptr
, D3DRENDERSTATE_ZENABLE
, TRUE
);
7038 emit_set_rs(&ptr
, D3DRENDERSTATE_FOGENABLE
, FALSE
);
7039 emit_set_rs(&ptr
, D3DRENDERSTATE_CULLMODE
, D3DCULL_NONE
);
7040 emit_set_rs(&ptr
, D3DRENDERSTATE_SHADEMODE
, D3DSHADE_FLAT
);
7042 emit_process_vertices(&ptr
, D3DPROCESSVERTICES_TRANSFORM
, 0, 4);
7043 emit_tquad(&ptr
, 0);
7046 inst_length
= (BYTE
*)ptr
- (BYTE
*)exec_desc
.lpData
;
7047 inst_length
-= sizeof(quad_strip
);
7049 hr
= IDirect3DExecuteBuffer_Unlock(execute_buffer
);
7050 ok(SUCCEEDED(hr
), "Failed to unlock execute buffer, hr %#lx.\n", hr
);
7052 hr
= IDirect3DDevice_BeginScene(device
);
7053 set_execute_data(execute_buffer
, 4, sizeof(quad_strip
), inst_length
);
7054 hr
= IDirect3DDevice_Execute(device
, execute_buffer
, viewport
, D3DEXECUTE_CLIPPED
);
7055 ok(SUCCEEDED(hr
), "Failed to execute exec buffer, hr %#lx.\n", hr
);
7056 hr
= IDirect3DDevice_EndScene(device
);
7057 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#lx.\n", hr
);
7059 IDirect3DExecuteBuffer_Release(execute_buffer
);
7062 static void test_viewport_clear1(void)
7064 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
7066 IDirectDrawClipper
*clipper
;
7067 IDirect3DRM
*d3drm1
;
7068 IDirect3DRMFrame
*frame1
, *camera1
;
7069 IDirect3DRMDevice
*device1
;
7070 IDirect3DViewport
*d3d_viewport
;
7071 IDirect3DRMViewport
*viewport1
;
7072 IDirect3DDevice
*d3d_device1
;
7073 IDirectDrawSurface
*surface
, *ds
, *d3drm_ds
;
7075 GUID driver
= IID_IDirect3DRGBDevice
;
7080 window
= create_window();
7081 GetClientRect(window
, &rc
);
7083 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
7084 ok(SUCCEEDED(hr
), "Cannot create IDirectDraw interface, hr %#lx.\n", hr
);
7086 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
7087 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
7089 hr
= IDirectDraw_CreateClipper(ddraw
, 0, &clipper
, NULL
);
7090 ok(SUCCEEDED(hr
), "Cannot create clipper, hr %#lx.\n", hr
);
7092 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
7093 ok(SUCCEEDED(hr
), "Cannot set HWnd to Clipper, hr %#lx\n", hr
);
7095 hr
= Direct3DRMCreate(&d3drm1
);
7096 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
7098 hr
= IDirect3DRM_CreateDeviceFromClipper(d3drm1
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device1
);
7099 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice interface, hr %#lx\n", hr
);
7101 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame1
);
7102 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
7103 hr
= IDirect3DRM_CreateFrame(d3drm1
, frame1
, &camera1
);
7104 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame interface, hr %#lx\n", hr
);
7106 hr
= IDirect3DRM_CreateViewport(d3drm1
, device1
, camera1
, 0, 0, rc
.right
,
7107 rc
.bottom
, &viewport1
);
7108 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface, hr %#lx\n", hr
);
7110 /* Fetch immediate mode device and viewport */
7111 hr
= IDirect3DRMDevice_GetDirect3DDevice(device1
, &d3d_device1
);
7112 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice interface, hr %#lx.\n", hr
);
7113 hr
= IDirect3DRMViewport_GetDirect3DViewport(viewport1
, &d3d_viewport
);
7114 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
7116 hr
= IDirect3DDevice_QueryInterface(d3d_device1
, &IID_IDirectDrawSurface
, (void **)&surface
);
7117 ok(SUCCEEDED(hr
), "Cannot get surface to the render target, hr %#lx.\n", hr
);
7119 ret_color
= get_surface_color(surface
, 320, 240);
7120 ok(compare_color(ret_color
, 0, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7122 /* Clear uses the scene frame's background color. */
7123 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 1.0f
, 1.0f
, 1.0f
);
7124 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx\n", hr
);
7125 ret_color
= IDirect3DRMFrame_GetSceneBackground(frame1
);
7126 ok(ret_color
== 0xffffffff, "Expected scene color returned == 0xffffffff, got %#lx.\n", ret_color
);
7127 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(camera1
, 0.0f
, 1.0f
, 0.0f
);
7128 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx\n", hr
);
7129 ret_color
= IDirect3DRMFrame_GetSceneBackground(camera1
);
7130 ok(ret_color
== 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#lx.\n", ret_color
);
7132 CHECK_REFCOUNT(frame1
, 1);
7133 hr
= IDirect3DRMViewport_Clear(viewport1
);
7134 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7135 ret_color
= get_surface_color(surface
, 320, 240);
7136 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7137 CHECK_REFCOUNT(frame1
, 1);
7139 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 0.5f
, 0.5f
, 0.5f
);
7140 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx\n", hr
);
7142 hr
= IDirect3DRMViewport_Render(viewport1
, frame1
);
7143 ok(SUCCEEDED(hr
), "Cannot Render, hr %#lx\n", hr
);
7145 ret_color
= get_surface_color(surface
, 320, 240);
7146 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7148 hr
= IDirect3DRMFrame_SetSceneBackgroundRGB(frame1
, 0.0f
, 0.0f
, 1.0f
);
7149 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx\n", hr
);
7150 ret_color
= IDirect3DRMFrame_GetSceneBackground(frame1
);
7151 ok(ret_color
== 0xff0000ff, "Expected scene color returned == 0xff00ff00, got %#lx.\n", ret_color
);
7153 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
7154 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7155 hr
= IDirect3DRMViewport_Clear(viewport1
);
7156 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7157 ret_color
= get_surface_color(surface
, 100, 200);
7158 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7160 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
7162 ret_color
= get_surface_color(surface
, 100, 200);
7163 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7165 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
7166 ok(SUCCEEDED(hr
), "Cannot get attached depth surface, hr %#lx.\n", hr
);
7168 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
7169 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7170 hr
= IDirect3DRMViewport_Clear(viewport1
);
7171 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7172 ret_color
= get_surface_color(surface
, 100, 200);
7173 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7175 /* Fill the depth surface with a value lower than the quad's depth value. */
7176 clear_depth_surface(ds
, 0x7fff);
7178 /* Depth test passes here */
7179 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
7180 ret_color
= get_surface_color(surface
, 100, 200);
7181 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7182 /* Depth test fails here */
7183 ret_color
= get_surface_color(surface
, 500, 400);
7184 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7186 /* Check what happens if we release the depth surface that d3drm created, and clear the viewport */
7187 hr
= IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, ds
);
7188 ok(SUCCEEDED(hr
), "Cannot delete attached surface, hr %#lx.\n", hr
);
7189 d3drm_ds
= (IDirectDrawSurface
*)0xdeadbeef;
7190 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
7191 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#lx.\n", hr
);
7192 ok(d3drm_ds
== NULL
, "Expected NULL z-surface, got %p.\n", d3drm_ds
);
7194 clear_depth_surface(ds
, 0x7fff);
7195 hr
= IDirect3DRMViewport_Configure(viewport1
, 0, 0, rc
.right
, rc
.bottom
);
7196 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7197 hr
= IDirect3DRMViewport_Clear(viewport1
);
7198 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7200 ret_color
= get_surface_color(surface
, 100, 200);
7201 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7203 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
7204 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
7205 IDirectDrawSurface_Release(ds
);
7207 d3d_draw_quad1(d3d_device1
, d3d_viewport
);
7209 ret_color
= get_surface_color(surface
, 100, 200);
7210 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7211 ret_color
= get_surface_color(surface
, 500, 400);
7212 ok(compare_color(ret_color
, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7214 IDirect3DViewport_Release(d3d_viewport
);
7215 IDirectDrawSurface_Release(surface
);
7216 IDirect3DDevice_Release(d3d_device1
);
7217 IDirect3DRMViewport_Release(viewport1
);
7218 IDirect3DRMFrame_Release(frame1
);
7219 IDirect3DRMFrame_Release(camera1
);
7220 IDirect3DRMDevice_Release(device1
);
7221 IDirect3DRM_Release(d3drm1
);
7222 IDirectDrawClipper_Release(clipper
);
7223 IDirectDraw_Release(ddraw
);
7224 DestroyWindow(window
);
7227 static void draw_quad2(IDirect3DDevice2
*device
, IDirect3DViewport
*viewport
)
7229 static D3DLVERTEX tquad
[] =
7231 {{-1.0f
}, {-1.0f
}, {0.0f
}, 0, {0xffbada55}, {0}, {0.0f
}, {0.0f
}},
7232 {{-1.0f
}, { 1.0f
}, {0.0f
}, 0, {0xffbada55}, {0}, {0.0f
}, {1.0f
}},
7233 {{ 1.0f
}, {-1.0f
}, {1.0f
}, 0, {0xffbada55}, {0}, {1.0f
}, {0.0f
}},
7234 {{ 1.0f
}, { 1.0f
}, {1.0f
}, 0, {0xffbada55}, {0}, {1.0f
}, {1.0f
}},
7236 static D3DMATRIX mat
=
7238 1.0f
, 0.0f
, 0.0f
, 0.0f
,
7239 0.0f
, 1.0f
, 0.0f
, 0.0f
,
7240 0.0f
, 0.0f
, 1.0f
, 0.0f
,
7241 0.0f
, 0.0f
, 0.0f
, 1.0f
,
7243 IDirect3DViewport2
*viewport2
;
7246 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_WORLD
, &mat
);
7247 ok(SUCCEEDED(hr
), "Failed to set world transform, hr %#lx.\n", hr
);
7248 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_VIEW
, &mat
);
7249 ok(SUCCEEDED(hr
), "Failed to set view transform, hr %#lx.\n", hr
);
7250 hr
= IDirect3DDevice2_SetTransform(device
, D3DTRANSFORMSTATE_PROJECTION
, &mat
);
7251 ok(SUCCEEDED(hr
), "Failed to set projection transform, hr %#lx.\n", hr
);
7253 hr
= IDirect3DViewport_QueryInterface(viewport
, &IID_IDirect3DViewport2
, (void **)&viewport2
);
7254 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport2 interface, hr %#lx.\n", hr
);
7255 hr
= IDirect3DDevice2_SetCurrentViewport(device
, viewport2
);
7256 ok(SUCCEEDED(hr
), "Failed to activate the viewport, hr %#lx.\n", hr
);
7257 IDirect3DViewport2_Release(viewport2
);
7259 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZENABLE
, D3DZB_TRUE
);
7260 ok(SUCCEEDED(hr
), "Failed to enable z testing, hr %#lx.\n", hr
);
7261 hr
= IDirect3DDevice2_SetRenderState(device
, D3DRENDERSTATE_ZFUNC
, D3DCMP_LESSEQUAL
);
7262 ok(SUCCEEDED(hr
), "Failed to set the z function, hr %#lx.\n", hr
);
7264 hr
= IDirect3DDevice2_BeginScene(device
);
7265 ok(SUCCEEDED(hr
), "Failed to begin scene, hr %#lx.\n", hr
);
7266 hr
= IDirect3DDevice2_DrawPrimitive(device
, D3DPT_TRIANGLESTRIP
, D3DVT_LVERTEX
, tquad
, 4, 0);
7267 ok(SUCCEEDED(hr
), "Failed to draw, hr %#lx.\n", hr
);
7268 hr
= IDirect3DDevice2_EndScene(device
);
7269 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#lx.\n", hr
);
7272 static void test_viewport_clear2(void)
7274 DDSCAPS caps
= { DDSCAPS_ZBUFFER
};
7276 IDirectDraw
*ddraw1
;
7277 IDirectDraw2
*ddraw2
;
7278 IDirectDrawClipper
*clipper
;
7279 IDirect3DRM
*d3drm1
;
7280 IDirect3DRM3
*d3drm3
;
7281 IDirect3DRMFrame3
*frame3
, *camera3
;
7282 IDirect3DRMDevice3
*device3
;
7283 IDirect3DViewport
*d3d_viewport
;
7284 IDirect3DRMViewport2
*viewport2
;
7285 IDirect3DDevice2
*d3d_device2
;
7286 IDirectDrawSurface
*surface
, *ds
, *d3drm_ds
;
7288 GUID driver
= IID_IDirect3DRGBDevice
;
7293 window
= create_window();
7294 GetClientRect(window
, &rc
);
7296 hr
= DirectDrawCreate(NULL
, &ddraw1
, NULL
);
7297 ok(SUCCEEDED(hr
), "Cannot create IDirectDraw interface, hr %#lx.\n", hr
);
7299 hr
= IDirectDraw_SetCooperativeLevel(ddraw1
, window
, DDSCL_NORMAL
);
7300 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
7302 hr
= IDirectDraw_CreateClipper(ddraw1
, 0, &clipper
, NULL
);
7303 ok(SUCCEEDED(hr
), "Cannot create clipper, hr %#lx.\n", hr
);
7305 hr
= IDirectDrawClipper_SetHWnd(clipper
, 0, window
);
7306 ok(SUCCEEDED(hr
), "Cannot set HWnd to Clipper, hr %#lx.\n", hr
);
7308 hr
= Direct3DRMCreate(&d3drm1
);
7309 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
7311 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
7312 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
7314 hr
= IDirect3DRM3_CreateDeviceFromClipper(d3drm3
, clipper
, &driver
, rc
.right
, rc
.bottom
, &device3
);
7315 ok(hr
== D3DRM_OK
, "Cannot get IDirect3DRMDevice3 interface, hr %#lx.\n", hr
);
7317 hr
= IDirect3DRM3_CreateFrame(d3drm3
, NULL
, &frame3
);
7318 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface, hr %#lx.\n", hr
);
7319 hr
= IDirect3DRM3_CreateFrame(d3drm3
, frame3
, &camera3
);
7320 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMFrame3 interface, hr %#lx.\n", hr
);
7322 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, rc
.right
,
7323 rc
.bottom
, &viewport2
);
7324 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface, hr %#lx.\n", hr
);
7326 /* Fetch immediate mode device in order to access render target and test its color. */
7327 hr
= IDirect3DRMDevice3_GetDirect3DDevice2(device3
, &d3d_device2
);
7328 ok(SUCCEEDED(hr
), "Cannot get IDirect3DDevice2 interface, hr %#lx.\n", hr
);
7330 hr
= IDirect3DDevice2_GetRenderTarget(d3d_device2
, &surface
);
7331 ok(SUCCEEDED(hr
), "Cannot get surface to the render target, hr %#lx.\n", hr
);
7333 ret_color
= get_surface_color(surface
, 320, 240);
7334 ok(compare_color(ret_color
, 0, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7336 /* Clear uses the scene frame's background color. */
7337 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 1.0f
, 1.0f
, 1.0f
);
7338 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx.\n", hr
);
7339 ret_color
= IDirect3DRMFrame3_GetSceneBackground(frame3
);
7340 ok(ret_color
== 0xffffffff, "Expected scene color returned == 0xffffffff, got %#lx.\n", ret_color
);
7341 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(camera3
, 0.0f
, 1.0f
, 0.0f
);
7342 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx.\n", hr
);
7343 ret_color
= IDirect3DRMFrame3_GetSceneBackground(camera3
);
7344 ok(ret_color
== 0xff00ff00, "Expected scene color returned == 0xff00ff00, got %#lx.\n", ret_color
);
7346 CHECK_REFCOUNT(frame3
, 1);
7347 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7348 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7349 ret_color
= get_surface_color(surface
, 320, 240);
7350 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7351 CHECK_REFCOUNT(frame3
, 1);
7353 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 0.5f
, 0.5f
, 0.5f
);
7354 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx\n", hr
);
7356 hr
= IDirect3DRMViewport2_Render(viewport2
, frame3
);
7357 ok(SUCCEEDED(hr
), "Cannot Render, hr %#lx\n", hr
);
7359 ret_color
= get_surface_color(surface
, 320, 240);
7360 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7362 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 1.0f
, 1.0f
, 1.0f
);
7363 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx\n", hr
);
7365 hr
= IDirect3DRMViewport2_GetDirect3DViewport(viewport2
, &d3d_viewport
);
7366 ok(SUCCEEDED(hr
), "Cannot get IDirect3DViewport interface, hr %#lx.\n", hr
);
7368 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7369 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7371 /* d3drm seems to be calling BeginScene when Clear is called. */
7372 hr
= IDirect3DDevice2_BeginScene(d3d_device2
);
7373 todo_wine
ok(hr
== D3DERR_SCENE_IN_SCENE
, "Expected hr == D3DERR_SCENE_IN_SCENE, got %#lx.\n", hr
);
7374 hr
= IDirect3DDevice2_EndScene(d3d_device2
);
7375 ok(SUCCEEDED(hr
), "Failed to end scene, hr %#lx.\n", hr
);
7377 ret_color
= get_surface_color(surface
, 320, 240);
7378 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7380 /* We're using d3d to draw using IDirect3DDevice2 created from d3drm. */
7381 draw_quad2(d3d_device2
, d3d_viewport
);
7382 ret_color
= get_surface_color(surface
, 320, 240);
7383 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7385 /* Without calling Configure, Clear doesn't work. */
7386 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7387 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7388 ret_color
= get_surface_color(surface
, 320, 240);
7389 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7391 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
7392 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7393 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7394 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7396 ret_color
= get_surface_color(surface
, 320, 240);
7397 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7399 /* Fetch attached depth surface and see if viewport clears it if it's detached from the render target. */
7400 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &ds
);
7401 ok(SUCCEEDED(hr
), "Cannot get attached depth surface, hr %#lx.\n", hr
);
7403 clear_depth_surface(ds
, 0x39);
7404 draw_quad2(d3d_device2
, d3d_viewport
);
7406 ret_color
= get_surface_color(surface
, 320, 240);
7407 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7409 hr
= IDirectDrawSurface_DeleteAttachedSurface(surface
, 0, ds
);
7410 ok(SUCCEEDED(hr
), "Cannot delete attached surface, hr %#lx.\n", hr
);
7411 d3drm_ds
= (IDirectDrawSurface
*)0xdeadbeef;
7412 hr
= IDirectDrawSurface_GetAttachedSurface(surface
, &caps
, &d3drm_ds
);
7413 ok(hr
== DDERR_NOTFOUND
, "Expected hr == DDERR_NOTFOUND, got %#lx.\n", hr
);
7414 ok(d3drm_ds
== NULL
, "Expected NULL z-surface, got %p.\n", d3drm_ds
);
7416 clear_depth_surface(ds
, 0x7fff);
7418 /* This version of Clear still clears the depth surface even if it's deleted from the render target. */
7419 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
7420 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7421 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7422 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7424 hr
= IDirectDrawSurface_AddAttachedSurface(surface
, ds
);
7425 ok(SUCCEEDED(hr
), "Failed to attach depth buffer, hr %#lx.\n", hr
);
7426 ret_color
= get_surface_color(surface
, 320, 240);
7427 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7429 draw_quad2(d3d_device2
, d3d_viewport
);
7430 ret_color
= get_surface_color(surface
, 100, 200);
7431 ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7432 ret_color
= get_surface_color(surface
, 500, 400);
7433 todo_wine
ok(compare_color(ret_color
, 0x00bada55, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7435 /* Remove old draw contents */
7436 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 0.0f
, 1.0f
, 0.0f
);
7437 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx.\n", hr
);
7438 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
7439 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7440 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7441 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7442 hr
= IDirect3DRMFrame3_SetSceneBackgroundRGB(frame3
, 1.0f
, 1.0f
, 1.0f
);
7443 ok(SUCCEEDED(hr
), "Cannot set scene background RGB, hr %#lx.\n", hr
);
7445 /* Clear with no flags */
7446 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
7447 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7448 hr
= IDirect3DRMViewport2_Clear(viewport2
, 0);
7449 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7450 ret_color
= get_surface_color(surface
, 320, 240);
7451 ok(compare_color(ret_color
, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7453 hr
= IDirect3DRMViewport2_Configure(viewport2
, 0, 0, rc
.right
, rc
.bottom
);
7454 todo_wine
ok(SUCCEEDED(hr
), "Cannot configure viewport, hr %#lx.\n", hr
);
7455 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7456 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7457 ret_color
= get_surface_color(surface
, 320, 240);
7458 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7460 IDirect3DViewport_Release(d3d_viewport
);
7461 IDirectDrawSurface_Release(surface
);
7462 IDirectDrawSurface_Release(ds
);
7463 IDirect3DDevice2_Release(d3d_device2
);
7464 IDirect3DRMViewport2_Release(viewport2
);
7465 IDirect3DRMDevice3_Release(device3
);
7467 /* Create device without depth surface attached */
7468 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirectDraw2
, (void **)&ddraw2
);
7469 ok(SUCCEEDED(hr
), "Cannot get IDirectDraw2 interface, hr %#lx.\n", hr
);
7470 hr
= IDirectDraw_QueryInterface(ddraw1
, &IID_IDirect3D2
, (void **)&d3d2
);
7471 ok(SUCCEEDED(hr
), "Cannot get IDirect3D2 interface, hr %#lx.\n", hr
);
7472 d3d_device2
= create_device2_without_ds(ddraw2
, window
);
7476 hr
= IDirect3DRM3_CreateDeviceFromD3D(d3drm3
, d3d2
, d3d_device2
, &device3
);
7477 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRMDevice interface, hr %#lx.\n", hr
);
7478 hr
= IDirect3DRM3_CreateViewport(d3drm3
, device3
, camera3
, 0, 0, rc
.right
,
7479 rc
.bottom
, &viewport2
);
7480 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMViewport2 interface, hr %#lx.\n", hr
);
7481 hr
= IDirect3DDevice2_GetRenderTarget(d3d_device2
, &surface
);
7482 ok(SUCCEEDED(hr
), "Cannot get surface to the render target, hr %#lx.\n", hr
);
7484 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ALL
);
7485 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7486 ret_color
= get_surface_color(surface
, 320, 240);
7487 ok(compare_color(ret_color
, 0x00ffffff, 1), "Got unexpected color 0x%08lx.\n", ret_color
);
7489 hr
= IDirect3DRMViewport2_Clear(viewport2
, D3DRMCLEAR_ZBUFFER
);
7490 ok(SUCCEEDED(hr
), "Cannot clear viewport, hr %#lx.\n", hr
);
7492 IDirectDrawSurface_Release(surface
);
7493 IDirect3DRMViewport2_Release(viewport2
);
7494 IDirect3DRMDevice3_Release(device3
);
7495 IDirect3DDevice2_Release(d3d_device2
);
7498 IDirect3DRMFrame3_Release(camera3
);
7499 IDirect3DRMFrame3_Release(frame3
);
7500 IDirect3DRM3_Release(d3drm3
);
7501 IDirect3DRM_Release(d3drm1
);
7502 IDirectDrawClipper_Release(clipper
);
7503 IDirect3D2_Release(d3d2
);
7504 IDirectDraw2_Release(ddraw2
);
7505 IDirectDraw_Release(ddraw1
);
7506 DestroyWindow(window
);
7509 static void test_create_texture_from_surface(void)
7511 D3DRMIMAGE testimg
=
7514 TRUE
, 0, (void *)0xcafebabe, NULL
,
7515 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
7517 IDirectDrawSurface
*surface
= NULL
, *surface2
= NULL
, *ds
= NULL
;
7518 IDirect3DRMTexture
*texture1
;
7519 IDirect3DRMTexture2
*texture2
;
7520 IDirect3DRMTexture3
*texture3
;
7521 IDirectDraw
*ddraw
= NULL
;
7522 IDirect3DRM
*d3drm1
= NULL
;
7523 IDirect3DRM2
*d3drm2
= NULL
;
7524 IDirect3DRM3
*d3drm3
= NULL
;
7525 ULONG ref1
, ref2
, ref3
;
7532 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
7533 ok(hr
== DD_OK
, "Cannot get IDirectDraw interface, hr %#lx.\n", hr
);
7535 window
= create_window();
7536 GetClientRect(window
, &rc
);
7538 hr
= IDirectDraw_SetCooperativeLevel(ddraw
, window
, DDSCL_NORMAL
);
7539 ok(SUCCEEDED(hr
), "Failed to set cooperative level, hr %#lx.\n", hr
);
7541 hr
= Direct3DRMCreate(&d3drm1
);
7542 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM interface, hr %#lx.\n", hr
);
7544 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM2
, (void **)&d3drm2
);
7545 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM2 interface, hr %#lx.\n", hr
);
7547 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
7548 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRM3 interface, hr %#lx.\n", hr
);
7550 /* Create a surface and use it to create a texture. */
7551 memset(&desc
, 0, sizeof(desc
));
7552 desc
.dwSize
= sizeof(desc
);
7553 desc
.dwFlags
= DDSD_CAPS
| DDSD_WIDTH
| DDSD_HEIGHT
;
7554 desc
.ddsCaps
.dwCaps
= DDSCAPS_OFFSCREENPLAIN
;
7555 desc
.dwWidth
= rc
.right
;
7556 desc
.dwHeight
= rc
.bottom
;
7558 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface
, NULL
);
7559 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
7561 hr
= IDirectDraw_CreateSurface(ddraw
, &desc
, &surface2
, NULL
);
7562 ok(SUCCEEDED(hr
), "Failed to create surface, hr %#lx.\n", hr
);
7564 /* Test NULL params */
7565 texture1
= (IDirect3DRMTexture
*)0xdeadbeef;
7566 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, NULL
, &texture1
);
7567 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
7568 ok(!texture1
, "Expected texture returned == NULL, got %p.\n", texture1
);
7570 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, NULL
, NULL
);
7571 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
7573 texture2
= (IDirect3DRMTexture2
*)0xdeadbeef;
7574 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, NULL
, &texture2
);
7575 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
7576 ok(!texture2
, "Expected texture returned == NULL, got %p.\n", texture2
);
7578 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, NULL
, NULL
);
7579 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
7581 texture3
= (IDirect3DRMTexture3
*)0xdeadbeef;
7582 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, NULL
, &texture3
);
7583 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
7584 ok(!texture3
, "Expected texture returned == NULL, got %p.\n", texture3
);
7586 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, NULL
, NULL
);
7587 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got %#lx.\n", hr
);
7589 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
7590 hr
= IDirect3DRM_CreateTextureFromSurface(d3drm1
, surface
, &texture1
);
7591 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#lx.\n", hr
);
7593 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
7594 image
= IDirect3DRMTexture_GetImage(texture1
);
7595 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
7596 hr
= IDirect3DRMTexture_InitFromSurface(texture1
, NULL
);
7597 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#lx.\n", hr
);
7598 IDirect3DRMTexture_Release(texture1
);
7600 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
7601 hr
= IDirect3DRM2_CreateTextureFromSurface(d3drm2
, surface
, &texture2
);
7602 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#lx.\n", hr
);
7603 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
7604 image
= IDirect3DRMTexture2_GetImage(texture2
);
7605 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
7606 hr
= IDirect3DRMTexture2_InitFromSurface(texture2
, NULL
);
7607 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got %#lx.\n", hr
);
7608 IDirect3DRMTexture_Release(texture2
);
7610 ok(get_refcount((IUnknown
*)surface
) == 1, "Unexpected surface refcount.\n");
7611 hr
= IDirect3DRM3_CreateTextureFromSurface(d3drm3
, surface
, &texture3
);
7612 ok(SUCCEEDED(hr
), "Failed to create texture, hr %#lx.\n", hr
);
7613 ok(get_refcount((IUnknown
*)surface
) == 2, "Unexpected surface refcount.\n");
7614 image
= IDirect3DRMTexture3_GetImage(texture3
);
7615 ok(image
== NULL
, "Unexpected image, %p.\n", image
);
7616 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, NULL
);
7617 ok(hr
== D3DRMERR_BADOBJECT
, "Expected hr == D3DRMERR_BADOBJECT, got hr %#lx.\n", hr
);
7618 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, NULL
);
7619 ok(hr
== D3DRMERR_BADVALUE
, "Expected hr == D3DRMERR_BADVALUE, got hr %#lx.\n", hr
);
7620 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &ds
);
7621 ok(SUCCEEDED(hr
), "Failed to get surface, hr %#lx.\n", hr
);
7622 ok(ds
== surface
, "Expected same surface back.\n");
7623 IDirectDrawSurface_Release(ds
);
7625 /* Init already initialized texture with same surface. */
7626 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface
);
7627 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#lx.\n", hr
);
7629 /* Init already initialized texture with different surface. */
7630 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface2
);
7631 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#lx.\n", hr
);
7633 hr
= IDirect3DRMTexture3_GetSurface(texture3
, 0, &ds
);
7634 ok(SUCCEEDED(hr
), "Failed to get surface, hr %#lx.\n", hr
);
7635 ok(ds
== surface
, "Expected same surface back.\n");
7636 IDirectDrawSurface_Release(ds
);
7638 ref1
= get_refcount((IUnknown
*)d3drm1
);
7639 ref2
= get_refcount((IUnknown
*)d3drm2
);
7640 ref3
= get_refcount((IUnknown
*)d3drm3
);
7641 hr
= IDirect3DRMTexture3_InitFromImage(texture3
, &testimg
);
7642 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#lx.\n", hr
);
7643 ok(ref1
< get_refcount((IUnknown
*)d3drm1
), "Expected d3drm1 reference taken.\n");
7644 ok(ref2
== get_refcount((IUnknown
*)d3drm2
), "Expected d3drm2 reference unchanged.\n");
7645 ok(ref3
== get_refcount((IUnknown
*)d3drm3
), "Expected d3drm3 reference unchanged.\n");
7646 /* Release leaked reference to d3drm1 */
7647 IDirect3DRM_Release(d3drm1
);
7649 IDirect3DRMTexture_Release(texture3
);
7651 /* Create from image, initialize from surface. */
7652 hr
= IDirect3DRM3_CreateTexture(d3drm3
, &testimg
, &texture3
);
7653 ok(SUCCEEDED(hr
), "Cannot get IDirect3DRMTexture3 interface, hr %#lx.\n", hr
);
7655 ref1
= get_refcount((IUnknown
*)d3drm1
);
7656 ref2
= get_refcount((IUnknown
*)d3drm2
);
7657 ref3
= get_refcount((IUnknown
*)d3drm3
);
7658 hr
= IDirect3DRMTexture3_InitFromSurface(texture3
, surface
);
7659 ok(hr
== D3DRMERR_BADOBJECT
, "Expected a failure, hr %#lx.\n", hr
);
7660 ok(ref1
< get_refcount((IUnknown
*)d3drm1
), "Expected d3drm1 reference taken.\n");
7661 ok(ref2
== get_refcount((IUnknown
*)d3drm2
), "Expected d3drm2 reference unchanged.\n");
7662 ok(ref3
== get_refcount((IUnknown
*)d3drm3
), "Expected d3drm3 reference unchanged.\n");
7663 /* Release leaked reference to d3drm1 */
7664 IDirect3DRM_Release(d3drm1
);
7665 IDirect3DRMTexture3_Release(texture3
);
7667 IDirectDrawSurface_Release(surface2
);
7668 IDirectDrawSurface_Release(surface
);
7669 IDirect3DRM3_Release(d3drm3
);
7670 IDirect3DRM2_Release(d3drm2
);
7671 IDirect3DRM_Release(d3drm1
);
7672 IDirectDraw_Release(ddraw
);
7675 static void test_animation(void)
7677 IDirect3DRMAnimation2
*animation2
;
7678 IDirect3DRMAnimation
*animation
;
7679 D3DRMANIMATIONOPTIONS options
;
7680 IDirect3DRMObject
*obj
, *obj2
;
7681 D3DRMANIMATIONKEY keys
[10];
7682 IDirect3DRMFrame3
*frame3
;
7683 IDirect3DRMFrame
*frame
;
7684 D3DRMANIMATIONKEY key
;
7685 IDirect3DRM
*d3drm1
;
7691 hr
= Direct3DRMCreate(&d3drm1
);
7692 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRM instance, hr %#lx.\n", hr
);
7694 hr
= IDirect3DRM_CreateAnimation(d3drm1
, NULL
);
7695 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7697 CHECK_REFCOUNT(d3drm1
, 1);
7698 hr
= IDirect3DRM_CreateAnimation(d3drm1
, &animation
);
7699 ok(SUCCEEDED(hr
), "Failed to create animation hr %#lx.\n", hr
);
7700 CHECK_REFCOUNT(d3drm1
, 2);
7702 test_class_name((IDirect3DRMObject
*)animation
, "Animation");
7704 hr
= IDirect3DRMAnimation_QueryInterface(animation
, &IID_IDirect3DRMAnimation2
, (void **)&animation2
);
7705 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMAnimation2, hr %#lx.\n", hr
);
7706 ok(animation
!= (void *)animation2
, "Expected different interface pointer.\n");
7708 hr
= IDirect3DRMAnimation_QueryInterface(animation
, &IID_IDirect3DRMObject
, (void **)&obj
);
7709 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr %#lx.\n", hr
);
7711 hr
= IDirect3DRMAnimation2_QueryInterface(animation2
, &IID_IDirect3DRMObject
, (void **)&obj2
);
7712 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMObject, hr %#lx.\n", hr
);
7714 ok(obj
== obj2
&& obj
== (IDirect3DRMObject
*)animation
, "Unexpected object pointer.\n");
7716 IDirect3DRMObject_Release(obj
);
7717 IDirect3DRMObject_Release(obj2
);
7719 /* Set animated frame, get it back. */
7720 hr
= IDirect3DRM_CreateFrame(d3drm1
, NULL
, &frame
);
7721 ok(SUCCEEDED(hr
), "Failed to create a frame, hr %#lx.\n", hr
);
7723 hr
= IDirect3DRMAnimation_SetFrame(animation
, NULL
);
7724 ok(SUCCEEDED(hr
), "Failed to reset frame, hr %#lx.\n", hr
);
7726 CHECK_REFCOUNT(frame
, 1);
7727 hr
= IDirect3DRMAnimation_SetFrame(animation
, frame
);
7728 ok(SUCCEEDED(hr
), "Failed to set a frame, hr %#lx.\n", hr
);
7729 CHECK_REFCOUNT(frame
, 1);
7731 hr
= IDirect3DRMAnimation2_GetFrame(animation2
, NULL
);
7732 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7734 hr
= IDirect3DRMAnimation2_GetFrame(animation2
, &frame3
);
7735 ok(SUCCEEDED(hr
), "Failed to get the frame, hr %#lx.\n", hr
);
7736 ok(frame3
!= (void *)frame
, "Unexpected interface pointer.\n");
7737 CHECK_REFCOUNT(frame
, 2);
7739 IDirect3DRMFrame3_Release(frame3
);
7741 hr
= IDirect3DRMAnimation_SetFrame(animation
, NULL
);
7742 ok(SUCCEEDED(hr
), "Failed to reset frame, hr %#lx.\n", hr
);
7744 hr
= IDirect3DRMFrame_QueryInterface(frame
, &IID_IDirect3DRMFrame3
, (void **)&frame3
);
7745 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRMFrame3, hr %#lx.\n", hr
);
7747 CHECK_REFCOUNT(frame3
, 2);
7748 hr
= IDirect3DRMAnimation2_SetFrame(animation2
, frame3
);
7749 ok(SUCCEEDED(hr
), "Failed to set a frame, hr %#lx.\n", hr
);
7750 CHECK_REFCOUNT(frame3
, 2);
7752 IDirect3DRMFrame3_Release(frame3
);
7753 IDirect3DRMFrame_Release(frame
);
7755 /* Animation options. */
7756 options
= IDirect3DRMAnimation_GetOptions(animation
);
7757 ok(options
== (D3DRMANIMATION_CLOSED
| D3DRMANIMATION_LINEARPOSITION
),
7758 "Unexpected default options %#lx.\n", options
);
7760 /* Undefined mask value */
7761 hr
= IDirect3DRMAnimation_SetOptions(animation
, 0xf0000000);
7762 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7764 options
= IDirect3DRMAnimation_GetOptions(animation
);
7765 ok(options
== (D3DRMANIMATION_CLOSED
| D3DRMANIMATION_LINEARPOSITION
),
7766 "Unexpected default options %#lx.\n", options
);
7768 /* Ambiguous mask */
7769 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_OPEN
| D3DRMANIMATION_CLOSED
);
7770 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7772 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_LINEARPOSITION
| D3DRMANIMATION_SPLINEPOSITION
);
7773 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7775 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_SCALEANDROTATION
| D3DRMANIMATION_POSITION
);
7776 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7778 options
= IDirect3DRMAnimation_GetOptions(animation
);
7779 ok(options
== (D3DRMANIMATION_CLOSED
| D3DRMANIMATION_LINEARPOSITION
),
7780 "Unexpected default options %#lx.\n", options
);
7782 /* Mask contains undefined bits together with valid one. */
7783 hr
= IDirect3DRMAnimation_SetOptions(animation
, 0xf0000000 | D3DRMANIMATION_OPEN
);
7784 ok(SUCCEEDED(hr
), "Failed to set animation options, hr %#lx.\n", hr
);
7786 options
= IDirect3DRMAnimation_GetOptions(animation
);
7787 ok(options
== (0xf0000000 | D3DRMANIMATION_OPEN
), "Unexpected animation options %#lx.\n", options
);
7789 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_SCALEANDROTATION
);
7790 ok(SUCCEEDED(hr
), "Failed to set animation options, hr %#lx.\n", hr
);
7792 options
= IDirect3DRMAnimation_GetOptions(animation
);
7793 ok(options
== D3DRMANIMATION_SCALEANDROTATION
, "Unexpected options %#lx.\n", options
);
7795 hr
= IDirect3DRMAnimation_SetOptions(animation
, D3DRMANIMATION_OPEN
);
7796 ok(SUCCEEDED(hr
), "Failed to set animation options, hr %#lx.\n", hr
);
7798 options
= IDirect3DRMAnimation_GetOptions(animation
);
7799 ok(options
== D3DRMANIMATION_OPEN
, "Unexpected options %#lx.\n", options
);
7801 hr
= IDirect3DRMAnimation_SetOptions(animation
, 0);
7802 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7804 options
= IDirect3DRMAnimation_GetOptions(animation
);
7805 ok(options
== D3DRMANIMATION_OPEN
, "Unexpected options %#lx.\n", options
);
7807 /* Key management. */
7808 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 0.0f
, 1.0f
, 0.0f
, 0.0f
);
7809 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#lx.\n", hr
);
7811 hr
= IDirect3DRMAnimation_AddScaleKey(animation
, 0.0f
, 1.0f
, 2.0f
, 1.0f
);
7812 ok(SUCCEEDED(hr
), "Failed to add scale key, hr %#lx.\n", hr
);
7814 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 0.0f
, 2.0f
, 0.0f
, 0.0f
);
7815 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#lx.\n", hr
);
7817 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 99.0f
, 3.0f
, 1.0f
, 0.0f
);
7818 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#lx.\n", hr
);
7820 hr
= IDirect3DRMAnimation_AddPositionKey(animation
, 80.0f
, 4.0f
, 1.0f
, 0.0f
);
7821 ok(SUCCEEDED(hr
), "Failed to add position key, hr %#lx.\n", hr
);
7826 D3DRMQuaternionFromRotation(&q
, &v
, 1.0f
);
7828 /* NULL quaternion pointer leads to a crash on Windows. */
7829 hr
= IDirect3DRMAnimation_AddRotateKey(animation
, 0.0f
, &q
);
7830 ok(SUCCEEDED(hr
), "Failed to add rotation key, hr %#lx.\n", hr
);
7833 memset(keys
, 0, sizeof(keys
));
7834 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 99.0f
, &count
, keys
);
7835 ok(SUCCEEDED(hr
), "Failed to get animation keys, hr %#lx.\n", hr
);
7836 ok(count
== 6, "Unexpected key count %lu.\n", count
);
7838 ok(keys
[0].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %lu.\n", keys
[0].dwKeyType
);
7839 ok(keys
[1].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[1].dwKeyType
);
7840 ok(keys
[2].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[2].dwKeyType
);
7841 ok(keys
[3].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[3].dwKeyType
);
7842 ok(keys
[4].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[4].dwKeyType
);
7843 ok(keys
[5].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %lu.\n", keys
[5].dwKeyType
);
7845 /* Relative order, keys are returned sorted by time. */
7846 ok(keys
[1].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[1].dvTime
);
7847 ok(keys
[2].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[2].dvTime
);
7848 ok(keys
[3].dvTime
== 80.0f
, "Unexpected key time %.8e.\n", keys
[3].dvTime
);
7849 ok(keys
[4].dvTime
== 99.0f
, "Unexpected key time %.8e.\n", keys
[4].dvTime
);
7851 /* For keys with same time, order they were added in is kept. */
7852 ok(keys
[1].dvPositionKey
.x
== 1.0f
, "Unexpected key position x %.8e.\n", keys
[1].dvPositionKey
.x
);
7853 ok(keys
[2].dvPositionKey
.x
== 2.0f
, "Unexpected key position x %.8e.\n", keys
[2].dvPositionKey
.x
);
7854 ok(keys
[3].dvPositionKey
.x
== 4.0f
, "Unexpected key position x %.8e.\n", keys
[3].dvPositionKey
.x
);
7855 ok(keys
[4].dvPositionKey
.x
== 3.0f
, "Unexpected key position x %.8e.\n", keys
[4].dvPositionKey
.x
);
7857 for (i
= 0; i
< count
; i
++)
7859 winetest_push_context("%lu", i
);
7861 ok(keys
[i
].dwSize
== sizeof(*keys
), "Unexpected dwSize value %lu.\n", keys
[i
].dwSize
);
7865 switch (keys
[i
].dwKeyType
)
7867 case D3DRMANIMATION_ROTATEKEY
:
7868 ok((keys
[i
].dwID
& 0xf0000000) == 0x40000000, "Unexpected id mask %#lx.\n", keys
[i
].dwID
);
7870 case D3DRMANIMATION_POSITIONKEY
:
7871 ok((keys
[i
].dwID
& 0xf0000000) == 0x80000000, "Unexpected id mask %#lx.\n", keys
[i
].dwID
);
7873 case D3DRMANIMATION_SCALEKEY
:
7874 ok((keys
[i
].dwID
& 0xf0000000) == 0xc0000000, "Unexpected id mask %#lx.\n", keys
[i
].dwID
);
7877 ok(0, "Unknown key type %ld.\n", keys
[i
].dwKeyType
);
7881 winetest_pop_context();
7884 /* No keys in this range. */
7886 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 100.0f
, 200.0f
, &count
, NULL
);
7887 ok(hr
== D3DRMERR_NOSUCHKEY
, "Unexpected hr %#lx.\n", hr
);
7888 ok(count
== 0, "Unexpected key count %lu.\n", count
);
7891 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 100.0f
, 200.0f
, &count
, keys
);
7892 ok(hr
== D3DRMERR_NOSUCHKEY
, "Unexpected hr %#lx.\n", hr
);
7893 ok(count
== 0, "Unexpected key count %lu.\n", count
);
7896 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 0.0f
, &count
, NULL
);
7897 ok(SUCCEEDED(hr
), "Failed to get animation keys, hr %#lx.\n", hr
);
7898 ok(count
== 4, "Unexpected key count %lu.\n", count
);
7900 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 100.0f
, NULL
, NULL
);
7901 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7903 /* Time is 0-based. */
7904 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -100.0f
, -50.0f
, NULL
, NULL
);
7905 ok(hr
== D3DRMERR_BADVALUE
, "Unexpected hr %#lx.\n", hr
);
7908 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -100.0f
, -50.0f
, &count
, NULL
);
7909 ok(hr
== D3DRMERR_NOSUCHKEY
, "Unexpected hr %#lx.\n", hr
);
7910 ok(count
== 0, "Unexpected key count %lu.\n", count
);
7913 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -100.0f
, 100.0f
, &count
, NULL
);
7914 ok(SUCCEEDED(hr
), "Failed to get animation keys, hr %#lx.\n", hr
);
7915 ok(count
== 6, "Unexpected key count %lu.\n", count
);
7917 /* AddKey() tests. */
7918 hr
= IDirect3DRMAnimation2_AddKey(animation2
, NULL
);
7919 ok(hr
== E_INVALIDARG
, "Unexpected hr %#lx.\n", hr
);
7921 memset(&key
, 0, sizeof(key
));
7922 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7923 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7924 ok(hr
== E_INVALIDARG
, "Unexpected hr %#lx.\n", hr
);
7926 memset(&key
, 0, sizeof(key
));
7927 key
.dwSize
= sizeof(key
) - 1;
7928 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7929 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7930 ok(hr
== E_INVALIDARG
, "Unexpected hr %#lx.\n", hr
);
7932 memset(&key
, 0, sizeof(key
));
7933 key
.dwSize
= sizeof(key
) + 1;
7934 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7935 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7936 ok(hr
== E_INVALIDARG
, "Unexpected hr %#lx.\n", hr
);
7938 memset(&key
, 0, sizeof(key
));
7939 key
.dwSize
= sizeof(key
);
7940 key
.dwKeyType
= D3DRMANIMATION_POSITIONKEY
;
7941 key
.dvPositionKey
.x
= 8.0f
;
7942 hr
= IDirect3DRMAnimation2_AddKey(animation2
, &key
);
7943 ok(SUCCEEDED(hr
), "Failed to add key, hr %#lx.\n", hr
);
7946 hr
= IDirect3DRMAnimation_AddRotateKey(animation
, 0.0f
, &q
);
7947 ok(SUCCEEDED(hr
), "Failed to add rotation key, hr %#lx.\n", hr
);
7949 hr
= IDirect3DRMAnimation_AddScaleKey(animation
, 0.0f
, 1.0f
, 2.0f
, 1.0f
);
7950 ok(SUCCEEDED(hr
), "Failed to add scale key, hr %#lx.\n", hr
);
7953 memset(keys
, 0, sizeof(keys
));
7954 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, -1000.0f
, 1000.0f
, &count
, keys
);
7955 ok(SUCCEEDED(hr
), "Failed to get key count, hr %#lx.\n", hr
);
7956 ok(count
== 9, "Unexpected key count %lu.\n", count
);
7958 ok(keys
[0].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %lu.\n", keys
[0].dwKeyType
);
7959 ok(keys
[1].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %lu.\n", keys
[1].dwKeyType
);
7960 ok(keys
[2].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[2].dwKeyType
);
7961 ok(keys
[3].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[3].dwKeyType
);
7962 ok(keys
[4].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[4].dwKeyType
);
7963 ok(keys
[5].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[5].dwKeyType
);
7964 ok(keys
[6].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[6].dwKeyType
);
7965 ok(keys
[7].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %lu.\n", keys
[7].dwKeyType
);
7966 ok(keys
[8].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %lu.\n", keys
[8].dwKeyType
);
7968 ok(keys
[0].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[0].dvTime
);
7969 ok(keys
[1].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[1].dvTime
);
7970 ok(keys
[2].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[2].dvTime
);
7971 ok(keys
[3].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[3].dvTime
);
7972 ok(keys
[4].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[4].dvTime
);
7973 ok(keys
[5].dvTime
== 80.0f
, "Unexpected key time %.8e.\n", keys
[5].dvTime
);
7974 ok(keys
[6].dvTime
== 99.0f
, "Unexpected key time %.8e.\n", keys
[6].dvTime
);
7975 ok(keys
[7].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[7].dvTime
);
7976 ok(keys
[8].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[8].dvTime
);
7978 hr
= IDirect3DRMAnimation_DeleteKey(animation
, -100.0f
);
7979 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#lx.\n", hr
);
7981 hr
= IDirect3DRMAnimation_DeleteKey(animation
, 100.0f
);
7982 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#lx.\n", hr
);
7984 /* Only first Position keys are not removed. */
7985 hr
= IDirect3DRMAnimation_DeleteKey(animation
, 0.0f
);
7986 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#lx.\n", hr
);
7989 memset(keys
, 0, sizeof(keys
));
7990 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 100.0f
, &count
, keys
);
7991 ok(SUCCEEDED(hr
), "Failed to get key count, hr %#lx.\n", hr
);
7992 ok(count
== 6, "Unexpected key count %lu.\n", count
);
7994 ok(keys
[0].dwKeyType
== D3DRMANIMATION_ROTATEKEY
, "Unexpected key type %lu.\n", keys
[0].dwKeyType
);
7995 ok(keys
[1].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[1].dwKeyType
);
7996 ok(keys
[2].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[2].dwKeyType
);
7997 ok(keys
[3].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[3].dwKeyType
);
7998 ok(keys
[4].dwKeyType
== D3DRMANIMATION_POSITIONKEY
, "Unexpected key type %lu.\n", keys
[4].dwKeyType
);
7999 ok(keys
[5].dwKeyType
== D3DRMANIMATION_SCALEKEY
, "Unexpected key type %lu.\n", keys
[5].dwKeyType
);
8001 ok(keys
[0].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[0].dvTime
);
8002 ok(keys
[1].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[1].dvTime
);
8003 ok(keys
[2].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[2].dvTime
);
8004 ok(keys
[3].dvTime
== 80.0f
, "Unexpected key time %.8e.\n", keys
[3].dvTime
);
8005 ok(keys
[4].dvTime
== 99.0f
, "Unexpected key time %.8e.\n", keys
[4].dvTime
);
8006 ok(keys
[5].dvTime
== 0.0f
, "Unexpected key time %.8e.\n", keys
[5].dvTime
);
8008 hr
= IDirect3DRMAnimation_DeleteKey(animation
, 0.0f
);
8009 ok(SUCCEEDED(hr
), "Failed to delete keys, hr %#lx.\n", hr
);
8012 hr
= IDirect3DRMAnimation2_GetKeys(animation2
, 0.0f
, 100.0f
, &count
, NULL
);
8013 ok(SUCCEEDED(hr
), "Failed to get key count, hr %#lx.\n", hr
);
8014 ok(count
== 3, "Unexpected key count %lu.\n", count
);
8016 IDirect3DRMAnimation2_Release(animation2
);
8017 IDirect3DRMAnimation_Release(animation
);
8019 IDirect3DRM_Release(d3drm1
);
8022 static void test_animation_qi(void)
8024 static const struct qi_test tests
[] =
8026 { &IID_IDirect3DRMAnimation2
, &IID_IUnknown
, &IID_IDirect3DRMAnimation2
, S_OK
},
8027 { &IID_IDirect3DRMAnimation
, &IID_IUnknown
, &IID_IDirect3DRMAnimation
, S_OK
},
8028 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8029 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8030 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMAnimation
, S_OK
},
8031 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8032 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8033 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8034 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8035 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8036 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8037 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8038 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8039 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8040 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8041 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8042 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8043 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8044 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8045 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8046 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8047 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8048 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8049 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8050 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8051 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8052 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8053 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8054 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8055 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8056 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8057 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8058 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8059 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8060 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8061 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8062 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8063 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8064 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8065 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8066 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8067 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8068 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8069 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8070 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8071 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8072 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8073 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8074 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8075 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8076 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8077 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8078 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8079 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8080 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8081 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8082 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8083 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8084 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8085 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8086 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8087 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8088 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
8090 IDirect3DRMAnimation2
*animation2
;
8091 IDirect3DRMAnimation
*animation
;
8092 IDirect3DRM3
*d3drm3
;
8093 IDirect3DRM
*d3drm1
;
8097 hr
= Direct3DRMCreate(&d3drm1
);
8098 ok(SUCCEEDED(hr
), "Failed to create d3drm instance, hr %#lx.\n", hr
);
8100 hr
= IDirect3DRM_CreateAnimation(d3drm1
, &animation
);
8101 ok(SUCCEEDED(hr
), "Failed to create animation hr %#lx.\n", hr
);
8103 hr
= IDirect3DRMAnimation_QueryInterface(animation
, &IID_IUnknown
, (void **)&unknown
);
8104 ok(SUCCEEDED(hr
), "Failed to get IUnknown from animation, hr %#lx.\n", hr
);
8105 IDirect3DRMAnimation_Release(animation
);
8107 test_qi("animation_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
8108 IUnknown_Release(unknown
);
8110 hr
= IDirect3DRM_QueryInterface(d3drm1
, &IID_IDirect3DRM3
, (void **)&d3drm3
);
8111 ok(SUCCEEDED(hr
), "Failed to get IDirect3DRM3, hr %#lx.\n", hr
);
8113 hr
= IDirect3DRM3_CreateAnimation(d3drm3
, &animation2
);
8114 ok(SUCCEEDED(hr
), "Failed to create animation hr %#lx.\n", hr
);
8116 hr
= IDirect3DRMAnimation2_QueryInterface(animation2
, &IID_IUnknown
, (void **)&unknown
);
8117 ok(SUCCEEDED(hr
), "Failed to get IUnknown from animation, hr %#lx.\n", hr
);
8118 IDirect3DRMAnimation2_Release(animation2
);
8120 test_qi("animation2_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
8121 IUnknown_Release(unknown
);
8123 IDirect3DRM3_Release(d3drm3
);
8124 IDirect3DRM_Release(d3drm1
);
8127 static void test_wrap(void)
8129 IDirect3DRMWrap
*wrap
;
8130 IDirect3DRM
*d3drm1
;
8133 hr
= Direct3DRMCreate(&d3drm1
);
8134 ok(SUCCEEDED(hr
), "Failed to create IDirect3DRM instance, hr %#lx.\n", hr
);
8136 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMWrap
, NULL
, &IID_IDirect3DRMWrap
, (void **)&wrap
);
8137 ok(SUCCEEDED(hr
), "Failed to create wrap instance, hr %#lx.\n", hr
);
8139 test_class_name((IDirect3DRMObject
*)wrap
, "");
8141 IDirect3DRMWrap_Release(wrap
);
8142 IDirect3DRM_Release(d3drm1
);
8145 static void test_wrap_qi(void)
8147 static const struct qi_test tests
[] =
8149 { &IID_IDirect3DRMWrap
, &IID_IUnknown
, &IID_IDirect3DRMWrap
, S_OK
},
8150 { &IID_IDirect3DRM
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8151 { &IID_IDirect3DRMDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8152 { &IID_IDirect3DRMObject
, &IID_IUnknown
, &IID_IDirect3DRMWrap
, S_OK
},
8153 { &IID_IDirect3DRMDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8154 { &IID_IDirect3DRMDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8155 { &IID_IDirect3DRMViewport
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8156 { &IID_IDirect3DRMViewport2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8157 { &IID_IDirect3DRM3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8158 { &IID_IDirect3DRM2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8159 { &IID_IDirect3DRMVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8160 { &IID_IDirect3DRMMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8161 { &IID_IDirect3DRMMeshBuilder
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8162 { &IID_IDirect3DRMMeshBuilder2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8163 { &IID_IDirect3DRMMeshBuilder3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8164 { &IID_IDirect3DRMFace
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8165 { &IID_IDirect3DRMFace2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8166 { &IID_IDirect3DRMLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8167 { &IID_IDirect3DRMTexture
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8168 { &IID_IDirect3DRMTexture2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8169 { &IID_IDirect3DRMTexture3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8170 { &IID_IDirect3DRMMaterial
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8171 { &IID_IDirect3DRMMaterial2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8172 { &IID_IDirect3DRMAnimation
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8173 { &IID_IDirect3DRMAnimation2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8174 { &IID_IDirect3DRMAnimationSet
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8175 { &IID_IDirect3DRMAnimationSet2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8176 { &IID_IDirect3DRMObjectArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8177 { &IID_IDirect3DRMDeviceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8178 { &IID_IDirect3DRMViewportArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8179 { &IID_IDirect3DRMFrameArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8180 { &IID_IDirect3DRMVisualArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8181 { &IID_IDirect3DRMLightArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8182 { &IID_IDirect3DRMPickedArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8183 { &IID_IDirect3DRMFaceArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8184 { &IID_IDirect3DRMAnimationArray
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8185 { &IID_IDirect3DRMUserVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8186 { &IID_IDirect3DRMShadow
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8187 { &IID_IDirect3DRMShadow2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8188 { &IID_IDirect3DRMInterpolator
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8189 { &IID_IDirect3DRMProgressiveMesh
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8190 { &IID_IDirect3DRMPicked2Array
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8191 { &IID_IDirect3DRMClippedVisual
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8192 { &IID_IDirectDrawClipper
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8193 { &IID_IDirectDrawSurface7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8194 { &IID_IDirectDrawSurface4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8195 { &IID_IDirectDrawSurface3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8196 { &IID_IDirectDrawSurface2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8197 { &IID_IDirectDrawSurface
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8198 { &IID_IDirect3DDevice7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8199 { &IID_IDirect3DDevice3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8200 { &IID_IDirect3DDevice2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8201 { &IID_IDirect3DDevice
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8202 { &IID_IDirect3D7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8203 { &IID_IDirect3D3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8204 { &IID_IDirect3D2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8205 { &IID_IDirect3D
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8206 { &IID_IDirectDraw7
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8207 { &IID_IDirectDraw4
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8208 { &IID_IDirectDraw3
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8209 { &IID_IDirectDraw2
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8210 { &IID_IDirectDraw
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8211 { &IID_IDirect3DLight
, NULL
, NULL
, CLASS_E_CLASSNOTAVAILABLE
},
8212 { &IID_IUnknown
, &IID_IUnknown
, NULL
, S_OK
},
8214 IDirect3DRMWrap
*wrap
;
8215 IDirect3DRM
*d3drm1
;
8219 hr
= Direct3DRMCreate(&d3drm1
);
8220 ok(SUCCEEDED(hr
), "Failed to create d3drm instance, hr %#lx.\n", hr
);
8222 hr
= IDirect3DRM_CreateObject(d3drm1
, &CLSID_CDirect3DRMWrap
, NULL
, &IID_IDirect3DRMWrap
, (void **)&wrap
);
8223 ok(SUCCEEDED(hr
), "Failed to create wrap instance, hr %#lx.\n", hr
);
8225 hr
= IDirect3DRMWrap_QueryInterface(wrap
, &IID_IUnknown
, (void **)&unknown
);
8226 ok(SUCCEEDED(hr
), "Failed to get IUnknown from wrap, hr %#lx.\n", hr
);
8227 IDirect3DRMWrap_Release(wrap
);
8228 test_qi("wrap_qi", unknown
, &IID_IUnknown
, tests
, ARRAY_SIZE(tests
));
8229 IUnknown_Release(unknown
);
8231 IDirect3DRM_Release(d3drm1
);
8236 test_MeshBuilder3();
8246 test_frame_transform();
8248 test_frame_mesh_materials();
8252 test_create_device_from_clipper1();
8253 test_create_device_from_clipper2();
8254 test_create_device_from_clipper3();
8255 test_create_device_from_surface1();
8256 test_create_device_from_surface2();
8257 test_create_device_from_surface3();
8258 test_create_device_from_d3d1();
8259 test_create_device_from_d3d2();
8260 test_create_device_from_d3d3();
8261 test_create_device_1();
8262 test_create_device_2();
8263 test_create_device_3();
8264 test_load_texture();
8267 test_viewport_clear1();
8268 test_viewport_clear2();
8269 test_create_texture_from_surface();
8271 test_animation_qi();