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