d3drm: Implement IDirect3DRMViewportX_[Get|Set]Projection.
[wine] / dlls / 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 "wine/debug.h"
23
24 #define COBJMACROS
25
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "dxfile.h"
29 #include "rmxfguid.h"
30
31 #include "d3drm_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
34
35 static const char* get_IID_string(const GUID* guid)
36 {
37     if (IsEqualGUID(guid, &IID_IDirect3DRMFrame))
38         return "IID_IDirect3DRMFrame";
39     else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame2))
40         return "IID_IDirect3DRMFrame2";
41     else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame3))
42         return "IID_IDirect3DRMFrame3";
43     else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder))
44         return "IID_IDirect3DRMMeshBuilder";
45     else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder2))
46         return "IID_IDirect3DRMMeshBuilder2";
47     else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder3))
48         return "IID_IDirect3DRMMeshBuilder3";
49
50     return "?";
51 }
52
53 typedef struct {
54     IDirect3DRM IDirect3DRM_iface;
55     IDirect3DRM2 IDirect3DRM2_iface;
56     IDirect3DRM3 IDirect3DRM3_iface;
57     LONG ref;
58 } IDirect3DRMImpl;
59
60 static inline IDirect3DRMImpl *impl_from_IDirect3DRM(IDirect3DRM *iface)
61 {
62     return CONTAINING_RECORD(iface, IDirect3DRMImpl, IDirect3DRM_iface);
63 }
64
65 static inline IDirect3DRMImpl *impl_from_IDirect3DRM2(IDirect3DRM2 *iface)
66 {
67     return CONTAINING_RECORD(iface, IDirect3DRMImpl, IDirect3DRM2_iface);
68 }
69
70 static inline IDirect3DRMImpl *impl_from_IDirect3DRM3(IDirect3DRM3 *iface)
71 {
72     return CONTAINING_RECORD(iface, IDirect3DRMImpl, IDirect3DRM3_iface);
73 }
74
75 /*** IUnknown methods ***/
76 static HRESULT WINAPI IDirect3DRMImpl_QueryInterface(IDirect3DRM* iface, REFIID riid, void** ppvObject)
77 {
78     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
79
80     TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
81
82     *ppvObject = NULL;
83
84     if(IsEqualGUID(riid, &IID_IUnknown) ||
85        IsEqualGUID(riid, &IID_IDirect3DRM))
86     {
87         *ppvObject = &This->IDirect3DRM_iface;
88     }
89     else if(IsEqualGUID(riid, &IID_IDirect3DRM2))
90     {
91         *ppvObject = &This->IDirect3DRM2_iface;
92     }
93     else if(IsEqualGUID(riid, &IID_IDirect3DRM3))
94     {
95         *ppvObject = &This->IDirect3DRM3_iface;
96     }
97     else
98     {
99         FIXME("interface %s not implemented\n", debugstr_guid(riid));
100         return E_NOINTERFACE;
101     }
102
103     IDirect3DRM_AddRef(iface);
104     return S_OK;
105 }
106
107 static ULONG WINAPI IDirect3DRMImpl_AddRef(IDirect3DRM* iface)
108 {
109     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
110     ULONG ref = InterlockedIncrement(&This->ref);
111
112     TRACE("(%p/%p)->(): new ref = %d\n", iface, This, ref);
113
114     return ref;
115 }
116
117 static ULONG WINAPI IDirect3DRMImpl_Release(IDirect3DRM* iface)
118 {
119     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
120     ULONG ref = InterlockedDecrement(&This->ref);
121
122     TRACE("(%p/%p)->(): new ref = %d\n", iface, This, ref);
123
124     if (!ref)
125         HeapFree(GetProcessHeap(), 0, This);
126
127     return ref;
128 }
129
130 /*** IDirect3DRM methods ***/
131 static HRESULT WINAPI IDirect3DRMImpl_CreateObject(IDirect3DRM* iface, REFCLSID rclsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
132 {
133     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
134
135     FIXME("(%p/%p)->(%s,%p,%s,%p): stub\n", iface, This, debugstr_guid(rclsid), pUnkOuter, debugstr_guid(riid), ppvObj);
136
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI IDirect3DRMImpl_CreateFrame(IDirect3DRM* iface, LPDIRECT3DRMFRAME parent_frame, LPDIRECT3DRMFRAME * frame)
141 {
142     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
143
144     TRACE("(%p/%p)->(%p,%p)\n", iface, This, parent_frame, frame);
145
146     return Direct3DRMFrame_create(&IID_IDirect3DRMFrame, (IUnknown*)parent_frame, (IUnknown**)frame);
147 }
148
149 static HRESULT WINAPI IDirect3DRMImpl_CreateMesh(IDirect3DRM* iface, LPDIRECT3DRMMESH * ppMesh)
150 {
151     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
152
153     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppMesh);
154
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI IDirect3DRMImpl_CreateMeshBuilder(IDirect3DRM* iface, LPDIRECT3DRMMESHBUILDER * ppMeshBuilder)
159 {
160     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
161
162     TRACE("(%p/%p)->(%p)\n", iface, This, ppMeshBuilder);
163
164     return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder, (IUnknown**)ppMeshBuilder);
165 }
166
167 static HRESULT WINAPI IDirect3DRMImpl_CreateFace(IDirect3DRM* iface, LPDIRECT3DRMFACE * ppFace)
168 {
169     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
170
171     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppFace);
172
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI IDirect3DRMImpl_CreateAnimation(IDirect3DRM* iface, LPDIRECT3DRMANIMATION * ppAnimation)
177 {
178     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
179
180     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppAnimation);
181
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI IDirect3DRMImpl_CreateAnimationSet(IDirect3DRM* iface, LPDIRECT3DRMANIMATIONSET * ppAnimationSet)
186 {
187     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
188
189     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppAnimationSet);
190
191     return E_NOTIMPL;
192 }
193
194 static HRESULT WINAPI IDirect3DRMImpl_CreateTexture(IDirect3DRM* iface, LPD3DRMIMAGE pImage, LPDIRECT3DRMTEXTURE * ppTexture)
195 {
196     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
197
198     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, pImage, ppTexture);
199
200     return E_NOTIMPL;
201 }
202
203 static HRESULT WINAPI IDirect3DRMImpl_CreateLight(IDirect3DRM* iface, D3DRMLIGHTTYPE type,
204                                                     D3DCOLOR color, LPDIRECT3DRMLIGHT* Light)
205 {
206     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
207
208     TRACE("(%p/%p)->(%d,%d,%p)\n", iface, This, type, color, Light);
209
210     return IDirect3DRM3_CreateLight(&This->IDirect3DRM3_iface, type, color, Light);
211 }
212
213 static HRESULT WINAPI IDirect3DRMImpl_CreateLightRGB(IDirect3DRM* iface, D3DRMLIGHTTYPE type,
214                                                        D3DVALUE red, D3DVALUE green, D3DVALUE blue,
215                                                        LPDIRECT3DRMLIGHT* Light)
216 {
217     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
218
219     TRACE("(%p/%p)->(%d,%f,%f,%f,%p)\n", iface, This, type, red, green, blue, Light);
220
221     return IDirect3DRM3_CreateLightRGB(&This->IDirect3DRM3_iface, type, red, green, blue, Light);
222 }
223
224 static HRESULT WINAPI IDirect3DRMImpl_CreateMaterial(IDirect3DRM* iface, D3DVALUE power, LPDIRECT3DRMMATERIAL * material)
225 {
226     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
227
228     TRACE("(%p/%p)->(%f,%p)\n", iface, This, power, material);
229
230     return IDirect3DRM3_CreateMaterial(&This->IDirect3DRM3_iface, power, (LPDIRECT3DRMMATERIAL2*)material);
231 }
232
233 static HRESULT WINAPI IDirect3DRMImpl_CreateDevice(IDirect3DRM* iface, DWORD width, DWORD height, LPDIRECT3DRMDEVICE * ppDevice)
234 {
235     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
236
237     FIXME("(%p/%p)->(%u,%u,%p): partial stub\n", iface, This, width, height, ppDevice);
238
239     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown**)ppDevice);
240 }
241
242 static HRESULT WINAPI IDirect3DRMImpl_CreateDeviceFromSurface(IDirect3DRM* iface, LPGUID pGUID, LPDIRECTDRAW pDD, LPDIRECTDRAWSURFACE pDDSBack, LPDIRECT3DRMDEVICE * ppDevice)
243 {
244     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
245
246     FIXME("(%p/%p)->(%s,%p,%p,%p): partial stub\n", iface, This, debugstr_guid(pGUID), pDD,
247           pDDSBack, ppDevice);
248
249     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown**)ppDevice);
250 }
251
252 static HRESULT WINAPI IDirect3DRMImpl_CreateDeviceFromD3D(IDirect3DRM* iface, LPDIRECT3D pD3D, LPDIRECT3DDEVICE pD3DDev, LPDIRECT3DRMDEVICE * ppDevice)
253 {
254     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
255
256     FIXME("(%p/%p)->(%p,%p,%p): partial stub\n", iface, This, pD3D, pD3DDev, ppDevice);
257
258     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown**)ppDevice);
259 }
260
261 static HRESULT WINAPI IDirect3DRMImpl_CreateDeviceFromClipper(IDirect3DRM* iface, LPDIRECTDRAWCLIPPER pDDClipper, LPGUID pGUID, int width, int height, LPDIRECT3DRMDEVICE * ppDevice)
262 {
263     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
264
265     FIXME("(%p/%p)->(%p,%s,%d,%d,%p): partial stub\n", iface, This, pDDClipper,
266           debugstr_guid(pGUID), width, height, ppDevice);
267
268     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown**)ppDevice);
269 }
270
271 static HRESULT WINAPI IDirect3DRMImpl_CreateTextureFromSurface(IDirect3DRM* iface, LPDIRECTDRAWSURFACE pDDS, LPDIRECT3DRMTEXTURE * ppTexture)
272 {
273     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
274
275     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, pDDS, ppTexture);
276
277     return E_NOTIMPL;
278 }
279
280 static HRESULT WINAPI IDirect3DRMImpl_CreateShadow(IDirect3DRM* iface, LPDIRECT3DRMVISUAL pVisual, LPDIRECT3DRMLIGHT pLight, D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, LPDIRECT3DRMVISUAL * ppVisual)
281 {
282     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
283
284     FIXME("(%p/%p)->(%p,%p,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, pVisual, pLight, px, py, pz, nx, ny, nz, ppVisual);
285
286     return E_NOTIMPL;
287 }
288
289 static HRESULT WINAPI IDirect3DRMImpl_CreateViewport(IDirect3DRM* iface, LPDIRECT3DRMDEVICE pDevice, LPDIRECT3DRMFRAME pFrame, DWORD xpos, DWORD ypos, DWORD width, DWORD height, LPDIRECT3DRMVIEWPORT * ppViewport)
290 {
291     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
292
293     FIXME("(%p/%p)->(%p,%p,%d,%d,%d,%d,%p): partial stub\n", iface, This, pDevice, pFrame,
294           xpos, ypos, width, height, ppViewport);
295
296     return Direct3DRMViewport_create(&IID_IDirect3DRMViewport, (IUnknown**)ppViewport);
297 }
298
299 static HRESULT WINAPI IDirect3DRMImpl_CreateWrap(IDirect3DRM* iface, D3DRMWRAPTYPE type, LPDIRECT3DRMFRAME pFrame, D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv, LPDIRECT3DRMWRAP * ppWrap)
300 {
301     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
302
303     FIXME("(%p/%p)->(%d,%p,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, type, pFrame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, ppWrap);
304
305     return E_NOTIMPL;
306 }
307
308 static HRESULT WINAPI IDirect3DRMImpl_CreateUserVisual(IDirect3DRM* iface, D3DRMUSERVISUALCALLBACK cb, LPVOID pArg, LPDIRECT3DRMUSERVISUAL * ppUserVisual)
309 {
310     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
311
312     FIXME("(%p/%p)->(%p,%p,%p): stub\n", iface, This, cb, pArg, ppUserVisual);
313
314     return E_NOTIMPL;
315 }
316
317 static HRESULT WINAPI IDirect3DRMImpl_LoadTexture(IDirect3DRM* iface, const char * filename, LPDIRECT3DRMTEXTURE * ppTexture)
318 {
319     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
320
321     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, filename, ppTexture);
322
323     return E_NOTIMPL;
324 }
325
326 static HRESULT WINAPI IDirect3DRMImpl_LoadTextureFromResource(IDirect3DRM* iface, HRSRC rs, LPDIRECT3DRMTEXTURE * ppTexture)
327 {
328     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
329
330     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, rs, ppTexture);
331
332     return E_NOTIMPL;
333 }
334
335 static HRESULT WINAPI IDirect3DRMImpl_SetSearchPath(IDirect3DRM* iface, LPCSTR path)
336 {
337     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
338
339     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
340
341     return E_NOTIMPL;
342 }
343
344 static HRESULT WINAPI IDirect3DRMImpl_AddSearchPath(IDirect3DRM* iface, LPCSTR path)
345 {
346     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
347
348     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
349
350     return E_NOTIMPL;
351 }
352
353 static HRESULT WINAPI IDirect3DRMImpl_GetSearchPath(IDirect3DRM* iface, DWORD *size_return, LPSTR path_return)
354 {
355     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
356
357     FIXME("(%p/%p)->(%p,%s): stub\n", iface, This, size_return, path_return);
358
359     return E_NOTIMPL;
360 }
361
362 static HRESULT WINAPI IDirect3DRMImpl_SetDefaultTextureColors(IDirect3DRM* iface, DWORD nb_colors)
363 {
364     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
365
366     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_colors);
367
368     return E_NOTIMPL;
369 }
370
371 static HRESULT WINAPI IDirect3DRMImpl_SetDefaultTextureShades(IDirect3DRM* iface, DWORD nb_shades)
372 {
373     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
374
375     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_shades);
376
377     return E_NOTIMPL;
378 }
379
380 static HRESULT WINAPI IDirect3DRMImpl_GetDevices(IDirect3DRM* iface, LPDIRECT3DRMDEVICEARRAY * ppDeviceArray)
381 {
382     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
383
384     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppDeviceArray);
385
386     return E_NOTIMPL;
387 }
388
389 static HRESULT WINAPI IDirect3DRMImpl_GetNamedObject(IDirect3DRM* iface, const char * pName, LPDIRECT3DRMOBJECT * ppObject)
390 {
391     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
392
393     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, pName, ppObject);
394
395     return E_NOTIMPL;
396 }
397
398 static HRESULT WINAPI IDirect3DRMImpl_EnumerateObjects(IDirect3DRM* iface, D3DRMOBJECTCALLBACK cb, LPVOID pArg)
399 {
400     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
401
402     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, cb, pArg);
403
404     return E_NOTIMPL;
405 }
406
407 static HRESULT WINAPI IDirect3DRMImpl_Load(IDirect3DRM* iface, LPVOID pObjSource, LPVOID pObjID, LPIID * ppGUIDs, DWORD nb_GUIDs, D3DRMLOADOPTIONS LOFlags, D3DRMLOADCALLBACK LoadProc, LPVOID pArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, LPVOID pArgLTP, LPDIRECT3DRMFRAME pParentFrame)
408 {
409     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
410     LPDIRECT3DRMFRAME3 pParentFrame3 = NULL;
411     HRESULT hr = D3DRM_OK;
412
413     TRACE("(%p/%p)->(%p,%p,%p,%d,%d,%p,%p,%p,%p,%p)\n", iface, This, pObjSource, pObjID, ppGUIDs, nb_GUIDs, LOFlags, LoadProc, pArgLP, LoadTextureProc, pArgLTP, pParentFrame);
414
415     if (pParentFrame)
416         hr = IDirect3DRMFrame_QueryInterface(pParentFrame, &IID_IDirect3DRMFrame3, (void**)&pParentFrame3);
417     if (SUCCEEDED(hr))
418         hr = IDirect3DRM3_Load(&This->IDirect3DRM3_iface, pObjSource, pObjID, ppGUIDs, nb_GUIDs, LOFlags, LoadProc, pArgLP, LoadTextureProc, pArgLTP, pParentFrame3);
419     if (pParentFrame3)
420         IDirect3DRMFrame3_Release(pParentFrame3);
421
422     return hr;
423 }
424
425 static HRESULT WINAPI IDirect3DRMImpl_Tick(IDirect3DRM* iface, D3DVALUE tick)
426 {
427     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
428
429     FIXME("(%p/%p)->(%f): stub\n", iface, This, tick);
430
431     return E_NOTIMPL;
432 }
433
434 static const struct IDirect3DRMVtbl Direct3DRM_Vtbl =
435 {
436     IDirect3DRMImpl_QueryInterface,
437     IDirect3DRMImpl_AddRef,
438     IDirect3DRMImpl_Release,
439     IDirect3DRMImpl_CreateObject,
440     IDirect3DRMImpl_CreateFrame,
441     IDirect3DRMImpl_CreateMesh,
442     IDirect3DRMImpl_CreateMeshBuilder,
443     IDirect3DRMImpl_CreateFace,
444     IDirect3DRMImpl_CreateAnimation,
445     IDirect3DRMImpl_CreateAnimationSet,
446     IDirect3DRMImpl_CreateTexture,
447     IDirect3DRMImpl_CreateLight,
448     IDirect3DRMImpl_CreateLightRGB,
449     IDirect3DRMImpl_CreateMaterial,
450     IDirect3DRMImpl_CreateDevice,
451     IDirect3DRMImpl_CreateDeviceFromSurface,
452     IDirect3DRMImpl_CreateDeviceFromD3D,
453     IDirect3DRMImpl_CreateDeviceFromClipper,
454     IDirect3DRMImpl_CreateTextureFromSurface,
455     IDirect3DRMImpl_CreateShadow,
456     IDirect3DRMImpl_CreateViewport,
457     IDirect3DRMImpl_CreateWrap,
458     IDirect3DRMImpl_CreateUserVisual,
459     IDirect3DRMImpl_LoadTexture,
460     IDirect3DRMImpl_LoadTextureFromResource,
461     IDirect3DRMImpl_SetSearchPath,
462     IDirect3DRMImpl_AddSearchPath,
463     IDirect3DRMImpl_GetSearchPath,
464     IDirect3DRMImpl_SetDefaultTextureColors,
465     IDirect3DRMImpl_SetDefaultTextureShades,
466     IDirect3DRMImpl_GetDevices,
467     IDirect3DRMImpl_GetNamedObject,
468     IDirect3DRMImpl_EnumerateObjects,
469     IDirect3DRMImpl_Load,
470     IDirect3DRMImpl_Tick
471 };
472
473
474 /*** IUnknown methods ***/
475 static HRESULT WINAPI IDirect3DRM2Impl_QueryInterface(IDirect3DRM2* iface, REFIID riid,
476                                                       void** ppvObject)
477 {
478     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
479     return IDirect3DRM_QueryInterface(&This->IDirect3DRM_iface, riid, ppvObject);
480 }
481
482 static ULONG WINAPI IDirect3DRM2Impl_AddRef(IDirect3DRM2* iface)
483 {
484     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
485     return IDirect3DRM_AddRef(&This->IDirect3DRM_iface);
486 }
487
488 static ULONG WINAPI IDirect3DRM2Impl_Release(IDirect3DRM2* iface)
489 {
490     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
491     return IDirect3DRM_Release(&This->IDirect3DRM_iface);
492 }
493
494 /*** IDirect3DRM2 methods ***/
495 static HRESULT WINAPI IDirect3DRM2Impl_CreateObject(IDirect3DRM2* iface, REFCLSID rclsid,
496                                                     LPUNKNOWN pUnkOuter, REFIID riid,
497                                                     LPVOID *ppvObj)
498 {
499     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
500
501     FIXME("(%p/%p)->(%s,%p,%s,%p): stub\n", iface, This, debugstr_guid(rclsid), pUnkOuter,
502                                             debugstr_guid(riid), ppvObj);
503
504     return E_NOTIMPL;
505 }
506
507 static HRESULT WINAPI IDirect3DRM2Impl_CreateFrame(IDirect3DRM2* iface, LPDIRECT3DRMFRAME parent_frame,
508                                                    LPDIRECT3DRMFRAME2 * frame)
509 {
510     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
511
512     TRACE("(%p/%p)->(%p,%p)\n", iface, This, parent_frame, frame);
513
514     return Direct3DRMFrame_create(&IID_IDirect3DRMFrame2, (IUnknown*)parent_frame, (IUnknown**)frame);
515 }
516
517 static HRESULT WINAPI IDirect3DRM2Impl_CreateMesh(IDirect3DRM2* iface, LPDIRECT3DRMMESH * ppMesh)
518 {
519     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
520
521     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppMesh);
522
523     return E_NOTIMPL;
524 }
525
526 static HRESULT WINAPI IDirect3DRM2Impl_CreateMeshBuilder(IDirect3DRM2* iface,
527                                                          LPDIRECT3DRMMESHBUILDER2 * ppMeshBuilder)
528 {
529     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
530
531     TRACE("(%p/%p)->(%p)\n", iface, This, ppMeshBuilder);
532
533     return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder2, (IUnknown**)ppMeshBuilder);
534 }
535
536 static HRESULT WINAPI IDirect3DRM2Impl_CreateFace(IDirect3DRM2* iface, LPDIRECT3DRMFACE * ppFace)
537 {
538     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
539
540     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppFace);
541
542     return E_NOTIMPL;
543 }
544
545 static HRESULT WINAPI IDirect3DRM2Impl_CreateAnimation(IDirect3DRM2* iface,
546                                                        LPDIRECT3DRMANIMATION * ppAnimation)
547 {
548     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
549
550     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppAnimation);
551
552     return E_NOTIMPL;
553 }
554
555 static HRESULT WINAPI IDirect3DRM2Impl_CreateAnimationSet(IDirect3DRM2* iface,
556                                                           LPDIRECT3DRMANIMATIONSET * ppAnimationSet)
557 {
558     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
559
560     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppAnimationSet);
561
562     return E_NOTIMPL;
563 }
564
565 static HRESULT WINAPI IDirect3DRM2Impl_CreateTexture(IDirect3DRM2* iface, LPD3DRMIMAGE pImage,
566                                                      LPDIRECT3DRMTEXTURE2 * ppTexture)
567 {
568     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
569
570     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, pImage, ppTexture);
571
572     return E_NOTIMPL;
573 }
574
575 static HRESULT WINAPI IDirect3DRM2Impl_CreateLight(IDirect3DRM2* iface, D3DRMLIGHTTYPE type,
576                                                      D3DCOLOR color, LPDIRECT3DRMLIGHT* Light)
577 {
578     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
579
580     TRACE("(%p/%p)->(%d,%d,%p)\n", iface, This, type, color, Light);
581
582     return IDirect3DRM3_CreateLight(&This->IDirect3DRM3_iface, type, color, Light);
583 }
584
585 static HRESULT WINAPI IDirect3DRM2Impl_CreateLightRGB(IDirect3DRM2* iface, D3DRMLIGHTTYPE type,
586                                                         D3DVALUE red, D3DVALUE green, D3DVALUE blue,
587                                                         LPDIRECT3DRMLIGHT* Light)
588 {
589     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
590
591     TRACE("(%p/%p)->(%d,%f,%f,%f,%p)\n", iface, This, type, red, green, blue, Light);
592
593     return IDirect3DRM3_CreateLightRGB(&This->IDirect3DRM3_iface, type, red, green, blue, Light);
594 }
595
596 static HRESULT WINAPI IDirect3DRM2Impl_CreateMaterial(IDirect3DRM2* iface, D3DVALUE power,
597                                                       LPDIRECT3DRMMATERIAL * material)
598 {
599     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
600
601     TRACE("(%p/%p)->(%f,%p)\n", iface, This, power, material);
602
603     return IDirect3DRM3_CreateMaterial(&This->IDirect3DRM3_iface, power, (LPDIRECT3DRMMATERIAL2*)material);
604 }
605
606 static HRESULT WINAPI IDirect3DRM2Impl_CreateDevice(IDirect3DRM2* iface, DWORD width, DWORD height,
607                                                     LPDIRECT3DRMDEVICE2 * ppDevice)
608 {
609     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
610
611     FIXME("(%p/%p)->(%u,%u,%p): partial stub\n", iface, This, width, height, ppDevice);
612
613     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown**)ppDevice);
614 }
615
616 static HRESULT WINAPI IDirect3DRM2Impl_CreateDeviceFromSurface(IDirect3DRM2* iface, LPGUID pGUID,
617                                                                LPDIRECTDRAW pDD,
618                                                                LPDIRECTDRAWSURFACE pDDSBack,
619                                                                LPDIRECT3DRMDEVICE2 * ppDevice)
620 {
621     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
622
623     FIXME("(%p/%p)->(%s,%p,%p,%p): partial stub\n", iface, This, debugstr_guid(pGUID),
624           pDD, pDDSBack, ppDevice);
625
626     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown**)ppDevice);
627 }
628
629 static HRESULT WINAPI IDirect3DRM2Impl_CreateDeviceFromD3D(IDirect3DRM2* iface, LPDIRECT3D2 pD3D,
630                                                            LPDIRECT3DDEVICE2 pD3DDev,
631                                                            LPDIRECT3DRMDEVICE2 * ppDevice)
632 {
633     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
634
635     FIXME("(%p/%p)->(%p,%p,%p): partial stub\n", iface, This, pD3D, pD3DDev, ppDevice);
636
637     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown**)ppDevice);
638 }
639
640 static HRESULT WINAPI IDirect3DRM2Impl_CreateDeviceFromClipper(IDirect3DRM2* iface,
641                                                                LPDIRECTDRAWCLIPPER pDDClipper,
642                                                                LPGUID pGUID, int width, int height,
643                                                                LPDIRECT3DRMDEVICE2 * ppDevice)
644 {
645     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
646
647     FIXME("(%p/%p)->(%p,%s,%d,%d,%p): partial stub\n", iface, This, pDDClipper,
648           debugstr_guid(pGUID), width, height, ppDevice);
649
650     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown**)ppDevice);
651 }
652
653 static HRESULT WINAPI IDirect3DRM2Impl_CreateTextureFromSurface(IDirect3DRM2* iface,
654                                                                 LPDIRECTDRAWSURFACE pDDS,
655                                                                 LPDIRECT3DRMTEXTURE2 * ppTexture)
656 {
657     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
658
659     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, pDDS, ppTexture);
660
661     return E_NOTIMPL;
662 }
663
664 static HRESULT WINAPI IDirect3DRM2Impl_CreateShadow(IDirect3DRM2* iface, LPDIRECT3DRMVISUAL pVisual,
665                                                     LPDIRECT3DRMLIGHT pLight,
666                                                     D3DVALUE px, D3DVALUE py, D3DVALUE pz,
667                                                     D3DVALUE nx, D3DVALUE ny, D3DVALUE nz,
668                                                     LPDIRECT3DRMVISUAL * ppVisual)
669 {
670     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
671
672     FIXME("(%p/%p)->(%p,%p,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, pVisual, pLight, px, py, pz,
673                                                            nx, ny, nz, ppVisual);
674
675     return E_NOTIMPL;
676 }
677
678 static HRESULT WINAPI IDirect3DRM2Impl_CreateViewport(IDirect3DRM2* iface,
679                                                       LPDIRECT3DRMDEVICE pDevice,
680                                                       LPDIRECT3DRMFRAME pFrame,
681                                                       DWORD xpos, DWORD ypos,
682                                                       DWORD width, DWORD height,
683                                                       LPDIRECT3DRMVIEWPORT * ppViewport)
684 {
685     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
686
687     FIXME("(%p/%p)->(%p,%p,%d,%d,%d,%d,%p): partial stub\n", iface, This, pDevice, pFrame,
688           xpos, ypos, width, height, ppViewport);
689
690     return Direct3DRMViewport_create(&IID_IDirect3DRMViewport, (IUnknown**)ppViewport);
691 }
692
693 static HRESULT WINAPI IDirect3DRM2Impl_CreateWrap(IDirect3DRM2* iface, D3DRMWRAPTYPE type,
694                                                   LPDIRECT3DRMFRAME pFrame,
695                                                   D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
696                                                   D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
697                                                   D3DVALUE ux, D3DVALUE uy, D3DVALUE uz,
698                                                   D3DVALUE ou, D3DVALUE ov, D3DVALUE su,
699                                                   D3DVALUE sv, LPDIRECT3DRMWRAP * ppWrap)
700 {
701     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
702
703     FIXME("(%p/%p)->(%d,%p,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, type,
704           pFrame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, ppWrap);
705
706     return E_NOTIMPL;
707 }
708
709 static HRESULT WINAPI IDirect3DRM2Impl_CreateUserVisual(IDirect3DRM2* iface,
710                                                         D3DRMUSERVISUALCALLBACK cb, LPVOID pArg,
711                                                         LPDIRECT3DRMUSERVISUAL * ppUserVisual)
712 {
713     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
714
715     FIXME("(%p/%p)->(%p,%p,%p): stub\n", iface, This, cb, pArg, ppUserVisual);
716
717     return E_NOTIMPL;
718 }
719
720 static HRESULT WINAPI IDirect3DRM2Impl_LoadTexture(IDirect3DRM2* iface, const char * filename,
721                                                    LPDIRECT3DRMTEXTURE2 * ppTexture)
722 {
723     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
724
725     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, filename, ppTexture);
726
727     return E_NOTIMPL;
728 }
729
730 static HRESULT WINAPI IDirect3DRM2Impl_LoadTextureFromResource(IDirect3DRM2* iface, HMODULE hModule,
731                                                                LPCSTR strName, LPCSTR strType,
732                                                                LPDIRECT3DRMTEXTURE2 * ppTexture)
733 {
734     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
735
736     FIXME("(%p/%p)->(%p,%p,%p,%p): stub\n", iface, This, hModule, strName, strType, ppTexture);
737
738     return E_NOTIMPL;
739 }
740
741 static HRESULT WINAPI IDirect3DRM2Impl_SetSearchPath(IDirect3DRM2* iface, LPCSTR path)
742 {
743     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
744
745     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
746
747     return E_NOTIMPL;
748 }
749
750 static HRESULT WINAPI IDirect3DRM2Impl_AddSearchPath(IDirect3DRM2* iface, LPCSTR path)
751 {
752     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
753
754     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
755
756     return E_NOTIMPL;
757 }
758
759 static HRESULT WINAPI IDirect3DRM2Impl_GetSearchPath(IDirect3DRM2* iface, DWORD *size_return,
760                                                      LPSTR path_return)
761 {
762     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
763
764     FIXME("(%p/%p)->(%p,%s): stub\n", iface, This, size_return, path_return);
765
766     return E_NOTIMPL;
767 }
768
769 static HRESULT WINAPI IDirect3DRM2Impl_SetDefaultTextureColors(IDirect3DRM2* iface, DWORD nb_colors)
770 {
771     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
772
773     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_colors);
774
775     return E_NOTIMPL;
776 }
777
778 static HRESULT WINAPI IDirect3DRM2Impl_SetDefaultTextureShades(IDirect3DRM2* iface, DWORD nb_shades)
779 {
780     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
781
782     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_shades);
783
784     return E_NOTIMPL;
785 }
786
787 static HRESULT WINAPI IDirect3DRM2Impl_GetDevices(IDirect3DRM2* iface,
788                                                   LPDIRECT3DRMDEVICEARRAY * ppDeviceArray)
789 {
790     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
791
792     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppDeviceArray);
793
794     return E_NOTIMPL;
795 }
796
797 static HRESULT WINAPI IDirect3DRM2Impl_GetNamedObject(IDirect3DRM2* iface, const char * pName,
798                                                       LPDIRECT3DRMOBJECT * ppObject)
799 {
800     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
801
802     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, pName, ppObject);
803
804     return E_NOTIMPL;
805 }
806
807 static HRESULT WINAPI IDirect3DRM2Impl_EnumerateObjects(IDirect3DRM2* iface, D3DRMOBJECTCALLBACK cb,
808                                                         LPVOID pArg)
809 {
810     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
811
812     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, cb, pArg);
813
814     return E_NOTIMPL;
815 }
816
817 static HRESULT WINAPI IDirect3DRM2Impl_Load(IDirect3DRM2* iface, LPVOID pObjSource, LPVOID pObjID,
818                                             LPIID * ppGUIDs, DWORD nb_GUIDs,
819                                             D3DRMLOADOPTIONS LOFlags, D3DRMLOADCALLBACK LoadProc,
820                                             LPVOID pArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc,
821                                             LPVOID pArgLTP, LPDIRECT3DRMFRAME pParentFrame)
822 {
823     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
824     LPDIRECT3DRMFRAME3 pParentFrame3 = NULL;
825     HRESULT hr = D3DRM_OK;
826
827     TRACE("(%p/%p)->(%p,%p,%p,%d,%d,%p,%p,%p,%p,%p)\n", iface, This, pObjSource, pObjID,
828           ppGUIDs, nb_GUIDs, LOFlags, LoadProc, pArgLP, LoadTextureProc, pArgLTP, pParentFrame);
829
830     if (pParentFrame)
831         hr = IDirect3DRMFrame_QueryInterface(pParentFrame, &IID_IDirect3DRMFrame3, (void**)&pParentFrame3);
832     if (SUCCEEDED(hr))
833         hr = IDirect3DRM3_Load(&This->IDirect3DRM3_iface, pObjSource, pObjID, ppGUIDs, nb_GUIDs, LOFlags, LoadProc, pArgLP, LoadTextureProc, pArgLTP, pParentFrame3);
834     if (pParentFrame3)
835         IDirect3DRMFrame3_Release(pParentFrame3);
836
837     return hr;
838 }
839
840 static HRESULT WINAPI IDirect3DRM2Impl_Tick(IDirect3DRM2* iface, D3DVALUE tick)
841 {
842     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
843
844     FIXME("(%p/%p)->(%f): stub\n", iface, This, tick);
845
846     return E_NOTIMPL;
847 }
848
849 static HRESULT WINAPI IDirect3DRM2Impl_CreateProgressiveMesh(IDirect3DRM2* iface,
850                                                              LPDIRECT3DRMPROGRESSIVEMESH * ppMesh)
851 {
852     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
853
854     FIXME("(%p/%p)->(%p): stub\n", iface, This, ppMesh);
855
856     return E_NOTIMPL;
857 }
858
859 static const struct IDirect3DRM2Vtbl Direct3DRM2_Vtbl =
860 {
861     IDirect3DRM2Impl_QueryInterface,
862     IDirect3DRM2Impl_AddRef,
863     IDirect3DRM2Impl_Release,
864     IDirect3DRM2Impl_CreateObject,
865     IDirect3DRM2Impl_CreateFrame,
866     IDirect3DRM2Impl_CreateMesh,
867     IDirect3DRM2Impl_CreateMeshBuilder,
868     IDirect3DRM2Impl_CreateFace,
869     IDirect3DRM2Impl_CreateAnimation,
870     IDirect3DRM2Impl_CreateAnimationSet,
871     IDirect3DRM2Impl_CreateTexture,
872     IDirect3DRM2Impl_CreateLight,
873     IDirect3DRM2Impl_CreateLightRGB,
874     IDirect3DRM2Impl_CreateMaterial,
875     IDirect3DRM2Impl_CreateDevice,
876     IDirect3DRM2Impl_CreateDeviceFromSurface,
877     IDirect3DRM2Impl_CreateDeviceFromD3D,
878     IDirect3DRM2Impl_CreateDeviceFromClipper,
879     IDirect3DRM2Impl_CreateTextureFromSurface,
880     IDirect3DRM2Impl_CreateShadow,
881     IDirect3DRM2Impl_CreateViewport,
882     IDirect3DRM2Impl_CreateWrap,
883     IDirect3DRM2Impl_CreateUserVisual,
884     IDirect3DRM2Impl_LoadTexture,
885     IDirect3DRM2Impl_LoadTextureFromResource,
886     IDirect3DRM2Impl_SetSearchPath,
887     IDirect3DRM2Impl_AddSearchPath,
888     IDirect3DRM2Impl_GetSearchPath,
889     IDirect3DRM2Impl_SetDefaultTextureColors,
890     IDirect3DRM2Impl_SetDefaultTextureShades,
891     IDirect3DRM2Impl_GetDevices,
892     IDirect3DRM2Impl_GetNamedObject,
893     IDirect3DRM2Impl_EnumerateObjects,
894     IDirect3DRM2Impl_Load,
895     IDirect3DRM2Impl_Tick,
896     IDirect3DRM2Impl_CreateProgressiveMesh
897 };
898
899
900 /*** IUnknown methods ***/
901 static HRESULT WINAPI IDirect3DRM3Impl_QueryInterface(IDirect3DRM3* iface, REFIID riid,
902                                                       void** ppvObject)
903 {
904     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
905     return IDirect3DRM_QueryInterface(&This->IDirect3DRM_iface, riid, ppvObject);
906 }
907
908 static ULONG WINAPI IDirect3DRM3Impl_AddRef(IDirect3DRM3* iface)
909 {
910     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
911     return IDirect3DRM_AddRef(&This->IDirect3DRM_iface);
912 }
913
914 static ULONG WINAPI IDirect3DRM3Impl_Release(IDirect3DRM3* iface)
915 {
916     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
917     return IDirect3DRM_Release(&This->IDirect3DRM_iface);
918 }
919
920 /*** IDirect3DRM3 methods ***/
921 static HRESULT WINAPI IDirect3DRM3Impl_CreateObject(IDirect3DRM3* iface, REFCLSID rclsid,
922                                                     LPUNKNOWN unkwn, REFIID riid, LPVOID* object)
923 {
924     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
925
926     FIXME("(%p/%p)->(%s,%p,%s,%p): stub\n", iface, This, debugstr_guid(rclsid), unkwn,
927           debugstr_guid(riid), object);
928
929     return E_NOTIMPL;
930 }
931
932 static HRESULT WINAPI IDirect3DRM3Impl_CreateFrame(IDirect3DRM3* iface, LPDIRECT3DRMFRAME3 parent_frame,
933                                                    LPDIRECT3DRMFRAME3* frame)
934 {
935     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
936
937     TRACE("(%p/%p)->(%p,%p)\n", iface, This, parent_frame, frame);
938
939     return Direct3DRMFrame_create(&IID_IDirect3DRMFrame3, (IUnknown*)parent_frame, (IUnknown**)frame);
940 }
941
942 static HRESULT WINAPI IDirect3DRM3Impl_CreateMesh(IDirect3DRM3* iface, LPDIRECT3DRMMESH* Mesh)
943 {
944     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
945
946     FIXME("(%p/%p)->(%p): stub\n", iface, This, Mesh);
947
948     return E_NOTIMPL;
949 }
950
951 static HRESULT WINAPI IDirect3DRM3Impl_CreateMeshBuilder(IDirect3DRM3* iface,
952                                                          LPDIRECT3DRMMESHBUILDER3* ppMeshBuilder)
953 {
954     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
955
956     TRACE("(%p/%p)->(%p)\n", iface, This, ppMeshBuilder);
957
958     return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder3, (IUnknown**)ppMeshBuilder);
959 }
960
961 static HRESULT WINAPI IDirect3DRM3Impl_CreateFace(IDirect3DRM3* iface, LPDIRECT3DRMFACE2* Face)
962 {
963     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
964
965     FIXME("(%p/%p)->(%p): stub\n", iface, This, Face);
966
967     return E_NOTIMPL;
968 }
969
970 static HRESULT WINAPI IDirect3DRM3Impl_CreateAnimation(IDirect3DRM3* iface,
971                                                        LPDIRECT3DRMANIMATION2* Animation)
972 {
973     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
974
975     FIXME("(%p/%p)->(%p): stub\n", iface, This, Animation);
976
977     return E_NOTIMPL;
978 }
979
980 static HRESULT WINAPI IDirect3DRM3Impl_CreateAnimationSet(IDirect3DRM3* iface,
981                                                           LPDIRECT3DRMANIMATIONSET2* AnimationSet)
982 {
983     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
984
985     FIXME("(%p/%p)->(%p): stub\n", iface, This, AnimationSet);
986
987     return E_NOTIMPL;
988 }
989
990 static HRESULT WINAPI IDirect3DRM3Impl_CreateTexture(IDirect3DRM3* iface, LPD3DRMIMAGE Image,
991                                                      LPDIRECT3DRMTEXTURE3* Texture)
992 {
993     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
994
995     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, Image, Texture);
996
997     return E_NOTIMPL;
998 }
999
1000 static HRESULT WINAPI IDirect3DRM3Impl_CreateLight(IDirect3DRM3* iface, D3DRMLIGHTTYPE type,
1001                                                      D3DCOLOR color, LPDIRECT3DRMLIGHT* Light)
1002 {
1003     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1004     HRESULT ret;
1005
1006     FIXME("(%p/%p)->(%d,%d,%p): partial stub\n", iface, This, type, color, Light);
1007
1008     ret = Direct3DRMLight_create((IUnknown**)Light);
1009
1010     if (SUCCEEDED(ret))
1011     {
1012         IDirect3DRMLight_SetType(*Light, type);
1013         IDirect3DRMLight_SetColor(*Light, color);
1014     }
1015
1016     return ret;
1017 }
1018
1019 static HRESULT WINAPI IDirect3DRM3Impl_CreateLightRGB(IDirect3DRM3* iface, D3DRMLIGHTTYPE type,
1020                                                         D3DVALUE red, D3DVALUE green, D3DVALUE blue,
1021                                                         LPDIRECT3DRMLIGHT* Light)
1022 {
1023     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1024     HRESULT ret;
1025
1026     FIXME("(%p/%p)->(%d,%f,%f,%f,%p): partial stub\n", iface, This, type, red, green, blue, Light);
1027
1028     ret = Direct3DRMLight_create((IUnknown**)Light);
1029
1030     if (SUCCEEDED(ret))
1031     {
1032         IDirect3DRMLight_SetType(*Light, type);
1033         IDirect3DRMLight_SetColorRGB(*Light, red, green, blue);
1034     }
1035
1036     return ret;
1037 }
1038
1039 static HRESULT WINAPI IDirect3DRM3Impl_CreateMaterial(IDirect3DRM3* iface, D3DVALUE power,
1040                                                       LPDIRECT3DRMMATERIAL2* material)
1041 {
1042     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1043     HRESULT ret;
1044
1045     TRACE("(%p/%p)->(%f,%p)\n", iface, This, power, material);
1046
1047     ret = Direct3DRMMaterial_create(material);
1048
1049     if (SUCCEEDED(ret))
1050         IDirect3DRMMaterial2_SetPower(*material, power);
1051
1052     return ret;
1053 }
1054
1055 static HRESULT WINAPI IDirect3DRM3Impl_CreateDevice(IDirect3DRM3* iface, DWORD width, DWORD height,
1056                                                     LPDIRECT3DRMDEVICE3* device)
1057 {
1058     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1059
1060     FIXME("(%p/%p)->(%d,%d,%p): partial stub\n", iface, This, width, height, device);
1061
1062     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1063 }
1064
1065 static HRESULT WINAPI IDirect3DRM3Impl_CreateDeviceFromSurface(IDirect3DRM3* iface, LPGUID pGUID,
1066                                                                LPDIRECTDRAW dd,
1067                                                                LPDIRECTDRAWSURFACE back,
1068                                                                LPDIRECT3DRMDEVICE3* device)
1069 {
1070     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1071
1072     FIXME("(%p/%p)->(%s,%p,%p,%p): partial stub\n", iface, This, debugstr_guid(pGUID), dd, back, device);
1073
1074     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1075 }
1076
1077 static HRESULT WINAPI IDirect3DRM3Impl_CreateDeviceFromD3D(IDirect3DRM3* iface, LPDIRECT3D2 d3d,
1078                                                            LPDIRECT3DDEVICE2 d3ddev,
1079                                                            LPDIRECT3DRMDEVICE3* device)
1080 {
1081     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1082
1083     FIXME("(%p/%p)->(%p,%p,%p): partial stub\n", iface, This, d3d, d3ddev, device);
1084
1085     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1086 }
1087
1088 static HRESULT WINAPI IDirect3DRM3Impl_CreateDeviceFromClipper(IDirect3DRM3* iface,
1089                                                                LPDIRECTDRAWCLIPPER clipper,
1090                                                                LPGUID GUID, int width, int height,
1091                                                                LPDIRECT3DRMDEVICE3* device)
1092 {
1093     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1094
1095     FIXME("(%p/%p)->(%p,%s,%d,%d,%p): partial stub\n", iface, This, clipper, debugstr_guid(GUID),
1096           width, height, device);
1097
1098     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1099 }
1100
1101 static HRESULT WINAPI IDirect3DRM3Impl_CreateShadow(IDirect3DRM3* iface, LPUNKNOWN Visual1,
1102                                                     LPDIRECT3DRMLIGHT Light, D3DVALUE px,
1103                                                     D3DVALUE py, D3DVALUE pz, D3DVALUE nx,
1104                                                     D3DVALUE ny, D3DVALUE nz,
1105                                                     LPDIRECT3DRMSHADOW2* Visual2)
1106 {
1107     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1108
1109     FIXME("(%p/%p)->(%p,%p,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, Visual1, Light, px, py, pz,
1110           nx, ny, nz, Visual2);
1111
1112     return E_NOTIMPL;
1113 }
1114
1115 static HRESULT WINAPI IDirect3DRM3Impl_CreateTextureFromSurface(IDirect3DRM3* iface,
1116                                                                 LPDIRECTDRAWSURFACE surface,
1117                                                                 LPDIRECT3DRMTEXTURE3* texture)
1118 {
1119     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1120
1121     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, surface, texture);
1122
1123     return E_NOTIMPL;
1124 }
1125
1126 static HRESULT WINAPI IDirect3DRM3Impl_CreateViewport(IDirect3DRM3* iface,
1127                                                       LPDIRECT3DRMDEVICE3 Device,
1128                                                       LPDIRECT3DRMFRAME3 frame, DWORD xpos,
1129                                                       DWORD ypos, DWORD width, DWORD height,
1130                                                       LPDIRECT3DRMVIEWPORT2* viewport)
1131 {
1132     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1133
1134     FIXME("(%p/%p)->(%p,%p,%d,%d,%d,%d,%p): stub\n", iface, This, Device, frame, xpos, ypos, width,
1135           height, viewport);
1136
1137     return Direct3DRMViewport_create(&IID_IDirect3DRMViewport2, (IUnknown**)viewport);
1138 }
1139
1140 static HRESULT WINAPI IDirect3DRM3Impl_CreateWrap(IDirect3DRM3* iface, D3DRMWRAPTYPE type,
1141                                                   LPDIRECT3DRMFRAME3 frame,
1142                                                   D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
1143                                                   D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
1144                                                   D3DVALUE ux, D3DVALUE uy, D3DVALUE uz,
1145                                                   D3DVALUE ou, D3DVALUE ov, D3DVALUE su,
1146                                                   D3DVALUE sv, LPDIRECT3DRMWRAP* wrap)
1147 {
1148     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1149
1150     FIXME("(%p/%p)->(%d,%p,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, type,
1151           frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
1152
1153     return E_NOTIMPL;
1154 }
1155
1156 static HRESULT WINAPI IDirect3DRM3Impl_CreateUserVisual(IDirect3DRM3* iface,
1157                                                         D3DRMUSERVISUALCALLBACK cb, LPVOID arg,
1158                                                         LPDIRECT3DRMUSERVISUAL* UserVisual)
1159 {
1160     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1161
1162     FIXME("(%p/%p)->(%p,%p,%p): stub\n", iface, This, cb, arg, UserVisual);
1163
1164     return E_NOTIMPL;
1165 }
1166
1167 static HRESULT WINAPI IDirect3DRM3Impl_LoadTexture(IDirect3DRM3* iface, const char* filename,
1168                                                    LPDIRECT3DRMTEXTURE3* Texture)
1169 {
1170     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1171
1172     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, filename, Texture);
1173
1174     return E_NOTIMPL;
1175 }
1176
1177 static HRESULT WINAPI IDirect3DRM3Impl_LoadTextureFromResource(IDirect3DRM3* iface, HMODULE mod,
1178                                                                LPCSTR strName, LPCSTR strType,
1179                                                                LPDIRECT3DRMTEXTURE3 * ppTexture)
1180 {
1181     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1182
1183     FIXME("(%p/%p)->(%p,%p,%p,%p): stub\n", iface, This, mod, strName, strType, ppTexture);
1184
1185     return E_NOTIMPL;
1186 }
1187
1188 static HRESULT WINAPI IDirect3DRM3Impl_SetSearchPath(IDirect3DRM3* iface, LPCSTR path)
1189 {
1190     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1191
1192     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
1193
1194     return E_NOTIMPL;
1195 }
1196
1197 static HRESULT WINAPI IDirect3DRM3Impl_AddSearchPath(IDirect3DRM3* iface, LPCSTR path)
1198 {
1199     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1200
1201     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
1202
1203     return E_NOTIMPL;
1204 }
1205
1206 static HRESULT WINAPI IDirect3DRM3Impl_GetSearchPath(IDirect3DRM3* iface, DWORD* size_return,
1207                                                      LPSTR path_return)
1208 {
1209     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1210
1211     FIXME("(%p/%p)->(%p,%s): stub\n", iface, This, size_return, path_return);
1212
1213     return E_NOTIMPL;
1214 }
1215
1216 static HRESULT WINAPI IDirect3DRM3Impl_SetDefaultTextureColors(IDirect3DRM3* iface, DWORD nb_colors)
1217 {
1218     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1219
1220     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_colors);
1221
1222     return E_NOTIMPL;
1223 }
1224
1225 static HRESULT WINAPI IDirect3DRM3Impl_SetDefaultTextureShades(IDirect3DRM3* iface, DWORD nb_shades)
1226 {
1227     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1228
1229     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_shades);
1230
1231     return E_NOTIMPL;
1232 }
1233
1234 static HRESULT WINAPI IDirect3DRM3Impl_GetDevices(IDirect3DRM3* iface,
1235                                                   LPDIRECT3DRMDEVICEARRAY* DeviceArray)
1236 {
1237     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1238
1239     FIXME("(%p/%p)->(%p): stub\n", iface, This, DeviceArray);
1240
1241     return E_NOTIMPL;
1242 }
1243
1244 static HRESULT WINAPI IDirect3DRM3Impl_GetNamedObject(IDirect3DRM3* iface, const char* Name,
1245                                                       LPDIRECT3DRMOBJECT* Object)
1246 {
1247     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1248
1249     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, Name, Object);
1250
1251     return E_NOTIMPL;
1252 }
1253
1254 static HRESULT WINAPI IDirect3DRM3Impl_EnumerateObjects(IDirect3DRM3* iface, D3DRMOBJECTCALLBACK cb,
1255                                                         LPVOID arg)
1256 {
1257     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1258
1259     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, cb, arg);
1260
1261     return E_NOTIMPL;
1262 }
1263
1264 static HRESULT load_data(IDirect3DRM3* iface, LPDIRECTXFILEDATA data_object, LPIID* GUIDs, DWORD nb_GUIDs, D3DRMLOADCALLBACK LoadProc,
1265                   LPVOID ArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, LPVOID ArgLTP, LPDIRECT3DRMFRAME3 parent_frame)
1266 {
1267     HRESULT ret = D3DRMERR_BADOBJECT;
1268     HRESULT hr;
1269     const GUID* guid;
1270     DWORD i;
1271     BOOL requested = FALSE;
1272
1273     hr = IDirectXFileData_GetType(data_object, &guid);
1274     if (hr != DXFILE_OK)
1275         goto end;
1276
1277     TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1278
1279     if (IsEqualGUID(guid, &TID_D3DRMMesh))
1280     {
1281         TRACE("Found TID_D3DRMMesh\n");
1282
1283         for (i = 0; i < nb_GUIDs; i++)
1284             if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder) ||
1285                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder2) ||
1286                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder3))
1287             {
1288                 requested = TRUE;
1289                 break;
1290             }
1291
1292         if (requested)
1293         {
1294             LPDIRECT3DRMMESHBUILDER3 meshbuilder;
1295
1296             TRACE("Load mesh data and notify application\n");
1297
1298             hr = IDirect3DRM3_CreateMeshBuilder(iface, &meshbuilder);
1299             if (SUCCEEDED(hr))
1300             {
1301                 LPDIRECT3DRMOBJECT object = NULL;
1302
1303                 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder, GUIDs[i], (void**)&object);
1304                 if (SUCCEEDED(hr))
1305                 {
1306                     hr = load_mesh_data(meshbuilder, data_object);
1307                     if (SUCCEEDED(hr))
1308                     {
1309                         /* Only top level objects are notified */
1310                         if (parent_frame)
1311                             IDirect3DRMFrame3_AddVisual(parent_frame, (IUnknown*)meshbuilder);
1312                         else
1313                             LoadProc(object, GUIDs[i], ArgLP);
1314                     }
1315                     IDirect3DRMObject_Release(object);
1316                 }
1317                 IDirect3DRMMeshBuilder3_Release(meshbuilder);
1318             }
1319
1320             if (FAILED(hr))
1321                 ERR("Cannot process mesh\n");
1322         }
1323     }
1324     else if (IsEqualGUID(guid, &TID_D3DRMFrame))
1325     {
1326         TRACE("Found TID_D3DRMFrame\n");
1327
1328         for (i = 0; i < nb_GUIDs; i++)
1329             if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame) ||
1330                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame2) ||
1331                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame3))
1332             {
1333                 requested = TRUE;
1334                 break;
1335             }
1336
1337         if (requested)
1338         {
1339             LPDIRECT3DRMFRAME3 frame;
1340
1341             TRACE("Load frame data and notify application\n");
1342
1343             hr = IDirect3DRM3_CreateFrame(iface, parent_frame, &frame);
1344             if (SUCCEEDED(hr))
1345             {
1346                 LPDIRECT3DRMOBJECT object;
1347
1348                 hr = IDirect3DRMFrame3_QueryInterface(frame, GUIDs[i], (void**)&object);
1349                 if (SUCCEEDED(hr))
1350                 {
1351                     LPDIRECTXFILEOBJECT child;
1352
1353                     while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(data_object, &child)))
1354                     {
1355                         LPDIRECTXFILEDATA data;
1356                         LPDIRECTXFILEDATAREFERENCE reference;
1357                         LPDIRECTXFILEBINARY binary;
1358
1359                         hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileBinary, (void **)&binary);
1360                         if (SUCCEEDED(hr))
1361                         {
1362                             FIXME("Binary Object not supported yet\n");
1363                             IDirectXFileBinary_Release(binary);
1364                             continue;
1365                         }
1366
1367                         hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1368                         if (SUCCEEDED(hr))
1369                         {
1370                             TRACE("Found Data Object\n");
1371                             hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1372                             IDirectXFileData_Release(data);
1373                             continue;
1374                         }
1375                         hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1376                         if (SUCCEEDED(hr))
1377                         {
1378                             TRACE("Found Data Object Reference\n");
1379                             IDirectXFileDataReference_Resolve(reference, &data);
1380                             hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1381                             IDirectXFileData_Release(data);
1382                             IDirectXFileDataReference_Release(reference);
1383                             continue;
1384                         }
1385                     }
1386
1387                     if (hr != DXFILEERR_NOMOREOBJECTS)
1388                     {
1389                         IDirect3DRMObject_Release(object);
1390                         IDirect3DRMFrame3_Release(frame);
1391                         goto end;
1392                     }
1393                     hr = S_OK;
1394
1395                     /* Only top level objects are notified */
1396                     if (!parent_frame)
1397                         LoadProc(object, GUIDs[i], ArgLP);
1398                     IDirect3DRMObject_Release(object);
1399                 }
1400                 IDirect3DRMFrame3_Release(frame);
1401             }
1402
1403             if (FAILED(hr))
1404                 ERR("Cannot process frame\n");
1405         }
1406     }
1407     else if (IsEqualGUID(guid, &TID_D3DRMMaterial))
1408     {
1409         TRACE("Found TID_D3DRMMaterial => Will be taken into account when a mesh will reference it\n");
1410     }
1411     else if (IsEqualGUID(guid, &TID_D3DRMFrameTransformMatrix))
1412     {
1413         TRACE("Found TID_D3DRMFrameTransformMatrix\n");
1414
1415         if (parent_frame)
1416         {
1417             D3DRMMATRIX4D matrix;
1418             DWORD size;
1419
1420             TRACE("Load Frame Transform Matrix data\n");
1421
1422             size = sizeof(matrix);
1423             hr = IDirectXFileData_GetData(data_object, NULL, &size, (void**)matrix);
1424             if ((hr != DXFILE_OK) || (size != sizeof(matrix)))
1425                 goto end;
1426
1427             hr = IDirect3DRMFrame3_AddTransform(parent_frame, D3DRMCOMBINE_REPLACE, matrix);
1428             if (FAILED(hr))
1429                 goto end;
1430         }
1431     }
1432     else
1433     {
1434         FIXME("Found unknown TID %s\n", debugstr_guid(guid));
1435     }
1436
1437     ret = D3DRM_OK;
1438
1439 end:
1440
1441     return ret;
1442 }
1443
1444 static HRESULT WINAPI IDirect3DRM3Impl_Load(IDirect3DRM3* iface, LPVOID ObjSource, LPVOID ObjID,
1445                                             LPIID* GUIDs, DWORD nb_GUIDs, D3DRMLOADOPTIONS LOFlags,
1446                                             D3DRMLOADCALLBACK LoadProc, LPVOID ArgLP,
1447                                             D3DRMLOADTEXTURECALLBACK LoadTextureProc, LPVOID ArgLTP,
1448                                             LPDIRECT3DRMFRAME3 ParentFrame)
1449 {
1450     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1451     DXFILELOADOPTIONS load_options;
1452     LPDIRECTXFILE pDXFile = NULL;
1453     LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1454     LPDIRECTXFILEDATA pData = NULL;
1455     HRESULT hr;
1456     const GUID* pGuid;
1457     DWORD size;
1458     Header* pHeader;
1459     HRESULT ret = D3DRMERR_BADOBJECT;
1460     DWORD i;
1461
1462     TRACE("(%p/%p)->(%p,%p,%p,%d,%d,%p,%p,%p,%p,%p)\n", iface, This, ObjSource, ObjID, GUIDs,
1463           nb_GUIDs, LOFlags, LoadProc, ArgLP, LoadTextureProc, ArgLTP, ParentFrame);
1464
1465     TRACE("Looking for GUIDs:\n");
1466     for (i = 0; i < nb_GUIDs; i++)
1467         TRACE("- %s (%s)\n", debugstr_guid(GUIDs[i]), get_IID_string(GUIDs[i]));
1468
1469     if (LOFlags == D3DRMLOAD_FROMMEMORY)
1470     {
1471         load_options = DXFILELOAD_FROMMEMORY;
1472     }
1473     else if (LOFlags == D3DRMLOAD_FROMFILE)
1474     {
1475         load_options = DXFILELOAD_FROMFILE;
1476         TRACE("Loading from file %s\n", debugstr_a(ObjSource));
1477     }
1478     else
1479     {
1480         FIXME("Load options %d not supported yet\n", LOFlags);
1481         return E_NOTIMPL;
1482     }
1483
1484     hr = DirectXFileCreate(&pDXFile);
1485     if (hr != DXFILE_OK)
1486         goto end;
1487
1488     hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1489     if (hr != DXFILE_OK)
1490         goto end;
1491
1492     hr = IDirectXFile_CreateEnumObject(pDXFile, ObjSource, load_options, &pEnumObject);
1493     if (hr != DXFILE_OK)
1494         goto end;
1495
1496     hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1497     if (hr != DXFILE_OK)
1498         goto end;
1499
1500     hr = IDirectXFileData_GetType(pData, &pGuid);
1501     if (hr != DXFILE_OK)
1502         goto end;
1503
1504     TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1505
1506     if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1507     {
1508         ret = D3DRMERR_BADFILE;
1509         goto end;
1510     }
1511
1512     hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1513     if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1514         goto end;
1515
1516     TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1517
1518     /* Version must be 1.0.x */
1519     if ((pHeader->major != 1) || (pHeader->minor != 0))
1520     {
1521         ret = D3DRMERR_BADFILE;
1522         goto end;
1523     }
1524
1525     IDirectXFileData_Release(pData);
1526     pData = NULL;
1527
1528     while (1)
1529     {
1530         hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1531         if (hr == DXFILEERR_NOMOREOBJECTS)
1532         {
1533             TRACE("No more object\n");
1534             break;
1535         }
1536         else if (hr != DXFILE_OK)
1537         {
1538             ret = D3DRMERR_NOTFOUND;
1539             goto end;
1540         }
1541
1542         ret = load_data(iface, pData, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, ParentFrame);
1543         if (ret != D3DRM_OK)
1544             goto end;
1545
1546         IDirectXFileData_Release(pData);
1547         pData = NULL;
1548     }
1549
1550     ret = D3DRM_OK;
1551
1552 end:
1553     if (pData)
1554         IDirectXFileData_Release(pData);
1555     if (pEnumObject)
1556         IDirectXFileEnumObject_Release(pEnumObject);
1557     if (pDXFile)
1558         IDirectXFile_Release(pDXFile);
1559
1560     return ret;
1561 }
1562
1563 static HRESULT WINAPI IDirect3DRM3Impl_Tick(IDirect3DRM3* iface, D3DVALUE tick)
1564 {
1565     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1566
1567     FIXME("(%p/%p)->(%f): stub\n", iface, This, tick);
1568
1569     return E_NOTIMPL;
1570 }
1571
1572 static HRESULT WINAPI IDirect3DRM3Impl_CreateProgressiveMesh(IDirect3DRM3* iface,
1573                                                              LPDIRECT3DRMPROGRESSIVEMESH Mesh)
1574 {
1575     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1576
1577     FIXME("(%p/%p)->(%p): stub\n", iface, This, Mesh);
1578
1579     return E_NOTIMPL;
1580 }
1581
1582 static HRESULT WINAPI IDirect3DRM3Impl_RegisterClient(IDirect3DRM3* iface, REFGUID rguid,
1583                                                       LPDWORD id)
1584 {
1585     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1586
1587     FIXME("(%p/%p)->(%s, %p): stub\n", iface, This, debugstr_guid(rguid), id);
1588
1589     return E_NOTIMPL;
1590 }
1591
1592 static HRESULT WINAPI IDirect3DRM3Impl_UnregisterClient(IDirect3DRM3* iface, REFGUID rguid)
1593 {
1594     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1595
1596     FIXME("(%p/%p)->(%s): stub\n", iface, This, debugstr_guid(rguid));
1597
1598     return E_NOTIMPL;
1599 }
1600
1601 static HRESULT WINAPI IDirect3DRM3Impl_CreateClippedVisual(IDirect3DRM3* iface,
1602                                                            LPDIRECT3DRMVISUAL vis,
1603                                                            LPDIRECT3DRMCLIPPEDVISUAL* clippedvis)
1604 {
1605     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1606
1607     FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, vis, clippedvis);
1608
1609     return E_NOTIMPL;
1610 }
1611
1612 static HRESULT WINAPI IDirect3DRM3Impl_SetOptions(IDirect3DRM3* iface, DWORD opt)
1613 {
1614     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1615
1616     FIXME("(%p/%p)->(%d): stub\n", iface, This, opt);
1617
1618     return E_NOTIMPL;
1619 }
1620
1621 static HRESULT WINAPI IDirect3DRM3Impl_GetOptions(IDirect3DRM3* iface, LPDWORD opt)
1622 {
1623     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1624
1625     FIXME("(%p/%p)->(%p): stub\n", iface, This, opt);
1626
1627     return E_NOTIMPL;
1628 }
1629
1630 static const struct IDirect3DRM3Vtbl Direct3DRM3_Vtbl =
1631 {
1632     IDirect3DRM3Impl_QueryInterface,
1633     IDirect3DRM3Impl_AddRef,
1634     IDirect3DRM3Impl_Release,
1635     IDirect3DRM3Impl_CreateObject,
1636     IDirect3DRM3Impl_CreateFrame,
1637     IDirect3DRM3Impl_CreateMesh,
1638     IDirect3DRM3Impl_CreateMeshBuilder,
1639     IDirect3DRM3Impl_CreateFace,
1640     IDirect3DRM3Impl_CreateAnimation,
1641     IDirect3DRM3Impl_CreateAnimationSet,
1642     IDirect3DRM3Impl_CreateTexture,
1643     IDirect3DRM3Impl_CreateLight,
1644     IDirect3DRM3Impl_CreateLightRGB,
1645     IDirect3DRM3Impl_CreateMaterial,
1646     IDirect3DRM3Impl_CreateDevice,
1647     IDirect3DRM3Impl_CreateDeviceFromSurface,
1648     IDirect3DRM3Impl_CreateDeviceFromD3D,
1649     IDirect3DRM3Impl_CreateDeviceFromClipper,
1650     IDirect3DRM3Impl_CreateTextureFromSurface,
1651     IDirect3DRM3Impl_CreateShadow,
1652     IDirect3DRM3Impl_CreateViewport,
1653     IDirect3DRM3Impl_CreateWrap,
1654     IDirect3DRM3Impl_CreateUserVisual,
1655     IDirect3DRM3Impl_LoadTexture,
1656     IDirect3DRM3Impl_LoadTextureFromResource,
1657     IDirect3DRM3Impl_SetSearchPath,
1658     IDirect3DRM3Impl_AddSearchPath,
1659     IDirect3DRM3Impl_GetSearchPath,
1660     IDirect3DRM3Impl_SetDefaultTextureColors,
1661     IDirect3DRM3Impl_SetDefaultTextureShades,
1662     IDirect3DRM3Impl_GetDevices,
1663     IDirect3DRM3Impl_GetNamedObject,
1664     IDirect3DRM3Impl_EnumerateObjects,
1665     IDirect3DRM3Impl_Load,
1666     IDirect3DRM3Impl_Tick,
1667     IDirect3DRM3Impl_CreateProgressiveMesh,
1668     IDirect3DRM3Impl_RegisterClient,
1669     IDirect3DRM3Impl_UnregisterClient,
1670     IDirect3DRM3Impl_CreateClippedVisual,
1671     IDirect3DRM3Impl_SetOptions,
1672     IDirect3DRM3Impl_GetOptions
1673 };
1674
1675 HRESULT Direct3DRM_create(IUnknown** ppObj)
1676 {
1677     IDirect3DRMImpl* object;
1678
1679     TRACE("(%p)\n", ppObj);
1680
1681     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMImpl));
1682     if (!object)
1683     {
1684         ERR("Out of memory\n");
1685         return E_OUTOFMEMORY;
1686     }
1687
1688     object->IDirect3DRM_iface.lpVtbl = &Direct3DRM_Vtbl;
1689     object->IDirect3DRM2_iface.lpVtbl = &Direct3DRM2_Vtbl;
1690     object->IDirect3DRM3_iface.lpVtbl = &Direct3DRM3_Vtbl;
1691     object->ref = 1;
1692
1693     *ppObj = (IUnknown*)&object->IDirect3DRM_iface;
1694
1695     return S_OK;
1696 }