ReactOS 0.4.15-dev-8109-gd7be748
d3drm.c
Go to the documentation of this file.
1/*
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
6 *
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.
11 *
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.
16 *
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
20 */
21
22#include <limits.h>
23
24#define COBJMACROS
25#define _USE_MATH_DEFINES
26#include <d3d.h>
27#include <initguid.h>
28#include <d3drm.h>
29#include <d3drmwin.h>
30#include <math.h>
31
32#include "wine/test.h"
33
34#define CHECK_REFCOUNT(obj,rc) \
35 { \
36 int rc_new = rc; \
37 int count = get_refcount( (IUnknown *)obj ); \
38 ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
39 }
40
42{
43 IUnknown_AddRef( object );
44 return IUnknown_Release( object );
45}
46
47static BOOL compare_float(float f, float g, unsigned int ulps)
48{
49 int x = *(int *)&f;
50 int y = *(int *)&g;
51
52 if (x < 0)
53 x = INT_MIN - x;
54 if (y < 0)
55 y = INT_MIN - y;
56
57 if (abs(x - y) > ulps)
58 return FALSE;
59
60 return TRUE;
61}
62
63#define expect_matrix(m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u) \
64 expect_matrix_(__LINE__, m, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44, u)
65static void expect_matrix_(unsigned int line, D3DRMMATRIX4D m,
66 float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
67 float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44,
68 unsigned int ulps)
69{
70 BOOL equal = compare_float(m[0][0], m11, ulps) && compare_float(m[0][1], m12, ulps)
71 && compare_float(m[0][2], m13, ulps) && compare_float(m[0][3], m14, ulps)
72 && compare_float(m[1][0], m21, ulps) && compare_float(m[1][1], m22, ulps)
73 && compare_float(m[1][2], m23, ulps) && compare_float(m[1][3], m24, ulps)
74 && compare_float(m[2][0], m31, ulps) && compare_float(m[2][1], m32, ulps)
75 && compare_float(m[2][2], m33, ulps) && compare_float(m[2][3], m34, ulps)
76 && compare_float(m[3][0], m41, ulps) && compare_float(m[3][1], m42, ulps)
77 && compare_float(m[3][2], m43, ulps) && compare_float(m[3][3], m44, ulps);
78
79 ok_(__FILE__, line)(equal,
80 "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
81 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}, "
82 "expected {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, "
83 "%.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
84 m[0][0], m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3],
85 m[2][0], m[2][1], m[2][2], m[2][3], m[3][0], m[3][1], m[3][2], m[3][3],
86 m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
87}
88
89#define expect_vector(v, x, y, z, u) expect_vector_(__LINE__, v, x, y, z, u)
90static void expect_vector_(unsigned int line, const D3DVECTOR *v, float x, float y, float z, unsigned int ulps)
91{
92 BOOL equal = compare_float(U1(*v).x, x, ulps)
93 && compare_float(U2(*v).y, y, ulps)
94 && compare_float(U3(*v).z, z, ulps);
95
96 ok_(__FILE__, line)(equal, "Got unexpected vector {%.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e}.\n",
97 U1(*v).x, U2(*v).y, U3(*v).z, x, y, z);
98}
99
100#define vector_eq(a, b) vector_eq_(__LINE__, a, b)
101static void vector_eq_(unsigned int line, const D3DVECTOR *left, const D3DVECTOR *right)
102{
103 expect_vector_(line, left, U1(*right).x, U2(*right).y, U3(*right).z, 0);
104}
105
107 { 1.0f, 0.0f, 0.0f, 0.0f },
108 { 0.0f, 1.0f, 0.0f, 0.0f },
109 { 0.0f, 0.0f, 1.0f, 0.0f },
110 { 0.0f, 0.0f, 0.0f, 1.0f }
111};
112
113static void frame_set_transform(IDirect3DRMFrame *frame,
114 float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24,
115 float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
116{
118 {
119 {m11, m12, m13, m14},
120 {m21, m22, m23, m24},
121 {m31, m32, m33, m34},
122 {m41, m42, m43, m44},
123 };
124
126}
127
128static void set_vector(D3DVECTOR *v, float x, float y, float z)
129{
130 U1(*v).x = x;
131 U2(*v).y = y;
132 U3(*v).z = z;
133}
134
136{
137 unsigned int i, j;
138
139 for (i = 0; i < 4; ++i)
140 {
141 for (j = 0; j < 4; ++j)
142 {
143 if (m[i][j] > -1e-7f && m[i][j] < 1e-7f)
144 m[i][j] = 0.0f;
145 }
146 }
147}
148
149static HWND create_window(void)
150{
151 RECT r = {0, 0, 640, 480};
152
154
155 return CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
156 CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
157}
158
159#define test_class_name(a, b) test_class_name_(__LINE__, a, b)
160static void test_class_name_(unsigned int line, IDirect3DRMObject *object, const char *name)
161{
162 char cname[64] = {0};
163 DWORD size, size2;
164 HRESULT hr;
165
166 hr = IDirect3DRMObject_GetClassName(object, NULL, cname);
167 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
169 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
170
171 size = 0;
173 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname size, hr %#x.\n", hr);
174 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
175
176 size = size2 = !!*name;
177 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
178 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
179 ok_(__FILE__, line)(size == size2, "Got size %u.\n", size);
180
181 size = sizeof(cname);
182 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
183 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#x.\n", hr);
184 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
185 ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
186
187 size = strlen(name) + 1;
188 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
189 ok_(__FILE__, line)(hr == D3DRM_OK, "Failed to get classname, hr %#x.\n", hr);
190 ok_(__FILE__, line)(size == strlen(name) + 1, "wrong size: %u\n", size);
191 ok_(__FILE__, line)(!strcmp(cname, name), "Expected cname to be \"%s\", but got \"%s\".\n", name, cname);
192
193 size = strlen(name);
194 strcpy(cname, "XXX");
195 hr = IDirect3DRMObject_GetClassName(object, &size, cname);
196 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
197 ok_(__FILE__, line)(size == strlen(name), "Wrong classname size: %u.\n", size);
198 ok_(__FILE__, line)(!strcmp(cname, "XXX"), "Expected unchanged buffer, but got \"%s\".\n", cname);
199}
200
201#define test_object_name(a) test_object_name_(__LINE__, a)
202static void test_object_name_(unsigned int line, IDirect3DRMObject *object)
203{
204 char name[64] = {0};
205 HRESULT hr;
206 DWORD size;
207
209 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
210
211 name[0] = 0x1f;
213 ok_(__FILE__, line)(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
214 ok_(__FILE__, line)(name[0] == 0x1f, "Unexpected buffer contents, %#x.\n", name[0]);
215
216 /* Name is not set yet. */
217 size = 100;
219 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
220 ok_(__FILE__, line)(size == 0, "Unexpected size %u.\n", size);
221
222 size = sizeof(name);
223 name[0] = 0x1f;
225 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
226 ok_(__FILE__, line)(size == 0, "Unexpected size %u.\n", size);
227 ok_(__FILE__, line)(name[0] == 0, "Unexpected name \"%s\".\n", name);
228
229 size = 0;
230 name[0] = 0x1f;
232 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
233 ok_(__FILE__, line)(size == 0, "Unexpected size %u.\n", size);
234 ok_(__FILE__, line)(name[0] == 0x1f, "Unexpected name \"%s\".\n", name);
235
237 ok_(__FILE__, line)(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
238
239 hr = IDirect3DRMObject_SetName(object, "name");
240 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to set a name, hr %#x.\n", hr);
241
242 size = 0;
244 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
245 ok_(__FILE__, line)(size == strlen("name") + 1, "Unexpected size %u.\n", size);
246
247 size = strlen("name") + 1;
249 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
250 ok_(__FILE__, line)(size == strlen("name") + 1, "Unexpected size %u.\n", size);
251 ok_(__FILE__, line)(!strcmp(name, "name"), "Unexpected name \"%s\".\n", name);
252
253 size = 2;
254 name[0] = 0x1f;
256 ok_(__FILE__, line)(hr == E_INVALIDARG, "Failed to get object name, hr %#x.\n", hr);
257 ok_(__FILE__, line)(size == 2, "Unexpected size %u.\n", size);
258 ok_(__FILE__, line)(name[0] == 0x1f, "Got unexpected name \"%s\".\n", name);
259
261 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to set object name, hr %#x.\n", hr);
262
263 size = 1;
265 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
266 ok_(__FILE__, line)(size == 0, "Unexpected size %u.\n", size);
267
268 size = 1;
269 name[0] = 0x1f;
271 ok_(__FILE__, line)(SUCCEEDED(hr), "Failed to get name size, hr %#x.\n", hr);
272 ok_(__FILE__, line)(size == 0, "Unexpected size %u.\n", size);
273 ok_(__FILE__, line)(name[0] == 0, "Got unexpected name \"%s\".\n", name);
274}
275
276static char data_bad_version[] =
277"xof 0302txt 0064\n"
278"Header Object\n"
279"{\n"
280"1; 2; 3;\n"
281"}\n";
282
283static char data_no_mesh[] =
284"xof 0302txt 0064\n"
285"Header Object\n"
286"{\n"
287"1; 0; 1;\n"
288"}\n";
289
290static char data_ok[] =
291"xof 0302txt 0064\n"
292"Header Object\n"
293"{\n"
294"1; 0; 1;\n"
295"}\n"
296"Mesh Object\n"
297"{\n"
298"4;\n"
299"1.0; 0.0; 0.0;,\n"
300"0.0; 1.0; 0.0;,\n"
301"0.0; 0.0; 1.0;,\n"
302"1.0; 1.0; 1.0;;\n"
303"3;\n"
304"3; 0, 1, 2;,\n"
305"3; 1, 2, 3;,\n"
306"3; 3, 1, 2;;\n"
307"}\n";
308
309static char data_full[] =
310"xof 0302txt 0064\n"
311"Header { 1; 0; 1; }\n"
312"Mesh {\n"
313" 3;\n"
314" 0.1; 0.2; 0.3;,\n"
315" 0.4; 0.5; 0.6;,\n"
316" 0.7; 0.8; 0.9;;\n"
317" 1;\n"
318" 3; 0, 1, 2;;\n"
319" MeshMaterialList {\n"
320" 1; 1; 0;\n"
321" Material {\n"
322" 0.0; 1.0; 0.0; 1.0;;\n"
323" 30.0;\n"
324" 1.0; 0.0; 0.0;;\n"
325" 0.5; 0.5; 0.5;;\n"
326" TextureFileName {\n"
327" \"Texture.bmp\";\n"
328" }\n"
329" }\n"
330" }\n"
331" MeshNormals {\n"
332" 3;\n"
333" 1.1; 1.2; 1.3;,\n"
334" 1.4; 1.5; 1.6;,\n"
335" 1.7; 1.8; 1.9;;\n"
336" 1;"
337" 3; 0, 1, 2;;\n"
338" }\n"
339" MeshTextureCoords {\n"
340" 3;\n"
341" 0.13; 0.17;,\n"
342" 0.23; 0.27;,\n"
343" 0.33; 0.37;;\n"
344" }\n"
345"}\n";
346
347static char data_d3drm_load[] =
348"xof 0302txt 0064\n"
349"Header Object\n"
350"{\n"
351"1; 0; 1;\n"
352"}\n"
353"Mesh Object1\n"
354"{\n"
355" 1;\n"
356" 0.1; 0.2; 0.3;,\n"
357" 1;\n"
358" 3; 0, 1, 2;;\n"
359"}\n"
360"Mesh Object2\n"
361"{\n"
362" 1;\n"
363" 0.1; 0.2; 0.3;,\n"
364" 1;\n"
365" 3; 0, 1, 2;;\n"
366"}\n"
367"Frame Scene\n"
368"{\n"
369" {Object1}\n"
370" {Object2}\n"
371"}\n"
372"Material\n"
373"{\n"
374" 0.1, 0.2, 0.3, 0.4;;\n"
375" 0.5;\n"
376" 0.6, 0.7, 0.8;;\n"
377" 0.9, 1.0, 1.1;;\n"
378"}\n";
379
381"xof 0302txt 0064\n"
382"Header { 1; 0; 1; }\n"
383"Frame {\n"
384" Mesh mesh1 {\n"
385" 5;\n"
386" 0.1; 0.2; 0.3;,\n"
387" 0.4; 0.5; 0.6;,\n"
388" 0.7; 0.8; 0.9;,\n"
389" 1.1; 1.2; 1.3;,\n"
390" 1.4; 1.5; 1.6;;\n"
391" 6;\n"
392" 3; 0, 1, 2;,\n"
393" 3; 0, 2, 1;,\n"
394" 3; 1, 2, 3;,\n"
395" 3; 1, 3, 2;,\n"
396" 3; 2, 3, 4;,\n"
397" 3; 2, 4, 3;;\n"
398" MeshMaterialList {\n"
399" 3; 6; 0, 1, 1, 2, 2, 2;\n"
400" Material mat1 {\n"
401" 1.0; 0.0; 0.0; 0.1;;\n"
402" 10.0;\n"
403" 0.11; 0.12; 0.13;;\n"
404" 0.14; 0.15; 0.16;;\n"
405" }\n"
406" Material mat2 {\n"
407" 0.0; 1.0; 0.0; 0.2;;\n"
408" 20.0;\n"
409" 0.21; 0.22; 0.23;;\n"
410" 0.24; 0.25; 0.26;;\n"
411" }\n"
412" Material mat3 {\n"
413" 0.0; 0.0; 1.0; 0.3;;\n"
414" 30.0;\n"
415" 0.31; 0.32; 0.33;;\n"
416" 0.34; 0.35; 0.36;;\n"
417" }\n"
418" }\n"
419" }\n"
420"}\n";
421
422static void test_MeshBuilder(void)
423{
424 HRESULT hr;
425 IDirect3DRM *d3drm;
426 IDirect3DRMMeshBuilder *pMeshBuilder;
427 IDirect3DRMMeshBuilder3 *meshbuilder3;
428 IDirect3DRMMesh *mesh;
430 int val;
431 DWORD val1, val2, val3;
432 D3DVALUE valu, valv;
433 D3DVECTOR v[3];
434 D3DVECTOR n[4];
435 DWORD f[8];
436 char name[10];
437 DWORD size;
439 IUnknown *unk;
440
442 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
443
444 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder);
445 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
446
447 hr = IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder, &IID_IDirect3DRMObject, (void **)&unk);
448 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, %#x.\n", hr);
449 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
450 IUnknown_Release(unk);
451
452 hr = IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder, &IID_IDirect3DRMVisual, (void **)&unk);
453 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMVisual, %#x.\n", hr);
454 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
455 IUnknown_Release(unk);
456
457 hr = IDirect3DRMMeshBuilder_QueryInterface(pMeshBuilder, &IID_IDirect3DRMMeshBuilder3, (void **)&meshbuilder3);
458 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMMeshBuilder3, %#x.\n", hr);
459
460 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3, &IID_IDirect3DRMObject, (void **)&unk);
461 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, %#x.\n", hr);
462 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
463 IUnknown_Release(unk);
464
465 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder3, &IID_IDirect3DRMVisual, (void **)&unk);
466 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMVisual, %#x.\n", hr);
467 ok(unk == (IUnknown *)pMeshBuilder, "Unexpected interface pointer.\n");
468 IUnknown_Release(unk);
469
471
472 test_class_name((IDirect3DRMObject *)pMeshBuilder, "Builder");
473 test_object_name((IDirect3DRMObject *)pMeshBuilder);
474
475 info.lpMemory = data_bad_version;
478 ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr);
479
480 info.lpMemory = data_no_mesh;
481 info.dSize = strlen(data_no_mesh);
483 ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr);
484
485 info.lpMemory = data_ok;
486 info.dSize = strlen(data_ok);
488 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
489
490 size = sizeof(name);
491 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
492 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
493 ok(!strcmp(name, "Object"), "Retrieved name '%s' instead of 'Object'\n", name);
494 size = strlen("Object"); /* No space for null character */
495 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
496 ok(hr == E_INVALIDARG, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
497 hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, NULL);
498 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr);
499 size = sizeof(name);
500 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
501 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
502 ok(size == 0, "Size should be 0 instead of %u\n", size);
503 hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, "");
504 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr);
505 size = sizeof(name);
506 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
507 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
508 ok(!strcmp(name, ""), "Retrieved name '%s' instead of ''\n", name);
509
511 ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
512
514 ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
515
516 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, NULL, &val2, NULL, &val3, NULL);
517 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
518 ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1);
519 ok(val2 == 4, "Wrong number of normals %d (must be 4)\n", val2);
520 ok(val3 == 22, "Wrong number of face data bytes %d (must be 22)\n", val3);
521
522 /* Check that Load method generated default normals */
523 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, NULL, &val2, n, NULL, NULL);
524 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
525 expect_vector(&n[0], 0.577350f, 0.577350f, 0.577350f, 32);
526 expect_vector(&n[1], -0.229416f, 0.688247f, 0.688247f, 32);
527 expect_vector(&n[2], -0.229416f, 0.688247f, 0.688247f, 32);
528 expect_vector(&n[3], -0.577350f, 0.577350f, 0.577350f, 32);
529
530 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
531 valu = 1.23f;
532 valv = 3.21f;
533 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv);
534 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
535 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
536 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
537 valu = 1.23f;
538 valv = 3.21f;
539 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 1, &valu, &valv);
540 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
541 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
542 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
543 valu = 1.23f;
544 valv = 3.21f;
545 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 2, &valu, &valv);
546 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\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);
549 valu = 1.23f;
550 valv = 3.21f;
551 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 3, &valu, &valv);
552 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\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);
555 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 4, &valu, &valv);
556 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
557
558 valu = 1.23f;
559 valv = 3.21f;
560 hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 0, valu, valv);
561 ok(hr == D3DRM_OK, "Cannot set texture coordinates (hr = %x)\n", hr);
562 hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 4, valu, valv);
563 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
564
565 valu = 0.0f;
566 valv = 0.0f;
567 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv);
568 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
569 ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu);
570 ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv);
571
572 IDirect3DRMMeshBuilder_Release(pMeshBuilder);
573
574 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder);
575 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
576
577 /* No group in mesh when mesh builder is not loaded */
578 hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh);
579 ok(hr == D3DRM_OK, "CreateMesh failed returning hr = %x\n", hr);
580 if (hr == D3DRM_OK)
581 {
582 DWORD nb_groups;
583
585 ok(nb_groups == 0, "GetCroupCount returned %u\n", nb_groups);
586
588 }
589
590 info.lpMemory = data_full;
591 info.dSize = strlen(data_full);
593 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
594
596 ok(val == 3, "Wrong number of vertices %d (must be 3)\n", val);
597
599 ok(val == 1, "Wrong number of faces %d (must be 1)\n", val);
600
601 /* Check no buffer size and too small buffer size errors */
602 val1 = 1; val2 = 3; val3 = 8;
603 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
604 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
605 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, v, &val2, n, &val3, f);
606 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
607 val1 = 3; val2 = 1; val3 = 8;
608 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
609 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
610 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, NULL, n, &val3, f);
611 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
612 val1 = 3; val2 = 3; val3 = 1;
613 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
614 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
615 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, NULL, f);
616 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
617
618 val1 = 3; val2 = 3; val3 = 8;
619 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
620 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
621 ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1);
622 ok(val2 == 3, "Wrong number of normals %d (must be 3)\n", val2);
623 ok(val3 == 8, "Wrong number of face data bytes %d (must be 8)\n", val3);
624 expect_vector(&v[0], 0.1f, 0.2f, 0.3f, 32);
625 expect_vector(&v[1], 0.4f, 0.5f, 0.6f, 32);
626 expect_vector(&v[2], 0.7f, 0.8f, 0.9f, 32);
627 expect_vector(&n[0], 1.1f, 1.2f, 1.3f, 32);
628 expect_vector(&n[1], 1.4f, 1.5f, 1.6f, 32);
629 expect_vector(&n[2], 1.7f, 1.8f, 1.9f, 32);
630 ok(f[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f[0]);
631 ok(f[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f[1]);
632 ok(f[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f[2]);
633 ok(f[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f[3]);
634 ok(f[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f[4]);
635 ok(f[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f[5]);
636 ok(f[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f[6]);
637 ok(f[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f[7]);
638
639 hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh);
640 ok(hr == D3DRM_OK, "CreateMesh failed returning hr = %x\n", hr);
641 if (hr == D3DRM_OK)
642 {
643 DWORD nb_groups;
644 unsigned nb_vertices, nb_faces, nb_face_vertices;
645 DWORD data_size;
646 IDirect3DRMMaterial *material = (IDirect3DRMMaterial *)0xdeadbeef;
647 IDirect3DRMTexture *texture = (IDirect3DRMTexture *)0xdeadbeef;
648 D3DVALUE values[3];
649
651 ok(nb_groups == 1, "GetCroupCount returned %u\n", nb_groups);
652 hr = IDirect3DRMMesh_GetGroup(mesh, 1, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL);
653 ok(hr == D3DRMERR_BADVALUE, "GetCroup returned hr = %x\n", hr);
654 hr = IDirect3DRMMesh_GetGroup(mesh, 0, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL);
655 ok(hr == D3DRM_OK, "GetCroup failed returning hr = %x\n", hr);
656 ok(nb_vertices == 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices);
657 ok(nb_faces == 1, "Wrong number of faces %u (must be 1)\n", nb_faces);
658 ok(nb_face_vertices == 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices);
659 ok(data_size == 3, "Wrong number of face data bytes %u (must be 3)\n", data_size);
661 ok(color == 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color, 0xff00ff00);
663 ok(hr == D3DRM_OK, "GetCroupTexture failed returning hr = %x\n", hr);
664 ok(texture == NULL, "No texture should be present\n");
666 ok(hr == D3DRM_OK, "GetCroupMaterial failed returning hr = %x\n", hr);
667 ok(material != NULL, "No material present\n");
668 hr = IDirect3DRMMaterial_GetEmissive(material, &values[0], &values[1], &values[2]);
669 ok(hr == D3DRM_OK, "Failed to get emissive color, hr %#x.\n", hr);
670 ok(values[0] == 0.5f, "Got unexpected red component %.8e.\n", values[0]);
671 ok(values[1] == 0.5f, "Got unexpected green component %.8e.\n", values[1]);
672 ok(values[2] == 0.5f, "Got unexpected blue component %.8e.\n", values[2]);
673 hr = IDirect3DRMMaterial_GetSpecular(material, &values[0], &values[1], &values[2]);
674 ok(hr == D3DRM_OK, "Failed to get specular color, hr %#x.\n", hr);
675 ok(values[0] == 1.0f, "Got unexpected red component %.8e.\n", values[0]);
676 ok(values[1] == 0.0f, "Got unexpected green component %.8e.\n", values[1]);
677 ok(values[2] == 0.0f, "Got unexpected blue component %.8e.\n", values[2]);
679 ok(values[0] == 30.0f, "Got unexpected power value %.8e.\n", values[0]);
681
683 }
684
685 hr = IDirect3DRMMeshBuilder_Scale(pMeshBuilder, 2, 3 ,4);
686 ok(hr == D3DRM_OK, "Scale failed returning hr = %x\n", hr);
687
688 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
689 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
690 ok(val2 == 3, "Wrong number of normals %d (must be 3)\n", val2);
691 ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1);
692
693 expect_vector(&v[0], 0.1f * 2, 0.2f * 3, 0.3f * 4, 32);
694 expect_vector(&v[1], 0.4f * 2, 0.5f * 3, 0.6f * 4, 32);
695 expect_vector(&v[2], 0.7f * 2, 0.8f * 3, 0.9f * 4, 32);
696 /* Normals are not affected by Scale */
697 expect_vector(&n[0], 1.1f, 1.2f, 1.3f, 32);
698 expect_vector(&n[1], 1.4f, 1.5f, 1.6f, 32);
699 expect_vector(&n[2], 1.7f, 1.8f, 1.9f, 32);
700
701 IDirect3DRMMeshBuilder_Release(pMeshBuilder);
702
704}
705
706static void test_MeshBuilder3(void)
707{
708 HRESULT hr;
709 IDirect3DRM *d3drm;
710 IDirect3DRM3 *d3drm3;
711 IDirect3DRMMeshBuilder3 *pMeshBuilder3;
713 int val;
714 DWORD val1;
715 D3DVALUE valu, valv;
716
718 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
719
720 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
721 {
722 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
724 return;
725 }
726
727 hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &pMeshBuilder3);
728 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr);
729
730 test_class_name((IDirect3DRMObject *)pMeshBuilder3, "Builder");
731 test_object_name((IDirect3DRMObject *)pMeshBuilder3);
732
733 info.lpMemory = data_bad_version;
736 ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr);
737
738 info.lpMemory = data_no_mesh;
739 info.dSize = strlen(data_no_mesh);
741 ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr);
742
743 info.lpMemory = data_ok;
744 info.dSize = strlen(data_ok);
746 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
747
749 ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
750
752 ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
753
754 hr = IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3, 0, &val1, NULL);
755 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
756 ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1);
757
758 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
759 valu = 1.23f;
760 valv = 3.21f;
761 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv);
762 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
763 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
764 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
765 valu = 1.23f;
766 valv = 3.21f;
767 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 1, &valu, &valv);
768 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
769 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
770 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
771 valu = 1.23f;
772 valv = 3.21f;
773 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 2, &valu, &valv);
774 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\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);
777 valu = 1.23f;
778 valv = 3.21f;
779 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 3, &valu, &valv);
780 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\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);
783 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 4, &valu, &valv);
784 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
785
786 valu = 1.23f;
787 valv = 3.21f;
788 hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 0, valu, valv);
789 ok(hr == D3DRM_OK, "Cannot set texture coordinates (hr = %x)\n", hr);
790 hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 4, valu, valv);
791 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
792
793 valu = 0.0f;
794 valv = 0.0f;
795 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv);
796 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
797 ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu);
798 ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv);
799
800 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3);
801 IDirect3DRM3_Release(d3drm3);
803}
804
805static void test_Mesh(void)
806{
807 HRESULT hr;
808 IDirect3DRM *d3drm;
809 IDirect3DRMMesh *mesh;
810 IUnknown *unk;
811
813 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
814
816 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr);
817
818 test_class_name((IDirect3DRMObject *)mesh, "Mesh");
819 test_object_name((IDirect3DRMObject *)mesh);
820
821 hr = IDirect3DRMMesh_QueryInterface(mesh, &IID_IDirect3DRMObject, (void **)&unk);
822 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, %#x.\n", hr);
823 IUnknown_Release(unk);
824
825 hr = IDirect3DRMMesh_QueryInterface(mesh, &IID_IDirect3DRMVisual, (void **)&unk);
826 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMVisual, %#x.\n", hr);
827 IUnknown_Release(unk);
828
830
832}
833
834static void test_Face(void)
835{
836 HRESULT hr;
837 IDirect3DRM *d3drm;
838 IDirect3DRM2 *d3drm2;
839 IDirect3DRM3 *d3drm3;
840 IDirect3DRMMeshBuilder2 *MeshBuilder2;
841 IDirect3DRMMeshBuilder3 *MeshBuilder3;
842 IDirect3DRMFace *face1;
843 IDirect3DRMObject *obj;
844 IDirect3DRMFace2 *face2;
845 IDirect3DRMFaceArray *array1;
847 D3DVECTOR v1[4], n1[4], v2[4], n2[4];
849 DWORD count;
850 int icount;
851
853 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
854
856 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr);
857 if (FAILED(hr))
858 {
859 skip("Cannot get IDirect3DRMFace interface (hr = %x), skipping tests\n", hr);
861 return;
862 }
863
864 hr = IDirect3DRMFace_QueryInterface(face1, &IID_IDirect3DRMObject, (void **)&obj);
865 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, %#x.\n", hr);
866 ok(obj == (IDirect3DRMObject *)face1, "Unexpected interface pointer.\n");
868
869 test_class_name((IDirect3DRMObject *)face1, "Face");
870 test_object_name((IDirect3DRMObject *)face1);
871
872 icount = IDirect3DRMFace_GetVertexCount(face1);
873 ok(!icount, "wrong VertexCount: %i\n", icount);
874
876
877 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM2, (void **)&d3drm2)))
878 {
879 win_skip("Cannot get IDirect3DRM2 interface (hr = %x), skipping tests\n", hr);
881 return;
882 }
883
884 hr = IDirect3DRM2_CreateMeshBuilder(d3drm2, &MeshBuilder2);
885 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder2 interface (hr = %x)\n", hr);
886
887 icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2);
888 ok(!icount, "wrong FaceCount: %i\n", icount);
889
890 array1 = NULL;
891 hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1);
893 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
894
895 hr = IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2, &face1);
896 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr);
897
898 icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2);
900 ok(icount == 1, "wrong FaceCount: %i\n", icount);
901
902 array1 = NULL;
903 hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1);
905 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
907 ok(array1 != NULL, "pArray = %p\n", array1);
908 if (array1)
909 {
910 IDirect3DRMFace *face;
912 ok(count == 1, "count = %u\n", count);
914 ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr);
917 }
918
919 icount = IDirect3DRMFace_GetVertexCount(face1);
920 ok(!icount, "wrong VertexCount: %i\n", icount);
921
924
925 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
926 {
927 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
929 return;
930 }
931
932 hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &MeshBuilder3);
933 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr);
934
935 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
936 ok(!icount, "wrong FaceCount: %i\n", icount);
937
938 hr = IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3, &face2);
939 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace2 interface (hr = %x)\n", hr);
940
941 hr = IDirect3DRMFace2_QueryInterface(face2, &IID_IDirect3DRMObject, (void **)&obj);
942 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, %#x.\n", hr);
943
944 hr = IDirect3DRMFace2_QueryInterface(face2, &IID_IDirect3DRMFace, (void **)&face1);
945 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, %#x.\n", hr);
946 ok(obj == (IDirect3DRMObject *)face1, "Unexpected interface pointer.\n");
947
950
951 test_class_name((IDirect3DRMObject *)face2, "Face");
952 test_object_name((IDirect3DRMObject *)face2);
953
954 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
956 ok(icount == 1, "wrong FaceCount: %i\n", icount);
957
958 array1 = NULL;
959 hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1);
961 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
963 ok(array1 != NULL, "pArray = %p\n", array1);
964 if (array1)
965 {
966 IDirect3DRMFace *face;
968 ok(count == 1, "count = %u\n", count);
970 ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr);
973 }
974
975 icount = IDirect3DRMFace2_GetVertexCount(face2);
976 ok(!icount, "wrong VertexCount: %i\n", icount);
977
978 info.lpMemory = data_ok;
979 info.dSize = strlen(data_ok);
981 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
982
983 icount = IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3);
984 ok(icount == 4, "Wrong number of vertices %d (must be 4)\n", icount);
985
986 icount = IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3);
987 ok(icount == 4, "Wrong number of normals %d (must be 4)\n", icount);
988
989 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
991 ok(icount == 4, "Wrong number of faces %d (must be 4)\n", icount);
992
993 count = 4;
994 hr = IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3, 0, &count, v1);
995 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
996 ok(count == 4, "Wrong number of vertices %d (must be 4)\n", count);
997
998 hr = IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3, 0, &count, n1);
999 ok(hr == D3DRM_OK, "Cannot get normals information (hr = %x)\n", hr);
1000 ok(count == 4, "Wrong number of normals %d (must be 4)\n", count);
1001
1002 array1 = NULL;
1003 hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1);
1004 todo_wine
1005 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
1006 todo_wine
1007 ok(array1 != NULL, "pArray = %p\n", array1);
1008 if (array1)
1009 {
1010 IDirect3DRMFace *face;
1012 ok(count == 4, "count = %u\n", count);
1014 ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr);
1016 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
1017 ok(count == 3, "Wrong number of vertices %d (must be 3)\n", count);
1018
1019 vector_eq(&v1[0], &v2[0]);
1020 vector_eq(&v1[1], &v2[1]);
1021 vector_eq(&v1[2], &v2[2]);
1022
1023 vector_eq(&n1[0], &n2[0]);
1024 vector_eq(&n1[1], &n2[1]);
1025 vector_eq(&n1[2], &n2[2]);
1026
1029 }
1030
1031 /* Setting face color. */
1032 hr = IDirect3DRMFace2_SetColor(face2, 0x1f180587);
1033 ok(SUCCEEDED(hr), "Failed to set face color, hr %#x.\n", hr);
1035 ok(color == 0x1f180587, "Unexpected color %8x.\n", color);
1036
1037 hr = IDirect3DRMFace2_SetColorRGB(face2, 0.5f, 0.5f, 0.5f);
1038 ok(SUCCEEDED(hr), "Failed to set color, hr %#x.\n", hr);
1040 ok(color == 0xff7f7f7f, "Unexpected color %8x.\n", color);
1041
1043 IDirect3DRMMeshBuilder3_Release(MeshBuilder3);
1044 IDirect3DRM3_Release(d3drm3);
1045 IDirect3DRM2_Release(d3drm2);
1047}
1048
1049static void test_Frame(void)
1050{
1051 HRESULT hr;
1052 IDirect3DRM *d3drm;
1053 IDirect3DRMFrame *pFrameC;
1054 IDirect3DRMFrame *pFrameP1;
1055 IDirect3DRMFrame *pFrameP2;
1056 IDirect3DRMFrame *pFrameTmp;
1057 IDirect3DRMFrame *scene_frame;
1058 IDirect3DRMFrameArray *frame_array;
1059 IDirect3DRMMeshBuilder *mesh_builder;
1060 IDirect3DRMVisual *visual1;
1061 IDirect3DRMVisual *visual_tmp;
1062 IDirect3DRMVisualArray *visual_array;
1063 IDirect3DRMLight *light1;
1064 IDirect3DRMLight *light_tmp;
1065 IDirect3DRMLightArray *light_array;
1066 IDirect3DRMFrame3 *frame3;
1068 ULONG ref, ref2;
1070
1072 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1073
1075 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameC);
1076 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1077 CHECK_REFCOUNT(pFrameC, 1);
1078 ref2 = get_refcount((IUnknown *)d3drm);
1079 ok(ref2 > ref, "Expected d3drm object to be referenced.\n");
1080
1081 test_class_name((IDirect3DRMObject *)pFrameC, "Frame");
1082 test_object_name((IDirect3DRMObject *)pFrameC);
1083
1085 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
1086 pFrameTmp = (void*)0xdeadbeef;
1087 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1088 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1089 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1090 CHECK_REFCOUNT(pFrameC, 1);
1091
1092 frame_array = NULL;
1093 hr = IDirect3DRMFrame_GetChildren(pFrameC, &frame_array);
1094 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1095 ok(!!frame_array, "frame_array = %p\n", frame_array);
1096 if (frame_array)
1097 {
1098 count = IDirect3DRMFrameArray_GetSize(frame_array);
1099 ok(count == 0, "count = %u\n", count);
1100 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1101 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
1102 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1103 IDirect3DRMFrameArray_Release(frame_array);
1104 }
1105
1106 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP1);
1107 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1108
1109 /* GetParent with NULL pointer */
1110 hr = IDirect3DRMFrame_GetParent(pFrameP1, NULL);
1111 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
1112 CHECK_REFCOUNT(pFrameP1, 1);
1113
1114 /* [Add/Delete]Child with NULL pointer */
1115 hr = IDirect3DRMFrame_AddChild(pFrameP1, NULL);
1116 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1117 CHECK_REFCOUNT(pFrameP1, 1);
1118
1120 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1121 CHECK_REFCOUNT(pFrameP1, 1);
1122
1123 /* Add child to first parent */
1124 pFrameTmp = (void*)0xdeadbeef;
1125 hr = IDirect3DRMFrame_GetParent(pFrameP1, &pFrameTmp);
1126 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1127 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1128
1129 hr = IDirect3DRMFrame_AddChild(pFrameP1, pFrameC);
1130 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1131 CHECK_REFCOUNT(pFrameP1, 1);
1132 CHECK_REFCOUNT(pFrameC, 2);
1133
1134 hr = IDirect3DRMFrame_GetScene(pFrameC, NULL);
1135 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1136 hr = IDirect3DRMFrame_GetScene(pFrameC, &scene_frame);
1137 ok(SUCCEEDED(hr), "Cannot get scene (hr == %#x).\n", hr);
1138 ok(scene_frame == pFrameP1, "Expected scene frame == %p, got %p.\n", pFrameP1, scene_frame);
1139 CHECK_REFCOUNT(pFrameP1, 2);
1140 IDirect3DRMFrame_Release(scene_frame);
1141 hr = IDirect3DRMFrame_GetScene(pFrameP1, &scene_frame);
1142 ok(SUCCEEDED(hr), "Cannot get scene (hr == %#x).\n", hr);
1143 ok(scene_frame == pFrameP1, "Expected scene frame == %p, got %p.\n", pFrameP1, scene_frame);
1144 CHECK_REFCOUNT(pFrameP1, 2);
1145 IDirect3DRMFrame_Release(scene_frame);
1146
1147 frame_array = NULL;
1148 hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array);
1149 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1150 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
1151 ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2),
1152 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown*)pFrameC));
1153 if (frame_array)
1154 {
1155 count = IDirect3DRMFrameArray_GetSize(frame_array);
1156 ok(count == 1, "count = %u\n", count);
1157 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1158 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1159 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1160 ok((get_refcount((IUnknown*)pFrameC) == 4) || broken(get_refcount((IUnknown*)pFrameC) == 3),
1161 "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown*)pFrameC));
1162 IDirect3DRMFrame_Release(pFrameTmp);
1163 ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2),
1164 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown*)pFrameC));
1165 IDirect3DRMFrameArray_Release(frame_array);
1166 CHECK_REFCOUNT(pFrameC, 2);
1167 }
1168
1169 pFrameTmp = (void*)0xdeadbeef;
1170 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1171 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1172 ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
1173 CHECK_REFCOUNT(pFrameP1, 2);
1174 IDirect3DRMFrame_Release(pFrameTmp);
1175 CHECK_REFCOUNT(pFrameP1, 1);
1176
1177 /* Add child to second parent */
1178 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP2);
1179 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1180
1181 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1182 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1183 CHECK_REFCOUNT(pFrameC, 2);
1184
1185 frame_array = NULL;
1186 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1187 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1188 if (frame_array)
1189 {
1190 count = IDirect3DRMFrameArray_GetSize(frame_array);
1191 ok(count == 1, "count = %u\n", count);
1192 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1193 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1194 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1195 IDirect3DRMFrame_Release(pFrameTmp);
1196 IDirect3DRMFrameArray_Release(frame_array);
1197 }
1198
1199 frame_array = NULL;
1200 hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array);
1201 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1202 if (frame_array)
1203 {
1204 count = IDirect3DRMFrameArray_GetSize(frame_array);
1205 ok(count == 0, "count = %u\n", count);
1206 pFrameTmp = (void*)0xdeadbeef;
1207 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1208 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
1209 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1210 IDirect3DRMFrameArray_Release(frame_array);
1211 }
1212 hr = IDirect3DRMFrame_GetScene(pFrameC, &scene_frame);
1213 ok(SUCCEEDED(hr), "Cannot get scene (hr == %#x).\n", hr);
1214 ok(scene_frame == pFrameP2, "Expected scene frame == %p, got %p.\n", pFrameP2, scene_frame);
1215 CHECK_REFCOUNT(pFrameP2, 2);
1216 IDirect3DRMFrame_Release(scene_frame);
1217 hr = IDirect3DRMFrame_GetScene(pFrameP2, &scene_frame);
1218 ok(SUCCEEDED(hr), "Cannot get scene (hr == %#x).\n", hr);
1219 ok(scene_frame == pFrameP2, "Expected scene frame == %p, got %p.\n", pFrameP2, scene_frame);
1220 CHECK_REFCOUNT(pFrameP2, 2);
1221 IDirect3DRMFrame_Release(scene_frame);
1222
1223 pFrameTmp = (void*)0xdeadbeef;
1224 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1225 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1226 ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp);
1227 CHECK_REFCOUNT(pFrameP2, 2);
1228 CHECK_REFCOUNT(pFrameC, 2);
1229 IDirect3DRMFrame_Release(pFrameTmp);
1230 CHECK_REFCOUNT(pFrameP2, 1);
1231
1232 /* Add child again */
1233 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1234 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1235 CHECK_REFCOUNT(pFrameC, 2);
1236
1237 frame_array = NULL;
1238 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1239 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1240 if (frame_array)
1241 {
1242 count = IDirect3DRMFrameArray_GetSize(frame_array);
1243 ok(count == 1, "count = %u\n", count);
1244 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1245 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1246 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1247 IDirect3DRMFrame_Release(pFrameTmp);
1248 IDirect3DRMFrameArray_Release(frame_array);
1249 }
1250
1251 /* Delete child */
1252 hr = IDirect3DRMFrame_DeleteChild(pFrameP2, pFrameC);
1253 ok(hr == D3DRM_OK, "Cannot delete child frame (hr = %x)\n", hr);
1254 CHECK_REFCOUNT(pFrameC, 1);
1255
1256 frame_array = NULL;
1257 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1258 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1259 if (frame_array)
1260 {
1261 count = IDirect3DRMFrameArray_GetSize(frame_array);
1262 ok(count == 0, "count = %u\n", count);
1263 pFrameTmp = (void*)0xdeadbeef;
1264 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1265 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
1266 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1267 IDirect3DRMFrameArray_Release(frame_array);
1268 }
1269
1270 pFrameTmp = (void*)0xdeadbeef;
1271 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1272 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1273 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1274
1275 /* Add two children */
1276 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1277 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1278 CHECK_REFCOUNT(pFrameC, 2);
1279
1280 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameP1);
1281 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1282 CHECK_REFCOUNT(pFrameP1, 2);
1283
1284 frame_array = NULL;
1285 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1286 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1287 if (frame_array)
1288 {
1289 count = IDirect3DRMFrameArray_GetSize(frame_array);
1290 ok(count == 2, "count = %u\n", count);
1291 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1292 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1293 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1294 IDirect3DRMFrame_Release(pFrameTmp);
1295 hr = IDirect3DRMFrameArray_GetElement(frame_array, 1, &pFrameTmp);
1296 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1297 ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
1298 IDirect3DRMFrame_Release(pFrameTmp);
1299 IDirect3DRMFrameArray_Release(frame_array);
1300 }
1301
1302 /* [Add/Delete]Visual with NULL pointer */
1303 hr = IDirect3DRMFrame_AddVisual(pFrameP1, NULL);
1304 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1305 CHECK_REFCOUNT(pFrameP1, 2);
1306
1308 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1309 CHECK_REFCOUNT(pFrameP1, 2);
1310
1311 /* Create Visual */
1313 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
1314 visual1 = (IDirect3DRMVisual *)mesh_builder;
1315
1316 /* Add Visual to first parent */
1317 hr = IDirect3DRMFrame_AddVisual(pFrameP1, visual1);
1318 ok(hr == D3DRM_OK, "Cannot add visual (hr = %x)\n", hr);
1319 CHECK_REFCOUNT(pFrameP1, 2);
1320 CHECK_REFCOUNT(visual1, 2);
1321
1322 visual_array = NULL;
1323 hr = IDirect3DRMFrame_GetVisuals(pFrameP1, &visual_array);
1324 ok(hr == D3DRM_OK, "Cannot get visuals (hr = %x)\n", hr);
1325 if (visual_array)
1326 {
1327 count = IDirect3DRMVisualArray_GetSize(visual_array);
1328 ok(count == 1, "count = %u\n", count);
1329 hr = IDirect3DRMVisualArray_GetElement(visual_array, 0, &visual_tmp);
1330 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1331 ok(visual_tmp == visual1, "visual_tmp = %p\n", visual_tmp);
1332 IDirect3DRMVisual_Release(visual_tmp);
1333 IDirect3DRMVisualArray_Release(visual_array);
1334 }
1335
1336 /* Delete Visual */
1337 hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, visual1);
1338 ok(hr == D3DRM_OK, "Cannot delete visual (hr = %x)\n", hr);
1339 CHECK_REFCOUNT(pFrameP1, 2);
1341
1342 /* [Add/Delete]Light with NULL pointer */
1343 hr = IDirect3DRMFrame_AddLight(pFrameP1, NULL);
1344 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1345 CHECK_REFCOUNT(pFrameP1, 2);
1346
1348 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1349 CHECK_REFCOUNT(pFrameP1, 2);
1350
1351 /* Create Light */
1352 hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.1, 0.2, 0.3, &light1);
1353 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr);
1354
1355 /* Add Light to first parent */
1356 hr = IDirect3DRMFrame_AddLight(pFrameP1, light1);
1357 ok(hr == D3DRM_OK, "Cannot add light (hr = %x)\n", hr);
1358 CHECK_REFCOUNT(pFrameP1, 2);
1359 CHECK_REFCOUNT(light1, 2);
1360
1361 light_array = NULL;
1362 hr = IDirect3DRMFrame_GetLights(pFrameP1, &light_array);
1363 ok(hr == D3DRM_OK, "Cannot get lights (hr = %x)\n", hr);
1364 if (light_array)
1365 {
1366 count = IDirect3DRMLightArray_GetSize(light_array);
1367 ok(count == 1, "count = %u\n", count);
1368 hr = IDirect3DRMLightArray_GetElement(light_array, 0, &light_tmp);
1369 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1370 ok(light_tmp == light1, "light_tmp = %p\n", light_tmp);
1371 IDirect3DRMLight_Release(light_tmp);
1372 IDirect3DRMLightArray_Release(light_array);
1373 }
1374
1375 /* Delete Light */
1376 hr = IDirect3DRMFrame_DeleteLight(pFrameP1, light1);
1377 ok(hr == D3DRM_OK, "Cannot delete light (hr = %x)\n", hr);
1378 CHECK_REFCOUNT(pFrameP1, 2);
1380
1381 /* Test SceneBackground on first parent */
1383 ok(color == 0xff000000, "wrong color (%x)\n", color);
1384
1385 hr = IDirect3DRMFrame_SetSceneBackground(pFrameP1, 0xff180587);
1386 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
1388 ok(color == 0xff180587, "wrong color (%x)\n", color);
1389
1390 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1, 0.5, 0.5, 0.5);
1391 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
1393 ok(color == 0xff7f7f7f, "wrong color (%x)\n", color);
1394
1395 /* Traversal options. */
1396 hr = IDirect3DRMFrame_QueryInterface(pFrameP2, &IID_IDirect3DRMFrame3, (void **)&frame3);
1397 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMFrame3 interface, hr %#x.\n", hr);
1398
1400 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
1401
1402 options = 0;
1404 ok(SUCCEEDED(hr), "Failed to get traversal options, hr %#x.\n", hr);
1405 ok(options == (D3DRMFRAME_RENDERENABLE | D3DRMFRAME_PICKENABLE), "Unexpected default options %#x.\n", options);
1406
1408 ok(SUCCEEDED(hr), "Unexpected hr %#x.\n", hr);
1409
1410 hr = IDirect3DRMFrame3_SetTraversalOptions(frame3, 0xf0000000);
1411 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
1412
1414 ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr);
1415
1416 options = 0xf;
1418 ok(SUCCEEDED(hr), "Failed to get traversal options, hr %#x.\n", hr);
1419 ok(options == 0, "Unexpected traversal options %#x.\n", options);
1420
1422 ok(SUCCEEDED(hr), "Failed to set traversal options, hr %#x.\n", hr);
1423
1424 options = 0;
1426 ok(SUCCEEDED(hr), "Failed to get traversal options, hr %#x.\n", hr);
1427 ok(options == D3DRMFRAME_PICKENABLE, "Unexpected traversal options %#x.\n", options);
1428
1430
1431 /* Cleanup */
1432 IDirect3DRMFrame_Release(pFrameP2);
1433 CHECK_REFCOUNT(pFrameC, 1);
1434 CHECK_REFCOUNT(pFrameP1, 1);
1435
1436 IDirect3DRMFrame_Release(pFrameC);
1437 IDirect3DRMFrame_Release(pFrameP1);
1438
1440}
1441
1443{
1444 IDirect3DRMObject *obj;
1445 unsigned int test_idx;
1447};
1448
1450{
1452 void *context;
1454
1455static void CDECL destroy_callback(IDirect3DRMObject *obj, void *arg)
1456{
1457 struct destroy_context *ctxt = arg;
1458 ok(ctxt->called == 1 || ctxt->called == 2, "got called counter %d\n", ctxt->called);
1459 ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1460 d3drm_corder[ctxt->called].callback = &destroy_callback;
1461 d3drm_corder[ctxt->called++].context = ctxt;
1462}
1463
1464static void CDECL destroy_callback1(IDirect3DRMObject *obj, void *arg)
1465{
1466 struct destroy_context *ctxt = (struct destroy_context*)arg;
1467 ok(ctxt->called == 0, "got called counter %d\n", ctxt->called);
1468 ok(obj == ctxt->obj, "called with %p, expected %p\n", obj, ctxt->obj);
1469 d3drm_corder[ctxt->called].callback = &destroy_callback1;
1470 d3drm_corder[ctxt->called++].context = ctxt;
1471}
1472
1473static void test_destroy_callback(unsigned int test_idx, REFCLSID clsid, REFIID iid)
1474{
1475 struct destroy_context context;
1476 IDirect3DRMObject *obj;
1478 IDirect3DRM *d3drm;
1479 HRESULT hr;
1480 int i;
1481
1483 ok(SUCCEEDED(hr), "Test %u: Cannot get IDirect3DRM interface (hr = %x).\n", test_idx, hr);
1484
1485 hr = IDirect3DRM_CreateObject(d3drm, clsid, NULL, iid, (void **)&unknown);
1486 ok(hr == D3DRM_OK, "Test %u: Cannot get IDirect3DRMObject interface (hr = %x).\n", test_idx, hr);
1487 hr = IUnknown_QueryInterface(unknown, &IID_IDirect3DRMObject, (void**)&obj);
1488 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1489 IUnknown_Release(unknown);
1490
1491 context.called = 0;
1492 context.test_idx = test_idx;
1493 context.obj = obj;
1494
1496 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected D3DRMERR_BADVALUE (hr = %x).\n", test_idx, hr);
1497
1499 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1500 corder[2].callback = &destroy_callback;
1501 corder[2].context = &context;
1502
1503 /* same callback added twice */
1505 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1506 corder[1].callback = &destroy_callback;
1507 corder[1].context = &context;
1508
1510 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1511
1513 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1514
1515 /* add one more */
1517 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1518 corder[0].callback = &destroy_callback1;
1519 corder[0].context = &context;
1520
1522 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected D3DRM_BADVALUE (hr = %x).\n", test_idx, hr);
1523
1524 context.called = 0;
1526 ok(context.called == 3, "Test %u: got %d, expected 3.\n", test_idx, context.called);
1527 for (i = 0; i < context.called; i++)
1528 {
1531 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder[i].callback,
1533 }
1534
1535 /* test this pattern - add cb1, add cb2, add cb1, delete cb1 */
1536 hr = IDirect3DRM_CreateObject(d3drm, clsid, NULL, iid, (void **)&unknown);
1537 ok(hr == D3DRM_OK, "Test %u: Cannot get IDirect3DRMObject interface (hr = %x).\n", test_idx, hr);
1538 hr = IUnknown_QueryInterface(unknown, &IID_IDirect3DRMObject, (void**)&obj);
1539 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1540 IUnknown_Release(unknown);
1541
1543 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1544 corder[1].callback = &destroy_callback;
1545 corder[1].context = &context;
1546
1548 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1549 corder[0].callback = &destroy_callback1;
1550 corder[0].context = &context;
1551
1553 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1554
1556 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1557
1558 context.called = 0;
1559 hr = IDirect3DRMObject_QueryInterface(obj, &IID_IDirect3DRMObject, (void**)&context.obj);
1560 ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx, hr);
1562 IUnknown_Release(unknown);
1563 ok(context.called == 2, "Test %u: got %d, expected 2.\n", test_idx, context.called);
1564 for (i = 0; i < context.called; i++)
1565 {
1568 "Expected callback = %p, context = %p. Got callback = %p, context = %p.\n", d3drm_corder[i].callback,
1570 }
1571
1573}
1574
1575static void test_object(void)
1576{
1577 static const struct
1578 {
1580 REFIID iid;
1581 BOOL takes_d3drm_ref;
1582 }
1583 tests[] =
1584 {
1585 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice },
1586 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice2 },
1587 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice3 },
1588 { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMWinDevice },
1589 { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture },
1590 { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture2 },
1591 { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture3 },
1592 { &CLSID_CDirect3DRMViewport, &IID_IDirect3DRMViewport },
1593 { &CLSID_CDirect3DRMViewport, &IID_IDirect3DRMViewport2 },
1594 { &CLSID_CDirect3DRMFace, &IID_IDirect3DRMFace },
1595 { &CLSID_CDirect3DRMFace, &IID_IDirect3DRMFace2 },
1596 { &CLSID_CDirect3DRMMeshBuilder, &IID_IDirect3DRMMeshBuilder, TRUE },
1597 { &CLSID_CDirect3DRMMeshBuilder, &IID_IDirect3DRMMeshBuilder2, TRUE },
1598 { &CLSID_CDirect3DRMMeshBuilder, &IID_IDirect3DRMMeshBuilder3, TRUE },
1599 { &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame, TRUE },
1600 { &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame2, TRUE },
1601 { &CLSID_CDirect3DRMFrame, &IID_IDirect3DRMFrame3, TRUE },
1602 { &CLSID_CDirect3DRMLight, &IID_IDirect3DRMLight, TRUE },
1603 { &CLSID_CDirect3DRMMaterial, &IID_IDirect3DRMMaterial, TRUE },
1604 { &CLSID_CDirect3DRMMaterial, &IID_IDirect3DRMMaterial2, TRUE },
1605 { &CLSID_CDirect3DRMMesh, &IID_IDirect3DRMMesh, TRUE },
1606 { &CLSID_CDirect3DRMAnimation, &IID_IDirect3DRMAnimation, TRUE },
1607 { &CLSID_CDirect3DRMAnimation, &IID_IDirect3DRMAnimation2, TRUE },
1608 { &CLSID_CDirect3DRMWrap, &IID_IDirect3DRMWrap },
1609 };
1610 IDirect3DRM *d3drm1;
1611 IDirect3DRM2 *d3drm2;
1612 IDirect3DRM3 *d3drm3;
1613 IUnknown *unknown = (IUnknown *)0xdeadbeef;
1614 HRESULT hr;
1615 ULONG ref1, ref2, ref3, ref4;
1616 int i;
1617
1618 hr = Direct3DRMCreate(&d3drm1);
1619 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr);
1620 ref1 = get_refcount((IUnknown *)d3drm1);
1621 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
1622 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr);
1623 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
1624 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr);
1625
1626 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_DirectDraw, NULL, &IID_IDirectDraw, (void **)&unknown);
1627 ok(hr == CLASSFACTORY_E_FIRST, "Expected hr == CLASSFACTORY_E_FIRST, got %#x.\n", hr);
1628 ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
1629
1630 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1631 {
1632 unknown = (IUnknown *)0xdeadbeef;
1633 hr = IDirect3DRM_CreateObject(d3drm1, NULL, NULL, tests[i].iid, (void **)&unknown);
1634 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i, hr);
1635 ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
1636 unknown = (IUnknown *)0xdeadbeef;
1637 hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, NULL, (void **)&unknown);
1638 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i, hr);
1639 ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
1641 ok(hr == D3DRMERR_BADVALUE, "Test %u: expected hr == D3DRMERR_BADVALUE, got %#x.\n", i, hr);
1642
1643 hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, tests[i].iid, (void **)&unknown);
1644 ok(SUCCEEDED(hr), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i, hr);
1645 if (SUCCEEDED(hr))
1646 {
1647 ref2 = get_refcount((IUnknown *)d3drm1);
1648 if (tests[i].takes_d3drm_ref)
1649 ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1650 else
1651 ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1652
1653 ref3 = get_refcount((IUnknown *)d3drm2);
1654 ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i, ref1, ref3);
1655 ref4 = get_refcount((IUnknown *)d3drm3);
1656 ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i, ref1, ref4);
1657 IUnknown_Release(unknown);
1658 ref2 = get_refcount((IUnknown *)d3drm1);
1659 ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1660 ref3 = get_refcount((IUnknown *)d3drm2);
1661 ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i, ref1, ref3);
1662 ref4 = get_refcount((IUnknown *)d3drm3);
1663 ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i, ref1, ref4);
1664
1665 /* test Add/Destroy callbacks */
1667
1668 hr = IDirect3DRM2_CreateObject(d3drm2, tests[i].clsid, NULL, tests[i].iid, (void **)&unknown);
1669 ok(SUCCEEDED(hr), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i, hr);
1670 ref2 = get_refcount((IUnknown *)d3drm1);
1671 if (tests[i].takes_d3drm_ref)
1672 ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1673 else
1674 ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1675 ref3 = get_refcount((IUnknown *)d3drm2);
1676 ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i, ref1, ref3);
1677 ref4 = get_refcount((IUnknown *)d3drm3);
1678 ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i, ref1, ref4);
1679 IUnknown_Release(unknown);
1680 ref2 = get_refcount((IUnknown *)d3drm1);
1681 ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1682 ref3 = get_refcount((IUnknown *)d3drm2);
1683 ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i, ref1, ref3);
1684 ref4 = get_refcount((IUnknown *)d3drm3);
1685 ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i, ref1, ref4);
1686
1687 hr = IDirect3DRM3_CreateObject(d3drm3, tests[i].clsid, NULL, tests[i].iid, (void **)&unknown);
1688 ok(SUCCEEDED(hr), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i, hr);
1689 ref2 = get_refcount((IUnknown *)d3drm1);
1690 if (tests[i].takes_d3drm_ref)
1691 ok(ref2 > ref1, "Test %u: expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1692 else
1693 ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1694 ref3 = get_refcount((IUnknown *)d3drm2);
1695 ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i, ref1, ref3);
1696 ref4 = get_refcount((IUnknown *)d3drm3);
1697 ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i, ref1, ref4);
1698 IUnknown_Release(unknown);
1699 ref2 = get_refcount((IUnknown *)d3drm1);
1700 ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", i, ref1, ref2);
1701 ref3 = get_refcount((IUnknown *)d3drm2);
1702 ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", i, ref1, ref3);
1703 ref4 = get_refcount((IUnknown *)d3drm3);
1704 ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", i, ref1, ref4);
1705 }
1706 }
1707
1708 IDirect3DRM_Release(d3drm1);
1709 IDirect3DRM2_Release(d3drm2);
1710 IDirect3DRM3_Release(d3drm3);
1711}
1712
1713static void test_Viewport(void)
1714{
1715 IDirect3DRMFrame3 *frame3, *d3drm_frame3, *tmp_frame3;
1716 IDirect3DRMFrame *frame, *d3drm_frame, *tmp_frame1;
1717 float field, left, top, right, bottom, front, back;
1718 IDirectDrawClipper *clipper;
1719 HRESULT hr;
1720 IDirect3DRM *d3drm1;
1721 IDirect3DRM2 *d3drm2;
1722 IDirect3DRM3 *d3drm3;
1723 IDirect3DRMDevice *device1, *d3drm_device1;
1724 IDirect3DRMDevice3 *device3, *d3drm_device3;
1725 IDirect3DRMViewport *viewport;
1726 IDirect3DRMViewport2 *viewport2;
1727 IDirect3DViewport *d3d_viewport;
1728 D3DVIEWPORT vp;
1729 D3DVALUE expected_val;
1730 IDirect3DRMObject *obj, *obj2;
1731 GUID driver;
1732 HWND window;
1733 RECT rc;
1734 DWORD data, ref1, ref2, ref3, ref4;
1735 DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2, viewport_ref;
1736
1738 GetClientRect(window, &rc);
1739
1740 hr = Direct3DRMCreate(&d3drm1);
1741 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1742 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
1743 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr);
1744 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
1745 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr);
1746 initial_ref1 = get_refcount((IUnknown *)d3drm1);
1747 initial_ref2 = get_refcount((IUnknown *)d3drm2);
1748 initial_ref3 = get_refcount((IUnknown *)d3drm3);
1749
1750 hr = DirectDrawCreateClipper(0, &clipper, NULL);
1751 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr);
1752
1753 hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
1754 ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr);
1755
1756 memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
1757 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3);
1758 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
1759 hr = IDirect3DRMDevice3_QueryInterface(device3, &IID_IDirect3DRMDevice, (void **)&device1);
1760 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %#x).\n", hr);
1761
1762 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame);
1763 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1764 hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &tmp_frame1);
1765 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1766 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
1767 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface (hr = %x).\n", hr);
1768 hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &tmp_frame3);
1769 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1770
1771 ref1 = get_refcount((IUnknown *)d3drm1);
1772 ref2 = get_refcount((IUnknown *)d3drm2);
1773 ref3 = get_refcount((IUnknown *)d3drm3);
1774 device_ref = get_refcount((IUnknown *)device1);
1775 frame_ref = get_refcount((IUnknown *)frame);
1776
1777 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, 0, 0, 0, 0, &viewport);
1778 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr);
1779 ref4 = get_refcount((IUnknown *)d3drm1);
1780 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
1781 ref4 = get_refcount((IUnknown *)d3drm2);
1782 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
1783 ref4 = get_refcount((IUnknown *)d3drm3);
1784 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
1785 ref4 = get_refcount((IUnknown *)device1);
1786 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
1787 ref4 = get_refcount((IUnknown *)frame);
1788 ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
1789
1790 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
1791 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
1792 ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1);
1793 IDirect3DRMDevice_Release(d3drm_device1);
1794
1796 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
1798 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1799 ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame);
1801
1802 hr = IDirect3DRMViewport_SetCamera(viewport, tmp_frame1);
1803 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1805 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1806 ok(d3drm_frame == tmp_frame1, "Got unexpected frame %p, expected %p.\n", d3drm_frame, tmp_frame1);
1808
1810 ref4 = get_refcount((IUnknown *)d3drm1);
1811 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
1812 ref4 = get_refcount((IUnknown *)d3drm2);
1813 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
1814 ref4 = get_refcount((IUnknown *)d3drm3);
1815 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
1816 ref4 = get_refcount((IUnknown *)device1);
1817 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
1818 ref4 = get_refcount((IUnknown *)frame);
1819 ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
1820
1821 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, 0, 0, 0, 0, &viewport);
1822 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr);
1823 ref4 = get_refcount((IUnknown *)d3drm1);
1824 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
1825 ref4 = get_refcount((IUnknown *)d3drm2);
1826 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
1827 ref4 = get_refcount((IUnknown *)d3drm3);
1828 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
1829 ref4 = get_refcount((IUnknown *)device1);
1830 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
1831 ref4 = get_refcount((IUnknown *)frame);
1832 ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
1833
1834 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
1835 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
1836 ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1);
1837 IDirect3DRMDevice_Release(d3drm_device1);
1838
1840 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
1842 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1843 ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame);
1845
1846 hr = IDirect3DRMViewport_SetCamera(viewport, tmp_frame1);
1847 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1849 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1850 ok(d3drm_frame == tmp_frame1, "Got unexpected frame %p, expected %p.\n", d3drm_frame, tmp_frame1);
1852
1854 ref4 = get_refcount((IUnknown *)d3drm1);
1855 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
1856 ref4 = get_refcount((IUnknown *)d3drm2);
1857 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
1858 ref4 = get_refcount((IUnknown *)d3drm3);
1859 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
1860 ref4 = get_refcount((IUnknown *)device1);
1861 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
1862 ref4 = get_refcount((IUnknown *)frame);
1863 ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
1864
1865 device_ref = get_refcount((IUnknown *)device3);
1866 frame_ref2 = get_refcount((IUnknown *)frame3);
1867
1868 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, 0, 0, 0, 0, &viewport2);
1869 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr);
1870 ref4 = get_refcount((IUnknown *)d3drm1);
1871 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
1872 ref4 = get_refcount((IUnknown *)d3drm2);
1873 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
1874 ref4 = get_refcount((IUnknown *)d3drm3);
1875 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
1876 ref4 = get_refcount((IUnknown *)device3);
1877 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
1878 ref4 = get_refcount((IUnknown *)frame3);
1879 ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
1880
1881 hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3);
1882 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr);
1883 ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
1884 IDirect3DRMDevice3_Release(d3drm_device3);
1885
1887 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
1888 hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3);
1889 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1890 ok(frame3 == d3drm_frame3, "Expected frame returned = %p, got %p.\n", frame3, d3drm_frame3);
1891 IDirect3DRMFrame3_Release(d3drm_frame3);
1892
1893 hr = IDirect3DRMViewport2_SetCamera(viewport2, tmp_frame3);
1894 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1895 hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3);
1896 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
1897 ok(d3drm_frame3 == tmp_frame3, "Got unexpected frame %p, expected %p.\n", d3drm_frame3, tmp_frame3);
1898 IDirect3DRMFrame3_Release(d3drm_frame3);
1899
1901 ref4 = get_refcount((IUnknown *)d3drm1);
1902 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
1903 ref4 = get_refcount((IUnknown *)d3drm2);
1904 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
1905 ref4 = get_refcount((IUnknown *)d3drm3);
1906 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
1907 ref4 = get_refcount((IUnknown *)device3);
1908 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
1909 ref4 = get_refcount((IUnknown *)frame3);
1910 ok(ref4 == frame_ref2, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
1911
1912 /* Test all failures together */
1913 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1914 hr = IDirect3DRM_CreateViewport(d3drm1, NULL, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1915 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
1916 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1917 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1918 hr = IDirect3DRM_CreateViewport(d3drm1, device1, NULL, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1919 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
1920 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1921 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1922 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport);
1923 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1924 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1925 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1926 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom, &viewport);
1927 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1928 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1929 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1930 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1, &viewport);
1931 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1932 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1933 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, NULL);
1934 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1935
1936 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1937 hr = IDirect3DRM2_CreateViewport(d3drm2, NULL, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1938 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
1939 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1940 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1941 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, NULL, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1942 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
1943 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1944 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1945 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport);
1946 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1947 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1948 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1949 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom, &viewport);
1950 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1951 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1952 viewport = (IDirect3DRMViewport *)0xdeadbeef;
1953 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1, &viewport);
1954 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1955 ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport);
1956 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, NULL);
1957 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1958
1959 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1960 hr = IDirect3DRM3_CreateViewport(d3drm3, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
1961 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
1962 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1963 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1964 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, NULL, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
1965 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
1966 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1967 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1968 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport2);
1969 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1970 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1971 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1972 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom, &viewport2);
1973 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1974 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1975 viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef;
1976 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom + 1, &viewport2);
1977 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1978 ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2);
1979 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, NULL);
1980 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
1981
1982 hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1983 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr);
1985 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
1986 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
1988 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
1990 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
1993 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
1995
1997 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
1998 vp.dwSize = sizeof(vp);
2000 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr);
2001 ok(vp.dwWidth == rc.right, "Expected viewport width = %u, got %u.\n", rc.right, vp.dwWidth);
2002 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %u, got %u.\n", rc.bottom, vp.dwHeight);
2003 ok(vp.dwX == rc.left, "Expected viewport X position = %u, got %u.\n", rc.left, vp.dwX);
2004 ok(vp.dwY == rc.top, "Expected viewport Y position = %u, got %u.\n", rc.top, vp.dwY);
2005 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2006 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2007 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2008 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2009 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2010 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2011 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2014
2015 hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
2016 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr);
2018 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2019 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2021 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2023 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2026 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2028
2030 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2031 vp.dwSize = sizeof(vp);
2033 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr);
2034 ok(vp.dwWidth == rc.right, "Expected viewport width = %u, got %u.\n", rc.right, vp.dwWidth);
2035 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %u, got %u.\n", rc.bottom, vp.dwHeight);
2036 ok(vp.dwX == rc.left, "Expected viewport X position = %u, got %u.\n", rc.left, vp.dwX);
2037 ok(vp.dwY == rc.top, "Expected viewport Y position = %u, got %u.\n", rc.top, vp.dwY);
2038 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2039 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2040 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2041 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2042 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2043 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2044 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2047
2048 hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
2049 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr);
2051 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2052 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2054 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2056 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2059 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2061
2063 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2064 vp.dwSize = sizeof(vp);
2066 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr);
2067 ok(vp.dwWidth == rc.right, "Expected viewport width = %u, got %u.\n", rc.right, vp.dwWidth);
2068 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %u, got %u.\n", rc.bottom, vp.dwHeight);
2069 ok(vp.dwX == rc.left, "Expected viewport X position = %u, got %u.\n", rc.left, vp.dwX);
2070 ok(vp.dwY == rc.top, "Expected viewport Y position = %u, got %u.\n", rc.top, vp.dwY);
2071 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2072 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2073 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2074 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2075 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2076 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2077 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2079
2080 hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMObject, (void**)&obj);
2081 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2082 ok((IDirect3DRMObject*)viewport == obj, "got object pointer %p, expected %p\n", obj, viewport);
2083
2084 hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMViewport2, (void**)&viewport2);
2085 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2086
2087 hr = IDirect3DRMViewport2_QueryInterface(viewport2, &IID_IDirect3DRMObject, (void**)&obj2);
2088 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2089 ok(obj == obj2, "got object pointer %p, expected %p\n", obj2, obj);
2090 ok((IUnknown*)viewport != (IUnknown*)viewport2, "got viewport1 %p, viewport2 %p\n", viewport, viewport2);
2091
2095
2096 test_class_name((IDirect3DRMObject *)viewport, "Viewport");
2097 test_object_name((IDirect3DRMObject *)viewport);
2098
2099 /* AppData */
2100 hr = IDirect3DRMViewport_SetAppData(viewport, 0);
2101 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2102
2103 hr = IDirect3DRMViewport_SetAppData(viewport, 0);
2104 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2105
2106 hr = IDirect3DRMViewport_SetAppData(viewport, 1);
2107 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2108
2109 hr = IDirect3DRMViewport_SetAppData(viewport, 1);
2110 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2111
2112 hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMViewport2, (void**)&viewport2);
2113 ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
2114
2116 ok(data == 1, "got %x\n", data);
2119
2120 /* IDirect3DRMViewport*::Init tests */
2121 ref1 = get_refcount((IUnknown *)d3drm1);
2122 ref2 = get_refcount((IUnknown *)d3drm2);
2123 ref3 = get_refcount((IUnknown *)d3drm3);
2124 hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_CDirect3DRMViewport, NULL, &IID_IDirect3DRMViewport,
2125 (void **)&viewport);
2126 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport interface (hr = %#x).\n", hr);
2127 ref4 = get_refcount((IUnknown *)d3drm1);
2128 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2129 ref4 = get_refcount((IUnknown *)d3drm2);
2130 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
2131 ref4 = get_refcount((IUnknown *)d3drm3);
2132 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
2133
2135 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2136 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
2137 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2139 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2141 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2142 left = right = bottom = top = 10.0f;
2143 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2144 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2145 ok(left == 10.0f, "Got unexpected left %.8e.\n", left);
2146 ok(right == 10.0f, "Got unexpected right %.8e.\n", right);
2147 ok(bottom == 10.0f, "Got unexpected bottom %.8e.\n", bottom);
2148 ok(top == 10.0f, "Got unexpected top %.8e.\n", top);
2150 ok(front == -1.0f, "Got unexpected front %.8e\n", front);
2151 back = IDirect3DRMViewport_GetBack(viewport);
2152 ok(back == -1.0f, "Got unexpected back %.8e\n", back);
2153
2154 hr = IDirect3DRMViewport_SetCamera(viewport, frame);
2155 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2156 hr = IDirect3DRMViewport_SetField(viewport, 0.5f);
2157 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2158 hr = IDirect3DRMViewport_SetPlane(viewport, -0.5f, 0.5f, -0.5f, 0.5f);
2159 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2160 hr = IDirect3DRMViewport_SetFront(viewport, 1.0f);
2161 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2162 hr = IDirect3DRMViewport_SetBack(viewport, 100.0f);
2163 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2164
2165 /* Test all failures together */
2166 hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom);
2167 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2168 hr = IDirect3DRMViewport_Init(viewport, device1, NULL, rc.left, rc.top, rc.right, rc.bottom);
2169 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2170 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2171 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2172 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom);
2173 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2174 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1);
2175 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2176
2177 device_ref = get_refcount((IUnknown *)device1);
2178 frame_ref = get_refcount((IUnknown *)frame);
2179 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom);
2180 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMViewport interface (hr = %#x).\n", hr);
2181 ref4 = get_refcount((IUnknown *)d3drm1);
2182 ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2183 ref4 = get_refcount((IUnknown *)d3drm2);
2184 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
2185 ref4 = get_refcount((IUnknown *)d3drm3);
2186 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
2187 ref4 = get_refcount((IUnknown *)device1);
2188 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
2189 ref4 = get_refcount((IUnknown *)frame);
2190 ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
2191
2192 hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
2193 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr);
2194 ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
2195 IDirect3DRMDevice_Release(d3drm_device1);
2196
2198 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2199 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2201 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2203 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2206 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2208
2210 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2211 vp.dwSize = sizeof(vp);
2213 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr);
2214 ok(vp.dwWidth == rc.right, "Expected viewport width = %u, got %u.\n", rc.right, vp.dwWidth);
2215 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %u, got %u.\n", rc.bottom, vp.dwHeight);
2216 ok(vp.dwX == rc.left, "Expected viewport X position = %u, got %u.\n", rc.left, vp.dwX);
2217 ok(vp.dwY == rc.top, "Expected viewport Y position = %u, got %u.\n", rc.top, vp.dwY);
2218 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2219 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2220 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2221 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2222 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2223 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2224 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2226
2228 ok(field == 0.5f, "Got unexpected field %.8e.\n", field);
2229 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2230 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2231 ok(left == -0.5f, "Got unexpected left %.8e.\n", left);
2232 ok(right == 0.5f, "Got unexpected right %.8e.\n", right);
2233 ok(bottom == -0.5f, "Got unexpected bottom %.8e.\n", bottom);
2234 ok(top == 0.5f, "Got unexpected top %.8e.\n", top);
2236 ok(front == 1.0f, "Got unexpected front %.8e.\n", front);
2237 back = IDirect3DRMViewport_GetBack(viewport);
2238 ok(back == 100.0f, "Got unexpected back %.8e.\n", back);
2239
2240 hr = IDirect3DRMViewport_SetField(viewport, 1.0f);
2241 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2243 ok(field == 1.0f, "Got unexpected field %.8e.\n", field);
2244 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2245 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2246 ok(left == -1.0f, "Got unexpected left %.8e.\n", left);
2247 ok(right == 1.0f, "Got unexpected right %.8e.\n", right);
2248 ok(bottom == -1.0f, "Got unexpected bottom %.8e.\n", bottom);
2249 ok(top == 1.0f, "Got unexpected top %.8e.\n", top);
2250
2251 hr = IDirect3DRMViewport_SetPlane(viewport, 5.0f, 3.0f, 2.0f, 0.0f);
2252 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2254 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2255 hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
2256 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2257 ok(left == 5.0f, "Got unexpected left %.8e.\n", left);
2258 ok(right == 3.0f, "Got unexpected right %.8e.\n", right);
2259 ok(bottom == 2.0f, "Got unexpected bottom %.8e.\n", bottom);
2260 ok(top == 0.0f, "Got unexpected top %.8e.\n", top);
2261 hr = IDirect3DRMViewport_SetFront(viewport, 2.0f);
2262 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2264 ok(front == 2.0f, "Got unexpected front %.8e.\n", front);
2265 hr = IDirect3DRMViewport_SetBack(viewport, 200.0f);
2266 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2267 back = IDirect3DRMViewport_GetBack(viewport);
2268 ok(back == 200.0f, "Got unexpected back %.8e.\n", back);
2269
2270 hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom);
2271 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2273 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2275 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2277 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2278 hr = IDirect3DRMViewport_SetField(viewport, 0.0f);
2279 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2280 hr = IDirect3DRMViewport_SetField(viewport, -1.0f);
2281 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2282 hr = IDirect3DRMViewport_SetFront(viewport, 0.0f);
2283 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2284 hr = IDirect3DRMViewport_SetFront(viewport, -1.0f);
2285 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2288 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2289 hr = IDirect3DRMViewport_SetBack(viewport, front / 2.0f);
2290 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2291
2293 ref4 = get_refcount((IUnknown *)d3drm1);
2294 todo_wine ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2295 ref4 = get_refcount((IUnknown *)d3drm2);
2296 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
2297 ref4 = get_refcount((IUnknown *)d3drm3);
2298 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
2299 ref4 = get_refcount((IUnknown *)device1);
2300 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
2301 ref4 = get_refcount((IUnknown *)frame);
2302 todo_wine ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
2303
2304 ref1 = get_refcount((IUnknown *)d3drm1);
2305 ref2 = get_refcount((IUnknown *)d3drm2);
2306 ref3 = get_refcount((IUnknown *)d3drm3);
2307 hr = IDirect3DRM3_CreateObject(d3drm2, &CLSID_CDirect3DRMViewport, NULL, &IID_IDirect3DRMViewport2,
2308 (void **)&viewport2);
2309 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMViewport2 interface (hr = %#x).\n", hr);
2310 ref4 = get_refcount((IUnknown *)d3drm1);
2311 ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2312 ref4 = get_refcount((IUnknown *)d3drm2);
2313 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
2314 ref4 = get_refcount((IUnknown *)d3drm3);
2315 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
2316
2318 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2319 hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3);
2320 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2321 hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3);
2322 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2324 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2325 left = right = bottom = top = 10.0f;
2326 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2327 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2328 ok(left == 10.0f, "Got unexpected left %.8e.\n", left);
2329 ok(right == 10.0f, "Got unexpected right %.8e.\n", right);
2330 ok(bottom == 10.0f, "Got unexpected bottom %.8e.\n", bottom);
2331 ok(top == 10.0f, "Got unexpected top %.8e.\n", top);
2333 ok(front == -1.0f, "Got unexpected front %.8e\n", front);
2334 back = IDirect3DRMViewport2_GetBack(viewport2);
2335 ok(back == -1.0f, "Got unexpected back %.8e\n", back);
2336
2337 hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3);
2338 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2339 hr = IDirect3DRMViewport2_SetField(viewport2, 0.5f);
2340 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2341 hr = IDirect3DRMViewport2_SetPlane(viewport2, -0.5f, 0.5f, -0.5f, 0.5f);
2342 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2343 hr = IDirect3DRMViewport2_SetFront(viewport2, 1.0f);
2344 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2345 hr = IDirect3DRMViewport2_SetBack(viewport2, 100.0f);
2346 ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
2347
2348 hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom);
2349 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2350 hr = IDirect3DRMViewport2_Init(viewport2, device3, NULL, rc.left, rc.top, rc.right, rc.bottom);
2351 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2352 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom + 1);
2353 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2354 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom);
2355 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2356 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom + 1);
2357 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2358
2359 device_ref = get_refcount((IUnknown *)device3);
2360 frame_ref2 = get_refcount((IUnknown *)frame3);
2361 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom);
2362 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMViewport2 interface (hr = %#x).\n", hr);
2363 ref4 = get_refcount((IUnknown *)device3);
2364 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
2365 ref4 = get_refcount((IUnknown *)frame3);
2366 ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
2367
2368 hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3);
2369 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr);
2370 ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
2371 IDirect3DRMDevice3_Release(d3drm_device3);
2372
2374 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2375 viewport_ref = get_refcount((IUnknown *)d3d_viewport);
2377 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2379 ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2382 ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
2384
2386 ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
2387 vp.dwSize = sizeof(vp);
2389 ok(SUCCEEDED(hr), "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr);
2390 ok(vp.dwWidth == rc.right, "Expected viewport width = %u, got %u.\n", rc.right, vp.dwWidth);
2391 ok(vp.dwHeight == rc.bottom, "Expected viewport height = %u, got %u.\n", rc.bottom, vp.dwHeight);
2392 ok(vp.dwX == rc.left, "Expected viewport X position = %u, got %u.\n", rc.left, vp.dwX);
2393 ok(vp.dwY == rc.top, "Expected viewport Y position = %u, got %u.\n", rc.top, vp.dwY);
2394 expected_val = (rc.right > rc.bottom) ? (rc.right / 2.0f) : (rc.bottom / 2.0f);
2395 ok(vp.dvScaleX == expected_val, "Expected dvScaleX = %f, got %f.\n", expected_val, vp.dvScaleX);
2396 ok(vp.dvScaleY == expected_val, "Expected dvScaleY = %f, got %f.\n", expected_val, vp.dvScaleY);
2397 expected_val = vp.dwWidth / (2.0f * vp.dvScaleX);
2398 ok(vp.dvMaxX == expected_val, "Expected dvMaxX = %f, got %f.\n", expected_val, vp.dvMaxX);
2399 expected_val = vp.dwHeight / (2.0f * vp.dvScaleY);
2400 ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
2402
2404 ok(field == 0.5f, "Got unexpected field %.8e.\n", field);
2405 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2406 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2407 ok(left == -0.5f, "Got unexpected left %.8e.\n", left);
2408 ok(right == 0.5f, "Got unexpected right %.8e.\n", right);
2409 ok(bottom == -0.5f, "Got unexpected bottom %.8e.\n", bottom);
2410 ok(top == 0.5f, "Got unexpected top %.8e.\n", top);
2412 ok(front == 1.0f, "Got unexpected front %.8e.\n", front);
2413 back = IDirect3DRMViewport2_GetBack(viewport2);
2414 ok(back == 100.0f, "Got unexpected back %.8e.\n", back);
2415
2416 hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f);
2417 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2419 ok(field == 1.0f, "Got unexpected field %.8e.\n", field);
2420 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2421 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2422 ok(left == -1.0f, "Got unexpected left %.8e.\n", left);
2423 ok(right == 1.0f, "Got unexpected right %.8e.\n", right);
2424 ok(bottom == -1.0f, "Got unexpected bottom %.8e.\n", bottom);
2425 ok(top == 1.0f, "Got unexpected top %.8e.\n", top);
2426
2427 hr = IDirect3DRMViewport2_SetPlane(viewport2, 5.0f, 3.0f, 2.0f, 0.0f);
2428 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2430 ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
2431 hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
2432 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2433 ok(left == 5.0f, "Got unexpected left %.8e.\n", left);
2434 ok(right == 3.0f, "Got unexpected right %.8e.\n", right);
2435 ok(bottom == 2.0f, "Got unexpected bottom %.8e.\n", bottom);
2436 ok(top == 0.0f, "Got unexpected top %.8e.\n", top);
2437 hr = IDirect3DRMViewport2_SetFront(viewport2, 2.0f);
2438 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2440 ok(front == 2.0f, "Got unexpected front %.8e.\n", front);
2441 hr = IDirect3DRMViewport2_SetBack(viewport2, 200.0f);
2442 ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
2443 back = IDirect3DRMViewport2_GetBack(viewport2);
2444 ok(back == 200.0f, "Got unexpected back %.8e.\n", back);
2445
2446 hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom);
2447 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2449 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2451 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2453 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2454 hr = IDirect3DRMViewport2_SetField(viewport2, 0.0f);
2455 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2456 hr = IDirect3DRMViewport2_SetField(viewport2, -1.0f);
2457 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2458 hr = IDirect3DRMViewport2_SetFront(viewport2, 0.0f);
2459 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2460 hr = IDirect3DRMViewport2_SetFront(viewport2, -1.0f);
2461 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2464 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2465 hr = IDirect3DRMViewport2_SetBack(viewport2, front / 2.0f);
2466 ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
2467
2469 ref4 = get_refcount((IUnknown *)d3drm1);
2470 todo_wine ok(ref4 > ref1, "Expected ref4 > ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2471 ref4 = get_refcount((IUnknown *)d3drm2);
2472 ok(ref4 == ref2, "Expected ref4 == ref2, got ref2 = %u, ref4 = %u.\n", ref2, ref4);
2473 ref4 = get_refcount((IUnknown *)d3drm3);
2474 ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
2475 ref4 = get_refcount((IUnknown *)device3);
2476 ok(ref4 == device_ref, "Expected ref4 == device_ref, got device_ref = %u, ref4 = %u.\n", device_ref, ref4);
2477 ref4 = get_refcount((IUnknown *)frame3);
2478 todo_wine ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
2479
2482 ref4 = get_refcount((IUnknown *)d3drm1);
2483 ok(ref4 > initial_ref1, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1, ref4);
2484 ref4 = get_refcount((IUnknown *)d3drm2);
2485 ok(ref4 == initial_ref2, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2, ref4);
2486 ref4 = get_refcount((IUnknown *)d3drm3);
2487 ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3, ref4);
2488 ref4 = get_refcount((IUnknown *)frame);
2489 ok(ref4 == frame_ref, "Expected ref4 == frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
2490 ref4 = get_refcount((IUnknown *)frame3);
2491 ok(ref4 == frame_ref2, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
2492
2493 IDirect3DRMFrame3_Release(tmp_frame3);
2495 ref4 = get_refcount((IUnknown *)d3drm1);
2496 ok(ref4 > initial_ref1, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1, ref4);
2497 ref4 = get_refcount((IUnknown *)d3drm2);
2498 ok(ref4 == initial_ref2, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2, ref4);
2499 ref4 = get_refcount((IUnknown *)d3drm3);
2500 ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3, ref4);
2501
2502 IDirect3DRMFrame3_Release(tmp_frame1);
2504 ref4 = get_refcount((IUnknown *)d3drm1);
2505 ok(ref4 == initial_ref1, "Expected ref4 == initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1, ref4);
2506 ref4 = get_refcount((IUnknown *)d3drm2);
2507 ok(ref4 == initial_ref2, "Expected ref4 == initial_ref2, got initial_ref2 = %u, ref4 = %u.\n", initial_ref2, ref4);
2508 ref4 = get_refcount((IUnknown *)d3drm3);
2509 ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3, ref4);
2510 IDirectDrawClipper_Release(clipper);
2511
2512 IDirect3DRM3_Release(d3drm3);
2513 IDirect3DRM2_Release(d3drm2);
2514 IDirect3DRM_Release(d3drm1);
2516}
2517
2518static void test_Light(void)
2519{
2520 IDirect3DRMObject *object;
2521 HRESULT hr;
2522 IDirect3DRM *d3drm;
2523 IDirect3DRMLight *light;
2526
2528 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
2529
2531 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr);
2532
2533 hr = IDirect3DRMLight_QueryInterface(light, &IID_IDirect3DRMObject, (void **)&object);
2534 ok(SUCCEEDED(hr), "Failed to get IDirect3DRMObject, hr %#x.\n", hr);
2536
2537 test_class_name((IDirect3DRMObject *)light, "Light");
2538 test_object_name((IDirect3DRMObject *)light);
2539
2541 ok(type == D3DRMLIGHT_SPOT, "wrong type (%u)\n", type);
2542
2544 ok(color == 0xff7f7f7f, "wrong color (%x)\n", color);
2545
2547 ok(hr == D3DRM_OK, "Cannot set type (hr = %x)\n", hr);
2549 ok(type == D3DRMLIGHT_POINT, "wrong type (%u)\n", type);
2550
2551 hr = IDirect3DRMLight_SetColor(light, 0xff180587);
2552 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
2554 ok(color == 0xff180587, "wrong color (%x)\n", color);
2555
2556 hr = IDirect3DRMLight_SetColorRGB(light, 0.5, 0.5, 0.5);
2557 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
2559 ok(color == 0xff7f7f7f, "wrong color (%x)\n", color);
2560
2562
2564}
2565
2566static void test_Material2(void)
2567{
2568 HRESULT hr;
2569 IDirect3DRM *d3drm;
2570 IDirect3DRM3 *d3drm3;
2571 IDirect3DRMMaterial2 *material2;
2572 D3DVALUE r, g, b;
2573
2575 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
2576
2577 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
2578 {
2579 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
2581 return;
2582 }
2583
2584 hr = IDirect3DRM3_CreateMaterial(d3drm3, 18.5f, &material2);
2585 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr);
2586
2587 test_class_name((IDirect3DRMObject *)material2, "Material");
2588 test_object_name((IDirect3DRMObject *)material2);
2589
2590 r = IDirect3DRMMaterial2_GetPower(material2);
2591 ok(r == 18.5f, "wrong power (%f)\n", r);
2592
2593 hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b);
2594 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
2595 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);
2596
2597 hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b);
2598 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
2599 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);
2600
2601 hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b);
2602 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
2603 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);
2604
2605 hr = IDirect3DRMMaterial2_SetPower(material2, 5.87f);
2606 ok(hr == D3DRM_OK, "Cannot set power (hr = %x)\n", hr);
2607 r = IDirect3DRMMaterial2_GetPower(material2);
2608 ok(r == 5.87f, "wrong power (%f)\n", r);
2609
2610 hr = IDirect3DRMMaterial2_SetEmissive(material2, 0.5f, 0.5f, 0.5f);
2611 ok(hr == D3DRM_OK, "Cannot set emissive (hr = %x)\n", hr);
2612 hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b);
2613 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
2614 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);
2615
2616 hr = IDirect3DRMMaterial2_SetSpecular(material2, 0.6f, 0.6f, 0.6f);
2617 ok(hr == D3DRM_OK, "Cannot set specular (hr = %x)\n", hr);
2618 hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b);
2619 ok(hr == D3DRM_OK, "Cannot get specular (hr = %x)\n", hr);
2620 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);
2621
2622 hr = IDirect3DRMMaterial2_SetAmbient(material2, 0.7f, 0.7f, 0.7f);
2623 ok(hr == D3DRM_OK, "Cannot set ambient (hr = %x)\n", hr);
2624 hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b);
2625 ok(hr == D3DRM_OK, "Cannot get ambient (hr = %x)\n", hr);
2626 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);
2627
2629
2630 IDirect3DRM3_Release(d3drm3);
2632}
2633
2634static void test_Texture(void)
2635{
2636 HRESULT hr;
2637 IDirect3DRM *d3drm1;
2638 IDirect3DRM2 *d3drm2;
2639 IDirect3DRM3 *d3drm3;
2640 IDirect3DRMTexture *texture1;
2641 IDirect3DRMTexture2 *texture2;
2642 IDirect3DRMTexture3 *texture3;
2643 IDirectDrawSurface *surface;
2644
2645 D3DRMIMAGE initimg =
2646 {
2647 2, 2, 1, 1, 32,
2648 TRUE, 2 * sizeof(DWORD), NULL, NULL,
2649 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
2650 },
2651 testimg =
2652 {
2653 0, 0, 0, 0, 0,
2654 TRUE, 0, (void *)0xcafebabe, NULL,
2655 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
2656 },
2657 *d3drm_img = NULL;
2658
2659 DWORD pixel[4] = { 20000, 30000, 10000, 0 };
2660 ULONG ref1, ref2, ref3, ref4;
2661
2662 hr = Direct3DRMCreate(&d3drm1);
2663 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
2664 ref1 = get_refcount((IUnknown *)d3drm1);
2665
2666 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
2667 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr);
2668
2669 hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3);
2670 ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
2671
2672 /* Test NULL params */
2673 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
2674 hr = IDirect3DRM_CreateTexture(d3drm1, NULL, &texture1);
2675 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2676 ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
2678 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2679
2680 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
2681 hr = IDirect3DRM2_CreateTexture(d3drm2, NULL, &texture2);
2682 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2683 ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
2685 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2686
2687 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
2688 hr = IDirect3DRM3_CreateTexture(d3drm3, NULL, &texture3);
2689 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2690 ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
2692 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2693
2694 /* Tests for validation of D3DRMIMAGE struct */
2695 hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);
2696 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr);
2697 hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);
2698 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr);
2699 hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
2700 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr);
2704
2705 testimg.rgb = 0;
2706 testimg.palette = (void *)0xdeadbeef;
2707 testimg.palette_size = 0x39;
2708 hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);
2709 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr);
2710 hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);
2711 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr);
2712 hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
2713 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr);
2717
2718 initimg.rgb = 0;
2719 texture1 = (IDirect3DRMTexture *)0xdeadbeef;
2720 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2721 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2722 ok(!texture1, "Expected texture == NULL, got %p.\n", texture1);
2723 texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
2724 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2725 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2726 ok(!texture2, "Expected texture == NULL, got %p.\n", texture2);
2727 texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
2728 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2729 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2730 ok(!texture3, "Expected texture == NULL, got %p.\n", texture3);
2731 initimg.rgb = 1;
2732 initimg.red_mask = 0;
2733 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2734 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2735 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2736 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2737 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2738 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2739 initimg.red_mask = 0x000000ff;
2740 initimg.green_mask = 0;
2741 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2742 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2743 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2744 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2745 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2746 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2747 initimg.green_mask = 0x0000ff00;
2748 initimg.blue_mask = 0;
2749 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2750 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2751 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2752 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2753 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2754 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2755 initimg.blue_mask = 0x00ff0000;
2756 initimg.buffer1 = NULL;
2757 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2758 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2759 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2760 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2761 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2762 ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr);
2763
2764 initimg.buffer1 = &pixel;
2765 hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
2766 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n", hr);
2767 ref2 = get_refcount((IUnknown *)d3drm1);
2768 ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
2769 ref3 = get_refcount((IUnknown *)d3drm2);
2770 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
2771 ref4 = get_refcount((IUnknown *)d3drm3);
2772 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1, ref4);
2773 hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
2774 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n", hr);
2775 ref2 = get_refcount((IUnknown *)d3drm1);
2776 ok(ref2 > ref1 + 1, "expected ref2 > (ref1 + 1), got ref1 = %u , ref2 = %u.\n", ref1, ref2);
2777 ref3 = get_refcount((IUnknown *)d3drm2);
2778 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
2779 ref4 = get_refcount((IUnknown *)d3drm3);
2780 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1, ref4);
2781 hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
2782 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n", hr);
2783 ref2 = get_refcount((IUnknown *)d3drm1);
2784 ok(ref2 > ref1 + 2, "expected ref2 > (ref1 + 2), got ref1 = %u , ref2 = %u.\n", ref1, ref2);
2785 ref3 = get_refcount((IUnknown *)d3drm2);
2786 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n", ref1, ref3);
2787 ref4 = get_refcount((IUnknown *)d3drm3);
2788 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n", ref1, ref4);
2789
2790 /* Created from image, GetSurface() does not work. */
2791 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, NULL);
2792 ok(hr == D3DRMERR_BADVALUE, "GetSurface() expected to fail, %#x\n", hr);
2793
2794 hr = IDirect3DRMTexture3_GetSurface(texture3, 0, &surface);
2795 ok(hr == D3DRMERR_NOTCREATEDFROMDDS, "GetSurface() expected to fail, %#x\n", hr);
2796
2797 /* Test all failures together */
2798 test_class_name((IDirect3DRMObject *)texture1, "Texture");
2799 test_class_name((IDirect3DRMObject *)texture2, "Texture");
2800 test_class_name((IDirect3DRMObject *)texture3, "Texture");
2801 test_object_name((IDirect3DRMObject *)texture1);
2802 test_object_name((IDirect3DRMObject *)texture2);
2803 test_object_name((IDirect3DRMObject *)texture3);
2804
2805 d3drm_img = IDirect3DRMTexture_GetImage(texture1);
2806 ok(!!d3drm_img, "Failed to get image.\n");
2807 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
2808
2810 ref2 = get_refcount((IUnknown *)d3drm1);
2811 ok(ref2 - 2 == ref1, "expected (ref2 - 2) == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
2812 ref3 = get_refcount((IUnknown *)d3drm2);
2813 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
2814 ref4 = get_refcount((IUnknown *)d3drm3);
2815 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2816
2817 d3drm_img = NULL;
2818 d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
2819 ok(!!d3drm_img, "Failed to get image.\n");
2820 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
2821
2823 ref2 = get_refcount((IUnknown *)d3drm1);
2824 ok(ref2 - 1 == ref1, "expected (ref2 - 1) == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
2825 ref3 = get_refcount((IUnknown *)d3drm2);
2826 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
2827 ref4 = get_refcount((IUnknown *)d3drm3);
2828 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2829
2830 d3drm_img = NULL;
2831 d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
2832 ok(!!d3drm_img, "Failed to get image.\n");
2833 ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n", &initimg, d3drm_img);
2834
2836 ref2 = get_refcount((IUnknown *)d3drm1);
2837 ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
2838 ref3 = get_refcount((IUnknown *)d3drm2);
2839 ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n", ref1, ref3);
2840 ref4 = get_refcount((IUnknown *)d3drm3);
2841 ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
2842
2843 /* InitFromImage tests */
2844 /* Tests for validation of D3DRMIMAGE struct */
2845 testimg.rgb = 1;
2846 testimg.palette = NULL;
2847 testimg.palette_size = 0;
2848 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture2,
2849 (void **)&texture2);
2850 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr);
2851 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture3,
2852 (void **)&texture3);
2853 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr);
2854 hr = IDirect3DRMTexture2_InitFromImage(texture2, &testimg);
2855 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 interface (hr = %#x)\n", hr);
2856 hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
2857 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 interface (hr = %#x)\n", hr);
2860
2861 testimg.rgb = 0;
2862 testimg.palette = (void *)0xdeadbeef;
2863 testimg.palette_size = 0x39;
2864 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture2,
2865 (void **)&texture2);
2866 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr);
2867 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture3,
2868 (void **)&texture3);
2869 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr);
2870 hr = IDirect3DRMTexture2_InitFromImage(texture2, &testimg);
2871 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 interface (hr = %#x)\n", hr);
2872 hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
2873 ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 interface (hr = %#x)\n", hr);
2876
2877 hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture2,
2878 (void **)&texture2);
2879 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n", hr);
2880 ref2 = get_refcount((IUnknown *)texture2);
2882 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2883 ref3 = get_refcount((IUnknown *)texture2);
2884 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
2885
2886 hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL, &IID_IDirect3DRMTexture3,
2887 (void **)&texture3);
2888 ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n", hr);
2889 ref2 = get_refcount((IUnknown *)texture3);
2891 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2892 ref3 = get_refcount((IUnknown *)texture3);
2893 ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n", ref2, ref3);
2894
2895 initimg.rgb = 0;
2896 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
2897 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2898 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
2899 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2900 initimg.rgb = 1;
2901 initimg.red_mask = 0;
2902 hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
2903 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2904 hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
2905 ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
2906 initimg.red_mask = 0x000000ff;
2907 initimg.green_mask = 0;