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