d3drm: Make load_data() static.
[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_Material(IDirect3DRM* iface, D3DVALUE m, LPDIRECT3DRMMATERIAL * ppMaterial)
225 {
226     IDirect3DRMImpl *This = impl_from_IDirect3DRM(iface);
227
228     FIXME("(%p/%p)->(%f,%p): stub\n", iface, This, m, ppMaterial);
229
230     return E_NOTIMPL;
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_Material,
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_Material(IDirect3DRM2* iface, D3DVALUE m,
597                                                 LPDIRECT3DRMMATERIAL * ppMaterial)
598 {
599     IDirect3DRMImpl *This = impl_from_IDirect3DRM2(iface);
600
601     FIXME("(%p/%p)->(%f,%p): stub\n", iface, This, m, ppMaterial);
602
603     return E_NOTIMPL;
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_Material,
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_Material(IDirect3DRM3* iface, D3DVALUE m,
1040                                                 LPDIRECT3DRMMATERIAL2* Material)
1041 {
1042     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1043
1044     FIXME("(%p/%p)->(%f,%p): stub\n", iface, This, m, Material);
1045
1046     return E_NOTIMPL;
1047 }
1048
1049 static HRESULT WINAPI IDirect3DRM3Impl_CreateDevice(IDirect3DRM3* iface, DWORD width, DWORD height,
1050                                                     LPDIRECT3DRMDEVICE3* device)
1051 {
1052     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1053
1054     FIXME("(%p/%p)->(%d,%d,%p): partial stub\n", iface, This, width, height, device);
1055
1056     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1057 }
1058
1059 static HRESULT WINAPI IDirect3DRM3Impl_CreateDeviceFromSurface(IDirect3DRM3* iface, LPGUID pGUID,
1060                                                                LPDIRECTDRAW dd,
1061                                                                LPDIRECTDRAWSURFACE back,
1062                                                                LPDIRECT3DRMDEVICE3* device)
1063 {
1064     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1065
1066     FIXME("(%p/%p)->(%s,%p,%p,%p): partial stub\n", iface, This, debugstr_guid(pGUID), dd, back, device);
1067
1068     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1069 }
1070
1071 static HRESULT WINAPI IDirect3DRM3Impl_CreateDeviceFromD3D(IDirect3DRM3* iface, LPDIRECT3D2 d3d,
1072                                                            LPDIRECT3DDEVICE2 d3ddev,
1073                                                            LPDIRECT3DRMDEVICE3* device)
1074 {
1075     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1076
1077     FIXME("(%p/%p)->(%p,%p,%p): partial stub\n", iface, This, d3d, d3ddev, device);
1078
1079     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1080 }
1081
1082 static HRESULT WINAPI IDirect3DRM3Impl_CreateDeviceFromClipper(IDirect3DRM3* iface,
1083                                                                LPDIRECTDRAWCLIPPER clipper,
1084                                                                LPGUID GUID, int width, int height,
1085                                                                LPDIRECT3DRMDEVICE3* device)
1086 {
1087     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1088
1089     FIXME("(%p/%p)->(%p,%s,%d,%d,%p): partial stub\n", iface, This, clipper, debugstr_guid(GUID),
1090           width, height, device);
1091
1092     return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown**)device);
1093 }
1094
1095 static HRESULT WINAPI IDirect3DRM3Impl_CreateShadow(IDirect3DRM3* iface, LPUNKNOWN Visual1,
1096                                                     LPDIRECT3DRMLIGHT Light, D3DVALUE px,
1097                                                     D3DVALUE py, D3DVALUE pz, D3DVALUE nx,
1098                                                     D3DVALUE ny, D3DVALUE nz,
1099                                                     LPDIRECT3DRMSHADOW2* Visual2)
1100 {
1101     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1102
1103     FIXME("(%p/%p)->(%p,%p,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, Visual1, Light, px, py, pz,
1104           nx, ny, nz, Visual2);
1105
1106     return E_NOTIMPL;
1107 }
1108
1109 static HRESULT WINAPI IDirect3DRM3Impl_CreateTextureFromSurface(IDirect3DRM3* iface,
1110                                                                 LPDIRECTDRAWSURFACE surface,
1111                                                                 LPDIRECT3DRMTEXTURE3* texture)
1112 {
1113     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1114
1115     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, surface, texture);
1116
1117     return E_NOTIMPL;
1118 }
1119
1120 static HRESULT WINAPI IDirect3DRM3Impl_CreateViewport(IDirect3DRM3* iface,
1121                                                       LPDIRECT3DRMDEVICE3 Device,
1122                                                       LPDIRECT3DRMFRAME3 frame, DWORD xpos,
1123                                                       DWORD ypos, DWORD width, DWORD height,
1124                                                       LPDIRECT3DRMVIEWPORT2* viewport)
1125 {
1126     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1127
1128     FIXME("(%p/%p)->(%p,%p,%d,%d,%d,%d,%p): stub\n", iface, This, Device, frame, xpos, ypos, width,
1129           height, viewport);
1130
1131     return Direct3DRMViewport_create(&IID_IDirect3DRMViewport2, (IUnknown**)viewport);
1132 }
1133
1134 static HRESULT WINAPI IDirect3DRM3Impl_CreateWrap(IDirect3DRM3* iface, D3DRMWRAPTYPE type,
1135                                                   LPDIRECT3DRMFRAME3 frame,
1136                                                   D3DVALUE ox, D3DVALUE oy, D3DVALUE oz,
1137                                                   D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
1138                                                   D3DVALUE ux, D3DVALUE uy, D3DVALUE uz,
1139                                                   D3DVALUE ou, D3DVALUE ov, D3DVALUE su,
1140                                                   D3DVALUE sv, LPDIRECT3DRMWRAP* wrap)
1141 {
1142     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1143
1144     FIXME("(%p/%p)->(%d,%p,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%p): stub\n", iface, This, type,
1145           frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
1146
1147     return E_NOTIMPL;
1148 }
1149
1150 static HRESULT WINAPI IDirect3DRM3Impl_CreateUserVisual(IDirect3DRM3* iface,
1151                                                         D3DRMUSERVISUALCALLBACK cb, LPVOID arg,
1152                                                         LPDIRECT3DRMUSERVISUAL* UserVisual)
1153 {
1154     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1155
1156     FIXME("(%p/%p)->(%p,%p,%p): stub\n", iface, This, cb, arg, UserVisual);
1157
1158     return E_NOTIMPL;
1159 }
1160
1161 static HRESULT WINAPI IDirect3DRM3Impl_LoadTexture(IDirect3DRM3* iface, const char* filename,
1162                                                    LPDIRECT3DRMTEXTURE3* Texture)
1163 {
1164     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1165
1166     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, filename, Texture);
1167
1168     return E_NOTIMPL;
1169 }
1170
1171 static HRESULT WINAPI IDirect3DRM3Impl_LoadTextureFromResource(IDirect3DRM3* iface, HMODULE mod,
1172                                                                LPCSTR strName, LPCSTR strType,
1173                                                                LPDIRECT3DRMTEXTURE3 * ppTexture)
1174 {
1175     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1176
1177     FIXME("(%p/%p)->(%p,%p,%p,%p): stub\n", iface, This, mod, strName, strType, ppTexture);
1178
1179     return E_NOTIMPL;
1180 }
1181
1182 static HRESULT WINAPI IDirect3DRM3Impl_SetSearchPath(IDirect3DRM3* iface, LPCSTR path)
1183 {
1184     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1185
1186     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
1187
1188     return E_NOTIMPL;
1189 }
1190
1191 static HRESULT WINAPI IDirect3DRM3Impl_AddSearchPath(IDirect3DRM3* iface, LPCSTR path)
1192 {
1193     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1194
1195     FIXME("(%p/%p)->(%s): stub\n", iface, This, path);
1196
1197     return E_NOTIMPL;
1198 }
1199
1200 static HRESULT WINAPI IDirect3DRM3Impl_GetSearchPath(IDirect3DRM3* iface, DWORD* size_return,
1201                                                      LPSTR path_return)
1202 {
1203     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1204
1205     FIXME("(%p/%p)->(%p,%s): stub\n", iface, This, size_return, path_return);
1206
1207     return E_NOTIMPL;
1208 }
1209
1210 static HRESULT WINAPI IDirect3DRM3Impl_SetDefaultTextureColors(IDirect3DRM3* iface, DWORD nb_colors)
1211 {
1212     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1213
1214     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_colors);
1215
1216     return E_NOTIMPL;
1217 }
1218
1219 static HRESULT WINAPI IDirect3DRM3Impl_SetDefaultTextureShades(IDirect3DRM3* iface, DWORD nb_shades)
1220 {
1221     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1222
1223     FIXME("(%p/%p)->(%d): stub\n", iface, This, nb_shades);
1224
1225     return E_NOTIMPL;
1226 }
1227
1228 static HRESULT WINAPI IDirect3DRM3Impl_GetDevices(IDirect3DRM3* iface,
1229                                                   LPDIRECT3DRMDEVICEARRAY* DeviceArray)
1230 {
1231     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1232
1233     FIXME("(%p/%p)->(%p): stub\n", iface, This, DeviceArray);
1234
1235     return E_NOTIMPL;
1236 }
1237
1238 static HRESULT WINAPI IDirect3DRM3Impl_GetNamedObject(IDirect3DRM3* iface, const char* Name,
1239                                                       LPDIRECT3DRMOBJECT* Object)
1240 {
1241     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1242
1243     FIXME("(%p/%p)->(%s,%p): stub\n", iface, This, Name, Object);
1244
1245     return E_NOTIMPL;
1246 }
1247
1248 static HRESULT WINAPI IDirect3DRM3Impl_EnumerateObjects(IDirect3DRM3* iface, D3DRMOBJECTCALLBACK cb,
1249                                                         LPVOID arg)
1250 {
1251     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1252
1253     FIXME("(%p/%p)->(%p,%p): stub\n", iface, This, cb, arg);
1254
1255     return E_NOTIMPL;
1256 }
1257
1258 static HRESULT load_data(IDirect3DRM3* iface, LPDIRECTXFILEDATA data_object, LPIID* GUIDs, DWORD nb_GUIDs, D3DRMLOADCALLBACK LoadProc,
1259                   LPVOID ArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, LPVOID ArgLTP, LPDIRECT3DRMFRAME3 parent_frame)
1260 {
1261     HRESULT ret = D3DRMERR_BADOBJECT;
1262     HRESULT hr;
1263     const GUID* guid;
1264     DWORD i;
1265     BOOL requested = FALSE;
1266
1267     hr = IDirectXFileData_GetType(data_object, &guid);
1268     if (hr != DXFILE_OK)
1269         goto end;
1270
1271     TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1272
1273     if (IsEqualGUID(guid, &TID_D3DRMMesh))
1274     {
1275         TRACE("Found TID_D3DRMMesh\n");
1276
1277         for (i = 0; i < nb_GUIDs; i++)
1278             if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder) ||
1279                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder2) ||
1280                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder3))
1281             {
1282                 requested = TRUE;
1283                 break;
1284             }
1285
1286         if (requested)
1287         {
1288             LPDIRECT3DRMMESHBUILDER3 meshbuilder;
1289
1290             TRACE("Load mesh data and notify application\n");
1291
1292             hr = IDirect3DRM3_CreateMeshBuilder(iface, &meshbuilder);
1293             if (SUCCEEDED(hr))
1294             {
1295                 LPDIRECT3DRMOBJECT object = NULL;
1296
1297                 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder, GUIDs[i], (void**)&object);
1298                 if (SUCCEEDED(hr))
1299                 {
1300                     hr = load_mesh_data(meshbuilder, data_object);
1301                     if (SUCCEEDED(hr))
1302                     {
1303                         /* Only top level objects are notified */
1304                         if (parent_frame)
1305                             IDirect3DRMFrame3_AddVisual(parent_frame, (IUnknown*)meshbuilder);
1306                         else
1307                             LoadProc(object, GUIDs[i], ArgLP);
1308                     }
1309                     IDirect3DRMObject_Release(object);
1310                 }
1311                 IDirect3DRMMeshBuilder3_Release(meshbuilder);
1312             }
1313
1314             if (FAILED(hr))
1315                 ERR("Cannot process mesh\n");
1316         }
1317     }
1318     else if (IsEqualGUID(guid, &TID_D3DRMFrame))
1319     {
1320         TRACE("Found TID_D3DRMFrame\n");
1321
1322         for (i = 0; i < nb_GUIDs; i++)
1323             if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame) ||
1324                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame2) ||
1325                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame3))
1326             {
1327                 requested = TRUE;
1328                 break;
1329             }
1330
1331         if (requested)
1332         {
1333             LPDIRECT3DRMFRAME3 frame;
1334
1335             TRACE("Load frame data and notify application\n");
1336
1337             hr = IDirect3DRM3_CreateFrame(iface, parent_frame, &frame);
1338             if (SUCCEEDED(hr))
1339             {
1340                 LPDIRECT3DRMOBJECT object;
1341
1342                 hr = IDirect3DRMFrame3_QueryInterface(frame, GUIDs[i], (void**)&object);
1343                 if (SUCCEEDED(hr))
1344                 {
1345                     LPDIRECTXFILEOBJECT child;
1346
1347                     while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(data_object, &child)))
1348                     {
1349                         LPDIRECTXFILEDATA data;
1350                         LPDIRECTXFILEDATAREFERENCE reference;
1351                         LPDIRECTXFILEBINARY binary;
1352
1353                         hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileBinary, (void **)&binary);
1354                         if (SUCCEEDED(hr))
1355                         {
1356                             FIXME("Binary Object not supported yet\n");
1357                             IDirectXFileBinary_Release(binary);
1358                             continue;
1359                         }
1360
1361                         hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileData, (void **)&data);
1362                         if (SUCCEEDED(hr))
1363                         {
1364                             TRACE("Found Data Object\n");
1365                             hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1366                             IDirectXFileData_Release(data);
1367                             continue;
1368                         }
1369                         hr = IDirectXFileObject_QueryInterface(child, &IID_IDirectXFileDataReference, (void **)&reference);
1370                         if (SUCCEEDED(hr))
1371                         {
1372                             TRACE("Found Data Object Reference\n");
1373                             IDirectXFileDataReference_Resolve(reference, &data);
1374                             hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1375                             IDirectXFileData_Release(data);
1376                             IDirectXFileDataReference_Release(reference);
1377                             continue;
1378                         }
1379                     }
1380
1381                     if (hr != DXFILEERR_NOMOREOBJECTS)
1382                     {
1383                         IDirect3DRMObject_Release(object);
1384                         IDirect3DRMFrame3_Release(frame);
1385                         goto end;
1386                     }
1387                     hr = S_OK;
1388
1389                     /* Only top level objects are notified */
1390                     if (!parent_frame)
1391                         LoadProc(object, GUIDs[i], ArgLP);
1392                     IDirect3DRMObject_Release(object);
1393                 }
1394                 IDirect3DRMFrame3_Release(frame);
1395             }
1396
1397             if (FAILED(hr))
1398                 ERR("Cannot process frame\n");
1399         }
1400     }
1401     else if (IsEqualGUID(guid, &TID_D3DRMMaterial))
1402     {
1403         TRACE("Found TID_D3DRMMaterial\n");
1404
1405         for (i = 0; i < nb_GUIDs; i++)
1406             if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMaterial) ||
1407                 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMaterial2))
1408                 requested = TRUE;
1409
1410          if (requested)
1411          {
1412             FIXME("Processing material not supported yet\n");
1413          }
1414     }
1415     else if (IsEqualGUID(guid, &TID_D3DRMFrameTransformMatrix))
1416     {
1417         TRACE("Found TID_D3DRMFrameTransformMatrix\n");
1418
1419         if (parent_frame)
1420         {
1421             D3DRMMATRIX4D matrix;
1422             DWORD size;
1423
1424             TRACE("Load Frame Transform Matrix data\n");
1425
1426             size = sizeof(matrix);
1427             hr = IDirectXFileData_GetData(data_object, NULL, &size, (void**)matrix);
1428             if ((hr != DXFILE_OK) || (size != sizeof(matrix)))
1429                 goto end;
1430
1431             hr = IDirect3DRMFrame3_AddTransform(parent_frame, D3DRMCOMBINE_REPLACE, matrix);
1432             if (FAILED(hr))
1433                 goto end;
1434         }
1435     }
1436     else
1437     {
1438         FIXME("Found unknown TID %s\n", debugstr_guid(guid));
1439     }
1440
1441     ret = D3DRM_OK;
1442
1443 end:
1444
1445     return ret;
1446 }
1447
1448 static HRESULT WINAPI IDirect3DRM3Impl_Load(IDirect3DRM3* iface, LPVOID ObjSource, LPVOID ObjID,
1449                                             LPIID* GUIDs, DWORD nb_GUIDs, D3DRMLOADOPTIONS LOFlags,
1450                                             D3DRMLOADCALLBACK LoadProc, LPVOID ArgLP,
1451                                             D3DRMLOADTEXTURECALLBACK LoadTextureProc, LPVOID ArgLTP,
1452                                             LPDIRECT3DRMFRAME3 ParentFrame)
1453 {
1454     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1455     DXFILELOADOPTIONS load_options;
1456     LPDIRECTXFILE pDXFile = NULL;
1457     LPDIRECTXFILEENUMOBJECT pEnumObject = NULL;
1458     LPDIRECTXFILEDATA pData = NULL;
1459     HRESULT hr;
1460     const GUID* pGuid;
1461     DWORD size;
1462     Header* pHeader;
1463     HRESULT ret = D3DRMERR_BADOBJECT;
1464     DWORD i;
1465
1466     TRACE("(%p/%p)->(%p,%p,%p,%d,%d,%p,%p,%p,%p,%p)\n", iface, This, ObjSource, ObjID, GUIDs,
1467           nb_GUIDs, LOFlags, LoadProc, ArgLP, LoadTextureProc, ArgLTP, ParentFrame);
1468
1469     TRACE("Looking for GUIDs:\n");
1470     for (i = 0; i < nb_GUIDs; i++)
1471         TRACE("- %s (%s)\n", debugstr_guid(GUIDs[i]), get_IID_string(GUIDs[i]));
1472
1473     if (LOFlags == D3DRMLOAD_FROMMEMORY)
1474     {
1475         load_options = DXFILELOAD_FROMMEMORY;
1476     }
1477     else if (LOFlags == D3DRMLOAD_FROMFILE)
1478     {
1479         load_options = DXFILELOAD_FROMFILE;
1480         TRACE("Loading from file %s\n", debugstr_a(ObjSource));
1481     }
1482     else
1483     {
1484         FIXME("Load options %d not supported yet\n", LOFlags);
1485         return E_NOTIMPL;
1486     }
1487
1488     hr = DirectXFileCreate(&pDXFile);
1489     if (hr != DXFILE_OK)
1490         goto end;
1491
1492     hr = IDirectXFile_RegisterTemplates(pDXFile, templates, strlen(templates));
1493     if (hr != DXFILE_OK)
1494         goto end;
1495
1496     hr = IDirectXFile_CreateEnumObject(pDXFile, ObjSource, load_options, &pEnumObject);
1497     if (hr != DXFILE_OK)
1498         goto end;
1499
1500     hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1501     if (hr != DXFILE_OK)
1502         goto end;
1503
1504     hr = IDirectXFileData_GetType(pData, &pGuid);
1505     if (hr != DXFILE_OK)
1506         goto end;
1507
1508     TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1509
1510     if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1511     {
1512         ret = D3DRMERR_BADFILE;
1513         goto end;
1514     }
1515
1516     hr = IDirectXFileData_GetData(pData, NULL, &size, (void**)&pHeader);
1517     if ((hr != DXFILE_OK) || (size != sizeof(Header)))
1518         goto end;
1519
1520     TRACE("Version is %d %d %d\n", pHeader->major, pHeader->minor, pHeader->flags);
1521
1522     /* Version must be 1.0.x */
1523     if ((pHeader->major != 1) || (pHeader->minor != 0))
1524     {
1525         ret = D3DRMERR_BADFILE;
1526         goto end;
1527     }
1528
1529     IDirectXFileData_Release(pData);
1530     pData = NULL;
1531
1532     while (1)
1533     {
1534         hr = IDirectXFileEnumObject_GetNextDataObject(pEnumObject, &pData);
1535         if (hr == DXFILEERR_NOMOREOBJECTS)
1536         {
1537             TRACE("No more object\n");
1538             break;
1539         }
1540         else if (hr != DXFILE_OK)
1541         {
1542             ret = D3DRMERR_NOTFOUND;
1543             goto end;
1544         }
1545
1546         ret = load_data(iface, pData, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, ParentFrame);
1547         if (ret != D3DRM_OK)
1548             goto end;
1549
1550         IDirectXFileData_Release(pData);
1551         pData = NULL;
1552     }
1553
1554     ret = D3DRM_OK;
1555
1556 end:
1557     if (pData)
1558         IDirectXFileData_Release(pData);
1559     if (pEnumObject)
1560         IDirectXFileEnumObject_Release(pEnumObject);
1561     if (pDXFile)
1562         IDirectXFile_Release(pDXFile);
1563
1564     return ret;
1565 }
1566
1567 static HRESULT WINAPI IDirect3DRM3Impl_Tick(IDirect3DRM3* iface, D3DVALUE tick)
1568 {
1569     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1570
1571     FIXME("(%p/%p)->(%f): stub\n", iface, This, tick);
1572
1573     return E_NOTIMPL;
1574 }
1575
1576 static HRESULT WINAPI IDirect3DRM3Impl_CreateProgressiveMesh(IDirect3DRM3* iface,
1577                                                              LPDIRECT3DRMPROGRESSIVEMESH Mesh)
1578 {
1579     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1580
1581     FIXME("(%p/%p)->(%p): stub\n", iface, This, Mesh);
1582
1583     return E_NOTIMPL;
1584 }
1585
1586 static HRESULT WINAPI IDirect3DRM3Impl_RegisterClient(IDirect3DRM3* iface, REFGUID rguid,
1587                                                       LPDWORD id)
1588 {
1589     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1590
1591     FIXME("(%p/%p)->(%s, %p): stub\n", iface, This, debugstr_guid(rguid), id);
1592
1593     return E_NOTIMPL;
1594 }
1595
1596 static HRESULT WINAPI IDirect3DRM3Impl_UnregisterClient(IDirect3DRM3* iface, REFGUID rguid)
1597 {
1598     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1599
1600     FIXME("(%p/%p)->(%s): stub\n", iface, This, debugstr_guid(rguid));
1601
1602     return E_NOTIMPL;
1603 }
1604
1605 static HRESULT WINAPI IDirect3DRM3Impl_CreateClippedVisual(IDirect3DRM3* iface,
1606                                                            LPDIRECT3DRMVISUAL vis,
1607                                                            LPDIRECT3DRMCLIPPEDVISUAL* clippedvis)
1608 {
1609     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1610
1611     FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, vis, clippedvis);
1612
1613     return E_NOTIMPL;
1614 }
1615
1616 static HRESULT WINAPI IDirect3DRM3Impl_SetOptions(IDirect3DRM3* iface, DWORD opt)
1617 {
1618     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1619
1620     FIXME("(%p/%p)->(%d): stub\n", iface, This, opt);
1621
1622     return E_NOTIMPL;
1623 }
1624
1625 static HRESULT WINAPI IDirect3DRM3Impl_GetOptions(IDirect3DRM3* iface, LPDWORD opt)
1626 {
1627     IDirect3DRMImpl *This = impl_from_IDirect3DRM3(iface);
1628
1629     FIXME("(%p/%p)->(%p): stub\n", iface, This, opt);
1630
1631     return E_NOTIMPL;
1632 }
1633
1634 static const struct IDirect3DRM3Vtbl Direct3DRM3_Vtbl =
1635 {
1636     IDirect3DRM3Impl_QueryInterface,
1637     IDirect3DRM3Impl_AddRef,
1638     IDirect3DRM3Impl_Release,
1639     IDirect3DRM3Impl_CreateObject,
1640     IDirect3DRM3Impl_CreateFrame,
1641     IDirect3DRM3Impl_CreateMesh,
1642     IDirect3DRM3Impl_CreateMeshBuilder,
1643     IDirect3DRM3Impl_CreateFace,
1644     IDirect3DRM3Impl_CreateAnimation,
1645     IDirect3DRM3Impl_CreateAnimationSet,
1646     IDirect3DRM3Impl_CreateTexture,
1647     IDirect3DRM3Impl_CreateLight,
1648     IDirect3DRM3Impl_CreateLightRGB,
1649     IDirect3DRM3Impl_Material,
1650     IDirect3DRM3Impl_CreateDevice,
1651     IDirect3DRM3Impl_CreateDeviceFromSurface,
1652     IDirect3DRM3Impl_CreateDeviceFromD3D,
1653     IDirect3DRM3Impl_CreateDeviceFromClipper,
1654     IDirect3DRM3Impl_CreateTextureFromSurface,
1655     IDirect3DRM3Impl_CreateShadow,
1656     IDirect3DRM3Impl_CreateViewport,
1657     IDirect3DRM3Impl_CreateWrap,
1658     IDirect3DRM3Impl_CreateUserVisual,
1659     IDirect3DRM3Impl_LoadTexture,
1660     IDirect3DRM3Impl_LoadTextureFromResource,
1661     IDirect3DRM3Impl_SetSearchPath,
1662     IDirect3DRM3Impl_AddSearchPath,
1663     IDirect3DRM3Impl_GetSearchPath,
1664     IDirect3DRM3Impl_SetDefaultTextureColors,
1665     IDirect3DRM3Impl_SetDefaultTextureShades,
1666     IDirect3DRM3Impl_GetDevices,
1667     IDirect3DRM3Impl_GetNamedObject,
1668     IDirect3DRM3Impl_EnumerateObjects,
1669     IDirect3DRM3Impl_Load,
1670     IDirect3DRM3Impl_Tick,
1671     IDirect3DRM3Impl_CreateProgressiveMesh,
1672     IDirect3DRM3Impl_RegisterClient,
1673     IDirect3DRM3Impl_UnregisterClient,
1674     IDirect3DRM3Impl_CreateClippedVisual,
1675     IDirect3DRM3Impl_SetOptions,
1676     IDirect3DRM3Impl_GetOptions
1677 };
1678
1679 HRESULT Direct3DRM_create(IUnknown** ppObj)
1680 {
1681     IDirect3DRMImpl* object;
1682
1683     TRACE("(%p)\n", ppObj);
1684
1685     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMImpl));
1686     if (!object)
1687     {
1688         ERR("Out of memory\n");
1689         return E_OUTOFMEMORY;
1690     }
1691
1692     object->IDirect3DRM_iface.lpVtbl = &Direct3DRM_Vtbl;
1693     object->IDirect3DRM2_iface.lpVtbl = &Direct3DRM2_Vtbl;
1694     object->IDirect3DRM3_iface.lpVtbl = &Direct3DRM3_Vtbl;
1695     object->ref = 1;
1696
1697     *ppObj = (IUnknown*)&object->IDirect3DRM_iface;
1698
1699     return S_OK;
1700 }