Release 1.6-rc2.
[wine/testsucceed.git] / dlls / d3drm / tests / d3drm.c
blob34b0fd04115c7c5acdf15b497ae72ea8f5280d9a
1 /*
2 * Copyright 2010, 2012 Christian Costa
3 * Copyright 2012 André Hentschel
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define COBJMACROS
21 #include <d3drm.h>
22 #include <initguid.h>
23 #include <d3drmwin.h>
25 #include "wine/test.h"
27 static HMODULE d3drm_handle = 0;
29 static HRESULT (WINAPI * pDirect3DRMCreate)(IDirect3DRM **d3drm);
31 #define CHECK_REFCOUNT(obj,rc) \
32 { \
33 int rc_new = rc; \
34 int count = get_refcount( (IUnknown *)obj ); \
35 ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
38 #define D3DRM_GET_PROC(func) \
39 p ## func = (void*)GetProcAddress(d3drm_handle, #func); \
40 if(!p ## func) { \
41 trace("GetProcAddress(%s) failed\n", #func); \
42 FreeLibrary(d3drm_handle); \
43 return FALSE; \
46 static BOOL InitFunctionPtrs(void)
48 d3drm_handle = LoadLibraryA("d3drm.dll");
50 if(!d3drm_handle)
52 skip("Could not load d3drm.dll\n");
53 return FALSE;
56 D3DRM_GET_PROC(Direct3DRMCreate)
58 return TRUE;
61 static int get_refcount(IUnknown *object)
63 IUnknown_AddRef( object );
64 return IUnknown_Release( object );
67 static BOOL match_float(float a, float b)
69 return (a - b) < 0.000001f;
72 static D3DRMMATRIX4D identity = {
73 { 1.0f, 0.0f, 0.0f, 0.0f },
74 { 0.0f, 1.0f, 0.0f, 0.0f },
75 { 0.0f, 0.0f, 1.0f, 0.0f },
76 { 0.0f, 0.0f, 0.0f, 1.0f }
79 static char data_bad_version[] =
80 "xof 0302txt 0064\n"
81 "Header Object\n"
82 "{\n"
83 "1; 2; 3;\n"
84 "}\n";
86 static char data_no_mesh[] =
87 "xof 0302txt 0064\n"
88 "Header Object\n"
89 "{\n"
90 "1; 0; 1;\n"
91 "}\n";
93 static char data_ok[] =
94 "xof 0302txt 0064\n"
95 "Header Object\n"
96 "{\n"
97 "1; 0; 1;\n"
98 "}\n"
99 "Mesh Object\n"
100 "{\n"
101 "4;\n"
102 "1.0; 0.0; 0.0;,\n"
103 "0.0; 1.0; 0.0;,\n"
104 "0.0; 0.0; 1.0;,\n"
105 "1.0; 1.0; 1.0;;\n"
106 "3;\n"
107 "3; 0, 1, 2;,\n"
108 "3; 1, 2, 3;,\n"
109 "3; 3, 1, 2;;\n"
110 "}\n";
112 static char data_full[] =
113 "xof 0302txt 0064\n"
114 "Header { 1; 0; 1; }\n"
115 "Mesh {\n"
116 " 3;\n"
117 " 0.1; 0.2; 0.3;,\n"
118 " 0.4; 0.5; 0.6;,\n"
119 " 0.7; 0.8; 0.9;;\n"
120 " 1;\n"
121 " 3; 0, 1, 2;;\n"
122 " MeshMaterialList {\n"
123 " 1; 1; 0;\n"
124 " Material {\n"
125 " 0.0; 1.0; 0.0; 1.0;;\n"
126 " 30.0;\n"
127 " 1.0; 0.0; 0.0;;\n"
128 " 0.5; 0.5; 0.5;;\n"
129 " TextureFileName {\n"
130 " \"Texture.bmp\";\n"
131 " }\n"
132 " }\n"
133 " }\n"
134 " MeshNormals {\n"
135 " 3;\n"
136 " 1.1; 1.2; 1.3;,\n"
137 " 1.4; 1.5; 1.6;,\n"
138 " 1.7; 1.8; 1.9;;\n"
139 " 1;"
140 " 3; 0, 1, 2;;\n"
141 " }\n"
142 " MeshTextureCoords {\n"
143 " 3;\n"
144 " 0.13; 0.17;,\n"
145 " 0.23; 0.27;,\n"
146 " 0.33; 0.37;;\n"
147 " }\n"
148 "}\n";
150 static char data_d3drm_load[] =
151 "xof 0302txt 0064\n"
152 "Header Object\n"
153 "{\n"
154 "1; 0; 1;\n"
155 "}\n"
156 "Mesh Object1\n"
157 "{\n"
158 " 1;\n"
159 " 0.1; 0.2; 0.3;,\n"
160 " 1;\n"
161 " 3; 0, 1, 2;;\n"
162 "}\n"
163 "Mesh Object2\n"
164 "{\n"
165 " 1;\n"
166 " 0.1; 0.2; 0.3;,\n"
167 " 1;\n"
168 " 3; 0, 1, 2;;\n"
169 "}\n"
170 "Frame Scene\n"
171 "{\n"
172 " {Object1}\n"
173 " {Object2}\n"
174 "}\n"
175 "Material\n"
176 "{\n"
177 " 0.1, 0.2, 0.3, 0.4;;\n"
178 " 0.5;\n"
179 " 0.6, 0.7, 0.8;;\n"
180 " 0.9, 1.0, 1.1;;\n"
181 "}\n";
183 static char data_frame_mesh_materials[] =
184 "xof 0302txt 0064\n"
185 "Header { 1; 0; 1; }\n"
186 "Frame {\n"
187 " Mesh mesh1 {\n"
188 " 5;\n"
189 " 0.1; 0.2; 0.3;,\n"
190 " 0.4; 0.5; 0.6;,\n"
191 " 0.7; 0.8; 0.9;,\n"
192 " 1.1; 1.2; 1.3;,\n"
193 " 1.4; 1.5; 1.6;;\n"
194 " 6;\n"
195 " 3; 0, 1, 2;,\n"
196 " 3; 0, 2, 1;,\n"
197 " 3; 1, 2, 3;,\n"
198 " 3; 1, 3, 2;,\n"
199 " 3; 2, 3, 4;,\n"
200 " 3; 2, 4, 3;;\n"
201 " MeshMaterialList {\n"
202 " 3; 6; 0, 1, 1, 2, 2, 2;\n"
203 " Material mat1 {\n"
204 " 1.0; 0.0; 0.0; 0.1;;\n"
205 " 10.0;\n"
206 " 0.11; 0.12; 0.13;;\n"
207 " 0.14; 0.15; 0.16;;\n"
208 " }\n"
209 " Material mat2 {\n"
210 " 0.0; 1.0; 0.0; 0.2;;\n"
211 " 20.0;\n"
212 " 0.21; 0.22; 0.23;;\n"
213 " 0.24; 0.25; 0.26;;\n"
214 " }\n"
215 " Material mat3 {\n"
216 " 0.0; 0.0; 1.0; 0.3;;\n"
217 " 30.0;\n"
218 " 0.31; 0.32; 0.33;;\n"
219 " 0.34; 0.35; 0.36;;\n"
220 " }\n"
221 " }\n"
222 " }\n"
223 "}\n";
225 static void test_MeshBuilder(void)
227 HRESULT hr;
228 IDirect3DRM *d3drm;
229 IDirect3DRMMeshBuilder *pMeshBuilder;
230 IDirect3DRMMesh *mesh;
231 D3DRMLOADMEMORY info;
232 int val;
233 DWORD val1, val2, val3;
234 D3DVALUE valu, valv;
235 D3DVECTOR v[3];
236 D3DVECTOR n[4];
237 DWORD f[8];
238 char name[10];
239 DWORD size;
240 D3DCOLOR color;
241 CHAR cname[64] = {0};
243 hr = pDirect3DRMCreate(&d3drm);
244 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
246 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder);
247 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
249 hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, NULL, cname);
250 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
251 hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, NULL, NULL);
252 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
253 size = 1;
254 hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, &size, cname);
255 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
256 size = sizeof(cname);
257 hr = IDirect3DRMMeshBuilder_GetClassName(pMeshBuilder, &size, cname);
258 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
259 ok(size == sizeof("Builder"), "wrong size: %u\n", size);
260 ok(!strcmp(cname, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname);
262 info.lpMemory = data_bad_version;
263 info.dSize = strlen(data_bad_version);
264 hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
265 ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr);
267 info.lpMemory = data_no_mesh;
268 info.dSize = strlen(data_no_mesh);
269 hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
270 ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr);
272 info.lpMemory = data_ok;
273 info.dSize = strlen(data_ok);
274 hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
275 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
277 size = sizeof(name);
278 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
279 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
280 ok(!strcmp(name, "Object"), "Retrieved name '%s' instead of 'Object'\n", name);
281 size = strlen("Object"); /* No space for null character */
282 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
283 ok(hr == E_INVALIDARG, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
284 hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, NULL);
285 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr);
286 size = sizeof(name);
287 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
288 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
289 ok(size == 0, "Size should be 0 instead of %u\n", size);
290 hr = IDirect3DRMMeshBuilder_SetName(pMeshBuilder, "");
291 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_SetName returned hr = %x\n", hr);
292 size = sizeof(name);
293 hr = IDirect3DRMMeshBuilder_GetName(pMeshBuilder, &size, name);
294 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned hr = %x\n", hr);
295 ok(!strcmp(name, ""), "Retrieved name '%s' instead of ''\n", name);
297 val = IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder);
298 ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
300 val = IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder);
301 ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
303 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, NULL, &val2, NULL, &val3, NULL);
304 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
305 ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1);
306 ok(val2 == 4, "Wrong number of normals %d (must be 4)\n", val2);
307 ok(val3 == 22, "Wrong number of face data bytes %d (must be 22)\n", val3);
309 /* Check that Load method generated default normals */
310 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, NULL, &val2, n, NULL, NULL);
311 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
312 ok(match_float(U1(n[0]).x, 0.577350f), "Wrong component n[0].x = %f (expected %f)\n", U1(n[0]).x, 0.577350f);
313 ok(match_float(U2(n[0]).y, 0.577350f), "Wrong component n[0].y = %f (expected %f)\n", U2(n[0]).y, 0.577350f);
314 ok(match_float(U3(n[0]).z, 0.577350f), "Wrong component n[0].z = %f (expected %f)\n", U3(n[0]).z, 0.577350f);
315 ok(match_float(U1(n[1]).x, -0.229416f), "Wrong component n[1].x = %f (expected %f)\n", U1(n[1]).x, -0.229416f);
316 ok(match_float(U2(n[1]).y, 0.688247f), "Wrong component n[1].y = %f (expected %f)\n", U2(n[1]).y, 0.688247f);
317 ok(match_float(U3(n[1]).z, 0.688247f), "Wrong component n[1].z = %f (expected %f)\n", U3(n[1]).z, 0.688247f);
318 ok(match_float(U1(n[2]).x, -0.229416f), "Wrong component n[2].x = %f (expected %f)\n", U1(n[2]).x, -0.229416f);
319 ok(match_float(U2(n[2]).y, 0.688247f), "Wrong component n[2].y = %f (expected %f)\n", U2(n[2]).y, 0.688247f);
320 ok(match_float(U3(n[2]).z, 0.688247f), "Wrong component n[2].z = %f (expected %f)\n", U3(n[2]).z, 0.688247f);
321 ok(match_float(U1(n[3]).x, -0.577350f), "Wrong component n[3].x = %f (expected %f)\n", U1(n[3]).x, -0.577350f);
322 ok(match_float(U2(n[3]).y, 0.577350f), "Wrong component n[3].y = %f (expected %f)\n", U2(n[3]).y, 0.577350f);
323 ok(match_float(U3(n[3]).z, 0.577350f), "Wrong component n[3].z = %f (expected %f)\n", U3(n[3]).z, 0.577350f);
325 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
326 valu = 1.23f;
327 valv = 3.21f;
328 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv);
329 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
330 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
331 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
332 valu = 1.23f;
333 valv = 3.21f;
334 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 1, &valu, &valv);
335 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
336 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
337 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
338 valu = 1.23f;
339 valv = 3.21f;
340 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 2, &valu, &valv);
341 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
342 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
343 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
344 valu = 1.23f;
345 valv = 3.21f;
346 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 3, &valu, &valv);
347 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
348 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
349 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
350 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 4, &valu, &valv);
351 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
353 valu = 1.23f;
354 valv = 3.21f;
355 hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 0, valu, valv);
356 ok(hr == D3DRM_OK, "Cannot set texture coordinates (hr = %x)\n", hr);
357 hr = IDirect3DRMMeshBuilder_SetTextureCoordinates(pMeshBuilder, 4, valu, valv);
358 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
360 valu = 0.0f;
361 valv = 0.0f;
362 hr = IDirect3DRMMeshBuilder_GetTextureCoordinates(pMeshBuilder, 0, &valu, &valv);
363 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
364 ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu);
365 ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv);
367 IDirect3DRMMeshBuilder_Release(pMeshBuilder);
369 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &pMeshBuilder);
370 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
372 /* No group in mesh when mesh builder is not loaded */
373 hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh);
374 ok(hr == D3DRM_OK, "CreateMesh failed returning hr = %x\n", hr);
375 if (hr == D3DRM_OK)
377 DWORD nb_groups;
379 nb_groups = IDirect3DRMMesh_GetGroupCount(mesh);
380 ok(nb_groups == 0, "GetCroupCount returned %u\n", nb_groups);
382 IDirect3DRMMesh_Release(mesh);
385 info.lpMemory = data_full;
386 info.dSize = strlen(data_full);
387 hr = IDirect3DRMMeshBuilder_Load(pMeshBuilder, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
388 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
390 val = IDirect3DRMMeshBuilder_GetVertexCount(pMeshBuilder);
391 ok(val == 3, "Wrong number of vertices %d (must be 3)\n", val);
393 val = IDirect3DRMMeshBuilder_GetFaceCount(pMeshBuilder);
394 ok(val == 1, "Wrong number of faces %d (must be 1)\n", val);
396 /* Check no buffer size and too small buffer size errors */
397 val1 = 1; val2 = 3; val3 = 8;
398 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
399 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
400 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, NULL, v, &val2, n, &val3, f);
401 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
402 val1 = 3; val2 = 1; val3 = 8;
403 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
404 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
405 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, NULL, n, &val3, f);
406 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
407 val1 = 3; val2 = 3; val3 = 1;
408 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
409 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
410 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, NULL, f);
411 ok(hr == D3DRMERR_BADVALUE, "IDirect3DRMMeshBuilder_GetVertices returned %#x\n", hr);
413 val1 = 3; val2 = 3; val3 = 8;
414 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
415 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
416 ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1);
417 ok(val2 == 3, "Wrong number of normals %d (must be 3)\n", val2);
418 ok(val3 == 8, "Wrong number of face data bytes %d (must be 8)\n", val3);
419 ok(U1(v[0]).x == 0.1f, "Wrong component v[0].x = %f (expected 0.1)\n", U1(v[0]).x);
420 ok(U2(v[0]).y == 0.2f, "Wrong component v[0].y = %f (expected 0.2)\n", U2(v[0]).y);
421 ok(U3(v[0]).z == 0.3f, "Wrong component v[0].z = %f (expected 0.3)\n", U3(v[0]).z);
422 ok(U1(v[1]).x == 0.4f, "Wrong component v[1].x = %f (expected 0.4)\n", U1(v[1]).x);
423 ok(U2(v[1]).y == 0.5f, "Wrong component v[1].y = %f (expected 0.5)\n", U2(v[1]).y);
424 ok(U3(v[1]).z == 0.6f, "Wrong component v[1].z = %f (expected 0.6)\n", U3(v[1]).z);
425 ok(U1(v[2]).x == 0.7f, "Wrong component v[2].x = %f (expected 0.7)\n", U1(v[2]).x);
426 ok(U2(v[2]).y == 0.8f, "Wrong component v[2].y = %f (expected 0.8)\n", U2(v[2]).y);
427 ok(U3(v[2]).z == 0.9f, "Wrong component v[2].z = %f (expected 0.9)\n", U3(v[2]).z);
428 ok(U1(n[0]).x == 1.1f, "Wrong component n[0].x = %f (expected 1.1)\n", U1(n[0]).x);
429 ok(U2(n[0]).y == 1.2f, "Wrong component n[0].y = %f (expected 1.2)\n", U2(n[0]).y);
430 ok(U3(n[0]).z == 1.3f, "Wrong component n[0].z = %f (expected 1.3)\n", U3(n[0]).z);
431 ok(U1(n[1]).x == 1.4f, "Wrong component n[1].x = %f (expected 1.4)\n", U1(n[1]).x);
432 ok(U2(n[1]).y == 1.5f, "Wrong component n[1].y = %f (expected 1.5)\n", U2(n[1]).y);
433 ok(U3(n[1]).z == 1.6f, "Wrong component n[1].z = %f (expected 1.6)\n", U3(n[1]).z);
434 ok(U1(n[2]).x == 1.7f, "Wrong component n[2].x = %f (expected 1.7)\n", U1(n[2]).x);
435 ok(U2(n[2]).y == 1.8f, "Wrong component n[2].y = %f (expected 1.8)\n", U2(n[2]).y);
436 ok(U3(n[2]).z == 1.9f, "Wrong component n[2].z = %f (expected 1.9)\n", U3(n[2]).z);
437 ok(f[0] == 3 , "Wrong component f[0] = %d (expected 3)\n", f[0]);
438 ok(f[1] == 0 , "Wrong component f[1] = %d (expected 0)\n", f[1]);
439 ok(f[2] == 0 , "Wrong component f[2] = %d (expected 0)\n", f[2]);
440 ok(f[3] == 1 , "Wrong component f[3] = %d (expected 1)\n", f[3]);
441 ok(f[4] == 1 , "Wrong component f[4] = %d (expected 1)\n", f[4]);
442 ok(f[5] == 2 , "Wrong component f[5] = %d (expected 2)\n", f[5]);
443 ok(f[6] == 2 , "Wrong component f[6] = %d (expected 2)\n", f[6]);
444 ok(f[7] == 0 , "Wrong component f[7] = %d (expected 0)\n", f[7]);
446 hr = IDirect3DRMMeshBuilder_CreateMesh(pMeshBuilder, &mesh);
447 ok(hr == D3DRM_OK, "CreateMesh failed returning hr = %x\n", hr);
448 if (hr == D3DRM_OK)
450 DWORD nb_groups;
451 unsigned nb_vertices, nb_faces, nb_face_vertices;
452 DWORD data_size;
453 IDirect3DRMMaterial *material = (IDirect3DRMMaterial *)0xdeadbeef;
454 IDirect3DRMTexture *texture = (IDirect3DRMTexture *)0xdeadbeef;
455 D3DVALUE values[3];
457 nb_groups = IDirect3DRMMesh_GetGroupCount(mesh);
458 ok(nb_groups == 1, "GetCroupCount returned %u\n", nb_groups);
459 hr = IDirect3DRMMesh_GetGroup(mesh, 1, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL);
460 ok(hr == D3DRMERR_BADVALUE, "GetCroup returned hr = %x\n", hr);
461 hr = IDirect3DRMMesh_GetGroup(mesh, 0, &nb_vertices, &nb_faces, &nb_face_vertices, &data_size, NULL);
462 ok(hr == D3DRM_OK, "GetCroup failed returning hr = %x\n", hr);
463 ok(nb_vertices == 3, "Wrong number of vertices %u (must be 3)\n", nb_vertices);
464 ok(nb_faces == 1, "Wrong number of faces %u (must be 1)\n", nb_faces);
465 ok(nb_face_vertices == 3, "Wrong number of vertices per face %u (must be 3)\n", nb_face_vertices);
466 ok(data_size == 3, "Wrong number of face data bytes %u (must be 3)\n", data_size);
467 color = IDirect3DRMMesh_GetGroupColor(mesh, 0);
468 ok(color == 0xff00ff00, "Wrong color returned %#x instead of %#x\n", color, 0xff00ff00);
469 hr = IDirect3DRMMesh_GetGroupTexture(mesh, 0, &texture);
470 ok(hr == D3DRM_OK, "GetCroupTexture failed returning hr = %x\n", hr);
471 ok(texture == NULL, "No texture should be present\n");
472 hr = IDirect3DRMMesh_GetGroupMaterial(mesh, 0, &material);
473 ok(hr == D3DRM_OK, "GetCroupMaterial failed returning hr = %x\n", hr);
474 ok(material != NULL, "No material present\n");
475 if ((hr == D3DRM_OK) && material)
477 hr = IDirect3DRMMaterial_GetEmissive(material, &values[0], &values[1], &values[2]);
478 ok(hr == D3DRM_OK, "GetMaterialEmissive failed returning hr = %x\n", hr);
479 ok(values[0] == 0.5f, "Emissive red component should be %f instead of %f\n", 0.5f, values[0]);
480 ok(values[1] == 0.5f, "Emissive green component should be %f instead of %f\n", 0.5f, values[1]);
481 ok(values[2] == 0.5f, "Emissive blue component should be %f instead of %f\n", 0.5f, values[2]);
482 hr = IDirect3DRMMaterial_GetSpecular(material, &values[0], &values[1], &values[2]);
483 ok(hr == D3DRM_OK, "GetMaterialEmissive failed returning hr = %x\n", hr);
484 ok(values[0] == 1.0f, "Specular red component should be %f instead of %f\n", 1.0f, values[0]);
485 ok(values[1] == 0.0f, "Specular green component should be %f instead of %f\n", 0.0f, values[1]);
486 ok(values[2] == 0.0f, "Specular blue component should be %f instead of %f\n", 0.0f, values[2]);
487 values[0] = IDirect3DRMMaterial_GetPower(material);
488 ok(values[0] == 30.0f, "Power value should be %f instead of %f\n", 30.0f, values[0]);
491 IDirect3DRMMesh_Release(mesh);
494 hr = IDirect3DRMMeshBuilder_Scale(pMeshBuilder, 2, 3 ,4);
495 ok(hr == D3DRM_OK, "Scale failed returning hr = %x\n", hr);
497 hr = IDirect3DRMMeshBuilder_GetVertices(pMeshBuilder, &val1, v, &val2, n, &val3, f);
498 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
499 ok(val2 == 3, "Wrong number of normals %d (must be 3)\n", val2);
500 ok(val1 == 3, "Wrong number of vertices %d (must be 3)\n", val1);
501 ok(U1(v[0]).x == 0.1f*2, "Wrong component v[0].x = %f (expected %f)\n", U1(v[0]).x, 0.1f*2);
502 ok(U2(v[0]).y == 0.2f*3, "Wrong component v[0].y = %f (expected %f)\n", U2(v[0]).y, 0.2f*3);
503 ok(U3(v[0]).z == 0.3f*4, "Wrong component v[0].z = %f (expected %f)\n", U3(v[0]).z, 0.3f*4);
504 ok(U1(v[1]).x == 0.4f*2, "Wrong component v[1].x = %f (expected %f)\n", U1(v[1]).x, 0.4f*2);
505 ok(U2(v[1]).y == 0.5f*3, "Wrong component v[1].y = %f (expected %f)\n", U2(v[1]).y, 0.5f*3);
506 ok(U3(v[1]).z == 0.6f*4, "Wrong component v[1].z = %f (expected %f)\n", U3(v[1]).z, 0.6f*4);
507 ok(U1(v[2]).x == 0.7f*2, "Wrong component v[2].x = %f (expected %f)\n", U1(v[2]).x, 0.7f*2);
508 ok(U2(v[2]).y == 0.8f*3, "Wrong component v[2].y = %f (expected %f)\n", U2(v[2]).y, 0.8f*3);
509 ok(U3(v[2]).z == 0.9f*4, "Wrong component v[2].z = %f (expected %f)\n", U3(v[2]).z, 0.9f*4);
510 /* Normals are not affected by Scale */
511 ok(U1(n[0]).x == 1.1f, "Wrong component n[0].x = %f (expected %f)\n", U1(n[0]).x, 1.1f);
512 ok(U2(n[0]).y == 1.2f, "Wrong component n[0].y = %f (expected %f)\n", U2(n[0]).y, 1.2f);
513 ok(U3(n[0]).z == 1.3f, "Wrong component n[0].z = %f (expected %f)\n", U3(n[0]).z, 1.3f);
514 ok(U1(n[1]).x == 1.4f, "Wrong component n[1].x = %f (expected %f)\n", U1(n[1]).x, 1.4f);
515 ok(U2(n[1]).y == 1.5f, "Wrong component n[1].y = %f (expected %f)\n", U2(n[1]).y, 1.5f);
516 ok(U3(n[1]).z == 1.6f, "Wrong component n[1].z = %f (expected %f)\n", U3(n[1]).z, 1.6f);
517 ok(U1(n[2]).x == 1.7f, "Wrong component n[2].x = %f (expected %f)\n", U1(n[2]).x, 1.7f);
518 ok(U2(n[2]).y == 1.8f, "Wrong component n[2].y = %f (expected %f)\n", U2(n[2]).y, 1.8f);
519 ok(U3(n[2]).z == 1.9f, "Wrong component n[2].z = %f (expected %f)\n", U3(n[2]).z, 1.9f);
521 IDirect3DRMMeshBuilder_Release(pMeshBuilder);
523 IDirect3DRM_Release(d3drm);
526 static void test_MeshBuilder3(void)
528 HRESULT hr;
529 IDirect3DRM *d3drm;
530 IDirect3DRM3 *d3drm3;
531 IDirect3DRMMeshBuilder3 *pMeshBuilder3;
532 D3DRMLOADMEMORY info;
533 int val;
534 DWORD val1;
535 D3DVALUE valu, valv;
536 DWORD size;
537 CHAR cname[64] = {0};
539 hr = pDirect3DRMCreate(&d3drm);
540 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
542 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
544 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
545 IDirect3DRM_Release(d3drm);
546 return;
549 hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &pMeshBuilder3);
550 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr);
552 hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, NULL, cname);
553 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
554 hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, NULL, NULL);
555 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
556 size = 1;
557 hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, &size, cname);
558 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
559 size = sizeof(cname);
560 hr = IDirect3DRMMeshBuilder3_GetClassName(pMeshBuilder3, &size, cname);
561 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
562 ok(size == sizeof("Builder"), "wrong size: %u\n", size);
563 ok(!strcmp(cname, "Builder"), "Expected cname to be \"Builder\", but got \"%s\"\n", cname);
565 info.lpMemory = data_bad_version;
566 info.dSize = strlen(data_bad_version);
567 hr = IDirect3DRMMeshBuilder3_Load(pMeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
568 ok(hr == D3DRMERR_BADFILE, "Should have returned D3DRMERR_BADFILE (hr = %x)\n", hr);
570 info.lpMemory = data_no_mesh;
571 info.dSize = strlen(data_no_mesh);
572 hr = IDirect3DRMMeshBuilder3_Load(pMeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
573 ok(hr == D3DRMERR_NOTFOUND, "Should have returned D3DRMERR_NOTFOUND (hr = %x)\n", hr);
575 info.lpMemory = data_ok;
576 info.dSize = strlen(data_ok);
577 hr = IDirect3DRMMeshBuilder3_Load(pMeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
578 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
580 val = IDirect3DRMMeshBuilder3_GetVertexCount(pMeshBuilder3);
581 ok(val == 4, "Wrong number of vertices %d (must be 4)\n", val);
583 val = IDirect3DRMMeshBuilder3_GetFaceCount(pMeshBuilder3);
584 ok(val == 3, "Wrong number of faces %d (must be 3)\n", val);
586 hr = IDirect3DRMMeshBuilder3_GetVertices(pMeshBuilder3, 0, &val1, NULL);
587 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
588 ok(val1 == 4, "Wrong number of vertices %d (must be 4)\n", val1);
590 /* Check that Load method generated default texture coordinates (0.0f, 0.0f) for each vertex */
591 valu = 1.23f;
592 valv = 3.21f;
593 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv);
594 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
595 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
596 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
597 valu = 1.23f;
598 valv = 3.21f;
599 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 1, &valu, &valv);
600 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
601 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
602 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
603 valu = 1.23f;
604 valv = 3.21f;
605 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 2, &valu, &valv);
606 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
607 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
608 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
609 valu = 1.23f;
610 valv = 3.21f;
611 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 3, &valu, &valv);
612 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
613 ok(valu == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valu);
614 ok(valv == 0.0f, "Wrong coordinate %f (must be 0.0)\n", valv);
615 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 4, &valu, &valv);
616 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
618 valu = 1.23f;
619 valv = 3.21f;
620 hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 0, valu, valv);
621 ok(hr == D3DRM_OK, "Cannot set texture coordinates (hr = %x)\n", hr);
622 hr = IDirect3DRMMeshBuilder3_SetTextureCoordinates(pMeshBuilder3, 4, valu, valv);
623 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
625 valu = 0.0f;
626 valv = 0.0f;
627 hr = IDirect3DRMMeshBuilder3_GetTextureCoordinates(pMeshBuilder3, 0, &valu, &valv);
628 ok(hr == D3DRM_OK, "Cannot get texture coordinates (hr = %x)\n", hr);
629 ok(valu == 1.23f, "Wrong coordinate %f (must be 1.23)\n", valu);
630 ok(valv == 3.21f, "Wrong coordinate %f (must be 3.21)\n", valv);
632 IDirect3DRMMeshBuilder3_Release(pMeshBuilder3);
633 IDirect3DRM3_Release(d3drm3);
634 IDirect3DRM_Release(d3drm);
637 static void test_Mesh(void)
639 HRESULT hr;
640 IDirect3DRM *d3drm;
641 IDirect3DRMMesh *mesh;
642 DWORD size;
643 CHAR cname[64] = {0};
645 hr = pDirect3DRMCreate(&d3drm);
646 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
648 hr = IDirect3DRM_CreateMesh(d3drm, &mesh);
649 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMesh interface (hr = %x)\n", hr);
651 hr = IDirect3DRMMesh_GetClassName(mesh, NULL, cname);
652 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
653 hr = IDirect3DRMMesh_GetClassName(mesh, NULL, NULL);
654 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
655 size = 1;
656 hr = IDirect3DRMMesh_GetClassName(mesh, &size, cname);
657 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
658 size = sizeof(cname);
659 hr = IDirect3DRMMesh_GetClassName(mesh, &size, cname);
660 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
661 ok(size == sizeof("Mesh"), "wrong size: %u\n", size);
662 ok(!strcmp(cname, "Mesh"), "Expected cname to be \"Mesh\", but got \"%s\"\n", cname);
664 IDirect3DRMMesh_Release(mesh);
666 IDirect3DRM_Release(d3drm);
669 static void test_Face(void)
671 HRESULT hr;
672 IDirect3DRM *d3drm;
673 IDirect3DRM2 *d3drm2;
674 IDirect3DRM3 *d3drm3;
675 IDirect3DRMMeshBuilder2 *MeshBuilder2;
676 IDirect3DRMMeshBuilder3 *MeshBuilder3;
677 IDirect3DRMFace *face1;
678 IDirect3DRMFace2 *face2;
679 IDirect3DRMFaceArray *array1;
680 D3DRMLOADMEMORY info;
681 D3DVECTOR v1[4], n1[4], v2[4], n2[4];
682 DWORD count;
683 CHAR cname[64] = {0};
684 int icount;
686 hr = pDirect3DRMCreate(&d3drm);
687 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
689 hr = IDirect3DRM_CreateFace(d3drm, &face1);
690 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr);
691 if (FAILED(hr))
693 skip("Cannot get IDirect3DRMFace interface (hr = %x), skipping tests\n", hr);
694 IDirect3DRM_Release(d3drm);
695 return;
698 hr = IDirect3DRMFace_GetClassName(face1, NULL, cname);
699 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
700 hr = IDirect3DRMFace_GetClassName(face1, NULL, NULL);
701 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
702 count = 1;
703 hr = IDirect3DRMFace_GetClassName(face1, &count, cname);
704 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
705 count = sizeof(cname);
706 hr = IDirect3DRMFace_GetClassName(face1, &count, cname);
707 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
708 ok(count == sizeof("Face"), "wrong size: %u\n", count);
709 ok(!strcmp(cname, "Face"), "Expected cname to be \"Face\", but got \"%s\"\n", cname);
711 icount = IDirect3DRMFace_GetVertexCount(face1);
712 ok(!icount, "wrong VertexCount: %i\n", icount);
714 IDirect3DRMFace_Release(face1);
716 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM2, (void **)&d3drm2)))
718 win_skip("Cannot get IDirect3DRM2 interface (hr = %x), skipping tests\n", hr);
719 IDirect3DRM_Release(d3drm);
720 return;
723 hr = IDirect3DRM2_CreateMeshBuilder(d3drm2, &MeshBuilder2);
724 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder2 interface (hr = %x)\n", hr);
726 icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2);
727 ok(!icount, "wrong FaceCount: %i\n", icount);
729 array1 = NULL;
730 hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1);
731 todo_wine
732 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
734 hr = IDirect3DRMMeshBuilder2_CreateFace(MeshBuilder2, &face1);
735 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace interface (hr = %x)\n", hr);
737 icount = IDirect3DRMMeshBuilder2_GetFaceCount(MeshBuilder2);
738 todo_wine
739 ok(icount == 1, "wrong FaceCount: %i\n", icount);
741 array1 = NULL;
742 hr = IDirect3DRMMeshBuilder2_GetFaces(MeshBuilder2, &array1);
743 todo_wine
744 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
745 todo_wine
746 ok(array1 != NULL, "pArray = %p\n", array1);
747 if (array1)
749 IDirect3DRMFace *face;
750 count = IDirect3DRMFaceArray_GetSize(array1);
751 ok(count == 1, "count = %u\n", count);
752 hr = IDirect3DRMFaceArray_GetElement(array1, 0, &face);
753 ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr);
754 IDirect3DRMFace_Release(face);
755 IDirect3DRMFaceArray_Release(array1);
758 icount = IDirect3DRMFace_GetVertexCount(face1);
759 ok(!icount, "wrong VertexCount: %i\n", icount);
761 IDirect3DRMFace_Release(face1);
762 IDirect3DRMMeshBuilder2_Release(MeshBuilder2);
764 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
766 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
767 IDirect3DRM_Release(d3drm);
768 return;
771 hr = IDirect3DRM3_CreateMeshBuilder(d3drm3, &MeshBuilder3);
772 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder3 interface (hr = %x)\n", hr);
774 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
775 ok(!icount, "wrong FaceCount: %i\n", icount);
777 hr = IDirect3DRMMeshBuilder3_CreateFace(MeshBuilder3, &face2);
778 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFace2 interface (hr = %x)\n", hr);
780 hr = IDirect3DRMFace2_GetClassName(face2, NULL, cname);
781 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
782 hr = IDirect3DRMFace2_GetClassName(face2, NULL, NULL);
783 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
784 count = 1;
785 hr = IDirect3DRMFace2_GetClassName(face2, &count, cname);
786 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
787 count = sizeof(cname);
788 hr = IDirect3DRMFace2_GetClassName(face2, &count, cname);
789 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
790 ok(count == sizeof("Face"), "wrong size: %u\n", count);
791 ok(!strcmp(cname, "Face"), "Expected cname to be \"Face\", but got \"%s\"\n", cname);
793 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
794 todo_wine
795 ok(icount == 1, "wrong FaceCount: %i\n", icount);
797 array1 = NULL;
798 hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1);
799 todo_wine
800 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
801 todo_wine
802 ok(array1 != NULL, "pArray = %p\n", array1);
803 if (array1)
805 IDirect3DRMFace *face;
806 count = IDirect3DRMFaceArray_GetSize(array1);
807 ok(count == 1, "count = %u\n", count);
808 hr = IDirect3DRMFaceArray_GetElement(array1, 0, &face);
809 ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr);
810 IDirect3DRMFace_Release(face);
811 IDirect3DRMFaceArray_Release(array1);
814 icount = IDirect3DRMFace2_GetVertexCount(face2);
815 ok(!icount, "wrong VertexCount: %i\n", icount);
817 info.lpMemory = data_ok;
818 info.dSize = strlen(data_ok);
819 hr = IDirect3DRMMeshBuilder3_Load(MeshBuilder3, &info, NULL, D3DRMLOAD_FROMMEMORY, NULL, NULL);
820 ok(hr == D3DRM_OK, "Cannot load mesh data (hr = %x)\n", hr);
822 icount = IDirect3DRMMeshBuilder3_GetVertexCount(MeshBuilder3);
823 ok(icount == 4, "Wrong number of vertices %d (must be 4)\n", icount);
825 icount = IDirect3DRMMeshBuilder3_GetNormalCount(MeshBuilder3);
826 ok(icount == 4, "Wrong number of normals %d (must be 4)\n", icount);
828 icount = IDirect3DRMMeshBuilder3_GetFaceCount(MeshBuilder3);
829 todo_wine
830 ok(icount == 4, "Wrong number of faces %d (must be 4)\n", icount);
832 count = 4;
833 hr = IDirect3DRMMeshBuilder3_GetVertices(MeshBuilder3, 0, &count, v1);
834 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
835 ok(count == 4, "Wrong number of vertices %d (must be 4)\n", count);
837 hr = IDirect3DRMMeshBuilder3_GetNormals(MeshBuilder3, 0, &count, n1);
838 ok(hr == D3DRM_OK, "Cannot get normals information (hr = %x)\n", hr);
839 ok(count == 4, "Wrong number of normals %d (must be 4)\n", count);
841 array1 = NULL;
842 hr = IDirect3DRMMeshBuilder3_GetFaces(MeshBuilder3, &array1);
843 todo_wine
844 ok(hr == D3DRM_OK, "Cannot get FaceArray (hr = %x)\n", hr);
845 todo_wine
846 ok(array1 != NULL, "pArray = %p\n", array1);
847 if (array1)
849 IDirect3DRMFace *face;
850 count = IDirect3DRMFaceArray_GetSize(array1);
851 ok(count == 4, "count = %u\n", count);
852 hr = IDirect3DRMFaceArray_GetElement(array1, 1, &face);
853 ok(hr == D3DRM_OK, "Cannot get face (hr = %x)\n", hr);
854 IDirect3DRMFace_GetVertices(face, &count, v2, n2);
855 ok(hr == D3DRM_OK, "Cannot get vertices information (hr = %x)\n", hr);
856 ok(count == 3, "Wrong number of vertices %d (must be 3)\n", count);
857 ok(U1(v2[0]).x == U1(v1[0]).x, "Wrong component v2[0].x = %f (expected %f)\n",
858 U1(v2[0]).x, U1(v1[0]).x);
859 ok(U2(v2[0]).y == U2(v1[0]).y, "Wrong component v2[0].y = %f (expected %f)\n",
860 U2(v2[0]).y, U2(v1[0]).y);
861 ok(U3(v2[0]).z == U3(v1[0]).z, "Wrong component v2[0].z = %f (expected %f)\n",
862 U3(v2[0]).z, U3(v1[0]).z);
863 ok(U1(v2[1]).x == U1(v1[1]).x, "Wrong component v2[1].x = %f (expected %f)\n",
864 U1(v2[1]).x, U1(v1[1]).x);
865 ok(U2(v2[1]).y == U2(v1[1]).y, "Wrong component v2[1].y = %f (expected %f)\n",
866 U2(v2[1]).y, U2(v1[1]).y);
867 ok(U3(v2[1]).z == U3(v1[1]).z, "Wrong component v2[1].z = %f (expected %f)\n",
868 U3(v2[1]).z, U3(v1[1]).z);
869 ok(U1(v2[2]).x == U1(v1[2]).x, "Wrong component v2[2].x = %f (expected %f)\n",
870 U1(v2[2]).x, U1(v1[2]).x);
871 ok(U2(v2[2]).y == U2(v1[2]).y, "Wrong component v2[2].y = %f (expected %f)\n",
872 U2(v2[2]).y, U2(v1[2]).y);
873 ok(U3(v2[2]).z == U3(v1[2]).z, "Wrong component v2[2].z = %f (expected %f)\n",
874 U3(v2[2]).z, U3(v1[2]).z);
876 ok(U1(n2[0]).x == U1(n1[0]).x, "Wrong component n2[0].x = %f (expected %f)\n",
877 U1(n2[0]).x, U1(n1[0]).x);
878 ok(U2(n2[0]).y == U2(n1[0]).y, "Wrong component n2[0].y = %f (expected %f)\n",
879 U2(n2[0]).y, U2(n1[0]).y);
880 ok(U3(n2[0]).z == U3(n1[0]).z, "Wrong component n2[0].z = %f (expected %f)\n",
881 U3(n2[0]).z, U3(n1[0]).z);
882 ok(U1(n2[1]).x == U1(n1[1]).x, "Wrong component n2[1].x = %f (expected %f)\n",
883 U1(n2[1]).x, U1(n1[1]).x);
884 ok(U2(n2[1]).y == U2(n1[1]).y, "Wrong component n2[1].y = %f (expected %f)\n",
885 U2(n2[1]).y, U2(n1[1]).y);
886 ok(U3(n2[1]).z == U3(n1[1]).z, "Wrong component n2[1].z = %f (expected %f)\n",
887 U3(n2[1]).z, U3(n1[1]).z);
888 ok(U1(n2[2]).x == U1(n1[2]).x, "Wrong component n2[2].x = %f (expected %f)\n",
889 U1(n2[2]).x, U1(n1[2]).x);
890 ok(U2(n2[2]).y == U2(n1[2]).y, "Wrong component n2[2].y = %f (expected %f)\n",
891 U2(n2[2]).y, U2(n1[2]).y);
892 ok(U3(n2[2]).z == U3(n1[2]).z, "Wrong component n2[2].z = %f (expected %f)\n",
893 U3(n2[2]).z, U3(n1[2]).z);
895 IDirect3DRMFace_Release(face);
896 IDirect3DRMFaceArray_Release(array1);
899 IDirect3DRMFace2_Release(face2);
900 IDirect3DRMMeshBuilder3_Release(MeshBuilder3);
901 IDirect3DRM3_Release(d3drm3);
902 IDirect3DRM2_Release(d3drm2);
903 IDirect3DRM_Release(d3drm);
906 static void test_Frame(void)
908 HRESULT hr;
909 IDirect3DRM *d3drm;
910 IDirect3DRMFrame *pFrameC;
911 IDirect3DRMFrame *pFrameP1;
912 IDirect3DRMFrame *pFrameP2;
913 IDirect3DRMFrame *pFrameTmp;
914 IDirect3DRMFrameArray *frame_array;
915 IDirect3DRMMeshBuilder *mesh_builder;
916 IDirect3DRMVisual *visual1;
917 IDirect3DRMVisual *visual_tmp;
918 IDirect3DRMVisualArray *visual_array;
919 IDirect3DRMLight *light1;
920 IDirect3DRMLight *light_tmp;
921 LPDIRECT3DRMLIGHTARRAY pLightArray;
922 D3DCOLOR color;
923 DWORD count;
924 CHAR cname[64] = {0};
926 hr = pDirect3DRMCreate(&d3drm);
927 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
929 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameC);
930 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
931 CHECK_REFCOUNT(pFrameC, 1);
933 hr = IDirect3DRMFrame_GetClassName(pFrameC, NULL, cname);
934 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
935 hr = IDirect3DRMFrame_GetClassName(pFrameC, NULL, NULL);
936 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
937 count = 1;
938 hr = IDirect3DRMFrame_GetClassName(pFrameC, &count, cname);
939 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
940 count = sizeof(cname);
941 hr = IDirect3DRMFrame_GetClassName(pFrameC, &count, cname);
942 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
943 ok(count == sizeof("Frame"), "wrong size: %u\n", count);
944 ok(!strcmp(cname, "Frame"), "Expected cname to be \"Frame\", but got \"%s\"\n", cname);
946 hr = IDirect3DRMFrame_GetParent(pFrameC, NULL);
947 ok(hr == D3DRMERR_BADVALUE, "Should fail and return D3DRM_BADVALUE (hr = %x)\n", hr);
948 pFrameTmp = (void*)0xdeadbeef;
949 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
950 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
951 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
952 CHECK_REFCOUNT(pFrameC, 1);
954 frame_array = NULL;
955 hr = IDirect3DRMFrame_GetChildren(pFrameC, &frame_array);
956 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
957 ok(!!frame_array, "frame_array = %p\n", frame_array);
958 if (frame_array)
960 count = IDirect3DRMFrameArray_GetSize(frame_array);
961 ok(count == 0, "count = %u\n", count);
962 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
963 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
964 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
965 IDirect3DRMFrameArray_Release(frame_array);
968 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP1);
969 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
971 /* GetParent with NULL pointer */
972 hr = IDirect3DRMFrame_GetParent(pFrameP1, NULL);
973 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
974 CHECK_REFCOUNT(pFrameP1, 1);
976 /* [Add/Delete]Child with NULL pointer */
977 hr = IDirect3DRMFrame_AddChild(pFrameP1, NULL);
978 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
979 CHECK_REFCOUNT(pFrameP1, 1);
981 hr = IDirect3DRMFrame_DeleteChild(pFrameP1, NULL);
982 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
983 CHECK_REFCOUNT(pFrameP1, 1);
985 /* Add child to first parent */
986 pFrameTmp = (void*)0xdeadbeef;
987 hr = IDirect3DRMFrame_GetParent(pFrameP1, &pFrameTmp);
988 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
989 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
991 hr = IDirect3DRMFrame_AddChild(pFrameP1, pFrameC);
992 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
993 CHECK_REFCOUNT(pFrameP1, 1);
994 CHECK_REFCOUNT(pFrameC, 2);
996 frame_array = NULL;
997 hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array);
998 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
999 /* In some older version of d3drm, creating IDirect3DRMFrameArray object with GetChildren does not increment refcount of children frames */
1000 ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2),
1001 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown*)pFrameC));
1002 if (frame_array)
1004 count = IDirect3DRMFrameArray_GetSize(frame_array);
1005 ok(count == 1, "count = %u\n", count);
1006 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1007 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1008 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1009 ok((get_refcount((IUnknown*)pFrameC) == 4) || broken(get_refcount((IUnknown*)pFrameC) == 3),
1010 "Invalid refcount. Expected 4 (or 3) got %d\n", get_refcount((IUnknown*)pFrameC));
1011 IDirect3DRMFrame_Release(pFrameTmp);
1012 ok((get_refcount((IUnknown*)pFrameC) == 3) || broken(get_refcount((IUnknown*)pFrameC) == 2),
1013 "Invalid refcount. Expected 3 (or 2) got %d\n", get_refcount((IUnknown*)pFrameC));
1014 IDirect3DRMFrameArray_Release(frame_array);
1015 CHECK_REFCOUNT(pFrameC, 2);
1018 pFrameTmp = (void*)0xdeadbeef;
1019 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1020 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1021 ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
1022 CHECK_REFCOUNT(pFrameP1, 2);
1024 /* Add child to second parent */
1025 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP2);
1026 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1028 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1029 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1030 CHECK_REFCOUNT(pFrameC, 2);
1032 frame_array = NULL;
1033 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1034 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1035 if (frame_array)
1037 count = IDirect3DRMFrameArray_GetSize(frame_array);
1038 ok(count == 1, "count = %u\n", count);
1039 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1040 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1041 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1042 IDirect3DRMFrame_Release(pFrameTmp);
1043 IDirect3DRMFrameArray_Release(frame_array);
1046 frame_array = NULL;
1047 hr = IDirect3DRMFrame_GetChildren(pFrameP1, &frame_array);
1048 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1049 if (frame_array)
1051 count = IDirect3DRMFrameArray_GetSize(frame_array);
1052 ok(count == 0, "count = %u\n", count);
1053 pFrameTmp = (void*)0xdeadbeef;
1054 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1055 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
1056 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1057 IDirect3DRMFrameArray_Release(frame_array);
1060 pFrameTmp = (void*)0xdeadbeef;
1061 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1062 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1063 ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp);
1064 CHECK_REFCOUNT(pFrameP2, 2);
1065 CHECK_REFCOUNT(pFrameC, 2);
1067 /* Add child again */
1068 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1069 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1070 CHECK_REFCOUNT(pFrameC, 2);
1072 frame_array = NULL;
1073 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1074 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1075 if (frame_array)
1077 count = IDirect3DRMFrameArray_GetSize(frame_array);
1078 ok(count == 1, "count = %u\n", count);
1079 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1080 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1081 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1082 IDirect3DRMFrame_Release(pFrameTmp);
1083 IDirect3DRMFrameArray_Release(frame_array);
1086 /* Delete child */
1087 hr = IDirect3DRMFrame_DeleteChild(pFrameP2, pFrameC);
1088 ok(hr == D3DRM_OK, "Cannot delete child frame (hr = %x)\n", hr);
1089 CHECK_REFCOUNT(pFrameC, 1);
1091 frame_array = NULL;
1092 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1093 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1094 if (frame_array)
1096 count = IDirect3DRMFrameArray_GetSize(frame_array);
1097 ok(count == 0, "count = %u\n", count);
1098 pFrameTmp = (void*)0xdeadbeef;
1099 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1100 ok(hr == D3DRMERR_BADVALUE, "Should have returned D3DRMERR_BADVALUE (hr = %x)\n", hr);
1101 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1102 IDirect3DRMFrameArray_Release(frame_array);
1105 pFrameTmp = (void*)0xdeadbeef;
1106 hr = IDirect3DRMFrame_GetParent(pFrameC, &pFrameTmp);
1107 ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
1108 ok(pFrameTmp == NULL, "pFrameTmp = %p\n", pFrameTmp);
1110 /* Add two children */
1111 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
1112 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1113 CHECK_REFCOUNT(pFrameC, 2);
1115 hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameP1);
1116 ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
1117 CHECK_REFCOUNT(pFrameP1, 3);
1119 frame_array = NULL;
1120 hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
1121 ok(hr == D3DRM_OK, "Cannot get children (hr = %x)\n", hr);
1122 if (frame_array)
1124 count = IDirect3DRMFrameArray_GetSize(frame_array);
1125 ok(count == 2, "count = %u\n", count);
1126 hr = IDirect3DRMFrameArray_GetElement(frame_array, 0, &pFrameTmp);
1127 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1128 ok(pFrameTmp == pFrameC, "pFrameTmp = %p\n", pFrameTmp);
1129 IDirect3DRMFrame_Release(pFrameTmp);
1130 hr = IDirect3DRMFrameArray_GetElement(frame_array, 1, &pFrameTmp);
1131 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1132 ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
1133 IDirect3DRMFrame_Release(pFrameTmp);
1134 IDirect3DRMFrameArray_Release(frame_array);
1137 /* [Add/Delete]Visual with NULL pointer */
1138 hr = IDirect3DRMFrame_AddVisual(pFrameP1, NULL);
1139 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1140 CHECK_REFCOUNT(pFrameP1, 3);
1142 hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, NULL);
1143 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1144 CHECK_REFCOUNT(pFrameP1, 3);
1146 /* Create Visual */
1147 hr = IDirect3DRM_CreateMeshBuilder(d3drm, &mesh_builder);
1148 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMeshBuilder interface (hr = %x)\n", hr);
1149 visual1 = (IDirect3DRMVisual *)mesh_builder;
1151 /* Add Visual to first parent */
1152 hr = IDirect3DRMFrame_AddVisual(pFrameP1, visual1);
1153 ok(hr == D3DRM_OK, "Cannot add visual (hr = %x)\n", hr);
1154 CHECK_REFCOUNT(pFrameP1, 3);
1155 CHECK_REFCOUNT(visual1, 2);
1157 visual_array = NULL;
1158 hr = IDirect3DRMFrame_GetVisuals(pFrameP1, &visual_array);
1159 ok(hr == D3DRM_OK, "Cannot get visuals (hr = %x)\n", hr);
1160 if (visual_array)
1162 count = IDirect3DRMVisualArray_GetSize(visual_array);
1163 ok(count == 1, "count = %u\n", count);
1164 hr = IDirect3DRMVisualArray_GetElement(visual_array, 0, &visual_tmp);
1165 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1166 ok(visual_tmp == visual1, "visual_tmp = %p\n", visual_tmp);
1167 IDirect3DRMVisual_Release(visual_tmp);
1168 IDirect3DRMVisualArray_Release(visual_array);
1171 /* Delete Visual */
1172 hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, visual1);
1173 ok(hr == D3DRM_OK, "Cannot delete visual (hr = %x)\n", hr);
1174 CHECK_REFCOUNT(pFrameP1, 3);
1175 IDirect3DRMMeshBuilder_Release(mesh_builder);
1177 /* [Add/Delete]Light with NULL pointer */
1178 hr = IDirect3DRMFrame_AddLight(pFrameP1, NULL);
1179 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1180 CHECK_REFCOUNT(pFrameP1, 3);
1182 hr = IDirect3DRMFrame_DeleteLight(pFrameP1, NULL);
1183 ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr = %x)\n", hr);
1184 CHECK_REFCOUNT(pFrameP1, 3);
1186 /* Create Light */
1187 hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.1, 0.2, 0.3, &light1);
1188 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr);
1190 /* Add Light to first parent */
1191 hr = IDirect3DRMFrame_AddLight(pFrameP1, light1);
1192 ok(hr == D3DRM_OK, "Cannot add light (hr = %x)\n", hr);
1193 CHECK_REFCOUNT(pFrameP1, 3);
1194 CHECK_REFCOUNT(light1, 2);
1196 pLightArray = NULL;
1197 hr = IDirect3DRMFrame_GetLights(pFrameP1, &pLightArray);
1198 ok(hr == D3DRM_OK, "Cannot get lights (hr = %x)\n", hr);
1199 if (pLightArray)
1201 count = IDirect3DRMLightArray_GetSize(pLightArray);
1202 ok(count == 1, "count = %u\n", count);
1203 hr = IDirect3DRMLightArray_GetElement(pLightArray, 0, &light_tmp);
1204 ok(hr == D3DRM_OK, "Cannot get element (hr = %x)\n", hr);
1205 ok(light_tmp == light1, "light_tmp = %p\n", light_tmp);
1206 IDirect3DRMLight_Release(light_tmp);
1207 IDirect3DRMLightArray_Release(pLightArray);
1210 /* Delete Light */
1211 hr = IDirect3DRMFrame_DeleteLight(pFrameP1, light1);
1212 ok(hr == D3DRM_OK, "Cannot delete light (hr = %x)\n", hr);
1213 CHECK_REFCOUNT(pFrameP1, 3);
1214 IDirect3DRMLight_Release(light1);
1216 /* Test SceneBackground on first parent */
1217 color = IDirect3DRMFrame_GetSceneBackground(pFrameP1);
1218 ok(color == 0xff000000, "wrong color (%x)\n", color);
1220 hr = IDirect3DRMFrame_SetSceneBackground(pFrameP1, 0xff180587);
1221 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
1222 color = IDirect3DRMFrame_GetSceneBackground(pFrameP1);
1223 ok(color == 0xff180587, "wrong color (%x)\n", color);
1225 hr = IDirect3DRMFrame_SetSceneBackgroundRGB(pFrameP1, 0.5, 0.5, 0.5);
1226 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
1227 color = IDirect3DRMFrame_GetSceneBackground(pFrameP1);
1228 ok(color == 0xff7f7f7f, "wrong color (%x)\n", color);
1230 /* Cleanup */
1231 IDirect3DRMFrame_Release(pFrameP2);
1232 CHECK_REFCOUNT(pFrameC, 2);
1233 CHECK_REFCOUNT(pFrameP1, 3);
1235 IDirect3DRMFrame_Release(pFrameC);
1236 IDirect3DRMFrame_Release(pFrameP1);
1238 IDirect3DRM_Release(d3drm);
1241 static void test_Viewport(void)
1243 IDirectDrawClipper *pClipper;
1244 HRESULT hr;
1245 IDirect3DRM *d3drm;
1246 IDirect3DRMDevice *device;
1247 IDirect3DRMFrame *frame;
1248 IDirect3DRMViewport *viewport;
1249 GUID driver;
1250 HWND window;
1251 RECT rc;
1252 DWORD size;
1253 CHAR cname[64] = {0};
1255 window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0);
1256 GetClientRect(window, &rc);
1258 hr = pDirect3DRMCreate(&d3drm);
1259 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1261 hr = DirectDrawCreateClipper(0, &pClipper, NULL);
1262 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr);
1264 hr = IDirectDrawClipper_SetHWnd(pClipper, 0, window);
1265 ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr);
1267 memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
1268 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm, pClipper, &driver, rc.right, rc.bottom, &device);
1269 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
1271 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &frame);
1272 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1274 hr = IDirect3DRM_CreateViewport(d3drm, device, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
1275 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr);
1277 hr = IDirect3DRMViewport_GetClassName(viewport, NULL, cname);
1278 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1279 hr = IDirect3DRMViewport_GetClassName(viewport, NULL, NULL);
1280 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1281 size = 1;
1282 hr = IDirect3DRMViewport_GetClassName(viewport, &size, cname);
1283 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1284 size = sizeof(cname);
1285 hr = IDirect3DRMViewport_GetClassName(viewport, &size, cname);
1286 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
1287 ok(size == sizeof("Viewport"), "wrong size: %u\n", size);
1288 ok(!strcmp(cname, "Viewport"), "Expected cname to be \"Viewport\", but got \"%s\"\n", cname);
1290 IDirect3DRMViewport_Release(viewport);
1291 IDirect3DRMFrame_Release(frame);
1292 IDirect3DRMDevice_Release(device);
1293 IDirectDrawClipper_Release(pClipper);
1295 IDirect3DRM_Release(d3drm);
1296 DestroyWindow(window);
1299 static void test_Light(void)
1301 HRESULT hr;
1302 IDirect3DRM *d3drm;
1303 IDirect3DRMLight *light;
1304 D3DRMLIGHTTYPE type;
1305 D3DCOLOR color;
1306 DWORD size;
1307 CHAR cname[64] = {0};
1309 hr = pDirect3DRMCreate(&d3drm);
1310 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1312 hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.5, 0.5, 0.5, &light);
1313 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMLight interface (hr = %x)\n", hr);
1315 hr = IDirect3DRMLight_GetClassName(light, NULL, cname);
1316 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1317 hr = IDirect3DRMLight_GetClassName(light, NULL, NULL);
1318 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1319 size = 1;
1320 hr = IDirect3DRMLight_GetClassName(light, &size, cname);
1321 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1322 size = sizeof(cname);
1323 hr = IDirect3DRMLight_GetClassName(light, &size, cname);
1324 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
1325 ok(size == sizeof("Light"), "wrong size: %u\n", size);
1326 ok(!strcmp(cname, "Light"), "Expected cname to be \"Light\", but got \"%s\"\n", cname);
1328 type = IDirect3DRMLight_GetType(light);
1329 ok(type == D3DRMLIGHT_SPOT, "wrong type (%u)\n", type);
1331 color = IDirect3DRMLight_GetColor(light);
1332 ok(color == 0xff7f7f7f, "wrong color (%x)\n", color);
1334 hr = IDirect3DRMLight_SetType(light, D3DRMLIGHT_POINT);
1335 ok(hr == D3DRM_OK, "Cannot set type (hr = %x)\n", hr);
1336 type = IDirect3DRMLight_GetType(light);
1337 ok(type == D3DRMLIGHT_POINT, "wrong type (%u)\n", type);
1339 hr = IDirect3DRMLight_SetColor(light, 0xff180587);
1340 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
1341 color = IDirect3DRMLight_GetColor(light);
1342 ok(color == 0xff180587, "wrong color (%x)\n", color);
1344 hr = IDirect3DRMLight_SetColorRGB(light, 0.5, 0.5, 0.5);
1345 ok(hr == D3DRM_OK, "Cannot set color (hr = %x)\n", hr);
1346 color = IDirect3DRMLight_GetColor(light);
1347 ok(color == 0xff7f7f7f, "wrong color (%x)\n", color);
1349 IDirect3DRMLight_Release(light);
1351 IDirect3DRM_Release(d3drm);
1354 static void test_Material2(void)
1356 HRESULT hr;
1357 IDirect3DRM *d3drm;
1358 IDirect3DRM3 *d3drm3;
1359 IDirect3DRMMaterial2 *material2;
1360 D3DVALUE r, g, b;
1361 DWORD size;
1362 CHAR cname[64] = {0};
1364 hr = pDirect3DRMCreate(&d3drm);
1365 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1367 if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
1369 win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
1370 IDirect3DRM_Release(d3drm);
1371 return;
1374 hr = IDirect3DRM3_CreateMaterial(d3drm3, 18.5f, &material2);
1375 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMMaterial2 interface (hr = %x)\n", hr);
1377 hr = IDirect3DRMMaterial2_GetClassName(material2, NULL, cname);
1378 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1379 hr = IDirect3DRMMaterial2_GetClassName(material2, NULL, NULL);
1380 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1381 size = 1;
1382 hr = IDirect3DRMMaterial2_GetClassName(material2, &size, cname);
1383 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1384 size = sizeof(cname);
1385 hr = IDirect3DRMMaterial2_GetClassName(material2, &size, cname);
1386 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
1387 ok(size == sizeof("Material"), "wrong size: %u\n", size);
1388 ok(!strcmp(cname, "Material"), "Expected cname to be \"Material\", but got \"%s\"\n", cname);
1390 r = IDirect3DRMMaterial2_GetPower(material2);
1391 ok(r == 18.5f, "wrong power (%f)\n", r);
1393 hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b);
1394 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
1395 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);
1397 hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b);
1398 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
1399 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);
1401 hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b);
1402 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
1403 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);
1405 hr = IDirect3DRMMaterial2_SetPower(material2, 5.87f);
1406 ok(hr == D3DRM_OK, "Cannot set power (hr = %x)\n", hr);
1407 r = IDirect3DRMMaterial2_GetPower(material2);
1408 ok(r == 5.87f, "wrong power (%f)\n", r);
1410 hr = IDirect3DRMMaterial2_SetEmissive(material2, 0.5f, 0.5f, 0.5f);
1411 ok(hr == D3DRM_OK, "Cannot set emissive (hr = %x)\n", hr);
1412 hr = IDirect3DRMMaterial2_GetEmissive(material2, &r, &g, &b);
1413 ok(hr == D3DRM_OK, "Cannot get emissive (hr = %x)\n", hr);
1414 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);
1416 hr = IDirect3DRMMaterial2_SetSpecular(material2, 0.6f, 0.6f, 0.6f);
1417 ok(hr == D3DRM_OK, "Cannot set specular (hr = %x)\n", hr);
1418 hr = IDirect3DRMMaterial2_GetSpecular(material2, &r, &g, &b);
1419 ok(hr == D3DRM_OK, "Cannot get specular (hr = %x)\n", hr);
1420 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);
1422 hr = IDirect3DRMMaterial2_SetAmbient(material2, 0.7f, 0.7f, 0.7f);
1423 ok(hr == D3DRM_OK, "Cannot set ambient (hr = %x)\n", hr);
1424 hr = IDirect3DRMMaterial2_GetAmbient(material2, &r, &g, &b);
1425 ok(hr == D3DRM_OK, "Cannot get ambient (hr = %x)\n", hr);
1426 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);
1428 IDirect3DRMMaterial2_Release(material2);
1430 IDirect3DRM3_Release(d3drm3);
1431 IDirect3DRM_Release(d3drm);
1434 static void test_Texture(void)
1436 HRESULT hr;
1437 IDirect3DRM *d3drm;
1438 IDirect3DRMTexture *texture;
1439 D3DRMIMAGE initimg = {
1440 2, 2, 1, 1, 32,
1441 TRUE, 2 * sizeof(DWORD), NULL, NULL,
1442 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
1444 DWORD pixel[4] = { 20000, 30000, 10000, 0 };
1445 DWORD size;
1446 CHAR cname[64] = {0};
1448 hr = pDirect3DRMCreate(&d3drm);
1449 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1451 initimg.buffer1 = &pixel;
1452 hr = IDirect3DRM_CreateTexture(d3drm, &initimg, &texture);
1453 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMTexture interface (hr = %x)\n", hr);
1455 hr = IDirect3DRMTexture_GetClassName(texture, NULL, cname);
1456 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1457 hr = IDirect3DRMTexture_GetClassName(texture, NULL, NULL);
1458 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1459 size = 1;
1460 hr = IDirect3DRMTexture_GetClassName(texture, &size, cname);
1461 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1462 size = sizeof(cname);
1463 hr = IDirect3DRMTexture_GetClassName(texture, &size, cname);
1464 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
1465 ok(size == sizeof("Texture"), "wrong size: %u\n", size);
1466 ok(!strcmp(cname, "Texture"), "Expected cname to be \"Texture\", but got \"%s\"\n", cname);
1468 IDirect3DRMTexture_Release(texture);
1470 IDirect3DRM_Release(d3drm);
1473 static void test_Device(void)
1475 IDirectDrawClipper *pClipper;
1476 HRESULT hr;
1477 IDirect3DRM *d3drm;
1478 IDirect3DRMDevice *device;
1479 LPDIRECT3DRMWINDEVICE pWinDevice;
1480 GUID driver;
1481 HWND window;
1482 RECT rc;
1483 DWORD size;
1484 CHAR cname[64] = {0};
1486 window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0);
1487 GetClientRect(window, &rc);
1489 hr = pDirect3DRMCreate(&d3drm);
1490 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1492 hr = DirectDrawCreateClipper(0, &pClipper, NULL);
1493 ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr);
1495 hr = IDirectDrawClipper_SetHWnd(pClipper, 0, window);
1496 ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr);
1498 memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
1499 hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm, pClipper, &driver, rc.right, rc.bottom, &device);
1500 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
1502 hr = IDirect3DRMDevice_GetClassName(device, NULL, cname);
1503 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1504 hr = IDirect3DRMDevice_GetClassName(device, NULL, NULL);
1505 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1506 size = 1;
1507 hr = IDirect3DRMDevice_GetClassName(device, &size, cname);
1508 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1509 size = sizeof(cname);
1510 hr = IDirect3DRMDevice_GetClassName(device, &size, cname);
1511 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
1512 ok(size == sizeof("Device"), "wrong size: %u\n", size);
1513 ok(!strcmp(cname, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname);
1515 /* WinDevice */
1516 hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMWinDevice, (LPVOID*)&pWinDevice);
1517 if (FAILED(hr))
1519 win_skip("Cannot get IDirect3DRMWinDevice interface (hr = %x), skipping tests\n", hr);
1520 goto cleanup;
1523 hr = IDirect3DRMWinDevice_GetClassName(pWinDevice, NULL, cname);
1524 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1525 hr = IDirect3DRMWinDevice_GetClassName(pWinDevice, NULL, NULL);
1526 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1527 size = 1;
1528 hr = IDirect3DRMWinDevice_GetClassName(pWinDevice, &size, cname);
1529 ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
1530 size = sizeof(cname);
1531 hr = IDirect3DRMWinDevice_GetClassName(pWinDevice, &size, cname);
1532 ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
1533 ok(size == sizeof("Device"), "wrong size: %u\n", size);
1534 ok(!strcmp(cname, "Device"), "Expected cname to be \"Device\", but got \"%s\"\n", cname);
1536 IDirect3DRMWinDevice_Release(pWinDevice);
1538 cleanup:
1539 IDirect3DRMDevice_Release(device);
1540 IDirectDrawClipper_Release(pClipper);
1542 IDirect3DRM_Release(d3drm);
1543 DestroyWindow(window);
1546 static void test_frame_transform(void)
1548 HRESULT hr;
1549 IDirect3DRM *d3drm;
1550 IDirect3DRMFrame *frame;
1551 D3DRMMATRIX4D matrix;
1553 hr = pDirect3DRMCreate(&d3drm);
1554 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1556 hr = IDirect3DRM_CreateFrame(d3drm, NULL, &frame);
1557 ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
1559 hr = IDirect3DRMFrame_GetTransform(frame, matrix);
1560 ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr);
1561 ok(!memcmp(matrix, identity, sizeof(D3DRMMATRIX4D)), "Returned matrix is not identity\n");
1563 IDirect3DRM_Release(d3drm);
1566 static int nb_objects = 0;
1567 static const GUID* refiids[] =
1569 &IID_IDirect3DRMMeshBuilder,
1570 &IID_IDirect3DRMMeshBuilder,
1571 &IID_IDirect3DRMFrame,
1572 &IID_IDirect3DRMMaterial /* Not taken into account and not notified */
1575 static void __cdecl object_load_callback(IDirect3DRMObject *object, REFIID objectguid, LPVOID arg)
1577 ok(object != NULL, "Arg 1 should not be null\n");
1578 ok(IsEqualGUID(objectguid, refiids[nb_objects]), "Arg 2 is incorrect\n");
1579 ok(arg == (LPVOID)0xdeadbeef, "Arg 3 should be 0xdeadbeef (got %p)\n", arg);
1580 nb_objects++;
1583 static void test_d3drm_load(void)
1585 HRESULT hr;
1586 IDirect3DRM *d3drm;
1587 D3DRMLOADMEMORY info;
1588 const GUID* req_refiids[] = { &IID_IDirect3DRMMeshBuilder, &IID_IDirect3DRMFrame, &IID_IDirect3DRMMaterial };
1590 hr = pDirect3DRMCreate(&d3drm);
1591 ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
1593 info.lpMemory = data_d3drm_load;
1594 info.dSize = strlen(data_d3drm_load);
1595 hr = IDirect3DRM_Load(d3drm, &info, NULL, (GUID **)req_refiids, 3, D3DRMLOAD_FROMMEMORY,
1596 object_load_callback, (void *)0xdeadbeef, NULL, NULL, NULL);
1597 ok(hr == D3DRM_OK, "Cannot load data (hr = %x)\n", hr);
1598 ok(nb_objects == 3, "Should have loaded 3 objects (got %d)\n", nb_objects);
1600 IDirect3DRM_Release(d3drm);
1603 IDirect3DRMMeshBuilder *mesh_builder = NULL;
1605 static void __cdecl object_load_callback_frame(IDirect3DRMObject *object, REFIID object_guid, void *arg)
1607 HRESULT hr;
1608 IDirect3DRMFrame *frame;
1609 IDirect3DRMVisualArray *array;
1610 IDirect3DRMVisual *visual;
1611 ULONG size;
1612 char name[128];
1614 hr = IDirect3DRMObject_QueryInterface(object, &IID_IDirect3DRMFrame, (void**)&frame);
1615 ok(hr == D3DRM_OK, "IDirect3DRMObject_QueryInterface returned %x\n", hr);
1617 hr = IDirect3DRMFrame_GetVisuals(frame, &array);
1618 ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetVisuals returned %x\n", hr);
1620 size = IDirect3DRMVisualArray_GetSize(array);
1621 ok(size == 1, "Wrong size %u returned, expected 1\n", size);
1623 hr = IDirect3DRMVisualArray_GetElement(array, 0, &visual);
1624 ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetElement returned %x\n", hr);
1626 hr = IDirect3DRMVisual_QueryInterface(visual, &IID_IDirect3DRMMeshBuilder, (void**)&mesh_builder);
1627 ok(hr == D3DRM_OK, "IDirect3DRMVisualArray_GetSize returned %x\n", hr);
1629 size = sizeof(name);
1630 hr = IDirect3DRMMeshBuilder_GetName(mesh_builder, &size, name);
1631 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_GetName returned %x\n", hr);
1632 ok(!strcmp(name, "mesh1"), "Wrong name %s, expected mesh1\n", name);
1634 IDirect3DRMVisual_Release(visual);
1635 IDirect3DRMVisualArray_Release(array);
1636 IDirect3DRMFrame_Release(frame);
1639 struct {
1640 int vertex_count;
1641 int face_count;
1642 int vertex_per_face;
1643 int face_data_size;
1644 DWORD color;
1645 float power;
1646 float specular[3];
1647 float emissive[3];
1648 } groups[3] = {
1649 { 4, 3, 3, 9, 0x4c0000ff, 30.0f, { 0.31f, 0.32f, 0.33f }, { 0.34f, 0.35f, 0.36f } },
1650 { 4, 2, 3, 6, 0x3300ff00, 20.0f, { 0.21f, 0.22f, 0.23f }, { 0.24f, 0.25f, 0.26f } },
1651 { 3, 1, 3, 3, 0x19ff0000, 10.0f, { 0.11f, 0.12f, 0.13f }, { 0.14f, 0.15f, 0.16f } }
1654 static void test_frame_mesh_materials(void)
1656 HRESULT hr;
1657 IDirect3DRM *d3drm;
1658 D3DRMLOADMEMORY info;
1659 const GUID *req_refiids[] = { &IID_IDirect3DRMFrame };
1660 IDirect3DRMMesh *mesh;
1661 ULONG size;
1662 IDirect3DRMMaterial *material;
1663 IDirect3DRMTexture *texture;
1664 int i;
1666 hr = pDirect3DRMCreate(&d3drm);
1667 ok(hr == D3DRM_OK, "Direct3DRMCreate returned %x\n", hr);
1669 info.lpMemory = data_frame_mesh_materials;
1670 info.dSize = strlen(data_frame_mesh_materials);
1671 hr = IDirect3DRM_Load(d3drm, &info, NULL, (GUID**)req_refiids, 1, D3DRMLOAD_FROMMEMORY, object_load_callback_frame, (void*)0xdeadbeef, NULL, NULL, NULL);
1672 ok(hr == D3DRM_OK, "Cannot load data (hr = %x)\n", hr);
1674 hr = IDirect3DRMMeshBuilder_CreateMesh(mesh_builder, &mesh);
1675 ok(hr == D3DRM_OK, "IDirect3DRMMeshBuilder_CreateMesh returned %x\n", hr);
1677 size = IDirect3DRMMesh_GetGroupCount(mesh);
1678 ok(size == 3, "Wrong size %u returned, expected 3\n", size);
1680 for (i = 0; i < size; i++)
1682 D3DVALUE red, green, blue, power;
1683 D3DCOLOR color;
1684 unsigned vertex_count, face_count, vertex_per_face;
1685 DWORD face_data_size;
1687 hr = IDirect3DRMMesh_GetGroup(mesh, i, &vertex_count, &face_count, &vertex_per_face, &face_data_size, NULL);
1688 ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMesh_GetGroup returned %x\n", i, hr);
1689 ok(vertex_count == groups[i].vertex_count, "Group %d: Wrong vertex count %d, expected %d\n", i, vertex_count, groups[i].vertex_count);
1690 ok(face_count == groups[i].face_count, "Group %d: Wrong face count %d; expected %d\n", i, face_count, groups[i].face_count);
1691 ok(vertex_per_face == groups[i].vertex_per_face, "Group %d: Wrong vertex per face %d, expected %d\n", i, vertex_per_face, groups[i].vertex_per_face);
1692 ok(face_data_size == groups[i].face_data_size, "Group %d: Wrong face data size %d, expected %d\n", i, face_data_size, groups[i].face_data_size);
1694 color = IDirect3DRMMesh_GetGroupColor(mesh, i);
1695 ok(color == groups[i].color, "Group %d: Wrong color %x, expected %x\n", i, color, groups[i].color);
1697 hr = IDirect3DRMMesh_GetGroupMaterial(mesh, i, &material);
1698 ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMesh_GetGroupMaterial returned %x\n", i, hr);
1699 ok(material != NULL, "Group %d: No material\n", i);
1700 power = IDirect3DRMMaterial_GetPower(material);
1701 ok(power == groups[i].power, "Group %d: Wrong power %f, expected %f\n", i, power, groups[i].power);
1702 hr = IDirect3DRMMaterial_GetSpecular(material, &red, &green, &blue);
1703 ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMaterial_GetSpecular returned %x\n", i, hr);
1704 ok(red == groups[i].specular[0], "Group %d: Wrong specular red %f, expected %f\n", i, red, groups[i].specular[0]);
1705 ok(green == groups[i].specular[1], "Group %d: Wrong specular green %f, pD3DRMexpected %f\n", i, green, groups[i].specular[1]);
1706 ok(blue == groups[i].specular[2], "Group %d: Wrong specular blue %f, expected %f\n", i, blue, groups[i].specular[2]);
1707 hr = IDirect3DRMMaterial_GetEmissive(material, &red, &green, &blue);
1708 ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMaterial_GetEmissive returned %x\n", i, hr);
1709 ok(red == groups[i].emissive[0], "Group %d: Wrong emissive red %f, expected %f\n", i, red, groups[i].emissive[0]);
1710 ok(green == groups[i].emissive[1], "Group %d: Wrong emissive green %f, expected %f\n", i, green, groups[i].emissive[1]);
1711 ok(blue == groups[i].emissive[2], "Group %d: Wrong emissive blue %f, expected %f\n", i, blue, groups[i].emissive[2]);
1713 hr = IDirect3DRMMesh_GetGroupTexture(mesh, i, &texture);
1714 ok(hr == D3DRM_OK, "Group %d: IDirect3DRMMesh_GetGroupTexture returned %x\n", i, hr);
1715 ok(!texture, "Group %d: Unexpected texture\n", i);
1717 if (material)
1718 IDirect3DRMMaterial_Release(material);
1719 if (texture)
1720 IDirect3DRMTexture_Release(texture);
1723 IDirect3DRMMesh_Release(mesh);
1724 IDirect3DRMMeshBuilder_Release(mesh_builder);
1725 IDirect3DRM_Release(d3drm);
1728 START_TEST(d3drm)
1730 if (!InitFunctionPtrs())
1731 return;
1733 test_MeshBuilder();
1734 test_MeshBuilder3();
1735 test_Mesh();
1736 test_Face();
1737 test_Frame();
1738 test_Device();
1739 test_Viewport();
1740 test_Light();
1741 test_Material2();
1742 test_Texture();
1743 test_frame_transform();
1744 test_d3drm_load();
1745 test_frame_mesh_materials();
1747 FreeLibrary(d3drm_handle);