[D3DRM]
[reactos.git] / reactos / dll / directx / wine / d3drm / d3drm.c
1 /*
2 * Implementation of IDirect3DRM Interface
3 *
4 * Copyright 2010, 2012 Christian Costa
5 * Copyright 2011 André Hentschel
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 "d3drm_private.h"
23
24 static const char* get_IID_string(const GUID* guid)
25 {
26 if (IsEqualGUID(guid, &IID_IDirect3DRMFrame))
27 return "IID_IDirect3DRMFrame";
28 else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame2))
29 return "IID_IDirect3DRMFrame2";
30 else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame3))
31 return "IID_IDirect3DRMFrame3";
32 else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder))
33 return "IID_IDirect3DRMMeshBuilder";
34 else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder2))
35 return "IID_IDirect3DRMMeshBuilder2";
36 else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder3))
37 return "IID_IDirect3DRMMeshBuilder3";
38
39 return "?";
40 }
41
42 struct d3drm
43 {
44 IDirect3DRM IDirect3DRM_iface;
45 IDirect3DRM2 IDirect3DRM2_iface;
46 IDirect3DRM3 IDirect3DRM3_iface;
47 LONG ref;
48 };
49
50 static inline struct d3drm *impl_from_IDirect3DRM(IDirect3DRM *iface)
51 {
52 return CONTAINING_RECORD(iface, struct d3drm, IDirect3DRM_iface);
53 }
54
55 static inline struct d3drm *impl_from_IDirect3DRM2(IDirect3DRM2 *iface)
56 {
57 return CONTAINING_RECORD(iface, struct d3drm, IDirect3DRM2_iface);
58 }
59
60 static inline struct d3drm *impl_from_IDirect3DRM3(IDirect3DRM3 *iface)
61 {
62 return CONTAINING_RECORD(iface, struct d3drm, IDirect3DRM3_iface);
63 }
64
65 static HRESULT WINAPI d3drm1_QueryInterface(IDirect3DRM *iface, REFIID riid, void **out)
66 {
67 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
68
69 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
70
71 if (IsEqualGUID(riid, &IID_IDirect3DRM)
72 || IsEqualGUID(riid, &IID_IUnknown))
73 {
74 *out = &d3drm->IDirect3DRM_iface;
75 }
76 else if (IsEqualGUID(riid, &IID_IDirect3DRM2))
77 {
78 *out = &d3drm->IDirect3DRM2_iface;
79 }
80 else if (IsEqualGUID(riid, &IID_IDirect3DRM3))
81 {
82 *out = &d3drm->IDirect3DRM3_iface;
83 }
84 else
85 {
86 *out = NULL;
87 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
88 return E_NOINTERFACE;
89 }
90
91 IUnknown_AddRef((IUnknown *)*out);
92 return S_OK;
93 }
94
95 static ULONG WINAPI d3drm1_AddRef(IDirect3DRM *iface)
96 {
97 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
98 ULONG refcount = InterlockedIncrement(&d3drm->ref);
99
100 TRACE("%p increasing refcount to %u.\n", iface, refcount);
101
102 return refcount;
103 }
104
105 static ULONG WINAPI d3drm1_Release(IDirect3DRM *iface)
106 {
107 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
108 ULONG refcount = InterlockedDecrement(&d3drm->ref);
109
110 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
111
112 if (!refcount)
113 HeapFree(GetProcessHeap(), 0, d3drm);
114
115 return refcount;
116 }
117
118 static HRESULT WINAPI d3drm1_CreateObject(IDirect3DRM *iface,
119 REFCLSID clsid, IUnknown *outer, REFIID iid, void **out)
120 {
121 FIXME("iface %p, clsid %s, outer %p, iid %s, out %p stub!\n",
122 iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
123
124 return E_NOTIMPL;
125 }
126
127 static HRESULT WINAPI d3drm1_CreateFrame(IDirect3DRM *iface,
128 IDirect3DRMFrame *parent_frame, IDirect3DRMFrame **frame)
129 {
130 TRACE("iface %p, parent_frame %p, frame %p.\n", iface, parent_frame, frame);
131
132 return Direct3DRMFrame_create(&IID_IDirect3DRMFrame, (IUnknown *)parent_frame, (IUnknown **)frame);
133 }
134
135 static HRESULT WINAPI d3drm1_CreateMesh(IDirect3DRM *iface, IDirect3DRMMesh **mesh)
136 {
137 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
138
139 TRACE("iface %p, mesh %p.\n", iface, mesh);
140
141 return IDirect3DRM3_CreateMesh(&d3drm->IDirect3DRM3_iface, mesh);
142 }
143
144 static HRESULT WINAPI d3drm1_CreateMeshBuilder(IDirect3DRM *iface, IDirect3DRMMeshBuilder **mesh_builder)
145 {
146 TRACE("iface %p, mesh_builder %p.\n", iface, mesh_builder);
147
148 return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder, (IUnknown **)mesh_builder);
149 }
150
151 static HRESULT WINAPI d3drm1_CreateFace(IDirect3DRM *iface, IDirect3DRMFace **face)
152 {
153 TRACE("iface %p, face %p.\n", iface, face);
154
155 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
156 }
157
158 static HRESULT WINAPI d3drm1_CreateAnimation(IDirect3DRM *iface, IDirect3DRMAnimation **animation)
159 {
160 FIXME("iface %p, animation %p stub!\n", iface, animation);
161
162 return E_NOTIMPL;
163 }
164
165 static HRESULT WINAPI d3drm1_CreateAnimationSet(IDirect3DRM *iface, IDirect3DRMAnimationSet **set)
166 {
167 FIXME("iface %p, set %p stub!\n", iface, set);
168
169 return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI d3drm1_CreateTexture(IDirect3DRM *iface,
173 D3DRMIMAGE *image, IDirect3DRMTexture **texture)
174 {
175 FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);
176
177 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture, (IUnknown **)texture);
178 }
179
180 static HRESULT WINAPI d3drm1_CreateLight(IDirect3DRM *iface,
181 D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
182 {
183 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
184
185 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface, type, color, light);
186
187 return IDirect3DRM3_CreateLight(&d3drm->IDirect3DRM3_iface, type, color, light);
188 }
189
190 static HRESULT WINAPI d3drm1_CreateLightRGB(IDirect3DRM *iface, D3DRMLIGHTTYPE type,
191 D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
192 {
193 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
194
195 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
196 iface, type, red, green, blue, light);
197
198 return IDirect3DRM3_CreateLightRGB(&d3drm->IDirect3DRM3_iface, type, red, green, blue, light);
199 }
200
201 static HRESULT WINAPI d3drm1_CreateMaterial(IDirect3DRM *iface,
202 D3DVALUE power, IDirect3DRMMaterial **material)
203 {
204 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
205
206 TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
207
208 return IDirect3DRM3_CreateMaterial(&d3drm->IDirect3DRM3_iface, power, (IDirect3DRMMaterial2 **)material);
209 }
210
211 static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface,
212 DWORD width, DWORD height, IDirect3DRMDevice **device)
213 {
214 FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
215
216 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
217 }
218
219 static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *guid,
220 IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice **device)
221 {
222 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p, device %p partial stub.\n",
223 iface, debugstr_guid(guid), ddraw, backbuffer, device);
224
225 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
226 }
227
228 static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface,
229 IDirect3D *d3d, IDirect3DDevice *d3d_device, IDirect3DRMDevice **device)
230 {
231 FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n",
232 iface, d3d, d3d_device, device);
233
234 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
235 }
236
237 static HRESULT WINAPI d3drm1_CreateDeviceFromClipper(IDirect3DRM *iface,
238 IDirectDrawClipper *clipper, GUID *guid, int width, int height,
239 IDirect3DRMDevice **device)
240 {
241 FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
242 iface, clipper, debugstr_guid(guid), width, height, device);
243
244 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
245 }
246
247 static HRESULT WINAPI d3drm1_CreateTextureFromSurface(IDirect3DRM *iface,
248 IDirectDrawSurface *surface, IDirect3DRMTexture **texture)
249 {
250 FIXME("iface %p, surface %p, texture %p stub!\n", iface, surface, texture);
251
252 return E_NOTIMPL;
253 }
254
255 static HRESULT WINAPI d3drm1_CreateShadow(IDirect3DRM *iface, IDirect3DRMVisual *visual,
256 IDirect3DRMLight *light, D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz,
257 IDirect3DRMVisual **shadow)
258 {
259 FIXME("iface %p, visual %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
260 iface, visual, light, px, py, pz, nx, ny, nz, shadow);
261
262 return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI d3drm1_CreateViewport(IDirect3DRM *iface, IDirect3DRMDevice *device,
266 IDirect3DRMFrame *camera, DWORD x, DWORD y, DWORD width, DWORD height, IDirect3DRMViewport **viewport)
267 {
268 FIXME("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p partial stub!\n",
269 iface, device, camera, x, y, width, height, viewport);
270
271 return Direct3DRMViewport_create(&IID_IDirect3DRMViewport, (IUnknown **)viewport);
272 }
273
274 static HRESULT WINAPI d3drm1_CreateWrap(IDirect3DRM *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame *frame,
275 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
276 D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv,
277 IDirect3DRMWrap **wrap)
278 {
279 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
280 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p stub!\n",
281 iface, type, frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
282
283 return E_NOTIMPL;
284 }
285
286 static HRESULT WINAPI d3drm1_CreateUserVisual(IDirect3DRM *iface,
287 D3DRMUSERVISUALCALLBACK cb, void *ctx, IDirect3DRMUserVisual **visual)
288 {
289 FIXME("iface %p, cb %p, ctx %p visual %p stub!\n", iface, cb, ctx, visual);
290
291 return E_NOTIMPL;
292 }
293
294 static HRESULT WINAPI d3drm1_LoadTexture(IDirect3DRM *iface,
295 const char *filename, IDirect3DRMTexture **texture)
296 {
297 FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
298
299 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture, (IUnknown **)texture);
300 }
301
302 static HRESULT WINAPI d3drm1_LoadTextureFromResource(IDirect3DRM *iface,
303 HRSRC resource, IDirect3DRMTexture **texture)
304 {
305 FIXME("iface %p, resource %p, texture %p stub!\n", iface, resource, texture);
306
307 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture, (IUnknown **)texture);
308 }
309
310 static HRESULT WINAPI d3drm1_SetSearchPath(IDirect3DRM *iface, const char *path)
311 {
312 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
313
314 return E_NOTIMPL;
315 }
316
317 static HRESULT WINAPI d3drm1_AddSearchPath(IDirect3DRM *iface, const char *path)
318 {
319 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
320
321 return E_NOTIMPL;
322 }
323
324 static HRESULT WINAPI d3drm1_GetSearchPath(IDirect3DRM *iface, DWORD *size, char *path)
325 {
326 FIXME("iface %p, size %p, path %p stub!\n", iface, size, path);
327
328 return E_NOTIMPL;
329 }
330
331 static HRESULT WINAPI d3drm1_SetDefaultTextureColors(IDirect3DRM *iface, DWORD color_count)
332 {
333 FIXME("iface %p, color_count %u stub!\n", iface, color_count);
334
335 return E_NOTIMPL;
336 }
337
338 static HRESULT WINAPI d3drm1_SetDefaultTextureShades(IDirect3DRM *iface, DWORD shade_count)
339 {
340 FIXME("iface %p, shade_count %u stub!\n", iface, shade_count);
341
342 return E_NOTIMPL;
343 }
344
345 static HRESULT WINAPI d3drm1_GetDevices(IDirect3DRM *iface, IDirect3DRMDeviceArray **array)
346 {
347 FIXME("iface %p, array %p stub!\n", iface, array);
348
349 return E_NOTIMPL;
350 }
351
352 static HRESULT WINAPI d3drm1_GetNamedObject(IDirect3DRM *iface,
353 const char *name, IDirect3DRMObject **object)
354 {
355 FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
356
357 return E_NOTIMPL;
358 }
359
360 static HRESULT WINAPI d3drm1_EnumerateObjects(IDirect3DRM *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
361 {
362 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
363
364 return E_NOTIMPL;
365 }
366
367 static HRESULT WINAPI d3drm1_Load(IDirect3DRM *iface, void *source, void *object_id, IID **iids,
368 DWORD iid_count, D3DRMLOADOPTIONS flags, D3DRMLOADCALLBACK load_cb, void *load_ctx,
369 D3DRMLOADTEXTURECALLBACK load_tex_cb, void *load_tex_ctx, IDirect3DRMFrame *parent_frame)
370 {
371 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
372 IDirect3DRMFrame3 *parent_frame3 = NULL;
373 HRESULT hr = D3DRM_OK;
374
375 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
376 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
377 iface, source, object_id, iids, iid_count, flags,
378 load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
379
380 if (parent_frame)
381 hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&parent_frame3);
382 if (SUCCEEDED(hr))
383 hr = IDirect3DRM3_Load(&d3drm->IDirect3DRM3_iface, source, object_id, iids, iid_count,
384 flags, load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame3);
385 if (parent_frame3)
386 IDirect3DRMFrame3_Release(parent_frame3);
387
388 return hr;
389 }
390
391 static HRESULT WINAPI d3drm1_Tick(IDirect3DRM *iface, D3DVALUE tick)
392 {
393 FIXME("iface %p, tick %.8e stub!\n", iface, tick);
394
395 return E_NOTIMPL;
396 }
397
398 static const struct IDirect3DRMVtbl d3drm1_vtbl =
399 {
400 d3drm1_QueryInterface,
401 d3drm1_AddRef,
402 d3drm1_Release,
403 d3drm1_CreateObject,
404 d3drm1_CreateFrame,
405 d3drm1_CreateMesh,
406 d3drm1_CreateMeshBuilder,
407 d3drm1_CreateFace,
408 d3drm1_CreateAnimation,
409 d3drm1_CreateAnimationSet,
410 d3drm1_CreateTexture,
411 d3drm1_CreateLight,
412 d3drm1_CreateLightRGB,
413 d3drm1_CreateMaterial,
414 d3drm1_CreateDevice,
415 d3drm1_CreateDeviceFromSurface,
416 d3drm1_CreateDeviceFromD3D,
417 d3drm1_CreateDeviceFromClipper,
418 d3drm1_CreateTextureFromSurface,
419 d3drm1_CreateShadow,
420 d3drm1_CreateViewport,
421 d3drm1_CreateWrap,
422 d3drm1_CreateUserVisual,
423 d3drm1_LoadTexture,
424 d3drm1_LoadTextureFromResource,
425 d3drm1_SetSearchPath,
426 d3drm1_AddSearchPath,
427 d3drm1_GetSearchPath,
428 d3drm1_SetDefaultTextureColors,
429 d3drm1_SetDefaultTextureShades,
430 d3drm1_GetDevices,
431 d3drm1_GetNamedObject,
432 d3drm1_EnumerateObjects,
433 d3drm1_Load,
434 d3drm1_Tick,
435 };
436
437 static HRESULT WINAPI d3drm2_QueryInterface(IDirect3DRM2 *iface, REFIID riid, void **out)
438 {
439 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
440
441 return d3drm1_QueryInterface(&d3drm->IDirect3DRM_iface, riid, out);
442 }
443
444 static ULONG WINAPI d3drm2_AddRef(IDirect3DRM2 *iface)
445 {
446 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
447
448 return d3drm1_AddRef(&d3drm->IDirect3DRM_iface);
449 }
450
451 static ULONG WINAPI d3drm2_Release(IDirect3DRM2 *iface)
452 {
453 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
454
455 return d3drm1_Release(&d3drm->IDirect3DRM_iface);
456 }
457
458 static HRESULT WINAPI d3drm2_CreateObject(IDirect3DRM2 *iface,
459 REFCLSID clsid, IUnknown *outer, REFIID iid, void **out)
460 {
461 FIXME("iface %p, clsid %s, outer %p, iid %s, out %p stub!\n",
462 iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
463
464 return E_NOTIMPL;
465 }
466
467 static HRESULT WINAPI d3drm2_CreateFrame(IDirect3DRM2 *iface,
468 IDirect3DRMFrame *parent_frame, IDirect3DRMFrame2 **frame)
469 {
470 TRACE("iface %p, parent_frame %p, frame %p.\n", iface, parent_frame, frame);
471
472 return Direct3DRMFrame_create(&IID_IDirect3DRMFrame2, (IUnknown*)parent_frame, (IUnknown**)frame);
473 }
474
475 static HRESULT WINAPI d3drm2_CreateMesh(IDirect3DRM2 *iface, IDirect3DRMMesh **mesh)
476 {
477 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
478
479 TRACE("iface %p, mesh %p.\n", iface, mesh);
480
481 return IDirect3DRM3_CreateMesh(&d3drm->IDirect3DRM3_iface, mesh);
482 }
483
484 static HRESULT WINAPI d3drm2_CreateMeshBuilder(IDirect3DRM2 *iface, IDirect3DRMMeshBuilder2 **mesh_builder)
485 {
486 TRACE("iface %p, mesh_builder %p.\n", iface, mesh_builder);
487
488 return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder2, (IUnknown **)mesh_builder);
489 }
490
491 static HRESULT WINAPI d3drm2_CreateFace(IDirect3DRM2 *iface, IDirect3DRMFace **face)
492 {
493 TRACE("iface %p, face %p.\n", iface, face);
494
495 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
496 }
497
498 static HRESULT WINAPI d3drm2_CreateAnimation(IDirect3DRM2 *iface, IDirect3DRMAnimation **animation)
499 {
500 FIXME("iface %p, animation %p stub!\n", iface, animation);
501
502 return E_NOTIMPL;
503 }
504
505 static HRESULT WINAPI d3drm2_CreateAnimationSet(IDirect3DRM2 *iface, IDirect3DRMAnimationSet **set)
506 {
507 FIXME("iface %p, set %p stub!\n", iface, set);
508
509 return E_NOTIMPL;
510 }
511
512 static HRESULT WINAPI d3drm2_CreateTexture(IDirect3DRM2 *iface,
513 D3DRMIMAGE *image, IDirect3DRMTexture2 **texture)
514 {
515 FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);
516
517 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture2, (IUnknown **)texture);
518 }
519
520 static HRESULT WINAPI d3drm2_CreateLight(IDirect3DRM2 *iface,
521 D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
522 {
523 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
524
525 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface, type, color, light);
526
527 return IDirect3DRM3_CreateLight(&d3drm->IDirect3DRM3_iface, type, color, light);
528 }
529
530 static HRESULT WINAPI d3drm2_CreateLightRGB(IDirect3DRM2 *iface, D3DRMLIGHTTYPE type,
531 D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
532 {
533 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
534
535 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
536 iface, type, red, green, blue, light);
537
538 return IDirect3DRM3_CreateLightRGB(&d3drm->IDirect3DRM3_iface, type, red, green, blue, light);
539 }
540
541 static HRESULT WINAPI d3drm2_CreateMaterial(IDirect3DRM2 *iface,
542 D3DVALUE power, IDirect3DRMMaterial **material)
543 {
544 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
545
546 TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
547
548 return IDirect3DRM3_CreateMaterial(&d3drm->IDirect3DRM3_iface, power, (IDirect3DRMMaterial2 **)material);
549 }
550
551 static HRESULT WINAPI d3drm2_CreateDevice(IDirect3DRM2 *iface,
552 DWORD width, DWORD height, IDirect3DRMDevice2 **device)
553 {
554 FIXME("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
555
556 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
557 }
558
559 static HRESULT WINAPI d3drm2_CreateDeviceFromSurface(IDirect3DRM2 *iface, GUID *guid,
560 IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice2 **device)
561 {
562 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p, device %p partial stub.\n",
563 iface, debugstr_guid(guid), ddraw, backbuffer, device);
564
565 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
566 }
567
568 static HRESULT WINAPI d3drm2_CreateDeviceFromD3D(IDirect3DRM2 *iface,
569 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device, IDirect3DRMDevice2 **device)
570 {
571 FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n",
572 iface, d3d, d3d_device, device);
573
574 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
575 }
576
577 static HRESULT WINAPI d3drm2_CreateDeviceFromClipper(IDirect3DRM2 *iface,
578 IDirectDrawClipper *clipper, GUID *guid, int width, int height,
579 IDirect3DRMDevice2 **device)
580 {
581 FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p partial stub.\n",
582 iface, clipper, debugstr_guid(guid), width, height, device);
583
584 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
585 }
586
587 static HRESULT WINAPI d3drm2_CreateTextureFromSurface(IDirect3DRM2 *iface,
588 IDirectDrawSurface *surface, IDirect3DRMTexture2 **texture)
589 {
590 FIXME("iface %p, surface %p, texture %p stub!\n", iface, surface, texture);
591
592 return E_NOTIMPL;
593 }
594
595 static HRESULT WINAPI d3drm2_CreateShadow(IDirect3DRM2 *iface, IDirect3DRMVisual *visual,
596 IDirect3DRMLight *light, D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz,
597 IDirect3DRMVisual **shadow)
598 {
599 FIXME("iface %p, visual %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
600 iface, visual, light, px, py, pz, nx, ny, nz, shadow);
601
602 return E_NOTIMPL;
603 }
604
605 static HRESULT WINAPI d3drm2_CreateViewport(IDirect3DRM2 *iface, IDirect3DRMDevice *device,
606 IDirect3DRMFrame *camera, DWORD x, DWORD y, DWORD width, DWORD height, IDirect3DRMViewport **viewport)
607 {
608 FIXME("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p partial stub!\n",
609 iface, device, camera, x, y, width, height, viewport);
610
611 return Direct3DRMViewport_create(&IID_IDirect3DRMViewport, (IUnknown **)viewport);
612 }
613
614 static HRESULT WINAPI d3drm2_CreateWrap(IDirect3DRM2 *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame *frame,
615 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
616 D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv,
617 IDirect3DRMWrap **wrap)
618 {
619 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
620 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p stub!\n",
621 iface, type, frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
622
623 return E_NOTIMPL;
624 }
625
626 static HRESULT WINAPI d3drm2_CreateUserVisual(IDirect3DRM2 *iface,
627 D3DRMUSERVISUALCALLBACK cb, void *ctx, IDirect3DRMUserVisual **visual)
628 {
629 FIXME("iface %p, cb %p, ctx %p, visual %p stub!\n", iface, cb, ctx, visual);
630
631 return E_NOTIMPL;
632 }
633
634 static HRESULT WINAPI d3drm2_LoadTexture(IDirect3DRM2 *iface,
635 const char *filename, IDirect3DRMTexture2 **texture)
636 {
637 FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
638
639 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture2, (IUnknown **)texture);
640 }
641
642 static HRESULT WINAPI d3drm2_LoadTextureFromResource(IDirect3DRM2 *iface, HMODULE module,
643 const char *resource_name, const char *resource_type, IDirect3DRMTexture2 **texture)
644 {
645 FIXME("iface %p, resource_name %s, resource_type %s, texture %p stub!\n",
646 iface, debugstr_a(resource_name), debugstr_a(resource_type), texture);
647
648 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture2, (IUnknown **)texture);
649 }
650
651 static HRESULT WINAPI d3drm2_SetSearchPath(IDirect3DRM2 *iface, const char *path)
652 {
653 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
654
655 return E_NOTIMPL;
656 }
657
658 static HRESULT WINAPI d3drm2_AddSearchPath(IDirect3DRM2 *iface, const char *path)
659 {
660 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
661
662 return E_NOTIMPL;
663 }
664
665 static HRESULT WINAPI d3drm2_GetSearchPath(IDirect3DRM2 *iface, DWORD *size, char *path)
666 {
667 FIXME("iface %p, size %p, path %p stub!\n", iface, size, path);
668
669 return E_NOTIMPL;
670 }
671
672 static HRESULT WINAPI d3drm2_SetDefaultTextureColors(IDirect3DRM2 *iface, DWORD color_count)
673 {
674 FIXME("iface %p, color_count %u stub!\n", iface, color_count);
675
676 return E_NOTIMPL;
677 }
678
679 static HRESULT WINAPI d3drm2_SetDefaultTextureShades(IDirect3DRM2 *iface, DWORD shade_count)
680 {
681 FIXME("iface %p, shade_count %u stub!\n", iface, shade_count);
682
683 return E_NOTIMPL;
684 }
685
686 static HRESULT WINAPI d3drm2_GetDevices(IDirect3DRM2 *iface, IDirect3DRMDeviceArray **array)
687 {
688 FIXME("iface %p, array %p stub!\n", iface, array);
689
690 return E_NOTIMPL;
691 }
692
693 static HRESULT WINAPI d3drm2_GetNamedObject(IDirect3DRM2 *iface,
694 const char *name, IDirect3DRMObject **object)
695 {
696 FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
697
698 return E_NOTIMPL;
699 }
700
701 static HRESULT WINAPI d3drm2_EnumerateObjects(IDirect3DRM2 *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
702 {
703 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
704
705 return E_NOTIMPL;
706 }
707
708 static HRESULT WINAPI d3drm2_Load(IDirect3DRM2 *iface, void *source, void *object_id, IID **iids,
709 DWORD iid_count, D3DRMLOADOPTIONS flags, D3DRMLOADCALLBACK load_cb, void *load_ctx,
710 D3DRMLOADTEXTURECALLBACK load_tex_cb, void *load_tex_ctx, IDirect3DRMFrame *parent_frame)
711 {
712 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
713 IDirect3DRMFrame3 *parent_frame3 = NULL;
714 HRESULT hr = D3DRM_OK;
715
716 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
717 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
718 iface, source, object_id, iids, iid_count, flags,
719 load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
720
721 if (parent_frame)
722 hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&parent_frame3);
723 if (SUCCEEDED(hr))
724 hr = IDirect3DRM3_Load(&d3drm->IDirect3DRM3_iface, source, object_id, iids, iid_count,
725 flags, load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame3);
726 if (parent_frame3)
727 IDirect3DRMFrame3_Release(parent_frame3);
728
729 return hr;
730 }
731
732 static HRESULT WINAPI d3drm2_Tick(IDirect3DRM2 *iface, D3DVALUE tick)
733 {
734 FIXME("iface %p, tick %.8e stub!\n", iface, tick);
735
736 return E_NOTIMPL;
737 }
738
739 static HRESULT WINAPI d3drm2_CreateProgressiveMesh(IDirect3DRM2 *iface, IDirect3DRMProgressiveMesh **mesh)
740 {
741 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
742
743 return E_NOTIMPL;
744 }
745
746 static const struct IDirect3DRM2Vtbl d3drm2_vtbl =
747 {
748 d3drm2_QueryInterface,
749 d3drm2_AddRef,
750 d3drm2_Release,
751 d3drm2_CreateObject,
752 d3drm2_CreateFrame,
753 d3drm2_CreateMesh,
754 d3drm2_CreateMeshBuilder,
755 d3drm2_CreateFace,
756 d3drm2_CreateAnimation,
757 d3drm2_CreateAnimationSet,
758 d3drm2_CreateTexture,
759 d3drm2_CreateLight,
760 d3drm2_CreateLightRGB,
761 d3drm2_CreateMaterial,
762 d3drm2_CreateDevice,
763 d3drm2_CreateDeviceFromSurface,
764 d3drm2_CreateDeviceFromD3D,
765 d3drm2_CreateDeviceFromClipper,
766 d3drm2_CreateTextureFromSurface,
767 d3drm2_CreateShadow,
768 d3drm2_CreateViewport,
769 d3drm2_CreateWrap,
770 d3drm2_CreateUserVisual,
771 d3drm2_LoadTexture,
772 d3drm2_LoadTextureFromResource,
773 d3drm2_SetSearchPath,
774 d3drm2_AddSearchPath,
775 d3drm2_GetSearchPath,
776 d3drm2_SetDefaultTextureColors,
777 d3drm2_SetDefaultTextureShades,
778 d3drm2_GetDevices,
779 d3drm2_GetNamedObject,
780 d3drm2_EnumerateObjects,
781 d3drm2_Load,
782 d3drm2_Tick,
783 d3drm2_CreateProgressiveMesh,
784 };
785
786 static HRESULT WINAPI d3drm3_QueryInterface(IDirect3DRM3 *iface, REFIID riid, void **out)
787 {
788 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
789
790 return d3drm1_QueryInterface(&d3drm->IDirect3DRM_iface, riid, out);
791 }
792
793 static ULONG WINAPI d3drm3_AddRef(IDirect3DRM3 *iface)
794 {
795 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
796
797 return d3drm1_AddRef(&d3drm->IDirect3DRM_iface);
798 }
799
800 static ULONG WINAPI d3drm3_Release(IDirect3DRM3 *iface)
801 {
802 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
803
804 return d3drm1_Release(&d3drm->IDirect3DRM_iface);
805 }
806
807 static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
808 REFCLSID clsid, IUnknown *outer, REFIID iid, void **out)
809 {
810 FIXME("iface %p, clsid %s, outer %p, iid %s, out %p stub!\n",
811 iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
812
813 return E_NOTIMPL;
814 }
815
816 static HRESULT WINAPI d3drm3_CreateFrame(IDirect3DRM3 *iface,
817 IDirect3DRMFrame3 *parent, IDirect3DRMFrame3 **frame)
818 {
819 TRACE("iface %p, parent %p, frame %p.\n", iface, parent, frame);
820
821 return Direct3DRMFrame_create(&IID_IDirect3DRMFrame3, (IUnknown *)parent, (IUnknown **)frame);
822 }
823
824 static HRESULT WINAPI d3drm3_CreateMesh(IDirect3DRM3 *iface, IDirect3DRMMesh **mesh)
825 {
826 TRACE("iface %p, mesh %p.\n", iface, mesh);
827
828 return Direct3DRMMesh_create(mesh);
829 }
830
831 static HRESULT WINAPI d3drm3_CreateMeshBuilder(IDirect3DRM3 *iface, IDirect3DRMMeshBuilder3 **mesh_builder)
832 {
833 TRACE("iface %p, mesh_builder %p.\n", iface, mesh_builder);
834
835 return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder3, (IUnknown **)mesh_builder);
836 }
837
838 static HRESULT WINAPI d3drm3_CreateFace(IDirect3DRM3 *iface, IDirect3DRMFace2 **face)
839 {
840 TRACE("iface %p, face %p.\n", iface, face);
841
842 return Direct3DRMFace_create(&IID_IDirect3DRMFace2, (IUnknown **)face);
843 }
844
845 static HRESULT WINAPI d3drm3_CreateAnimation(IDirect3DRM3 *iface, IDirect3DRMAnimation2 **animation)
846 {
847 FIXME("iface %p, animation %p stub!\n", iface, animation);
848
849 return E_NOTIMPL;
850 }
851
852 static HRESULT WINAPI d3drm3_CreateAnimationSet(IDirect3DRM3 *iface, IDirect3DRMAnimationSet2 **set)
853 {
854 FIXME("iface %p, set %p stub!\n", iface, set);
855
856 return E_NOTIMPL;
857 }
858
859 static HRESULT WINAPI d3drm3_CreateTexture(IDirect3DRM3 *iface,
860 D3DRMIMAGE *image, IDirect3DRMTexture3 **texture)
861 {
862 FIXME("iface %p, image %p, texture %p partial stub.\n", iface, image, texture);
863
864 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown **)texture);
865 }
866
867 static HRESULT WINAPI d3drm3_CreateLight(IDirect3DRM3 *iface,
868 D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
869 {
870 HRESULT hr;
871
872 FIXME("iface %p, type %#x, color 0x%08x, light %p partial stub!\n", iface, type, color, light);
873
874 if (SUCCEEDED(hr = Direct3DRMLight_create((IUnknown **)light)))
875 {
876 IDirect3DRMLight_SetType(*light, type);
877 IDirect3DRMLight_SetColor(*light, color);
878 }
879
880 return hr;
881 }
882
883 static HRESULT WINAPI d3drm3_CreateLightRGB(IDirect3DRM3 *iface, D3DRMLIGHTTYPE type,
884 D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
885 {
886 HRESULT hr;
887
888 FIXME("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p partial stub!\n",
889 iface, type, red, green, blue, light);
890
891 if (SUCCEEDED(hr = Direct3DRMLight_create((IUnknown **)light)))
892 {
893 IDirect3DRMLight_SetType(*light, type);
894 IDirect3DRMLight_SetColorRGB(*light, red, green, blue);
895 }
896
897 return hr;
898 }
899
900 static HRESULT WINAPI d3drm3_CreateMaterial(IDirect3DRM3 *iface,
901 D3DVALUE power, IDirect3DRMMaterial2 **material)
902 {
903 HRESULT hr;
904
905 TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
906
907 if (SUCCEEDED(hr = Direct3DRMMaterial_create(material)))
908 IDirect3DRMMaterial2_SetPower(*material, power);
909
910 return hr;
911 }
912
913 static HRESULT WINAPI d3drm3_CreateDevice(IDirect3DRM3 *iface,
914 DWORD width, DWORD height, IDirect3DRMDevice3 **device)
915 {
916 FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
917
918 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
919 }
920
921 static HRESULT WINAPI d3drm3_CreateDeviceFromSurface(IDirect3DRM3 *iface, GUID *guid,
922 IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice3 **device)
923 {
924 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p, device %p partial stub.\n",
925 iface, debugstr_guid(guid), ddraw, backbuffer, device);
926
927 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
928 }
929
930 static HRESULT WINAPI d3drm3_CreateDeviceFromD3D(IDirect3DRM3 *iface,
931 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device, IDirect3DRMDevice3 **device)
932 {
933 FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n",
934 iface, d3d, d3d_device, device);
935
936 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
937 }
938
939 static HRESULT WINAPI d3drm3_CreateDeviceFromClipper(IDirect3DRM3 *iface,
940 IDirectDrawClipper *clipper, GUID *guid, int width, int height,
941 IDirect3DRMDevice3 **device)
942 {
943 FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p partial stub.\n",
944 iface, clipper, debugstr_guid(guid), width, height, device);
945
946 return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
947 }
948
949 static HRESULT WINAPI d3drm3_CreateShadow(IDirect3DRM3 *iface, IUnknown *object, IDirect3DRMLight *light,
950 D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, IDirect3DRMShadow2 **shadow)
951 {
952 FIXME("iface %p, object %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
953 iface, object, light, px, py, pz, nx, ny, nz, shadow);
954
955 return E_NOTIMPL;
956 }
957
958 static HRESULT WINAPI d3drm3_CreateTextureFromSurface(IDirect3DRM3 *iface,
959 IDirectDrawSurface *surface, IDirect3DRMTexture3 **texture)
960 {
961 FIXME("iface %p, surface %p, texture %p stub!\n", iface, surface, texture);
962
963 return E_NOTIMPL;
964 }
965
966 static HRESULT WINAPI d3drm3_CreateViewport(IDirect3DRM3 *iface, IDirect3DRMDevice3 *device,
967 IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height, IDirect3DRMViewport2 **viewport)
968 {
969 FIXME("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p partial stub!\n",
970 iface, device, camera, x, y, width, height, viewport);
971
972 return Direct3DRMViewport_create(&IID_IDirect3DRMViewport2, (IUnknown **)viewport);
973 }
974
975 static HRESULT WINAPI d3drm3_CreateWrap(IDirect3DRM3 *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame3 *frame,
976 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
977 D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv,
978 IDirect3DRMWrap **wrap)
979 {
980 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
981 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p stub!\n",
982 iface, type, frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
983
984 return E_NOTIMPL;
985 }
986
987 static HRESULT WINAPI d3drm3_CreateUserVisual(IDirect3DRM3 *iface,
988 D3DRMUSERVISUALCALLBACK cb, void *ctx, IDirect3DRMUserVisual **visual)
989 {
990 FIXME("iface %p, cb %p, ctx %p, visual %p stub!\n", iface, cb, ctx, visual);
991
992 return E_NOTIMPL;
993 }
994
995 static HRESULT WINAPI d3drm3_LoadTexture(IDirect3DRM3 *iface,
996 const char *filename, IDirect3DRMTexture3 **texture)
997 {
998 FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
999
1000 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown **)texture);
1001 }
1002
1003 static HRESULT WINAPI d3drm3_LoadTextureFromResource(IDirect3DRM3 *iface, HMODULE module,
1004 const char *resource_name, const char *resource_type, IDirect3DRMTexture3 **texture)
1005 {
1006 FIXME("iface %p, module %p, resource_name %s, resource_type %s, texture %p stub!\n",
1007 iface, module, debugstr_a(resource_name), debugstr_a(resource_type), texture);
1008
1009 return Direct3DRMTexture_create(&IID_IDirect3DRMTexture3, (IUnknown **)texture);
1010 }
1011
1012 static HRESULT WINAPI d3drm3_SetSearchPath(IDirect3DRM3 *iface, const char *path)
1013 {
1014 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
1015
1016 return E_NOTIMPL;
1017 }
1018
1019 static HRESULT WINAPI d3drm3_AddSearchPath(IDirect3DRM3 *iface, const char *path)
1020 {
1021 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
1022
1023 return E_NOTIMPL;
1024 }
1025
1026 static HRESULT WINAPI d3drm3_GetSearchPath(IDirect3DRM3 *iface, DWORD *size, char *path)
1027 {
1028 FIXME("iface %p, size %p, path %p stub!\n", iface, size, path);
1029
1030 return E_NOTIMPL;
1031 }
1032
1033 static HRESULT WINAPI d3drm3_SetDefaultTextureColors(IDirect3DRM3 *iface, DWORD color_count)
1034 {
1035 FIXME("iface %p, color_count %u stub!\n", iface, color_count);
1036
1037 return E_NOTIMPL;
1038 }
1039
1040 static HRESULT WINAPI d3drm3_SetDefaultTextureShades(IDirect3DRM3 *iface, DWORD shade_count)
1041 {
1042 FIXME("iface %p, shade_count %u stub!\n", iface, shade_count);
1043
1044 return E_NOTIMPL;
1045 }
1046
1047 static HRESULT WINAPI d3drm3_GetDevices(IDirect3DRM3 *iface, IDirect3DRMDeviceArray **array)
1048 {
1049 FIXME("iface %p, array %p stub!\n", iface, array);
1050
1051 return E_NOTIMPL;
1052 }
1053
1054 static HRESULT WINAPI d3drm3_GetNamedObject(IDirect3DRM3 *iface,
1055 const char *name, IDirect3DRMObject **object)
1056 {
1057 FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
1058
1059 return E_NOTIMPL;
1060 }
1061
1062 static HRESULT WINAPI d3drm3_EnumerateObjects(IDirect3DRM3 *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
1063 {
1064 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1065
1066 return E_NOTIMPL;
1067 }
1068
1069 static HRESULT load_data(IDirect3DRM3 *iface, IDirectXFileData *data_object, IID **GUIDs, DWORD nb_GUIDs, D3DRMLOADCALLBACK LoadProc,
1070 void *ArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, void *ArgLTP, IDirect3DRMFrame3 *parent_frame)
1071 {
1072 HRESULT ret = D3DRMERR_BADOBJECT;
1073 HRESULT hr;
1074 const GUID* guid;
1075 DWORD i;
1076 BOOL requested = FALSE;
1077
1078 hr = IDirectXFileData_GetType(data_object, &guid);
1079 if (hr != DXFILE_OK)
1080 goto end;
1081
1082 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1083
1084 /* Load object only if it is top level and requested or if it is part of another object */
1085
1086 if (IsEqualGUID(guid, &TID_D3DRMMesh))
1087 {
1088 TRACE("Found TID_D3DRMMesh\n");
1089
1090 for (i = 0; i < nb_GUIDs; i++)
1091 if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder) ||
1092 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder2) ||
1093 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder3))
1094 {
1095 requested = TRUE;
1096 break;
1097 }
1098
1099 if (requested || parent_frame)
1100 {
1101 IDirect3DRMMeshBuilder3 *meshbuilder;
1102
1103 TRACE("Load mesh data\n");
1104
1105 hr = IDirect3DRM3_CreateMeshBuilder(iface, &meshbuilder);
1106 if (SUCCEEDED(hr))
1107 {
1108 hr = load_mesh_data(meshbuilder, data_object, LoadTextureProc, ArgLTP);
1109 if (SUCCEEDED(hr))
1110 {
1111 /* Only top level objects are notified */
1112 if (!parent_frame)
1113 {
1114 IDirect3DRMObject *object;
1115
1116 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder, GUIDs[i], (void**)&object);
1117 if (SUCCEEDED(hr))
1118 {
1119 LoadProc(object, GUIDs[i], ArgLP);
1120 IDirect3DRMObject_Release(object);
1121 }
1122 }
1123 else
1124 {
1125 IDirect3DRMFrame3_AddVisual(parent_frame, (IUnknown*)meshbuilder);
1126 }
1127 }
1128 IDirect3DRMMeshBuilder3_Release(meshbuilder);
1129 }
1130
1131 if (FAILED(hr))
1132 ERR("Cannot process mesh\n");
1133 }
1134 }
1135 else if (IsEqualGUID(guid, &TID_D3DRMFrame))
1136 {
1137 TRACE("Found TID_D3DRMFrame\n");
1138
1139 for (i = 0; i < nb_GUIDs; i++)
1140 if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame) ||
1141 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame2) ||
1142 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame3))
1143 {
1144 requested = TRUE;
1145 break;
1146 }
1147
1148 if (requested || parent_frame)
1149 {
1150 IDirect3DRMFrame3 *frame;
1151
1152 TRACE("Load frame data\n");
1153
1154 hr = IDirect3DRM3_CreateFrame(iface, parent_frame, &frame);
1155 if (SUCCEEDED(hr))
1156 {
1157 IDirectXFileObject *child;
1158
1159 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(data_object, &child)))
1160 {
1161 IDirectXFileData *data;
1162 IDirectXFileDataReference *reference;
1163 IDirectXFileBinary *binary;
1164
1165 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileBinary, (void **)&binary);
1166 if (SUCCEEDED(hr))
1167 {
1168 FIXME("Binary Object not supported yet\n");
1169 IDirectXFileBinary_Release(binary);
1170 continue;
1171 }
1172
1173 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1174 if (SUCCEEDED(hr))
1175 {
1176 TRACE("Found Data Object\n");
1177 hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1178 IDirectXFileData_Release(data);
1179 continue;
1180 }
1181 hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1182 if (SUCCEEDED(hr))
1183 {
1184 TRACE("Found Data Object Reference\n");
1185 IDirectXFileDataReference_Resolve(reference, &data);
1186 hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1187 IDirectXFileData_Release(data);
1188 IDirectXFileDataReference_Release(reference);
1189 continue;
1190 }
1191 }
1192
1193 if (hr != DXFILEERR_NOMOREOBJECTS)
1194 {
1195 IDirect3DRMFrame3_Release(frame);
1196 goto end;
1197 }
1198 hr = S_OK;
1199
1200 /* Only top level objects are notified */
1201 if (!parent_frame)
1202 {
1203 IDirect3DRMObject *object;
1204
1205 hr = IDirect3DRMFrame3_QueryInterface(frame, GUIDs[i], (void**)&object);
1206 if (SUCCEEDED(hr))
1207 {
1208 LoadProc(object, GUIDs[i], ArgLP);
1209 IDirect3DRMObject_Release(object);
1210 }
1211 }
1212 IDirect3DRMFrame3_Release(frame);
1213 }
1214
1215 if (FAILED(hr))
1216 ERR("Cannot process frame\n");
1217 }
1218 }
1219 else if (IsEqualGUID(guid, &TID_D3DRMMaterial))
1220 {
1221 TRACE("Found TID_D3DRMMaterial\n");
1222
1223 /* Cannot be requested so nothing to do */
1224 }
1225 else if (IsEqualGUID(guid, &TID_D3DRMFrameTransformMatrix))
1226 {
1227 TRACE("Found TID_D3DRMFrameTransformMatrix\n");
1228
1229 /* Cannot be requested */
1230 if (parent_frame)
1231 {
1232 D3DRMMATRIX4D matrix;
1233 DWORD size;
1234
1235 TRACE("Load Frame Transform Matrix data\n");
1236
1237 size = sizeof(matrix);
1238 hr = IDirectXFileData_GetData(data_object, NULL, &size, (void**)matrix);
1239 if ((hr != DXFILE_OK) || (size != sizeof(matrix)))
1240 goto end;
1241
1242 hr = IDirect3DRMFrame3_AddTransform(parent_frame, D3DRMCOMBINE_REPLACE, matrix);
1243 if (FAILED(hr))
1244 goto end;
1245 }
1246 }
1247 else
1248 {
1249 FIXME("Found unknown TID %s\n", debugstr_guid(guid));
1250 }
1251
1252 ret = D3DRM_OK;
1253
1254 end:
1255
1256 return ret;
1257 }
1258
1259 static HRESULT WINAPI d3drm3_Load(IDirect3DRM3 *iface, void *source, void *object_id, IID **iids,
1260 DWORD iid_count, D3DRMLOADOPTIONS flags, D3DRMLOADCALLBACK load_cb, void *load_ctx,
1261 D3DRMLOADTEXTURECALLBACK load_tex_cb, void *load_tex_ctx, IDirect3DRMFrame3 *parent_frame)
1262 {
1263 DXFILELOADOPTIONS load_options;
1264 IDirectXFile *file = NULL;
1265 IDirectXFileEnumObject *enum_object = NULL;
1266 IDirectXFileData *data = NULL;
1267 HRESULT hr;
1268 const GUID* pGuid;
1269 DWORD size;
1270 struct d3drm_file_header *header;
1271 HRESULT ret = D3DRMERR_BADOBJECT;
1272 DWORD i;
1273
1274 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
1275 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
1276 iface, source, object_id, iids, iid_count, flags,
1277 load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
1278
1279 TRACE("Looking for GUIDs:\n");
1280 for (i = 0; i < iid_count; ++i)
1281 TRACE("- %s (%s)\n", debugstr_guid(iids[i]), get_IID_string(iids[i]));
1282
1283 if (flags == D3DRMLOAD_FROMMEMORY)
1284 {
1285 load_options = DXFILELOAD_FROMMEMORY;
1286 }
1287 else if (flags == D3DRMLOAD_FROMFILE)
1288 {
1289 load_options = DXFILELOAD_FROMFILE;
1290 TRACE("Loading from file %s\n", debugstr_a(source));
1291 }
1292 else
1293 {
1294 FIXME("Load options %#x not supported yet.\n", flags);
1295 return E_NOTIMPL;
1296 }
1297
1298 hr = DirectXFileCreate(&file);
1299 if (hr != DXFILE_OK)
1300 goto end;
1301
1302 hr = IDirectXFile_RegisterTemplates(file, templates, strlen(templates));
1303 if (hr != DXFILE_OK)
1304 goto end;
1305
1306 hr = IDirectXFile_CreateEnumObject(file, source, load_options, &enum_object);
1307 if (hr != DXFILE_OK)
1308 goto end;
1309
1310 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1311 if (hr != DXFILE_OK)
1312 goto end;
1313
1314 hr = IDirectXFileData_GetType(data, &pGuid);
1315 if (hr != DXFILE_OK)
1316 goto end;
1317
1318 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1319
1320 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1321 {
1322 ret = D3DRMERR_BADFILE;
1323 goto end;
1324 }
1325
1326 hr = IDirectXFileData_GetData(data, NULL, &size, (void **)&header);
1327 if ((hr != DXFILE_OK) || (size != sizeof(*header)))
1328 goto end;
1329
1330 TRACE("Version is %u.%u, flags %#x.\n", header->major, header->minor, header->flags);
1331
1332 /* Version must be 1.0.x */
1333 if ((header->major != 1) || (header->minor != 0))
1334 {
1335 ret = D3DRMERR_BADFILE;
1336 goto end;
1337 }
1338
1339 IDirectXFileData_Release(data);
1340 data = NULL;
1341
1342 while (1)
1343 {
1344 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1345 if (hr == DXFILEERR_NOMOREOBJECTS)
1346 {
1347 TRACE("No more object\n");
1348 break;
1349 }
1350 else if (hr != DXFILE_OK)
1351 {
1352 ret = D3DRMERR_BADFILE;
1353 goto end;
1354 }
1355
1356 ret = load_data(iface, data, iids, iid_count, load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
1357 if (ret != D3DRM_OK)
1358 goto end;
1359
1360 IDirectXFileData_Release(data);
1361 data = NULL;
1362 }
1363
1364 ret = D3DRM_OK;
1365
1366 end:
1367 if (data)
1368 IDirectXFileData_Release(data);
1369 if (enum_object)
1370 IDirectXFileEnumObject_Release(enum_object);
1371 if (file)
1372 IDirectXFile_Release(file);
1373
1374 return ret;
1375 }
1376
1377 static HRESULT WINAPI d3drm3_Tick(IDirect3DRM3 *iface, D3DVALUE tick)
1378 {
1379 FIXME("iface %p, tick %.8e stub!\n", iface, tick);
1380
1381 return E_NOTIMPL;
1382 }
1383
1384 static HRESULT WINAPI d3drm3_CreateProgressiveMesh(IDirect3DRM3 *iface, IDirect3DRMProgressiveMesh **mesh)
1385 {
1386 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1387
1388 return E_NOTIMPL;
1389 }
1390
1391 static HRESULT WINAPI d3drm3_RegisterClient(IDirect3DRM3 *iface, REFGUID guid, DWORD *id)
1392 {
1393 FIXME("iface %p, guid %s, id %p stub!\n", iface, debugstr_guid(guid), id);
1394
1395 return E_NOTIMPL;
1396 }
1397
1398 static HRESULT WINAPI d3drm3_UnregisterClient(IDirect3DRM3 *iface, REFGUID guid)
1399 {
1400 FIXME("iface %p, guid %s stub!\n", iface, debugstr_guid(guid));
1401
1402 return E_NOTIMPL;
1403 }
1404
1405 static HRESULT WINAPI d3drm3_CreateClippedVisual(IDirect3DRM3 *iface,
1406 IDirect3DRMVisual *visual, IDirect3DRMClippedVisual **clipped_visual)
1407 {
1408 FIXME("iface %p, visual %p, clipped_visual %p stub!\n", iface, visual, clipped_visual);
1409
1410 return E_NOTIMPL;
1411 }
1412
1413 static HRESULT WINAPI d3drm3_SetOptions(IDirect3DRM3 *iface, DWORD flags)
1414 {
1415 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1416
1417 return E_NOTIMPL;
1418 }
1419
1420 static HRESULT WINAPI d3drm3_GetOptions(IDirect3DRM3 *iface, DWORD *flags)
1421 {
1422 FIXME("iface %p, flags %p stub!\n", iface, flags);
1423
1424 return E_NOTIMPL;
1425 }
1426
1427 static const struct IDirect3DRM3Vtbl d3drm3_vtbl =
1428 {
1429 d3drm3_QueryInterface,
1430 d3drm3_AddRef,
1431 d3drm3_Release,
1432 d3drm3_CreateObject,
1433 d3drm3_CreateFrame,
1434 d3drm3_CreateMesh,
1435 d3drm3_CreateMeshBuilder,
1436 d3drm3_CreateFace,
1437 d3drm3_CreateAnimation,
1438 d3drm3_CreateAnimationSet,
1439 d3drm3_CreateTexture,
1440 d3drm3_CreateLight,
1441 d3drm3_CreateLightRGB,
1442 d3drm3_CreateMaterial,
1443 d3drm3_CreateDevice,
1444 d3drm3_CreateDeviceFromSurface,
1445 d3drm3_CreateDeviceFromD3D,
1446 d3drm3_CreateDeviceFromClipper,
1447 d3drm3_CreateTextureFromSurface,
1448 d3drm3_CreateShadow,
1449 d3drm3_CreateViewport,
1450 d3drm3_CreateWrap,
1451 d3drm3_CreateUserVisual,
1452 d3drm3_LoadTexture,
1453 d3drm3_LoadTextureFromResource,
1454 d3drm3_SetSearchPath,
1455 d3drm3_AddSearchPath,
1456 d3drm3_GetSearchPath,
1457 d3drm3_SetDefaultTextureColors,
1458 d3drm3_SetDefaultTextureShades,
1459 d3drm3_GetDevices,
1460 d3drm3_GetNamedObject,
1461 d3drm3_EnumerateObjects,
1462 d3drm3_Load,
1463 d3drm3_Tick,
1464 d3drm3_CreateProgressiveMesh,
1465 d3drm3_RegisterClient,
1466 d3drm3_UnregisterClient,
1467 d3drm3_CreateClippedVisual,
1468 d3drm3_SetOptions,
1469 d3drm3_GetOptions,
1470 };
1471
1472 HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
1473 {
1474 struct d3drm *object;
1475
1476 TRACE("d3drm %p.\n", d3drm);
1477
1478 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1479 return E_OUTOFMEMORY;
1480
1481 object->IDirect3DRM_iface.lpVtbl = &d3drm1_vtbl;
1482 object->IDirect3DRM2_iface.lpVtbl = &d3drm2_vtbl;
1483 object->IDirect3DRM3_iface.lpVtbl = &d3drm3_vtbl;
1484 object->ref = 1;
1485
1486 *d3drm = &object->IDirect3DRM_iface;
1487
1488 return S_OK;
1489 }