wineandroid: Create the top-level view on desktop window creation.
[wine.git] / dlls / d3drm / d3drm.c
blob260cc7d21730d103170918eaacbd9f18fa84e624
1 /*
2 * Implementation of IDirect3DRM Interface
4 * Copyright 2010, 2012 Christian Costa
5 * Copyright 2011 André Hentschel
6 * Copyright 2016 Aaryaman Vasishta
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include "d3drm_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
30 static const char* get_IID_string(const GUID* guid)
32 if (IsEqualGUID(guid, &IID_IDirect3DRMFrame))
33 return "IID_IDirect3DRMFrame";
34 else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame2))
35 return "IID_IDirect3DRMFrame2";
36 else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame3))
37 return "IID_IDirect3DRMFrame3";
38 else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder))
39 return "IID_IDirect3DRMMeshBuilder";
40 else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder2))
41 return "IID_IDirect3DRMMeshBuilder2";
42 else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder3))
43 return "IID_IDirect3DRMMeshBuilder3";
45 return "?";
48 static HRESULT d3drm_create_texture_object(void **object, IDirect3DRM *d3drm)
50 struct d3drm_texture *texture;
51 HRESULT hr;
53 if (FAILED(hr = d3drm_texture_create(&texture, d3drm)))
54 return hr;
56 *object = &texture->IDirect3DRMTexture_iface;
58 return hr;
61 static HRESULT d3drm_create_device_object(void **object, IDirect3DRM *d3drm)
63 struct d3drm_device *device;
64 HRESULT hr;
66 if (FAILED(hr = d3drm_device_create(&device, d3drm)))
67 return hr;
69 *object = &device->IDirect3DRMDevice_iface;
71 return hr;
74 static HRESULT d3drm_create_viewport_object(void **object, IDirect3DRM *d3drm)
76 struct d3drm_viewport *viewport;
77 HRESULT hr;
79 if (FAILED(hr = d3drm_viewport_create(&viewport, d3drm)))
80 return hr;
82 *object = &viewport->IDirect3DRMViewport_iface;
84 return hr;
87 struct d3drm
89 IDirect3DRM IDirect3DRM_iface;
90 IDirect3DRM2 IDirect3DRM2_iface;
91 IDirect3DRM3 IDirect3DRM3_iface;
92 LONG ref1, ref2, ref3, iface_count;
95 static inline struct d3drm *impl_from_IDirect3DRM(IDirect3DRM *iface)
97 return CONTAINING_RECORD(iface, struct d3drm, IDirect3DRM_iface);
100 static inline struct d3drm *impl_from_IDirect3DRM2(IDirect3DRM2 *iface)
102 return CONTAINING_RECORD(iface, struct d3drm, IDirect3DRM2_iface);
105 static inline struct d3drm *impl_from_IDirect3DRM3(IDirect3DRM3 *iface)
107 return CONTAINING_RECORD(iface, struct d3drm, IDirect3DRM3_iface);
110 static void d3drm_destroy(struct d3drm *d3drm)
112 HeapFree(GetProcessHeap(), 0, d3drm);
113 TRACE("d3drm object %p is being destroyed.\n", d3drm);
116 static HRESULT WINAPI d3drm1_QueryInterface(IDirect3DRM *iface, REFIID riid, void **out)
118 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
120 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
122 if (IsEqualGUID(riid, &IID_IDirect3DRM)
123 || IsEqualGUID(riid, &IID_IUnknown))
125 *out = &d3drm->IDirect3DRM_iface;
127 else if (IsEqualGUID(riid, &IID_IDirect3DRM2))
129 *out = &d3drm->IDirect3DRM2_iface;
131 else if (IsEqualGUID(riid, &IID_IDirect3DRM3))
133 *out = &d3drm->IDirect3DRM3_iface;
135 else
137 *out = NULL;
138 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
139 return CLASS_E_CLASSNOTAVAILABLE;
142 IUnknown_AddRef((IUnknown *)*out);
143 return S_OK;
146 static ULONG WINAPI d3drm1_AddRef(IDirect3DRM *iface)
148 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
149 ULONG refcount = InterlockedIncrement(&d3drm->ref1);
151 TRACE("%p increasing refcount to %u.\n", iface, refcount);
153 if (refcount == 1)
154 InterlockedIncrement(&d3drm->iface_count);
156 return refcount;
159 static ULONG WINAPI d3drm1_Release(IDirect3DRM *iface)
161 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
162 ULONG refcount = InterlockedDecrement(&d3drm->ref1);
164 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
166 if (!refcount && !InterlockedDecrement(&d3drm->iface_count))
167 d3drm_destroy(d3drm);
169 return refcount;
172 static HRESULT WINAPI d3drm1_CreateObject(IDirect3DRM *iface,
173 REFCLSID clsid, IUnknown *outer, REFIID iid, void **out)
175 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
177 TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
178 iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
180 return IDirect3DRM3_CreateObject(&d3drm->IDirect3DRM3_iface, clsid, outer, iid, out);
183 static HRESULT WINAPI d3drm1_CreateFrame(IDirect3DRM *iface,
184 IDirect3DRMFrame *parent_frame, IDirect3DRMFrame **frame)
186 struct d3drm_frame *object;
187 HRESULT hr;
189 TRACE("iface %p, parent_frame %p, frame %p.\n", iface, parent_frame, frame);
191 if (FAILED(hr = d3drm_frame_create(&object, (IUnknown *)parent_frame, iface)))
192 return hr;
194 *frame = &object->IDirect3DRMFrame_iface;
196 return D3DRM_OK;
199 static HRESULT WINAPI d3drm1_CreateMesh(IDirect3DRM *iface, IDirect3DRMMesh **mesh)
201 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
203 TRACE("iface %p, mesh %p.\n", iface, mesh);
205 return IDirect3DRM3_CreateMesh(&d3drm->IDirect3DRM3_iface, mesh);
208 static HRESULT WINAPI d3drm1_CreateMeshBuilder(IDirect3DRM *iface, IDirect3DRMMeshBuilder **mesh_builder)
210 TRACE("iface %p, mesh_builder %p.\n", iface, mesh_builder);
212 return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder, (IUnknown **)mesh_builder);
215 static HRESULT WINAPI d3drm1_CreateFace(IDirect3DRM *iface, IDirect3DRMFace **face)
217 TRACE("iface %p, face %p.\n", iface, face);
219 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
222 static HRESULT WINAPI d3drm1_CreateAnimation(IDirect3DRM *iface, IDirect3DRMAnimation **animation)
224 FIXME("iface %p, animation %p stub!\n", iface, animation);
226 return E_NOTIMPL;
229 static HRESULT WINAPI d3drm1_CreateAnimationSet(IDirect3DRM *iface, IDirect3DRMAnimationSet **set)
231 FIXME("iface %p, set %p stub!\n", iface, set);
233 return E_NOTIMPL;
236 static HRESULT WINAPI d3drm1_CreateTexture(IDirect3DRM *iface,
237 D3DRMIMAGE *image, IDirect3DRMTexture **texture)
239 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
240 IDirect3DRMTexture3 *texture3;
241 HRESULT hr;
243 TRACE("iface %p, image %p, texture %p.\n", iface, image, texture);
245 if (!texture)
246 return D3DRMERR_BADVALUE;
248 if (FAILED(hr = IDirect3DRM3_CreateTexture(&d3drm->IDirect3DRM3_iface, image, &texture3)))
250 *texture = NULL;
251 return hr;
254 hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture, (void **)texture);
255 IDirect3DRMTexture3_Release(texture3);
257 return hr;
260 static HRESULT WINAPI d3drm1_CreateLight(IDirect3DRM *iface,
261 D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
263 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
265 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface, type, color, light);
267 return IDirect3DRM3_CreateLight(&d3drm->IDirect3DRM3_iface, type, color, light);
270 static HRESULT WINAPI d3drm1_CreateLightRGB(IDirect3DRM *iface, D3DRMLIGHTTYPE type,
271 D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
273 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
275 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
276 iface, type, red, green, blue, light);
278 return IDirect3DRM3_CreateLightRGB(&d3drm->IDirect3DRM3_iface, type, red, green, blue, light);
281 static HRESULT WINAPI d3drm1_CreateMaterial(IDirect3DRM *iface,
282 D3DVALUE power, IDirect3DRMMaterial **material)
284 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
286 TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
288 return IDirect3DRM3_CreateMaterial(&d3drm->IDirect3DRM3_iface, power, (IDirect3DRMMaterial2 **)material);
291 static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface,
292 DWORD width, DWORD height, IDirect3DRMDevice **device)
294 struct d3drm_device *object;
295 HRESULT hr;
297 FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
299 if (FAILED(hr = d3drm_device_create(&object, iface)))
300 return hr;
302 *device = &object->IDirect3DRMDevice_iface;
304 return D3DRM_OK;
307 static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *guid,
308 IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice **device)
310 struct d3drm_device *object;
311 HRESULT hr;
313 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p, device %p.\n",
314 iface, debugstr_guid(guid), ddraw, backbuffer, device);
316 if (!device)
317 return D3DRMERR_BADVALUE;
318 *device = NULL;
320 if (!backbuffer || !ddraw)
321 return D3DRMERR_BADDEVICE;
323 if (FAILED(hr = d3drm_device_create(&object, iface)))
324 return hr;
326 if (SUCCEEDED(hr = d3drm_device_init(object, 1, ddraw, backbuffer, TRUE)))
327 *device = &object->IDirect3DRMDevice_iface;
328 else
329 d3drm_device_destroy(object);
331 return hr;
334 static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface,
335 IDirect3D *d3d, IDirect3DDevice *d3d_device, IDirect3DRMDevice **device)
337 struct d3drm_device *object;
338 HRESULT hr;
339 TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
340 iface, d3d, d3d_device, device);
342 if (!device)
343 return D3DRMERR_BADVALUE;
344 *device = NULL;
346 if (FAILED(hr = d3drm_device_create(&object, iface)))
347 return hr;
349 if (FAILED(hr = IDirect3DRMDevice_InitFromD3D(&object->IDirect3DRMDevice_iface, d3d, d3d_device)))
351 d3drm_device_destroy(object);
352 return hr;
354 *device = &object->IDirect3DRMDevice_iface;
356 return D3DRM_OK;
359 static HRESULT WINAPI d3drm1_CreateDeviceFromClipper(IDirect3DRM *iface,
360 IDirectDrawClipper *clipper, GUID *guid, int width, int height,
361 IDirect3DRMDevice **device)
363 struct d3drm_device *object;
364 IDirectDraw *ddraw;
365 IDirectDrawSurface *render_target;
366 HRESULT hr;
368 TRACE("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
369 iface, clipper, debugstr_guid(guid), width, height, device);
371 if (!device)
372 return D3DRMERR_BADVALUE;
373 *device = NULL;
375 if (!clipper || !width || !height)
376 return D3DRMERR_BADVALUE;
378 hr = DirectDrawCreate(NULL, &ddraw, NULL);
379 if (FAILED(hr))
380 return hr;
382 if (FAILED(hr = d3drm_device_create(&object, iface)))
384 IDirectDraw_Release(ddraw);
385 return hr;
388 hr = d3drm_device_create_surfaces_from_clipper(object, ddraw, clipper, width, height, &render_target);
389 if (FAILED(hr))
391 IDirectDraw_Release(ddraw);
392 d3drm_device_destroy(object);
393 return hr;
396 hr = d3drm_device_init(object, 1, ddraw, render_target, TRUE);
397 IDirectDraw_Release(ddraw);
398 IDirectDrawSurface_Release(render_target);
399 if (FAILED(hr))
400 d3drm_device_destroy(object);
401 else
402 *device = &object->IDirect3DRMDevice_iface;
404 return hr;
407 static HRESULT WINAPI d3drm1_CreateTextureFromSurface(IDirect3DRM *iface,
408 IDirectDrawSurface *surface, IDirect3DRMTexture **texture)
410 FIXME("iface %p, surface %p, texture %p stub!\n", iface, surface, texture);
412 return E_NOTIMPL;
415 static HRESULT WINAPI d3drm1_CreateShadow(IDirect3DRM *iface, IDirect3DRMVisual *visual,
416 IDirect3DRMLight *light, D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz,
417 IDirect3DRMVisual **shadow)
419 FIXME("iface %p, visual %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
420 iface, visual, light, px, py, pz, nx, ny, nz, shadow);
422 return E_NOTIMPL;
425 static HRESULT WINAPI d3drm1_CreateViewport(IDirect3DRM *iface, IDirect3DRMDevice *device,
426 IDirect3DRMFrame *camera, DWORD x, DWORD y, DWORD width, DWORD height, IDirect3DRMViewport **viewport)
428 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
429 IDirect3DRMDevice3 *device3;
430 IDirect3DRMFrame3 *camera3;
431 IDirect3DRMViewport2 *viewport2;
432 HRESULT hr;
434 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
435 iface, device, camera, x, y, width, height, viewport);
437 if (!device || !camera)
438 return D3DRMERR_BADOBJECT;
439 if (!viewport)
440 return D3DRMERR_BADVALUE;
442 if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
443 return hr;
445 if (FAILED(hr = IDirect3DRMFrame_QueryInterface(camera, &IID_IDirect3DRMFrame3, (void **)&camera3)))
447 IDirect3DRMDevice3_Release(device3);
448 return hr;
451 hr = IDirect3DRM3_CreateViewport(&d3drm->IDirect3DRM3_iface, device3, camera3, x, y, width, height, &viewport2);
452 IDirect3DRMDevice3_Release(device3);
453 IDirect3DRMFrame3_Release(camera3);
454 if (FAILED(hr))
455 return hr;
457 hr = IDirect3DRMViewport2_QueryInterface(viewport2, &IID_IDirect3DRMViewport, (void **)viewport);
458 IDirect3DRMViewport2_Release(viewport2);
460 return hr;
463 static HRESULT WINAPI d3drm1_CreateWrap(IDirect3DRM *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame *frame,
464 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
465 D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv,
466 IDirect3DRMWrap **wrap)
468 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
469 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p stub!\n",
470 iface, type, frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
472 return E_NOTIMPL;
475 static HRESULT WINAPI d3drm1_CreateUserVisual(IDirect3DRM *iface,
476 D3DRMUSERVISUALCALLBACK cb, void *ctx, IDirect3DRMUserVisual **visual)
478 FIXME("iface %p, cb %p, ctx %p visual %p stub!\n", iface, cb, ctx, visual);
480 return E_NOTIMPL;
483 static HRESULT WINAPI d3drm1_LoadTexture(IDirect3DRM *iface,
484 const char *filename, IDirect3DRMTexture **texture)
486 struct d3drm_texture *object;
487 HRESULT hr;
489 FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
491 if (FAILED(hr = d3drm_texture_create(&object, iface)))
492 return hr;
494 *texture = &object->IDirect3DRMTexture_iface;
496 return D3DRM_OK;
499 static HRESULT WINAPI d3drm1_LoadTextureFromResource(IDirect3DRM *iface,
500 HRSRC resource, IDirect3DRMTexture **texture)
502 struct d3drm_texture *object;
503 HRESULT hr;
505 FIXME("iface %p, resource %p, texture %p stub!\n", iface, resource, texture);
507 if (FAILED(hr = d3drm_texture_create(&object, iface)))
508 return hr;
510 *texture = &object->IDirect3DRMTexture_iface;
512 return D3DRM_OK;
515 static HRESULT WINAPI d3drm1_SetSearchPath(IDirect3DRM *iface, const char *path)
517 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
519 return E_NOTIMPL;
522 static HRESULT WINAPI d3drm1_AddSearchPath(IDirect3DRM *iface, const char *path)
524 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
526 return E_NOTIMPL;
529 static HRESULT WINAPI d3drm1_GetSearchPath(IDirect3DRM *iface, DWORD *size, char *path)
531 FIXME("iface %p, size %p, path %p stub!\n", iface, size, path);
533 return E_NOTIMPL;
536 static HRESULT WINAPI d3drm1_SetDefaultTextureColors(IDirect3DRM *iface, DWORD color_count)
538 FIXME("iface %p, color_count %u stub!\n", iface, color_count);
540 return E_NOTIMPL;
543 static HRESULT WINAPI d3drm1_SetDefaultTextureShades(IDirect3DRM *iface, DWORD shade_count)
545 FIXME("iface %p, shade_count %u stub!\n", iface, shade_count);
547 return E_NOTIMPL;
550 static HRESULT WINAPI d3drm1_GetDevices(IDirect3DRM *iface, IDirect3DRMDeviceArray **array)
552 FIXME("iface %p, array %p stub!\n", iface, array);
554 return E_NOTIMPL;
557 static HRESULT WINAPI d3drm1_GetNamedObject(IDirect3DRM *iface,
558 const char *name, IDirect3DRMObject **object)
560 FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
562 return E_NOTIMPL;
565 static HRESULT WINAPI d3drm1_EnumerateObjects(IDirect3DRM *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
567 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
569 return E_NOTIMPL;
572 static HRESULT WINAPI d3drm1_Load(IDirect3DRM *iface, void *source, void *object_id, IID **iids,
573 DWORD iid_count, D3DRMLOADOPTIONS flags, D3DRMLOADCALLBACK load_cb, void *load_ctx,
574 D3DRMLOADTEXTURECALLBACK load_tex_cb, void *load_tex_ctx, IDirect3DRMFrame *parent_frame)
576 struct d3drm *d3drm = impl_from_IDirect3DRM(iface);
577 IDirect3DRMFrame3 *parent_frame3 = NULL;
578 HRESULT hr = D3DRM_OK;
580 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
581 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
582 iface, source, object_id, iids, iid_count, flags,
583 load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
585 if (parent_frame)
586 hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&parent_frame3);
587 if (SUCCEEDED(hr))
588 hr = IDirect3DRM3_Load(&d3drm->IDirect3DRM3_iface, source, object_id, iids, iid_count,
589 flags, load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame3);
590 if (parent_frame3)
591 IDirect3DRMFrame3_Release(parent_frame3);
593 return hr;
596 static HRESULT WINAPI d3drm1_Tick(IDirect3DRM *iface, D3DVALUE tick)
598 FIXME("iface %p, tick %.8e stub!\n", iface, tick);
600 return E_NOTIMPL;
603 static const struct IDirect3DRMVtbl d3drm1_vtbl =
605 d3drm1_QueryInterface,
606 d3drm1_AddRef,
607 d3drm1_Release,
608 d3drm1_CreateObject,
609 d3drm1_CreateFrame,
610 d3drm1_CreateMesh,
611 d3drm1_CreateMeshBuilder,
612 d3drm1_CreateFace,
613 d3drm1_CreateAnimation,
614 d3drm1_CreateAnimationSet,
615 d3drm1_CreateTexture,
616 d3drm1_CreateLight,
617 d3drm1_CreateLightRGB,
618 d3drm1_CreateMaterial,
619 d3drm1_CreateDevice,
620 d3drm1_CreateDeviceFromSurface,
621 d3drm1_CreateDeviceFromD3D,
622 d3drm1_CreateDeviceFromClipper,
623 d3drm1_CreateTextureFromSurface,
624 d3drm1_CreateShadow,
625 d3drm1_CreateViewport,
626 d3drm1_CreateWrap,
627 d3drm1_CreateUserVisual,
628 d3drm1_LoadTexture,
629 d3drm1_LoadTextureFromResource,
630 d3drm1_SetSearchPath,
631 d3drm1_AddSearchPath,
632 d3drm1_GetSearchPath,
633 d3drm1_SetDefaultTextureColors,
634 d3drm1_SetDefaultTextureShades,
635 d3drm1_GetDevices,
636 d3drm1_GetNamedObject,
637 d3drm1_EnumerateObjects,
638 d3drm1_Load,
639 d3drm1_Tick,
642 static HRESULT WINAPI d3drm2_QueryInterface(IDirect3DRM2 *iface, REFIID riid, void **out)
644 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
646 return d3drm1_QueryInterface(&d3drm->IDirect3DRM_iface, riid, out);
649 static ULONG WINAPI d3drm2_AddRef(IDirect3DRM2 *iface)
651 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
652 ULONG refcount = InterlockedIncrement(&d3drm->ref2);
654 TRACE("%p increasing refcount to %u.\n", iface, refcount);
656 if (refcount == 1)
657 InterlockedIncrement(&d3drm->iface_count);
659 return refcount;
662 static ULONG WINAPI d3drm2_Release(IDirect3DRM2 *iface)
664 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
665 ULONG refcount = InterlockedDecrement(&d3drm->ref2);
667 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
669 if (!refcount && !InterlockedDecrement(&d3drm->iface_count))
670 d3drm_destroy(d3drm);
672 return refcount;
675 static HRESULT WINAPI d3drm2_CreateObject(IDirect3DRM2 *iface,
676 REFCLSID clsid, IUnknown *outer, REFIID iid, void **out)
678 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
680 TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
681 iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
683 return IDirect3DRM3_CreateObject(&d3drm->IDirect3DRM3_iface, clsid, outer, iid, out);
686 static HRESULT WINAPI d3drm2_CreateFrame(IDirect3DRM2 *iface,
687 IDirect3DRMFrame *parent_frame, IDirect3DRMFrame2 **frame)
689 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
690 struct d3drm_frame *object;
691 HRESULT hr;
693 TRACE("iface %p, parent_frame %p, frame %p.\n", iface, parent_frame, frame);
695 if (FAILED(hr = d3drm_frame_create(&object, (IUnknown *)parent_frame, &d3drm->IDirect3DRM_iface)))
696 return hr;
698 *frame = &object->IDirect3DRMFrame2_iface;
700 return D3DRM_OK;
703 static HRESULT WINAPI d3drm2_CreateMesh(IDirect3DRM2 *iface, IDirect3DRMMesh **mesh)
705 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
707 TRACE("iface %p, mesh %p.\n", iface, mesh);
709 return IDirect3DRM3_CreateMesh(&d3drm->IDirect3DRM3_iface, mesh);
712 static HRESULT WINAPI d3drm2_CreateMeshBuilder(IDirect3DRM2 *iface, IDirect3DRMMeshBuilder2 **mesh_builder)
714 TRACE("iface %p, mesh_builder %p.\n", iface, mesh_builder);
716 return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder2, (IUnknown **)mesh_builder);
719 static HRESULT WINAPI d3drm2_CreateFace(IDirect3DRM2 *iface, IDirect3DRMFace **face)
721 TRACE("iface %p, face %p.\n", iface, face);
723 return Direct3DRMFace_create(&IID_IDirect3DRMFace, (IUnknown **)face);
726 static HRESULT WINAPI d3drm2_CreateAnimation(IDirect3DRM2 *iface, IDirect3DRMAnimation **animation)
728 FIXME("iface %p, animation %p stub!\n", iface, animation);
730 return E_NOTIMPL;
733 static HRESULT WINAPI d3drm2_CreateAnimationSet(IDirect3DRM2 *iface, IDirect3DRMAnimationSet **set)
735 FIXME("iface %p, set %p stub!\n", iface, set);
737 return E_NOTIMPL;
740 static HRESULT WINAPI d3drm2_CreateTexture(IDirect3DRM2 *iface,
741 D3DRMIMAGE *image, IDirect3DRMTexture2 **texture)
743 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
744 IDirect3DRMTexture3 *texture3;
745 HRESULT hr;
747 TRACE("iface %p, image %p, texture %p.\n", iface, image, texture);
749 if (!texture)
750 return D3DRMERR_BADVALUE;
752 if (FAILED(hr = IDirect3DRM3_CreateTexture(&d3drm->IDirect3DRM3_iface, image, &texture3)))
754 *texture = NULL;
755 return hr;
758 hr = IDirect3DRMTexture3_QueryInterface(texture3, &IID_IDirect3DRMTexture2, (void **)texture);
759 IDirect3DRMTexture3_Release(texture3);
761 return hr;
764 static HRESULT WINAPI d3drm2_CreateLight(IDirect3DRM2 *iface,
765 D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
767 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
769 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface, type, color, light);
771 return IDirect3DRM3_CreateLight(&d3drm->IDirect3DRM3_iface, type, color, light);
774 static HRESULT WINAPI d3drm2_CreateLightRGB(IDirect3DRM2 *iface, D3DRMLIGHTTYPE type,
775 D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
777 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
779 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
780 iface, type, red, green, blue, light);
782 return IDirect3DRM3_CreateLightRGB(&d3drm->IDirect3DRM3_iface, type, red, green, blue, light);
785 static HRESULT WINAPI d3drm2_CreateMaterial(IDirect3DRM2 *iface,
786 D3DVALUE power, IDirect3DRMMaterial **material)
788 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
790 TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
792 return IDirect3DRM3_CreateMaterial(&d3drm->IDirect3DRM3_iface, power, (IDirect3DRMMaterial2 **)material);
795 static HRESULT WINAPI d3drm2_CreateDevice(IDirect3DRM2 *iface,
796 DWORD width, DWORD height, IDirect3DRMDevice2 **device)
798 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
799 struct d3drm_device *object;
800 HRESULT hr;
802 FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
804 if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
805 return hr;
807 *device = &object->IDirect3DRMDevice2_iface;
809 return D3DRM_OK;
812 static HRESULT WINAPI d3drm2_CreateDeviceFromSurface(IDirect3DRM2 *iface, GUID *guid,
813 IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice2 **device)
815 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
816 IDirect3DRMDevice3 *device3;
817 HRESULT hr;
818 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p, device %p.\n",
819 iface, debugstr_guid(guid), ddraw, backbuffer, device);
821 if (!device)
822 return D3DRMERR_BADVALUE;
823 *device = NULL;
824 hr = IDirect3DRM3_CreateDeviceFromSurface(&d3drm->IDirect3DRM3_iface, guid, ddraw, backbuffer, 0, &device3);
825 if (FAILED(hr))
826 return hr;
828 hr = IDirect3DRMDevice3_QueryInterface(device3, &IID_IDirect3DRMDevice2, (void**)device);
829 IDirect3DRMDevice3_Release(device3);
831 return hr;
834 static HRESULT WINAPI d3drm2_CreateDeviceFromD3D(IDirect3DRM2 *iface,
835 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device, IDirect3DRMDevice2 **device)
837 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
838 IDirect3DRMDevice3 *device3;
839 HRESULT hr;
841 TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
842 iface, d3d, d3d_device, device);
844 if (!device)
845 return D3DRMERR_BADVALUE;
846 *device = NULL;
848 hr = IDirect3DRM3_CreateDeviceFromD3D(&d3drm->IDirect3DRM3_iface, d3d, d3d_device, &device3);
849 if (FAILED(hr))
850 return hr;
852 hr = IDirect3DRMDevice3_QueryInterface(device3, &IID_IDirect3DRMDevice2, (void **)device);
853 IDirect3DRMDevice3_Release(device3);
855 return hr;
858 static HRESULT WINAPI d3drm2_CreateDeviceFromClipper(IDirect3DRM2 *iface,
859 IDirectDrawClipper *clipper, GUID *guid, int width, int height,
860 IDirect3DRMDevice2 **device)
862 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
863 IDirect3DRMDevice3 *device3;
864 HRESULT hr;
866 TRACE("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
867 iface, clipper, debugstr_guid(guid), width, height, device);
869 if (!device)
870 return D3DRMERR_BADVALUE;
871 *device = NULL;
872 hr = IDirect3DRM3_CreateDeviceFromClipper(&d3drm->IDirect3DRM3_iface, clipper, guid, width, height, &device3);
873 if (FAILED(hr))
874 return hr;
876 hr = IDirect3DRMDevice3_QueryInterface(device3, &IID_IDirect3DRMDevice2, (void**)device);
877 IDirect3DRMDevice3_Release(device3);
879 return hr;
882 static HRESULT WINAPI d3drm2_CreateTextureFromSurface(IDirect3DRM2 *iface,
883 IDirectDrawSurface *surface, IDirect3DRMTexture2 **texture)
885 FIXME("iface %p, surface %p, texture %p stub!\n", iface, surface, texture);
887 return E_NOTIMPL;
890 static HRESULT WINAPI d3drm2_CreateShadow(IDirect3DRM2 *iface, IDirect3DRMVisual *visual,
891 IDirect3DRMLight *light, D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz,
892 IDirect3DRMVisual **shadow)
894 FIXME("iface %p, visual %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
895 iface, visual, light, px, py, pz, nx, ny, nz, shadow);
897 return E_NOTIMPL;
900 static HRESULT WINAPI d3drm2_CreateViewport(IDirect3DRM2 *iface, IDirect3DRMDevice *device,
901 IDirect3DRMFrame *camera, DWORD x, DWORD y, DWORD width, DWORD height, IDirect3DRMViewport **viewport)
903 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
904 IDirect3DRMDevice3 *device3;
905 IDirect3DRMFrame3 *camera3;
906 IDirect3DRMViewport2 *viewport2;
907 HRESULT hr;
909 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
910 iface, device, camera, x, y, width, height, viewport);
912 if (!device || !camera)
913 return D3DRMERR_BADOBJECT;
914 if (!viewport)
915 return D3DRMERR_BADVALUE;
917 if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
918 return hr;
920 if (FAILED(hr = IDirect3DRMFrame_QueryInterface(camera, &IID_IDirect3DRMFrame3, (void **)&camera3)))
922 IDirect3DRMDevice3_Release(device3);
923 return hr;
926 hr = IDirect3DRM3_CreateViewport(&d3drm->IDirect3DRM3_iface, device3, camera3, x, y, width, height, &viewport2);
927 IDirect3DRMDevice3_Release(device3);
928 IDirect3DRMFrame3_Release(camera3);
929 if (FAILED(hr))
930 return hr;
932 hr = IDirect3DRMViewport2_QueryInterface(viewport2, &IID_IDirect3DRMViewport, (void **)viewport);
933 IDirect3DRMViewport2_Release(viewport2);
935 return hr;
938 static HRESULT WINAPI d3drm2_CreateWrap(IDirect3DRM2 *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame *frame,
939 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
940 D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv,
941 IDirect3DRMWrap **wrap)
943 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
944 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p stub!\n",
945 iface, type, frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
947 return E_NOTIMPL;
950 static HRESULT WINAPI d3drm2_CreateUserVisual(IDirect3DRM2 *iface,
951 D3DRMUSERVISUALCALLBACK cb, void *ctx, IDirect3DRMUserVisual **visual)
953 FIXME("iface %p, cb %p, ctx %p, visual %p stub!\n", iface, cb, ctx, visual);
955 return E_NOTIMPL;
958 static HRESULT WINAPI d3drm2_LoadTexture(IDirect3DRM2 *iface,
959 const char *filename, IDirect3DRMTexture2 **texture)
961 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
962 struct d3drm_texture *object;
963 HRESULT hr;
965 FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
967 if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
968 return hr;
970 *texture = &object->IDirect3DRMTexture2_iface;
972 return hr;
975 static HRESULT WINAPI d3drm2_LoadTextureFromResource(IDirect3DRM2 *iface, HMODULE module,
976 const char *resource_name, const char *resource_type, IDirect3DRMTexture2 **texture)
978 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
979 struct d3drm_texture *object;
980 HRESULT hr;
982 FIXME("iface %p, resource_name %s, resource_type %s, texture %p stub!\n",
983 iface, debugstr_a(resource_name), debugstr_a(resource_type), texture);
985 if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
986 return hr;
988 *texture = &object->IDirect3DRMTexture2_iface;
990 return D3DRM_OK;
993 static HRESULT WINAPI d3drm2_SetSearchPath(IDirect3DRM2 *iface, const char *path)
995 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
997 return E_NOTIMPL;
1000 static HRESULT WINAPI d3drm2_AddSearchPath(IDirect3DRM2 *iface, const char *path)
1002 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
1004 return E_NOTIMPL;
1007 static HRESULT WINAPI d3drm2_GetSearchPath(IDirect3DRM2 *iface, DWORD *size, char *path)
1009 FIXME("iface %p, size %p, path %p stub!\n", iface, size, path);
1011 return E_NOTIMPL;
1014 static HRESULT WINAPI d3drm2_SetDefaultTextureColors(IDirect3DRM2 *iface, DWORD color_count)
1016 FIXME("iface %p, color_count %u stub!\n", iface, color_count);
1018 return E_NOTIMPL;
1021 static HRESULT WINAPI d3drm2_SetDefaultTextureShades(IDirect3DRM2 *iface, DWORD shade_count)
1023 FIXME("iface %p, shade_count %u stub!\n", iface, shade_count);
1025 return E_NOTIMPL;
1028 static HRESULT WINAPI d3drm2_GetDevices(IDirect3DRM2 *iface, IDirect3DRMDeviceArray **array)
1030 FIXME("iface %p, array %p stub!\n", iface, array);
1032 return E_NOTIMPL;
1035 static HRESULT WINAPI d3drm2_GetNamedObject(IDirect3DRM2 *iface,
1036 const char *name, IDirect3DRMObject **object)
1038 FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
1040 return E_NOTIMPL;
1043 static HRESULT WINAPI d3drm2_EnumerateObjects(IDirect3DRM2 *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
1045 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1047 return E_NOTIMPL;
1050 static HRESULT WINAPI d3drm2_Load(IDirect3DRM2 *iface, void *source, void *object_id, IID **iids,
1051 DWORD iid_count, D3DRMLOADOPTIONS flags, D3DRMLOADCALLBACK load_cb, void *load_ctx,
1052 D3DRMLOADTEXTURECALLBACK load_tex_cb, void *load_tex_ctx, IDirect3DRMFrame *parent_frame)
1054 struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
1055 IDirect3DRMFrame3 *parent_frame3 = NULL;
1056 HRESULT hr = D3DRM_OK;
1058 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
1059 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
1060 iface, source, object_id, iids, iid_count, flags,
1061 load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
1063 if (parent_frame)
1064 hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&parent_frame3);
1065 if (SUCCEEDED(hr))
1066 hr = IDirect3DRM3_Load(&d3drm->IDirect3DRM3_iface, source, object_id, iids, iid_count,
1067 flags, load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame3);
1068 if (parent_frame3)
1069 IDirect3DRMFrame3_Release(parent_frame3);
1071 return hr;
1074 static HRESULT WINAPI d3drm2_Tick(IDirect3DRM2 *iface, D3DVALUE tick)
1076 FIXME("iface %p, tick %.8e stub!\n", iface, tick);
1078 return E_NOTIMPL;
1081 static HRESULT WINAPI d3drm2_CreateProgressiveMesh(IDirect3DRM2 *iface, IDirect3DRMProgressiveMesh **mesh)
1083 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1085 return E_NOTIMPL;
1088 static const struct IDirect3DRM2Vtbl d3drm2_vtbl =
1090 d3drm2_QueryInterface,
1091 d3drm2_AddRef,
1092 d3drm2_Release,
1093 d3drm2_CreateObject,
1094 d3drm2_CreateFrame,
1095 d3drm2_CreateMesh,
1096 d3drm2_CreateMeshBuilder,
1097 d3drm2_CreateFace,
1098 d3drm2_CreateAnimation,
1099 d3drm2_CreateAnimationSet,
1100 d3drm2_CreateTexture,
1101 d3drm2_CreateLight,
1102 d3drm2_CreateLightRGB,
1103 d3drm2_CreateMaterial,
1104 d3drm2_CreateDevice,
1105 d3drm2_CreateDeviceFromSurface,
1106 d3drm2_CreateDeviceFromD3D,
1107 d3drm2_CreateDeviceFromClipper,
1108 d3drm2_CreateTextureFromSurface,
1109 d3drm2_CreateShadow,
1110 d3drm2_CreateViewport,
1111 d3drm2_CreateWrap,
1112 d3drm2_CreateUserVisual,
1113 d3drm2_LoadTexture,
1114 d3drm2_LoadTextureFromResource,
1115 d3drm2_SetSearchPath,
1116 d3drm2_AddSearchPath,
1117 d3drm2_GetSearchPath,
1118 d3drm2_SetDefaultTextureColors,
1119 d3drm2_SetDefaultTextureShades,
1120 d3drm2_GetDevices,
1121 d3drm2_GetNamedObject,
1122 d3drm2_EnumerateObjects,
1123 d3drm2_Load,
1124 d3drm2_Tick,
1125 d3drm2_CreateProgressiveMesh,
1128 static HRESULT WINAPI d3drm3_QueryInterface(IDirect3DRM3 *iface, REFIID riid, void **out)
1130 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1132 return d3drm1_QueryInterface(&d3drm->IDirect3DRM_iface, riid, out);
1135 static ULONG WINAPI d3drm3_AddRef(IDirect3DRM3 *iface)
1137 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1138 ULONG refcount = InterlockedIncrement(&d3drm->ref3);
1140 TRACE("%p increasing refcount to %u.\n", iface, refcount);
1142 if (refcount == 1)
1143 InterlockedIncrement(&d3drm->iface_count);
1145 return refcount;
1148 static ULONG WINAPI d3drm3_Release(IDirect3DRM3 *iface)
1150 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1151 ULONG refcount = InterlockedDecrement(&d3drm->ref3);
1153 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
1155 if (!refcount && !InterlockedDecrement(&d3drm->iface_count))
1156 d3drm_destroy(d3drm);
1158 return refcount;
1161 static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
1162 REFCLSID clsid, IUnknown *outer, REFIID iid, void **out)
1164 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1165 IUnknown *object;
1166 unsigned int i;
1167 HRESULT hr;
1169 static const struct
1171 const CLSID *clsid;
1172 HRESULT (*create_object)(void **object, IDirect3DRM *d3drm);
1174 object_table[] =
1176 {&CLSID_CDirect3DRMTexture, d3drm_create_texture_object},
1177 {&CLSID_CDirect3DRMDevice, d3drm_create_device_object},
1178 {&CLSID_CDirect3DRMViewport, d3drm_create_viewport_object},
1181 TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
1182 iface, debugstr_guid(clsid), outer, debugstr_guid(iid), out);
1184 if (!out)
1185 return D3DRMERR_BADVALUE;
1187 if (!clsid || !iid)
1189 *out = NULL;
1190 return D3DRMERR_BADVALUE;
1193 if (outer)
1195 FIXME("COM aggregation for outer IUnknown (%p) not implemented. Returning E_NOTIMPL.\n", outer);
1196 *out = NULL;
1197 return E_NOTIMPL;
1200 for (i = 0; i < ARRAY_SIZE(object_table); ++i)
1202 if (IsEqualGUID(clsid, object_table[i].clsid))
1204 if (FAILED(hr = object_table[i].create_object((void **)&object, &d3drm->IDirect3DRM_iface)))
1206 *out = NULL;
1207 return hr;
1209 break;
1212 if (i == ARRAY_SIZE(object_table))
1214 FIXME("%s not implemented. Returning CLASSFACTORY_E_FIRST.\n", debugstr_guid(clsid));
1215 *out = NULL;
1216 return CLASSFACTORY_E_FIRST;
1219 if (FAILED(hr = IUnknown_QueryInterface(object, iid, out)))
1220 *out = NULL;
1221 IUnknown_Release(object);
1223 return hr;
1226 static HRESULT WINAPI d3drm3_CreateFrame(IDirect3DRM3 *iface,
1227 IDirect3DRMFrame3 *parent, IDirect3DRMFrame3 **frame)
1229 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1230 struct d3drm_frame *object;
1231 HRESULT hr;
1233 TRACE("iface %p, parent %p, frame %p.\n", iface, parent, frame);
1235 if (FAILED(hr = d3drm_frame_create(&object, (IUnknown *)parent, &d3drm->IDirect3DRM_iface)))
1236 return hr;
1238 *frame = &object->IDirect3DRMFrame3_iface;
1240 return D3DRM_OK;
1243 static HRESULT WINAPI d3drm3_CreateMesh(IDirect3DRM3 *iface, IDirect3DRMMesh **mesh)
1245 TRACE("iface %p, mesh %p.\n", iface, mesh);
1247 return Direct3DRMMesh_create(mesh);
1250 static HRESULT WINAPI d3drm3_CreateMeshBuilder(IDirect3DRM3 *iface, IDirect3DRMMeshBuilder3 **mesh_builder)
1252 TRACE("iface %p, mesh_builder %p.\n", iface, mesh_builder);
1254 return Direct3DRMMeshBuilder_create(&IID_IDirect3DRMMeshBuilder3, (IUnknown **)mesh_builder);
1257 static HRESULT WINAPI d3drm3_CreateFace(IDirect3DRM3 *iface, IDirect3DRMFace2 **face)
1259 TRACE("iface %p, face %p.\n", iface, face);
1261 return Direct3DRMFace_create(&IID_IDirect3DRMFace2, (IUnknown **)face);
1264 static HRESULT WINAPI d3drm3_CreateAnimation(IDirect3DRM3 *iface, IDirect3DRMAnimation2 **animation)
1266 FIXME("iface %p, animation %p stub!\n", iface, animation);
1268 return E_NOTIMPL;
1271 static HRESULT WINAPI d3drm3_CreateAnimationSet(IDirect3DRM3 *iface, IDirect3DRMAnimationSet2 **set)
1273 FIXME("iface %p, set %p stub!\n", iface, set);
1275 return E_NOTIMPL;
1278 static HRESULT WINAPI d3drm3_CreateTexture(IDirect3DRM3 *iface,
1279 D3DRMIMAGE *image, IDirect3DRMTexture3 **texture)
1281 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1282 struct d3drm_texture *object;
1283 HRESULT hr;
1285 TRACE("iface %p, image %p, texture %p.\n", iface, image, texture);
1287 if (!texture)
1288 return D3DRMERR_BADVALUE;
1290 if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
1291 return hr;
1293 *texture = &object->IDirect3DRMTexture3_iface;
1295 if (FAILED(IDirect3DRMTexture3_InitFromImage(*texture, image)))
1297 IDirect3DRMTexture3_Release(*texture);
1298 *texture = NULL;
1299 return D3DRMERR_BADVALUE;
1302 return D3DRM_OK;
1305 static HRESULT WINAPI d3drm3_CreateLight(IDirect3DRM3 *iface,
1306 D3DRMLIGHTTYPE type, D3DCOLOR color, IDirect3DRMLight **light)
1308 HRESULT hr;
1310 FIXME("iface %p, type %#x, color 0x%08x, light %p partial stub!\n", iface, type, color, light);
1312 if (SUCCEEDED(hr = Direct3DRMLight_create((IUnknown **)light)))
1314 IDirect3DRMLight_SetType(*light, type);
1315 IDirect3DRMLight_SetColor(*light, color);
1318 return hr;
1321 static HRESULT WINAPI d3drm3_CreateLightRGB(IDirect3DRM3 *iface, D3DRMLIGHTTYPE type,
1322 D3DVALUE red, D3DVALUE green, D3DVALUE blue, IDirect3DRMLight **light)
1324 HRESULT hr;
1326 FIXME("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p partial stub!\n",
1327 iface, type, red, green, blue, light);
1329 if (SUCCEEDED(hr = Direct3DRMLight_create((IUnknown **)light)))
1331 IDirect3DRMLight_SetType(*light, type);
1332 IDirect3DRMLight_SetColorRGB(*light, red, green, blue);
1335 return hr;
1338 static HRESULT WINAPI d3drm3_CreateMaterial(IDirect3DRM3 *iface,
1339 D3DVALUE power, IDirect3DRMMaterial2 **material)
1341 HRESULT hr;
1343 TRACE("iface %p, power %.8e, material %p.\n", iface, power, material);
1345 if (SUCCEEDED(hr = Direct3DRMMaterial_create(material)))
1346 IDirect3DRMMaterial2_SetPower(*material, power);
1348 return hr;
1351 static HRESULT WINAPI d3drm3_CreateDevice(IDirect3DRM3 *iface,
1352 DWORD width, DWORD height, IDirect3DRMDevice3 **device)
1354 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1355 struct d3drm_device *object;
1356 HRESULT hr;
1358 FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
1360 if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
1361 return hr;
1363 *device = &object->IDirect3DRMDevice3_iface;
1365 return D3DRM_OK;
1368 static HRESULT WINAPI d3drm3_CreateDeviceFromSurface(IDirect3DRM3 *iface, GUID *guid,
1369 IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, DWORD flags, IDirect3DRMDevice3 **device)
1371 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1372 struct d3drm_device *object;
1373 BOOL use_z_surface;
1374 HRESULT hr;
1376 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p, flags %#x, device %p.\n",
1377 iface, debugstr_guid(guid), ddraw, backbuffer, flags, device);
1379 if (!device)
1380 return D3DRMERR_BADVALUE;
1381 *device = NULL;
1383 if (!backbuffer || !ddraw)
1384 return D3DRMERR_BADDEVICE;
1386 if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
1387 return hr;
1389 use_z_surface = !(flags & D3DRMDEVICE_NOZBUFFER);
1391 if (SUCCEEDED(hr = d3drm_device_init(object, 3, ddraw, backbuffer, use_z_surface)))
1392 *device = &object->IDirect3DRMDevice3_iface;
1393 else
1394 d3drm_device_destroy(object);
1396 return hr;
1399 static HRESULT WINAPI d3drm3_CreateDeviceFromD3D(IDirect3DRM3 *iface,
1400 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device, IDirect3DRMDevice3 **device)
1402 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1403 struct d3drm_device *object;
1404 HRESULT hr;
1406 TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
1407 iface, d3d, d3d_device, device);
1409 if (!device)
1410 return D3DRMERR_BADVALUE;
1411 *device = NULL;
1413 if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
1414 return hr;
1416 if (FAILED(hr = IDirect3DRMDevice3_InitFromD3D2(&object->IDirect3DRMDevice3_iface, d3d, d3d_device)))
1418 d3drm_device_destroy(object);
1419 return hr;
1421 *device = &object->IDirect3DRMDevice3_iface;
1423 return D3DRM_OK;
1426 static HRESULT WINAPI d3drm3_CreateDeviceFromClipper(IDirect3DRM3 *iface,
1427 IDirectDrawClipper *clipper, GUID *guid, int width, int height,
1428 IDirect3DRMDevice3 **device)
1430 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1431 struct d3drm_device *object;
1432 IDirectDraw *ddraw;
1433 IDirectDrawSurface *render_target;
1434 HRESULT hr;
1436 TRACE("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
1437 iface, clipper, debugstr_guid(guid), width, height, device);
1439 if (!device)
1440 return D3DRMERR_BADVALUE;
1441 *device = NULL;
1443 if (!clipper || !width || !height)
1444 return D3DRMERR_BADVALUE;
1446 hr = DirectDrawCreate(NULL, &ddraw, NULL);
1447 if (FAILED(hr))
1448 return hr;
1450 if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface)))
1452 IDirectDraw_Release(ddraw);
1453 return hr;
1456 hr = d3drm_device_create_surfaces_from_clipper(object, ddraw, clipper, width, height, &render_target);
1457 if (FAILED(hr))
1459 IDirectDraw_Release(ddraw);
1460 d3drm_device_destroy(object);
1461 return hr;
1464 hr = d3drm_device_init(object, 3, ddraw, render_target, TRUE);
1465 IDirectDraw_Release(ddraw);
1466 IDirectDrawSurface_Release(render_target);
1467 if (FAILED(hr))
1468 d3drm_device_destroy(object);
1469 else
1470 *device = &object->IDirect3DRMDevice3_iface;
1472 return hr;
1475 static HRESULT WINAPI d3drm3_CreateShadow(IDirect3DRM3 *iface, IUnknown *object, IDirect3DRMLight *light,
1476 D3DVALUE px, D3DVALUE py, D3DVALUE pz, D3DVALUE nx, D3DVALUE ny, D3DVALUE nz, IDirect3DRMShadow2 **shadow)
1478 FIXME("iface %p, object %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
1479 iface, object, light, px, py, pz, nx, ny, nz, shadow);
1481 return E_NOTIMPL;
1484 static HRESULT WINAPI d3drm3_CreateTextureFromSurface(IDirect3DRM3 *iface,
1485 IDirectDrawSurface *surface, IDirect3DRMTexture3 **texture)
1487 FIXME("iface %p, surface %p, texture %p stub!\n", iface, surface, texture);
1489 return E_NOTIMPL;
1492 static HRESULT WINAPI d3drm3_CreateViewport(IDirect3DRM3 *iface, IDirect3DRMDevice3 *device,
1493 IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height, IDirect3DRMViewport2 **viewport)
1495 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1496 struct d3drm_viewport *object;
1497 HRESULT hr;
1499 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
1500 iface, device, camera, x, y, width, height, viewport);
1502 if (!device || !camera)
1503 return D3DRMERR_BADOBJECT;
1504 if (!viewport)
1505 return D3DRMERR_BADVALUE;
1507 if (FAILED(hr = d3drm_viewport_create(&object, &d3drm->IDirect3DRM_iface)))
1508 return hr;
1510 *viewport = &object->IDirect3DRMViewport2_iface;
1512 if (FAILED(hr = IDirect3DRMViewport2_Init(*viewport, device, camera, x, y, width, height)))
1514 IDirect3DRMViewport2_Release(*viewport);
1515 *viewport = NULL;
1516 return D3DRMERR_BADVALUE;
1519 return D3DRM_OK;
1522 static HRESULT WINAPI d3drm3_CreateWrap(IDirect3DRM3 *iface, D3DRMWRAPTYPE type, IDirect3DRMFrame3 *frame,
1523 D3DVALUE ox, D3DVALUE oy, D3DVALUE oz, D3DVALUE dx, D3DVALUE dy, D3DVALUE dz,
1524 D3DVALUE ux, D3DVALUE uy, D3DVALUE uz, D3DVALUE ou, D3DVALUE ov, D3DVALUE su, D3DVALUE sv,
1525 IDirect3DRMWrap **wrap)
1527 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
1528 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p stub!\n",
1529 iface, type, frame, ox, oy, oz, dx, dy, dz, ux, uy, uz, ou, ov, su, sv, wrap);
1531 return E_NOTIMPL;
1534 static HRESULT WINAPI d3drm3_CreateUserVisual(IDirect3DRM3 *iface,
1535 D3DRMUSERVISUALCALLBACK cb, void *ctx, IDirect3DRMUserVisual **visual)
1537 FIXME("iface %p, cb %p, ctx %p, visual %p stub!\n", iface, cb, ctx, visual);
1539 return E_NOTIMPL;
1542 static HRESULT WINAPI d3drm3_LoadTexture(IDirect3DRM3 *iface,
1543 const char *filename, IDirect3DRMTexture3 **texture)
1545 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1546 struct d3drm_texture *object;
1547 HRESULT hr;
1549 FIXME("iface %p, filename %s, texture %p stub!\n", iface, debugstr_a(filename), texture);
1551 if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
1552 return hr;
1554 *texture = &object->IDirect3DRMTexture3_iface;
1556 return D3DRM_OK;
1559 static HRESULT WINAPI d3drm3_LoadTextureFromResource(IDirect3DRM3 *iface, HMODULE module,
1560 const char *resource_name, const char *resource_type, IDirect3DRMTexture3 **texture)
1562 struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
1563 struct d3drm_texture *object;
1564 HRESULT hr;
1566 FIXME("iface %p, module %p, resource_name %s, resource_type %s, texture %p stub!\n",
1567 iface, module, debugstr_a(resource_name), debugstr_a(resource_type), texture);
1569 if (FAILED(hr = d3drm_texture_create(&object, &d3drm->IDirect3DRM_iface)))
1570 return hr;
1572 *texture = &object->IDirect3DRMTexture3_iface;
1574 return D3DRM_OK;
1577 static HRESULT WINAPI d3drm3_SetSearchPath(IDirect3DRM3 *iface, const char *path)
1579 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
1581 return E_NOTIMPL;
1584 static HRESULT WINAPI d3drm3_AddSearchPath(IDirect3DRM3 *iface, const char *path)
1586 FIXME("iface %p, path %s stub!\n", iface, debugstr_a(path));
1588 return E_NOTIMPL;
1591 static HRESULT WINAPI d3drm3_GetSearchPath(IDirect3DRM3 *iface, DWORD *size, char *path)
1593 FIXME("iface %p, size %p, path %p stub!\n", iface, size, path);
1595 return E_NOTIMPL;
1598 static HRESULT WINAPI d3drm3_SetDefaultTextureColors(IDirect3DRM3 *iface, DWORD color_count)
1600 FIXME("iface %p, color_count %u stub!\n", iface, color_count);
1602 return E_NOTIMPL;
1605 static HRESULT WINAPI d3drm3_SetDefaultTextureShades(IDirect3DRM3 *iface, DWORD shade_count)
1607 FIXME("iface %p, shade_count %u stub!\n", iface, shade_count);
1609 return E_NOTIMPL;
1612 static HRESULT WINAPI d3drm3_GetDevices(IDirect3DRM3 *iface, IDirect3DRMDeviceArray **array)
1614 FIXME("iface %p, array %p stub!\n", iface, array);
1616 return E_NOTIMPL;
1619 static HRESULT WINAPI d3drm3_GetNamedObject(IDirect3DRM3 *iface,
1620 const char *name, IDirect3DRMObject **object)
1622 FIXME("iface %p, name %s, object %p stub!\n", iface, debugstr_a(name), object);
1624 return E_NOTIMPL;
1627 static HRESULT WINAPI d3drm3_EnumerateObjects(IDirect3DRM3 *iface, D3DRMOBJECTCALLBACK cb, void *ctx)
1629 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1631 return E_NOTIMPL;
1634 static HRESULT load_data(IDirect3DRM3 *iface, IDirectXFileData *data_object, IID **GUIDs, DWORD nb_GUIDs, D3DRMLOADCALLBACK LoadProc,
1635 void *ArgLP, D3DRMLOADTEXTURECALLBACK LoadTextureProc, void *ArgLTP, IDirect3DRMFrame3 *parent_frame)
1637 HRESULT ret = D3DRMERR_BADOBJECT;
1638 HRESULT hr;
1639 const GUID* guid;
1640 DWORD i;
1641 BOOL requested = FALSE;
1643 hr = IDirectXFileData_GetType(data_object, &guid);
1644 if (hr != DXFILE_OK)
1645 goto end;
1647 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid));
1649 /* Load object only if it is top level and requested or if it is part of another object */
1651 if (IsEqualGUID(guid, &TID_D3DRMMesh))
1653 TRACE("Found TID_D3DRMMesh\n");
1655 for (i = 0; i < nb_GUIDs; i++)
1656 if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder) ||
1657 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder2) ||
1658 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMMeshBuilder3))
1660 requested = TRUE;
1661 break;
1664 if (requested || parent_frame)
1666 IDirect3DRMMeshBuilder3 *meshbuilder;
1668 TRACE("Load mesh data\n");
1670 hr = IDirect3DRM3_CreateMeshBuilder(iface, &meshbuilder);
1671 if (SUCCEEDED(hr))
1673 hr = load_mesh_data(meshbuilder, data_object, LoadTextureProc, ArgLTP);
1674 if (SUCCEEDED(hr))
1676 /* Only top level objects are notified */
1677 if (!parent_frame)
1679 IDirect3DRMObject *object;
1681 hr = IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder, GUIDs[i], (void**)&object);
1682 if (SUCCEEDED(hr))
1684 LoadProc(object, GUIDs[i], ArgLP);
1685 IDirect3DRMObject_Release(object);
1688 else
1690 IDirect3DRMFrame3_AddVisual(parent_frame, (IUnknown*)meshbuilder);
1693 IDirect3DRMMeshBuilder3_Release(meshbuilder);
1696 if (FAILED(hr))
1697 ERR("Cannot process mesh\n");
1700 else if (IsEqualGUID(guid, &TID_D3DRMFrame))
1702 TRACE("Found TID_D3DRMFrame\n");
1704 for (i = 0; i < nb_GUIDs; i++)
1705 if (IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame) ||
1706 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame2) ||
1707 IsEqualGUID(GUIDs[i], &IID_IDirect3DRMFrame3))
1709 requested = TRUE;
1710 break;
1713 if (requested || parent_frame)
1715 IDirect3DRMFrame3 *frame;
1717 TRACE("Load frame data\n");
1719 hr = IDirect3DRM3_CreateFrame(iface, parent_frame, &frame);
1720 if (SUCCEEDED(hr))
1722 IDirectXFileObject *child;
1724 while (SUCCEEDED(hr = IDirectXFileData_GetNextObject(data_object, &child)))
1726 IDirectXFileData *data;
1727 IDirectXFileDataReference *reference;
1728 IDirectXFileBinary *binary;
1730 if (SUCCEEDED(IDirectXFileObject_QueryInterface(child,
1731 &IID_IDirectXFileBinary, (void **)&binary)))
1733 FIXME("Binary Object not supported yet\n");
1734 IDirectXFileBinary_Release(binary);
1736 else if (SUCCEEDED(IDirectXFileObject_QueryInterface(child,
1737 &IID_IDirectXFileData, (void **)&data)))
1739 TRACE("Found Data Object\n");
1740 hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1741 IDirectXFileData_Release(data);
1743 else if (SUCCEEDED(IDirectXFileObject_QueryInterface(child,
1744 &IID_IDirectXFileDataReference, (void **)&reference)))
1746 TRACE("Found Data Object Reference\n");
1747 IDirectXFileDataReference_Resolve(reference, &data);
1748 hr = load_data(iface, data, GUIDs, nb_GUIDs, LoadProc, ArgLP, LoadTextureProc, ArgLTP, frame);
1749 IDirectXFileData_Release(data);
1750 IDirectXFileDataReference_Release(reference);
1752 IDirectXFileObject_Release(child);
1755 if (hr != DXFILEERR_NOMOREOBJECTS)
1757 IDirect3DRMFrame3_Release(frame);
1758 goto end;
1760 hr = S_OK;
1762 /* Only top level objects are notified */
1763 if (!parent_frame)
1765 IDirect3DRMObject *object;
1767 hr = IDirect3DRMFrame3_QueryInterface(frame, GUIDs[i], (void**)&object);
1768 if (SUCCEEDED(hr))
1770 LoadProc(object, GUIDs[i], ArgLP);
1771 IDirect3DRMObject_Release(object);
1774 IDirect3DRMFrame3_Release(frame);
1777 if (FAILED(hr))
1778 ERR("Cannot process frame\n");
1781 else if (IsEqualGUID(guid, &TID_D3DRMMaterial))
1783 TRACE("Found TID_D3DRMMaterial\n");
1785 /* Cannot be requested so nothing to do */
1787 else if (IsEqualGUID(guid, &TID_D3DRMFrameTransformMatrix))
1789 TRACE("Found TID_D3DRMFrameTransformMatrix\n");
1791 /* Cannot be requested */
1792 if (parent_frame)
1794 D3DRMMATRIX4D *matrix;
1795 DWORD size;
1797 TRACE("Load Frame Transform Matrix data\n");
1799 hr = IDirectXFileData_GetData(data_object, NULL, &size, (void**)&matrix);
1800 if ((hr != DXFILE_OK) || (size != sizeof(matrix)))
1801 goto end;
1803 hr = IDirect3DRMFrame3_AddTransform(parent_frame, D3DRMCOMBINE_REPLACE, *matrix);
1804 if (FAILED(hr))
1805 goto end;
1808 else
1810 FIXME("Found unknown TID %s\n", debugstr_guid(guid));
1813 ret = D3DRM_OK;
1815 end:
1817 return ret;
1820 static HRESULT WINAPI d3drm3_Load(IDirect3DRM3 *iface, void *source, void *object_id, IID **iids,
1821 DWORD iid_count, D3DRMLOADOPTIONS flags, D3DRMLOADCALLBACK load_cb, void *load_ctx,
1822 D3DRMLOADTEXTURECALLBACK load_tex_cb, void *load_tex_ctx, IDirect3DRMFrame3 *parent_frame)
1824 DXFILELOADOPTIONS load_options;
1825 IDirectXFile *file = NULL;
1826 IDirectXFileEnumObject *enum_object = NULL;
1827 IDirectXFileData *data = NULL;
1828 HRESULT hr;
1829 const GUID* pGuid;
1830 DWORD size;
1831 struct d3drm_file_header *header;
1832 HRESULT ret = D3DRMERR_BADOBJECT;
1833 DWORD i;
1835 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
1836 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
1837 iface, source, object_id, iids, iid_count, flags,
1838 load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
1840 TRACE("Looking for GUIDs:\n");
1841 for (i = 0; i < iid_count; ++i)
1842 TRACE("- %s (%s)\n", debugstr_guid(iids[i]), get_IID_string(iids[i]));
1844 if (flags == D3DRMLOAD_FROMMEMORY)
1846 load_options = DXFILELOAD_FROMMEMORY;
1848 else if (flags == D3DRMLOAD_FROMFILE)
1850 load_options = DXFILELOAD_FROMFILE;
1851 TRACE("Loading from file %s\n", debugstr_a(source));
1853 else
1855 FIXME("Load options %#x not supported yet.\n", flags);
1856 return E_NOTIMPL;
1859 hr = DirectXFileCreate(&file);
1860 if (hr != DXFILE_OK)
1861 goto end;
1863 hr = IDirectXFile_RegisterTemplates(file, templates, strlen(templates));
1864 if (hr != DXFILE_OK)
1865 goto end;
1867 hr = IDirectXFile_CreateEnumObject(file, source, load_options, &enum_object);
1868 if (hr != DXFILE_OK)
1869 goto end;
1871 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1872 if (hr != DXFILE_OK)
1873 goto end;
1875 hr = IDirectXFileData_GetType(data, &pGuid);
1876 if (hr != DXFILE_OK)
1877 goto end;
1879 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid));
1881 if (!IsEqualGUID(pGuid, &TID_DXFILEHeader))
1883 ret = D3DRMERR_BADFILE;
1884 goto end;
1887 hr = IDirectXFileData_GetData(data, NULL, &size, (void **)&header);
1888 if ((hr != DXFILE_OK) || (size != sizeof(*header)))
1889 goto end;
1891 TRACE("Version is %u.%u, flags %#x.\n", header->major, header->minor, header->flags);
1893 /* Version must be 1.0.x */
1894 if ((header->major != 1) || (header->minor != 0))
1896 ret = D3DRMERR_BADFILE;
1897 goto end;
1900 IDirectXFileData_Release(data);
1901 data = NULL;
1903 while (1)
1905 hr = IDirectXFileEnumObject_GetNextDataObject(enum_object, &data);
1906 if (hr == DXFILEERR_NOMOREOBJECTS)
1908 TRACE("No more object\n");
1909 break;
1911 else if (hr != DXFILE_OK)
1913 ret = D3DRMERR_BADFILE;
1914 goto end;
1917 ret = load_data(iface, data, iids, iid_count, load_cb, load_ctx, load_tex_cb, load_tex_ctx, parent_frame);
1918 if (ret != D3DRM_OK)
1919 goto end;
1921 IDirectXFileData_Release(data);
1922 data = NULL;
1925 ret = D3DRM_OK;
1927 end:
1928 if (data)
1929 IDirectXFileData_Release(data);
1930 if (enum_object)
1931 IDirectXFileEnumObject_Release(enum_object);
1932 if (file)
1933 IDirectXFile_Release(file);
1935 return ret;
1938 static HRESULT WINAPI d3drm3_Tick(IDirect3DRM3 *iface, D3DVALUE tick)
1940 FIXME("iface %p, tick %.8e stub!\n", iface, tick);
1942 return E_NOTIMPL;
1945 static HRESULT WINAPI d3drm3_CreateProgressiveMesh(IDirect3DRM3 *iface, IDirect3DRMProgressiveMesh **mesh)
1947 FIXME("iface %p, mesh %p stub!\n", iface, mesh);
1949 return E_NOTIMPL;
1952 static HRESULT WINAPI d3drm3_RegisterClient(IDirect3DRM3 *iface, REFGUID guid, DWORD *id)
1954 FIXME("iface %p, guid %s, id %p stub!\n", iface, debugstr_guid(guid), id);
1956 return E_NOTIMPL;
1959 static HRESULT WINAPI d3drm3_UnregisterClient(IDirect3DRM3 *iface, REFGUID guid)
1961 FIXME("iface %p, guid %s stub!\n", iface, debugstr_guid(guid));
1963 return E_NOTIMPL;
1966 static HRESULT WINAPI d3drm3_CreateClippedVisual(IDirect3DRM3 *iface,
1967 IDirect3DRMVisual *visual, IDirect3DRMClippedVisual **clipped_visual)
1969 FIXME("iface %p, visual %p, clipped_visual %p stub!\n", iface, visual, clipped_visual);
1971 return E_NOTIMPL;
1974 static HRESULT WINAPI d3drm3_SetOptions(IDirect3DRM3 *iface, DWORD flags)
1976 FIXME("iface %p, flags %#x stub!\n", iface, flags);
1978 return E_NOTIMPL;
1981 static HRESULT WINAPI d3drm3_GetOptions(IDirect3DRM3 *iface, DWORD *flags)
1983 FIXME("iface %p, flags %p stub!\n", iface, flags);
1985 return E_NOTIMPL;
1988 static const struct IDirect3DRM3Vtbl d3drm3_vtbl =
1990 d3drm3_QueryInterface,
1991 d3drm3_AddRef,
1992 d3drm3_Release,
1993 d3drm3_CreateObject,
1994 d3drm3_CreateFrame,
1995 d3drm3_CreateMesh,
1996 d3drm3_CreateMeshBuilder,
1997 d3drm3_CreateFace,
1998 d3drm3_CreateAnimation,
1999 d3drm3_CreateAnimationSet,
2000 d3drm3_CreateTexture,
2001 d3drm3_CreateLight,
2002 d3drm3_CreateLightRGB,
2003 d3drm3_CreateMaterial,
2004 d3drm3_CreateDevice,
2005 d3drm3_CreateDeviceFromSurface,
2006 d3drm3_CreateDeviceFromD3D,
2007 d3drm3_CreateDeviceFromClipper,
2008 d3drm3_CreateTextureFromSurface,
2009 d3drm3_CreateShadow,
2010 d3drm3_CreateViewport,
2011 d3drm3_CreateWrap,
2012 d3drm3_CreateUserVisual,
2013 d3drm3_LoadTexture,
2014 d3drm3_LoadTextureFromResource,
2015 d3drm3_SetSearchPath,
2016 d3drm3_AddSearchPath,
2017 d3drm3_GetSearchPath,
2018 d3drm3_SetDefaultTextureColors,
2019 d3drm3_SetDefaultTextureShades,
2020 d3drm3_GetDevices,
2021 d3drm3_GetNamedObject,
2022 d3drm3_EnumerateObjects,
2023 d3drm3_Load,
2024 d3drm3_Tick,
2025 d3drm3_CreateProgressiveMesh,
2026 d3drm3_RegisterClient,
2027 d3drm3_UnregisterClient,
2028 d3drm3_CreateClippedVisual,
2029 d3drm3_SetOptions,
2030 d3drm3_GetOptions,
2033 HRESULT WINAPI Direct3DRMCreate(IDirect3DRM **d3drm)
2035 struct d3drm *object;
2037 TRACE("d3drm %p.\n", d3drm);
2039 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
2040 return E_OUTOFMEMORY;
2042 object->IDirect3DRM_iface.lpVtbl = &d3drm1_vtbl;
2043 object->IDirect3DRM2_iface.lpVtbl = &d3drm2_vtbl;
2044 object->IDirect3DRM3_iface.lpVtbl = &d3drm3_vtbl;
2045 object->ref1 = 1;
2046 object->iface_count = 1;
2048 *d3drm = &object->IDirect3DRM_iface;
2050 return S_OK;
2053 HRESULT WINAPI DllCanUnloadNow(void)
2055 return S_FALSE;
2058 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
2060 TRACE("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
2062 if(!ppv)
2063 return E_INVALIDARG;
2065 return CLASS_E_CLASSNOTAVAILABLE;