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 "d3drm_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3drm
);
27 static const char* get_IID_string(const GUID
* guid
)
29 if (IsEqualGUID(guid
, &IID_IDirect3DRMFrame
))
30 return "IID_IDirect3DRMFrame";
31 else if (IsEqualGUID(guid
, &IID_IDirect3DRMFrame2
))
32 return "IID_IDirect3DRMFrame2";
33 else if (IsEqualGUID(guid
, &IID_IDirect3DRMFrame3
))
34 return "IID_IDirect3DRMFrame3";
35 else if (IsEqualGUID(guid
, &IID_IDirect3DRMMeshBuilder
))
36 return "IID_IDirect3DRMMeshBuilder";
37 else if (IsEqualGUID(guid
, &IID_IDirect3DRMMeshBuilder2
))
38 return "IID_IDirect3DRMMeshBuilder2";
39 else if (IsEqualGUID(guid
, &IID_IDirect3DRMMeshBuilder3
))
40 return "IID_IDirect3DRMMeshBuilder3";
45 static HRESULT
d3drm_create_texture_object(void **object
, IDirect3DRM
*d3drm
)
47 struct d3drm_texture
*texture
;
50 if (FAILED(hr
= d3drm_texture_create(&texture
, d3drm
)))
53 *object
= &texture
->IDirect3DRMTexture_iface
;
58 static HRESULT
d3drm_create_device_object(void **object
, IDirect3DRM
*d3drm
)
60 struct d3drm_device
*device
;
63 if (FAILED(hr
= d3drm_device_create(&device
, d3drm
)))
66 *object
= &device
->IDirect3DRMDevice_iface
;
71 static HRESULT
d3drm_create_viewport_object(void **object
, IDirect3DRM
*d3drm
)
73 struct d3drm_viewport
*viewport
;
76 if (FAILED(hr
= d3drm_viewport_create(&viewport
, d3drm
)))
79 *object
= &viewport
->IDirect3DRMViewport_iface
;
84 static HRESULT
d3drm_create_face_object(void **object
, IDirect3DRM
*d3drm
)
86 struct d3drm_face
*face
;
89 if (FAILED(hr
= d3drm_face_create(&face
)))
92 *object
= &face
->IDirect3DRMFace_iface
;
97 static HRESULT
d3drm_create_mesh_builder_object(void **object
, IDirect3DRM
*d3drm
)
99 struct d3drm_mesh_builder
*mesh_builder
;
102 if (FAILED(hr
= d3drm_mesh_builder_create(&mesh_builder
, d3drm
)))
105 *object
= &mesh_builder
->IDirect3DRMMeshBuilder2_iface
;
110 static HRESULT
d3drm_create_frame_object(void **object
, IDirect3DRM
*d3drm
)
112 struct d3drm_frame
*frame
;
115 if (FAILED(hr
= d3drm_frame_create(&frame
, NULL
, d3drm
)))
118 *object
= &frame
->IDirect3DRMFrame_iface
;
123 static HRESULT
d3drm_create_light_object(void **object
, IDirect3DRM
*d3drm
)
125 struct d3drm_light
*light
;
128 if (FAILED(hr
= d3drm_light_create(&light
, d3drm
)))
131 *object
= &light
->IDirect3DRMLight_iface
;
136 static HRESULT
d3drm_create_material_object(void **object
, IDirect3DRM
*d3drm
)
138 struct d3drm_material
*material
;
141 if (FAILED(hr
= d3drm_material_create(&material
, d3drm
)))
144 *object
= &material
->IDirect3DRMMaterial2_iface
;
149 static HRESULT
d3drm_create_mesh_object(void **object
, IDirect3DRM
*d3drm
)
151 struct d3drm_mesh
*mesh
;
154 if (FAILED(hr
= d3drm_mesh_create(&mesh
, d3drm
)))
157 *object
= &mesh
->IDirect3DRMMesh_iface
;
162 static HRESULT
d3drm_create_animation_object(void **object
, IDirect3DRM
*d3drm
)
164 struct d3drm_animation
*animation
;
167 if (FAILED(hr
= d3drm_animation_create(&animation
, d3drm
)))
170 *object
= &animation
->IDirect3DRMAnimation_iface
;
175 static HRESULT
d3drm_create_wrap_object(void **object
, IDirect3DRM
*d3drm
)
177 struct d3drm_wrap
*wrap
;
180 if (FAILED(hr
= d3drm_wrap_create(&wrap
, d3drm
)))
183 *object
= &wrap
->IDirect3DRMWrap_iface
;
190 IDirect3DRM IDirect3DRM_iface
;
191 IDirect3DRM2 IDirect3DRM2_iface
;
192 IDirect3DRM3 IDirect3DRM3_iface
;
193 LONG ref1
, ref2
, ref3
, iface_count
;
196 static inline struct d3drm
*impl_from_IDirect3DRM(IDirect3DRM
*iface
)
198 return CONTAINING_RECORD(iface
, struct d3drm
, IDirect3DRM_iface
);
201 static inline struct d3drm
*impl_from_IDirect3DRM2(IDirect3DRM2
*iface
)
203 return CONTAINING_RECORD(iface
, struct d3drm
, IDirect3DRM2_iface
);
206 static inline struct d3drm
*impl_from_IDirect3DRM3(IDirect3DRM3
*iface
)
208 return CONTAINING_RECORD(iface
, struct d3drm
, IDirect3DRM3_iface
);
211 static void d3drm_destroy(struct d3drm
*d3drm
)
214 TRACE("d3drm object %p is being destroyed.\n", d3drm
);
217 static HRESULT WINAPI
d3drm1_QueryInterface(IDirect3DRM
*iface
, REFIID riid
, void **out
)
219 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
221 TRACE("iface %p, riid %s, out %p.\n", iface
, debugstr_guid(riid
), out
);
223 if (IsEqualGUID(riid
, &IID_IDirect3DRM
)
224 || IsEqualGUID(riid
, &IID_IUnknown
))
226 *out
= &d3drm
->IDirect3DRM_iface
;
228 else if (IsEqualGUID(riid
, &IID_IDirect3DRM2
))
230 *out
= &d3drm
->IDirect3DRM2_iface
;
232 else if (IsEqualGUID(riid
, &IID_IDirect3DRM3
))
234 *out
= &d3drm
->IDirect3DRM3_iface
;
239 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid
));
240 return CLASS_E_CLASSNOTAVAILABLE
;
243 IUnknown_AddRef((IUnknown
*)*out
);
247 static ULONG WINAPI
d3drm1_AddRef(IDirect3DRM
*iface
)
249 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
250 ULONG refcount
= InterlockedIncrement(&d3drm
->ref1
);
252 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
255 InterlockedIncrement(&d3drm
->iface_count
);
260 static ULONG WINAPI
d3drm1_Release(IDirect3DRM
*iface
)
262 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
263 ULONG refcount
= InterlockedDecrement(&d3drm
->ref1
);
265 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
267 if (!refcount
&& !InterlockedDecrement(&d3drm
->iface_count
))
268 d3drm_destroy(d3drm
);
273 static HRESULT WINAPI
d3drm1_CreateObject(IDirect3DRM
*iface
,
274 REFCLSID clsid
, IUnknown
*outer
, REFIID iid
, void **out
)
276 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
278 TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
279 iface
, debugstr_guid(clsid
), outer
, debugstr_guid(iid
), out
);
281 return IDirect3DRM3_CreateObject(&d3drm
->IDirect3DRM3_iface
, clsid
, outer
, iid
, out
);
284 static HRESULT WINAPI
d3drm1_CreateFrame(IDirect3DRM
*iface
,
285 IDirect3DRMFrame
*parent_frame
, IDirect3DRMFrame
**frame
)
287 struct d3drm_frame
*object
;
290 TRACE("iface %p, parent_frame %p, frame %p.\n", iface
, parent_frame
, frame
);
292 if (FAILED(hr
= d3drm_frame_create(&object
, (IUnknown
*)parent_frame
, iface
)))
295 *frame
= &object
->IDirect3DRMFrame_iface
;
300 static HRESULT WINAPI
d3drm1_CreateMesh(IDirect3DRM
*iface
, IDirect3DRMMesh
**mesh
)
302 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
304 TRACE("iface %p, mesh %p.\n", iface
, mesh
);
306 return IDirect3DRM3_CreateMesh(&d3drm
->IDirect3DRM3_iface
, mesh
);
309 static HRESULT WINAPI
d3drm1_CreateMeshBuilder(IDirect3DRM
*iface
, IDirect3DRMMeshBuilder
**mesh_builder
)
311 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
313 TRACE("iface %p, mesh_builder %p.\n", iface
, mesh_builder
);
315 return IDirect3DRM2_CreateMeshBuilder(&d3drm
->IDirect3DRM2_iface
, (IDirect3DRMMeshBuilder2
**)mesh_builder
);
318 static HRESULT WINAPI
d3drm1_CreateFace(IDirect3DRM
*iface
, IDirect3DRMFace
**face
)
320 struct d3drm_face
*object
;
323 TRACE("iface %p, face %p.\n", iface
, face
);
325 if (FAILED(hr
= d3drm_face_create(&object
)))
328 *face
= &object
->IDirect3DRMFace_iface
;
333 static HRESULT WINAPI
d3drm1_CreateAnimation(IDirect3DRM
*iface
, IDirect3DRMAnimation
**animation
)
335 struct d3drm_animation
*object
;
338 TRACE("iface %p, animation %p.\n", iface
, animation
);
341 return D3DRMERR_BADVALUE
;
343 if (FAILED(hr
= d3drm_animation_create(&object
, iface
)))
346 *animation
= &object
->IDirect3DRMAnimation_iface
;
351 static HRESULT WINAPI
d3drm1_CreateAnimationSet(IDirect3DRM
*iface
, IDirect3DRMAnimationSet
**set
)
353 FIXME("iface %p, set %p stub!\n", iface
, set
);
358 static HRESULT WINAPI
d3drm1_CreateTexture(IDirect3DRM
*iface
,
359 D3DRMIMAGE
*image
, IDirect3DRMTexture
**texture
)
361 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
362 IDirect3DRMTexture3
*texture3
;
365 TRACE("iface %p, image %p, texture %p.\n", iface
, image
, texture
);
368 return D3DRMERR_BADVALUE
;
370 if (FAILED(hr
= IDirect3DRM3_CreateTexture(&d3drm
->IDirect3DRM3_iface
, image
, &texture3
)))
376 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture
, (void **)texture
);
377 IDirect3DRMTexture3_Release(texture3
);
382 static HRESULT WINAPI
d3drm1_CreateLight(IDirect3DRM
*iface
,
383 D3DRMLIGHTTYPE type
, D3DCOLOR color
, IDirect3DRMLight
**light
)
385 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
387 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface
, type
, color
, light
);
389 return IDirect3DRM3_CreateLight(&d3drm
->IDirect3DRM3_iface
, type
, color
, light
);
392 static HRESULT WINAPI
d3drm1_CreateLightRGB(IDirect3DRM
*iface
, D3DRMLIGHTTYPE type
,
393 D3DVALUE red
, D3DVALUE green
, D3DVALUE blue
, IDirect3DRMLight
**light
)
395 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
397 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
398 iface
, type
, red
, green
, blue
, light
);
400 return IDirect3DRM3_CreateLightRGB(&d3drm
->IDirect3DRM3_iface
, type
, red
, green
, blue
, light
);
403 static HRESULT WINAPI
d3drm1_CreateMaterial(IDirect3DRM
*iface
,
404 D3DVALUE power
, IDirect3DRMMaterial
**material
)
406 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
408 TRACE("iface %p, power %.8e, material %p.\n", iface
, power
, material
);
410 return IDirect3DRM3_CreateMaterial(&d3drm
->IDirect3DRM3_iface
, power
, (IDirect3DRMMaterial2
**)material
);
413 static HRESULT WINAPI
d3drm1_CreateDevice(IDirect3DRM
*iface
,
414 DWORD width
, DWORD height
, IDirect3DRMDevice
**device
)
416 TRACE("iface %p, width %u, height %u, device %p.\n", iface
, width
, height
, device
);
419 return D3DRMERR_BADVALUE
;
422 return D3DRMERR_BADDEVICE
;
425 static HRESULT WINAPI
d3drm1_CreateDeviceFromSurface(IDirect3DRM
*iface
, GUID
*guid
,
426 IDirectDraw
*ddraw
, IDirectDrawSurface
*backbuffer
, IDirect3DRMDevice
**device
)
428 struct d3drm_device
*object
;
431 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p, device %p.\n",
432 iface
, debugstr_guid(guid
), ddraw
, backbuffer
, device
);
435 return D3DRMERR_BADVALUE
;
438 if (!backbuffer
|| !ddraw
)
439 return D3DRMERR_BADDEVICE
;
441 if (FAILED(hr
= d3drm_device_create(&object
, iface
)))
444 if (SUCCEEDED(hr
= d3drm_device_init(object
, 1, ddraw
, backbuffer
, TRUE
)))
445 *device
= &object
->IDirect3DRMDevice_iface
;
447 d3drm_device_destroy(object
);
452 static HRESULT WINAPI
d3drm1_CreateDeviceFromD3D(IDirect3DRM
*iface
,
453 IDirect3D
*d3d
, IDirect3DDevice
*d3d_device
, IDirect3DRMDevice
**device
)
455 struct d3drm_device
*object
;
457 TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
458 iface
, d3d
, d3d_device
, device
);
461 return D3DRMERR_BADVALUE
;
464 if (FAILED(hr
= d3drm_device_create(&object
, iface
)))
467 if (FAILED(hr
= IDirect3DRMDevice_InitFromD3D(&object
->IDirect3DRMDevice_iface
, d3d
, d3d_device
)))
469 d3drm_device_destroy(object
);
472 *device
= &object
->IDirect3DRMDevice_iface
;
477 static HRESULT WINAPI
d3drm1_CreateDeviceFromClipper(IDirect3DRM
*iface
,
478 IDirectDrawClipper
*clipper
, GUID
*guid
, int width
, int height
,
479 IDirect3DRMDevice
**device
)
481 struct d3drm_device
*object
;
483 IDirectDrawSurface
*render_target
;
486 TRACE("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
487 iface
, clipper
, debugstr_guid(guid
), width
, height
, device
);
490 return D3DRMERR_BADVALUE
;
493 if (!clipper
|| !width
|| !height
)
494 return D3DRMERR_BADVALUE
;
496 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
500 if (FAILED(hr
= d3drm_device_create(&object
, iface
)))
502 IDirectDraw_Release(ddraw
);
506 hr
= d3drm_device_create_surfaces_from_clipper(object
, ddraw
, clipper
, width
, height
, &render_target
);
509 IDirectDraw_Release(ddraw
);
510 d3drm_device_destroy(object
);
514 hr
= d3drm_device_init(object
, 1, ddraw
, render_target
, TRUE
);
515 IDirectDraw_Release(ddraw
);
516 IDirectDrawSurface_Release(render_target
);
518 d3drm_device_destroy(object
);
520 *device
= &object
->IDirect3DRMDevice_iface
;
525 static HRESULT WINAPI
d3drm1_CreateTextureFromSurface(IDirect3DRM
*iface
,
526 IDirectDrawSurface
*surface
, IDirect3DRMTexture
**texture
)
528 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
529 IDirect3DRMTexture3
*texture3
;
532 TRACE("iface %p, surface %p, texture %p.\n", iface
, surface
, texture
);
535 return D3DRMERR_BADVALUE
;
537 if (FAILED(hr
= IDirect3DRM3_CreateTextureFromSurface(&d3drm
->IDirect3DRM3_iface
, surface
, &texture3
)))
543 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture
, (void **)texture
);
544 IDirect3DRMTexture3_Release(texture3
);
549 static HRESULT WINAPI
d3drm1_CreateShadow(IDirect3DRM
*iface
, IDirect3DRMVisual
*visual
,
550 IDirect3DRMLight
*light
, D3DVALUE px
, D3DVALUE py
, D3DVALUE pz
, D3DVALUE nx
, D3DVALUE ny
, D3DVALUE nz
,
551 IDirect3DRMVisual
**shadow
)
553 FIXME("iface %p, visual %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
554 iface
, visual
, light
, px
, py
, pz
, nx
, ny
, nz
, shadow
);
559 static HRESULT WINAPI
d3drm1_CreateViewport(IDirect3DRM
*iface
, IDirect3DRMDevice
*device
,
560 IDirect3DRMFrame
*camera
, DWORD x
, DWORD y
, DWORD width
, DWORD height
, IDirect3DRMViewport
**viewport
)
562 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
563 IDirect3DRMDevice3
*device3
;
564 IDirect3DRMFrame3
*camera3
;
565 IDirect3DRMViewport2
*viewport2
;
568 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
569 iface
, device
, camera
, x
, y
, width
, height
, viewport
);
572 return D3DRMERR_BADVALUE
;
575 if (!device
|| !camera
)
576 return D3DRMERR_BADOBJECT
;
578 if (FAILED(hr
= IDirect3DRMDevice_QueryInterface(device
, &IID_IDirect3DRMDevice3
, (void **)&device3
)))
581 if (FAILED(hr
= IDirect3DRMFrame_QueryInterface(camera
, &IID_IDirect3DRMFrame3
, (void **)&camera3
)))
583 IDirect3DRMDevice3_Release(device3
);
587 hr
= IDirect3DRM3_CreateViewport(&d3drm
->IDirect3DRM3_iface
, device3
, camera3
, x
, y
, width
, height
, &viewport2
);
588 IDirect3DRMDevice3_Release(device3
);
589 IDirect3DRMFrame3_Release(camera3
);
593 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IDirect3DRMViewport
, (void **)viewport
);
594 IDirect3DRMViewport2_Release(viewport2
);
599 static HRESULT WINAPI
d3drm1_CreateWrap(IDirect3DRM
*iface
, D3DRMWRAPTYPE type
, IDirect3DRMFrame
*frame
,
600 D3DVALUE ox
, D3DVALUE oy
, D3DVALUE oz
, D3DVALUE dx
, D3DVALUE dy
, D3DVALUE dz
,
601 D3DVALUE ux
, D3DVALUE uy
, D3DVALUE uz
, D3DVALUE ou
, D3DVALUE ov
, D3DVALUE su
, D3DVALUE sv
,
602 IDirect3DRMWrap
**wrap
)
604 struct d3drm_wrap
*object
;
607 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
608 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p, semi-stub.\n",
609 iface
, type
, frame
, ox
, oy
, oz
, dx
, dy
, dz
, ux
, uy
, uz
, ou
, ov
, su
, sv
, wrap
);
612 return D3DRMERR_BADVALUE
;
614 if (FAILED(hr
= d3drm_wrap_create(&object
, iface
)))
617 *wrap
= &object
->IDirect3DRMWrap_iface
;
622 static HRESULT WINAPI
d3drm1_CreateUserVisual(IDirect3DRM
*iface
,
623 D3DRMUSERVISUALCALLBACK cb
, void *ctx
, IDirect3DRMUserVisual
**visual
)
625 FIXME("iface %p, cb %p, ctx %p visual %p stub!\n", iface
, cb
, ctx
, visual
);
630 static HRESULT WINAPI
d3drm1_LoadTexture(IDirect3DRM
*iface
,
631 const char *filename
, IDirect3DRMTexture
**texture
)
633 struct d3drm_texture
*object
;
636 TRACE("iface %p, filename %s, texture %p.\n", iface
, debugstr_a(filename
), texture
);
639 return D3DRMERR_BADVALUE
;
641 if (FAILED(hr
= d3drm_texture_create(&object
, iface
)))
644 *texture
= &object
->IDirect3DRMTexture_iface
;
645 if (FAILED(hr
= IDirect3DRMTexture_InitFromFile(*texture
, filename
)))
647 IDirect3DRMTexture_Release(*texture
);
650 return D3DRMERR_BADVALUE
;
652 return hr
== D3DRMERR_BADOBJECT
? D3DRMERR_FILENOTFOUND
: hr
;
658 static HRESULT WINAPI
d3drm1_LoadTextureFromResource(IDirect3DRM
*iface
,
659 HRSRC resource
, IDirect3DRMTexture
**texture
)
661 struct d3drm_texture
*object
;
664 FIXME("iface %p, resource %p, texture %p stub!\n", iface
, resource
, texture
);
666 if (FAILED(hr
= d3drm_texture_create(&object
, iface
)))
669 *texture
= &object
->IDirect3DRMTexture_iface
;
674 static HRESULT WINAPI
d3drm1_SetSearchPath(IDirect3DRM
*iface
, const char *path
)
676 FIXME("iface %p, path %s stub!\n", iface
, debugstr_a(path
));
681 static HRESULT WINAPI
d3drm1_AddSearchPath(IDirect3DRM
*iface
, const char *path
)
683 FIXME("iface %p, path %s stub!\n", iface
, debugstr_a(path
));
688 static HRESULT WINAPI
d3drm1_GetSearchPath(IDirect3DRM
*iface
, DWORD
*size
, char *path
)
690 FIXME("iface %p, size %p, path %p stub!\n", iface
, size
, path
);
695 static HRESULT WINAPI
d3drm1_SetDefaultTextureColors(IDirect3DRM
*iface
, DWORD color_count
)
697 FIXME("iface %p, color_count %u stub!\n", iface
, color_count
);
702 static HRESULT WINAPI
d3drm1_SetDefaultTextureShades(IDirect3DRM
*iface
, DWORD shade_count
)
704 FIXME("iface %p, shade_count %u stub!\n", iface
, shade_count
);
709 static HRESULT WINAPI
d3drm1_GetDevices(IDirect3DRM
*iface
, IDirect3DRMDeviceArray
**array
)
711 FIXME("iface %p, array %p stub!\n", iface
, array
);
716 static HRESULT WINAPI
d3drm1_GetNamedObject(IDirect3DRM
*iface
,
717 const char *name
, IDirect3DRMObject
**object
)
719 FIXME("iface %p, name %s, object %p stub!\n", iface
, debugstr_a(name
), object
);
724 static HRESULT WINAPI
d3drm1_EnumerateObjects(IDirect3DRM
*iface
, D3DRMOBJECTCALLBACK cb
, void *ctx
)
726 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
731 static HRESULT WINAPI
d3drm1_Load(IDirect3DRM
*iface
, void *source
, void *object_id
, IID
**iids
,
732 DWORD iid_count
, D3DRMLOADOPTIONS flags
, D3DRMLOADCALLBACK load_cb
, void *load_ctx
,
733 D3DRMLOADTEXTURECALLBACK load_tex_cb
, void *load_tex_ctx
, IDirect3DRMFrame
*parent_frame
)
735 struct d3drm
*d3drm
= impl_from_IDirect3DRM(iface
);
736 IDirect3DRMFrame3
*parent_frame3
= NULL
;
737 HRESULT hr
= D3DRM_OK
;
739 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
740 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
741 iface
, source
, object_id
, iids
, iid_count
, flags
,
742 load_cb
, load_ctx
, load_tex_cb
, load_tex_ctx
, parent_frame
);
745 hr
= IDirect3DRMFrame_QueryInterface(parent_frame
, &IID_IDirect3DRMFrame3
, (void **)&parent_frame3
);
747 hr
= IDirect3DRM3_Load(&d3drm
->IDirect3DRM3_iface
, source
, object_id
, iids
, iid_count
,
748 flags
, load_cb
, load_ctx
, load_tex_cb
, load_tex_ctx
, parent_frame3
);
750 IDirect3DRMFrame3_Release(parent_frame3
);
755 static HRESULT WINAPI
d3drm1_Tick(IDirect3DRM
*iface
, D3DVALUE tick
)
757 FIXME("iface %p, tick %.8e stub!\n", iface
, tick
);
762 static const struct IDirect3DRMVtbl d3drm1_vtbl
=
764 d3drm1_QueryInterface
,
770 d3drm1_CreateMeshBuilder
,
772 d3drm1_CreateAnimation
,
773 d3drm1_CreateAnimationSet
,
774 d3drm1_CreateTexture
,
776 d3drm1_CreateLightRGB
,
777 d3drm1_CreateMaterial
,
779 d3drm1_CreateDeviceFromSurface
,
780 d3drm1_CreateDeviceFromD3D
,
781 d3drm1_CreateDeviceFromClipper
,
782 d3drm1_CreateTextureFromSurface
,
784 d3drm1_CreateViewport
,
786 d3drm1_CreateUserVisual
,
788 d3drm1_LoadTextureFromResource
,
789 d3drm1_SetSearchPath
,
790 d3drm1_AddSearchPath
,
791 d3drm1_GetSearchPath
,
792 d3drm1_SetDefaultTextureColors
,
793 d3drm1_SetDefaultTextureShades
,
795 d3drm1_GetNamedObject
,
796 d3drm1_EnumerateObjects
,
801 static HRESULT WINAPI
d3drm2_QueryInterface(IDirect3DRM2
*iface
, REFIID riid
, void **out
)
803 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
805 return d3drm1_QueryInterface(&d3drm
->IDirect3DRM_iface
, riid
, out
);
808 static ULONG WINAPI
d3drm2_AddRef(IDirect3DRM2
*iface
)
810 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
811 ULONG refcount
= InterlockedIncrement(&d3drm
->ref2
);
813 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
816 InterlockedIncrement(&d3drm
->iface_count
);
821 static ULONG WINAPI
d3drm2_Release(IDirect3DRM2
*iface
)
823 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
824 ULONG refcount
= InterlockedDecrement(&d3drm
->ref2
);
826 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
828 if (!refcount
&& !InterlockedDecrement(&d3drm
->iface_count
))
829 d3drm_destroy(d3drm
);
834 static HRESULT WINAPI
d3drm2_CreateObject(IDirect3DRM2
*iface
,
835 REFCLSID clsid
, IUnknown
*outer
, REFIID iid
, void **out
)
837 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
839 TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
840 iface
, debugstr_guid(clsid
), outer
, debugstr_guid(iid
), out
);
842 return IDirect3DRM3_CreateObject(&d3drm
->IDirect3DRM3_iface
, clsid
, outer
, iid
, out
);
845 static HRESULT WINAPI
d3drm2_CreateFrame(IDirect3DRM2
*iface
,
846 IDirect3DRMFrame
*parent_frame
, IDirect3DRMFrame2
**frame
)
848 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
849 struct d3drm_frame
*object
;
852 TRACE("iface %p, parent_frame %p, frame %p.\n", iface
, parent_frame
, frame
);
854 if (FAILED(hr
= d3drm_frame_create(&object
, (IUnknown
*)parent_frame
, &d3drm
->IDirect3DRM_iface
)))
857 *frame
= &object
->IDirect3DRMFrame2_iface
;
862 static HRESULT WINAPI
d3drm2_CreateMesh(IDirect3DRM2
*iface
, IDirect3DRMMesh
**mesh
)
864 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
866 TRACE("iface %p, mesh %p.\n", iface
, mesh
);
868 return IDirect3DRM3_CreateMesh(&d3drm
->IDirect3DRM3_iface
, mesh
);
871 static HRESULT WINAPI
d3drm2_CreateMeshBuilder(IDirect3DRM2
*iface
, IDirect3DRMMeshBuilder2
**mesh_builder
)
873 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
874 struct d3drm_mesh_builder
*object
;
877 TRACE("iface %p, mesh_builder %p.\n", iface
, mesh_builder
);
879 if (FAILED(hr
= d3drm_mesh_builder_create(&object
, &d3drm
->IDirect3DRM_iface
)))
882 *mesh_builder
= &object
->IDirect3DRMMeshBuilder2_iface
;
887 static HRESULT WINAPI
d3drm2_CreateFace(IDirect3DRM2
*iface
, IDirect3DRMFace
**face
)
889 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
891 TRACE("iface %p, face %p.\n", iface
, face
);
893 return IDirect3DRM_CreateFace(&d3drm
->IDirect3DRM_iface
, face
);
896 static HRESULT WINAPI
d3drm2_CreateAnimation(IDirect3DRM2
*iface
, IDirect3DRMAnimation
**animation
)
898 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
900 TRACE("iface %p, animation %p.\n", iface
, animation
);
902 return IDirect3DRM_CreateAnimation(&d3drm
->IDirect3DRM_iface
, animation
);
905 static HRESULT WINAPI
d3drm2_CreateAnimationSet(IDirect3DRM2
*iface
, IDirect3DRMAnimationSet
**set
)
907 FIXME("iface %p, set %p stub!\n", iface
, set
);
912 static HRESULT WINAPI
d3drm2_CreateTexture(IDirect3DRM2
*iface
,
913 D3DRMIMAGE
*image
, IDirect3DRMTexture2
**texture
)
915 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
916 IDirect3DRMTexture3
*texture3
;
919 TRACE("iface %p, image %p, texture %p.\n", iface
, image
, texture
);
922 return D3DRMERR_BADVALUE
;
924 if (FAILED(hr
= IDirect3DRM3_CreateTexture(&d3drm
->IDirect3DRM3_iface
, image
, &texture3
)))
930 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture2
, (void **)texture
);
931 IDirect3DRMTexture3_Release(texture3
);
936 static HRESULT WINAPI
d3drm2_CreateLight(IDirect3DRM2
*iface
,
937 D3DRMLIGHTTYPE type
, D3DCOLOR color
, IDirect3DRMLight
**light
)
939 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
941 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface
, type
, color
, light
);
943 return IDirect3DRM3_CreateLight(&d3drm
->IDirect3DRM3_iface
, type
, color
, light
);
946 static HRESULT WINAPI
d3drm2_CreateLightRGB(IDirect3DRM2
*iface
, D3DRMLIGHTTYPE type
,
947 D3DVALUE red
, D3DVALUE green
, D3DVALUE blue
, IDirect3DRMLight
**light
)
949 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
951 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
952 iface
, type
, red
, green
, blue
, light
);
954 return IDirect3DRM3_CreateLightRGB(&d3drm
->IDirect3DRM3_iface
, type
, red
, green
, blue
, light
);
957 static HRESULT WINAPI
d3drm2_CreateMaterial(IDirect3DRM2
*iface
,
958 D3DVALUE power
, IDirect3DRMMaterial
**material
)
960 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
962 TRACE("iface %p, power %.8e, material %p.\n", iface
, power
, material
);
964 return IDirect3DRM3_CreateMaterial(&d3drm
->IDirect3DRM3_iface
, power
, (IDirect3DRMMaterial2
**)material
);
967 static HRESULT WINAPI
d3drm2_CreateDevice(IDirect3DRM2
*iface
,
968 DWORD width
, DWORD height
, IDirect3DRMDevice2
**device
)
970 TRACE("iface %p, width %u, height %u, device %p.\n", iface
, width
, height
, device
);
973 return D3DRMERR_BADVALUE
;
976 return D3DRMERR_BADDEVICE
;
979 static HRESULT WINAPI
d3drm2_CreateDeviceFromSurface(IDirect3DRM2
*iface
, GUID
*guid
,
980 IDirectDraw
*ddraw
, IDirectDrawSurface
*backbuffer
, IDirect3DRMDevice2
**device
)
982 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
983 IDirect3DRMDevice3
*device3
;
985 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p, device %p.\n",
986 iface
, debugstr_guid(guid
), ddraw
, backbuffer
, device
);
989 return D3DRMERR_BADVALUE
;
991 hr
= IDirect3DRM3_CreateDeviceFromSurface(&d3drm
->IDirect3DRM3_iface
, guid
, ddraw
, backbuffer
, 0, &device3
);
995 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice2
, (void**)device
);
996 IDirect3DRMDevice3_Release(device3
);
1001 static HRESULT WINAPI
d3drm2_CreateDeviceFromD3D(IDirect3DRM2
*iface
,
1002 IDirect3D2
*d3d
, IDirect3DDevice2
*d3d_device
, IDirect3DRMDevice2
**device
)
1004 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1005 IDirect3DRMDevice3
*device3
;
1008 TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
1009 iface
, d3d
, d3d_device
, device
);
1012 return D3DRMERR_BADVALUE
;
1015 hr
= IDirect3DRM3_CreateDeviceFromD3D(&d3drm
->IDirect3DRM3_iface
, d3d
, d3d_device
, &device3
);
1019 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice2
, (void **)device
);
1020 IDirect3DRMDevice3_Release(device3
);
1025 static HRESULT WINAPI
d3drm2_CreateDeviceFromClipper(IDirect3DRM2
*iface
,
1026 IDirectDrawClipper
*clipper
, GUID
*guid
, int width
, int height
,
1027 IDirect3DRMDevice2
**device
)
1029 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1030 IDirect3DRMDevice3
*device3
;
1033 TRACE("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
1034 iface
, clipper
, debugstr_guid(guid
), width
, height
, device
);
1037 return D3DRMERR_BADVALUE
;
1039 hr
= IDirect3DRM3_CreateDeviceFromClipper(&d3drm
->IDirect3DRM3_iface
, clipper
, guid
, width
, height
, &device3
);
1043 hr
= IDirect3DRMDevice3_QueryInterface(device3
, &IID_IDirect3DRMDevice2
, (void**)device
);
1044 IDirect3DRMDevice3_Release(device3
);
1049 static HRESULT WINAPI
d3drm2_CreateTextureFromSurface(IDirect3DRM2
*iface
,
1050 IDirectDrawSurface
*surface
, IDirect3DRMTexture2
**texture
)
1052 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1053 IDirect3DRMTexture3
*texture3
;
1056 TRACE("iface %p, surface %p, texture %p.\n", iface
, surface
, texture
);
1059 return D3DRMERR_BADVALUE
;
1061 if (FAILED(hr
= IDirect3DRM3_CreateTextureFromSurface(&d3drm
->IDirect3DRM3_iface
, surface
, &texture3
)))
1067 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture
, (void **)texture
);
1068 IDirect3DRMTexture3_Release(texture3
);
1073 static HRESULT WINAPI
d3drm2_CreateShadow(IDirect3DRM2
*iface
, IDirect3DRMVisual
*visual
,
1074 IDirect3DRMLight
*light
, D3DVALUE px
, D3DVALUE py
, D3DVALUE pz
, D3DVALUE nx
, D3DVALUE ny
, D3DVALUE nz
,
1075 IDirect3DRMVisual
**shadow
)
1077 FIXME("iface %p, visual %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
1078 iface
, visual
, light
, px
, py
, pz
, nx
, ny
, nz
, shadow
);
1083 static HRESULT WINAPI
d3drm2_CreateViewport(IDirect3DRM2
*iface
, IDirect3DRMDevice
*device
,
1084 IDirect3DRMFrame
*camera
, DWORD x
, DWORD y
, DWORD width
, DWORD height
, IDirect3DRMViewport
**viewport
)
1086 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1087 IDirect3DRMDevice3
*device3
;
1088 IDirect3DRMFrame3
*camera3
;
1089 IDirect3DRMViewport2
*viewport2
;
1092 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
1093 iface
, device
, camera
, x
, y
, width
, height
, viewport
);
1096 return D3DRMERR_BADVALUE
;
1099 if (!device
|| !camera
)
1100 return D3DRMERR_BADOBJECT
;
1102 if (FAILED(hr
= IDirect3DRMDevice_QueryInterface(device
, &IID_IDirect3DRMDevice3
, (void **)&device3
)))
1105 if (FAILED(hr
= IDirect3DRMFrame_QueryInterface(camera
, &IID_IDirect3DRMFrame3
, (void **)&camera3
)))
1107 IDirect3DRMDevice3_Release(device3
);
1111 hr
= IDirect3DRM3_CreateViewport(&d3drm
->IDirect3DRM3_iface
, device3
, camera3
, x
, y
, width
, height
, &viewport2
);
1112 IDirect3DRMDevice3_Release(device3
);
1113 IDirect3DRMFrame3_Release(camera3
);
1117 hr
= IDirect3DRMViewport2_QueryInterface(viewport2
, &IID_IDirect3DRMViewport
, (void **)viewport
);
1118 IDirect3DRMViewport2_Release(viewport2
);
1123 static HRESULT WINAPI
d3drm2_CreateWrap(IDirect3DRM2
*iface
, D3DRMWRAPTYPE type
, IDirect3DRMFrame
*frame
,
1124 D3DVALUE ox
, D3DVALUE oy
, D3DVALUE oz
, D3DVALUE dx
, D3DVALUE dy
, D3DVALUE dz
,
1125 D3DVALUE ux
, D3DVALUE uy
, D3DVALUE uz
, D3DVALUE ou
, D3DVALUE ov
, D3DVALUE su
, D3DVALUE sv
,
1126 IDirect3DRMWrap
**wrap
)
1128 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1130 TRACE("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
1131 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p.\n",
1132 iface
, type
, frame
, ox
, oy
, oz
, dx
, dy
, dz
, ux
, uy
, uz
, ou
, ov
, su
, sv
, wrap
);
1134 return IDirect3DRM_CreateWrap(&d3drm
->IDirect3DRM_iface
, type
, frame
, ox
, oy
, oz
, dx
, dy
, dz
, ux
, uy
, uz
,
1135 ou
, ov
, su
, sv
, wrap
);
1138 static HRESULT WINAPI
d3drm2_CreateUserVisual(IDirect3DRM2
*iface
,
1139 D3DRMUSERVISUALCALLBACK cb
, void *ctx
, IDirect3DRMUserVisual
**visual
)
1141 FIXME("iface %p, cb %p, ctx %p, visual %p stub!\n", iface
, cb
, ctx
, visual
);
1146 static HRESULT WINAPI
d3drm2_LoadTexture(IDirect3DRM2
*iface
,
1147 const char *filename
, IDirect3DRMTexture2
**texture
)
1149 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1150 IDirect3DRMTexture3
*texture3
;
1153 TRACE("iface %p, filename %s, texture %p.\n", iface
, debugstr_a(filename
), texture
);
1156 return D3DRMERR_BADVALUE
;
1158 if (FAILED(hr
= IDirect3DRM3_LoadTexture(&d3drm
->IDirect3DRM3_iface
, filename
, &texture3
)))
1164 hr
= IDirect3DRMTexture3_QueryInterface(texture3
, &IID_IDirect3DRMTexture2
, (void **)texture
);
1165 IDirect3DRMTexture3_Release(texture3
);
1170 static HRESULT WINAPI
d3drm2_LoadTextureFromResource(IDirect3DRM2
*iface
, HMODULE module
,
1171 const char *resource_name
, const char *resource_type
, IDirect3DRMTexture2
**texture
)
1173 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1174 struct d3drm_texture
*object
;
1177 FIXME("iface %p, resource_name %s, resource_type %s, texture %p stub!\n",
1178 iface
, debugstr_a(resource_name
), debugstr_a(resource_type
), texture
);
1180 if (FAILED(hr
= d3drm_texture_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1183 *texture
= &object
->IDirect3DRMTexture2_iface
;
1188 static HRESULT WINAPI
d3drm2_SetSearchPath(IDirect3DRM2
*iface
, const char *path
)
1190 FIXME("iface %p, path %s stub!\n", iface
, debugstr_a(path
));
1195 static HRESULT WINAPI
d3drm2_AddSearchPath(IDirect3DRM2
*iface
, const char *path
)
1197 FIXME("iface %p, path %s stub!\n", iface
, debugstr_a(path
));
1202 static HRESULT WINAPI
d3drm2_GetSearchPath(IDirect3DRM2
*iface
, DWORD
*size
, char *path
)
1204 FIXME("iface %p, size %p, path %p stub!\n", iface
, size
, path
);
1209 static HRESULT WINAPI
d3drm2_SetDefaultTextureColors(IDirect3DRM2
*iface
, DWORD color_count
)
1211 FIXME("iface %p, color_count %u stub!\n", iface
, color_count
);
1216 static HRESULT WINAPI
d3drm2_SetDefaultTextureShades(IDirect3DRM2
*iface
, DWORD shade_count
)
1218 FIXME("iface %p, shade_count %u stub!\n", iface
, shade_count
);
1223 static HRESULT WINAPI
d3drm2_GetDevices(IDirect3DRM2
*iface
, IDirect3DRMDeviceArray
**array
)
1225 FIXME("iface %p, array %p stub!\n", iface
, array
);
1230 static HRESULT WINAPI
d3drm2_GetNamedObject(IDirect3DRM2
*iface
,
1231 const char *name
, IDirect3DRMObject
**object
)
1233 FIXME("iface %p, name %s, object %p stub!\n", iface
, debugstr_a(name
), object
);
1238 static HRESULT WINAPI
d3drm2_EnumerateObjects(IDirect3DRM2
*iface
, D3DRMOBJECTCALLBACK cb
, void *ctx
)
1240 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1245 static HRESULT WINAPI
d3drm2_Load(IDirect3DRM2
*iface
, void *source
, void *object_id
, IID
**iids
,
1246 DWORD iid_count
, D3DRMLOADOPTIONS flags
, D3DRMLOADCALLBACK load_cb
, void *load_ctx
,
1247 D3DRMLOADTEXTURECALLBACK load_tex_cb
, void *load_tex_ctx
, IDirect3DRMFrame
*parent_frame
)
1249 struct d3drm
*d3drm
= impl_from_IDirect3DRM2(iface
);
1250 IDirect3DRMFrame3
*parent_frame3
= NULL
;
1251 HRESULT hr
= D3DRM_OK
;
1253 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
1254 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
1255 iface
, source
, object_id
, iids
, iid_count
, flags
,
1256 load_cb
, load_ctx
, load_tex_cb
, load_tex_ctx
, parent_frame
);
1259 hr
= IDirect3DRMFrame_QueryInterface(parent_frame
, &IID_IDirect3DRMFrame3
, (void **)&parent_frame3
);
1261 hr
= IDirect3DRM3_Load(&d3drm
->IDirect3DRM3_iface
, source
, object_id
, iids
, iid_count
,
1262 flags
, load_cb
, load_ctx
, load_tex_cb
, load_tex_ctx
, parent_frame3
);
1264 IDirect3DRMFrame3_Release(parent_frame3
);
1269 static HRESULT WINAPI
d3drm2_Tick(IDirect3DRM2
*iface
, D3DVALUE tick
)
1271 FIXME("iface %p, tick %.8e stub!\n", iface
, tick
);
1276 static HRESULT WINAPI
d3drm2_CreateProgressiveMesh(IDirect3DRM2
*iface
, IDirect3DRMProgressiveMesh
**mesh
)
1278 FIXME("iface %p, mesh %p stub!\n", iface
, mesh
);
1283 static const struct IDirect3DRM2Vtbl d3drm2_vtbl
=
1285 d3drm2_QueryInterface
,
1288 d3drm2_CreateObject
,
1291 d3drm2_CreateMeshBuilder
,
1293 d3drm2_CreateAnimation
,
1294 d3drm2_CreateAnimationSet
,
1295 d3drm2_CreateTexture
,
1297 d3drm2_CreateLightRGB
,
1298 d3drm2_CreateMaterial
,
1299 d3drm2_CreateDevice
,
1300 d3drm2_CreateDeviceFromSurface
,
1301 d3drm2_CreateDeviceFromD3D
,
1302 d3drm2_CreateDeviceFromClipper
,
1303 d3drm2_CreateTextureFromSurface
,
1304 d3drm2_CreateShadow
,
1305 d3drm2_CreateViewport
,
1307 d3drm2_CreateUserVisual
,
1309 d3drm2_LoadTextureFromResource
,
1310 d3drm2_SetSearchPath
,
1311 d3drm2_AddSearchPath
,
1312 d3drm2_GetSearchPath
,
1313 d3drm2_SetDefaultTextureColors
,
1314 d3drm2_SetDefaultTextureShades
,
1316 d3drm2_GetNamedObject
,
1317 d3drm2_EnumerateObjects
,
1320 d3drm2_CreateProgressiveMesh
,
1323 static HRESULT WINAPI
d3drm3_QueryInterface(IDirect3DRM3
*iface
, REFIID riid
, void **out
)
1325 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1327 return d3drm1_QueryInterface(&d3drm
->IDirect3DRM_iface
, riid
, out
);
1330 static ULONG WINAPI
d3drm3_AddRef(IDirect3DRM3
*iface
)
1332 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1333 ULONG refcount
= InterlockedIncrement(&d3drm
->ref3
);
1335 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
1338 InterlockedIncrement(&d3drm
->iface_count
);
1343 static ULONG WINAPI
d3drm3_Release(IDirect3DRM3
*iface
)
1345 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1346 ULONG refcount
= InterlockedDecrement(&d3drm
->ref3
);
1348 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
1350 if (!refcount
&& !InterlockedDecrement(&d3drm
->iface_count
))
1351 d3drm_destroy(d3drm
);
1356 static HRESULT WINAPI
d3drm3_CreateObject(IDirect3DRM3
*iface
,
1357 REFCLSID clsid
, IUnknown
*outer
, REFIID iid
, void **out
)
1359 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1367 HRESULT (*create_object
)(void **object
, IDirect3DRM
*d3drm
);
1371 {&CLSID_CDirect3DRMTexture
, d3drm_create_texture_object
},
1372 {&CLSID_CDirect3DRMDevice
, d3drm_create_device_object
},
1373 {&CLSID_CDirect3DRMViewport
, d3drm_create_viewport_object
},
1374 {&CLSID_CDirect3DRMFace
, d3drm_create_face_object
},
1375 {&CLSID_CDirect3DRMMeshBuilder
, d3drm_create_mesh_builder_object
},
1376 {&CLSID_CDirect3DRMFrame
, d3drm_create_frame_object
},
1377 {&CLSID_CDirect3DRMLight
, d3drm_create_light_object
},
1378 {&CLSID_CDirect3DRMMaterial
, d3drm_create_material_object
},
1379 {&CLSID_CDirect3DRMMesh
, d3drm_create_mesh_object
},
1380 {&CLSID_CDirect3DRMAnimation
, d3drm_create_animation_object
},
1381 {&CLSID_CDirect3DRMWrap
, d3drm_create_wrap_object
},
1384 TRACE("iface %p, clsid %s, outer %p, iid %s, out %p.\n",
1385 iface
, debugstr_guid(clsid
), outer
, debugstr_guid(iid
), out
);
1388 return D3DRMERR_BADVALUE
;
1393 return D3DRMERR_BADVALUE
;
1398 FIXME("COM aggregation for outer IUnknown (%p) not implemented. Returning E_NOTIMPL.\n", outer
);
1403 for (i
= 0; i
< ARRAY_SIZE(object_table
); ++i
)
1405 if (IsEqualGUID(clsid
, object_table
[i
].clsid
))
1407 if (FAILED(hr
= object_table
[i
].create_object((void **)&object
, &d3drm
->IDirect3DRM_iface
)))
1415 if (i
== ARRAY_SIZE(object_table
))
1417 FIXME("%s not implemented. Returning CLASSFACTORY_E_FIRST.\n", debugstr_guid(clsid
));
1419 return CLASSFACTORY_E_FIRST
;
1422 if (FAILED(hr
= IUnknown_QueryInterface(object
, iid
, out
)))
1424 IUnknown_Release(object
);
1429 static HRESULT WINAPI
d3drm3_CreateFrame(IDirect3DRM3
*iface
,
1430 IDirect3DRMFrame3
*parent
, IDirect3DRMFrame3
**frame
)
1432 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1433 struct d3drm_frame
*object
;
1436 TRACE("iface %p, parent %p, frame %p.\n", iface
, parent
, frame
);
1438 if (FAILED(hr
= d3drm_frame_create(&object
, (IUnknown
*)parent
, &d3drm
->IDirect3DRM_iface
)))
1441 *frame
= &object
->IDirect3DRMFrame3_iface
;
1446 static HRESULT WINAPI
d3drm3_CreateMesh(IDirect3DRM3
*iface
, IDirect3DRMMesh
**mesh
)
1448 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1449 struct d3drm_mesh
*object
;
1452 TRACE("iface %p, mesh %p.\n", iface
, mesh
);
1454 if (FAILED(hr
= d3drm_mesh_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1457 *mesh
= &object
->IDirect3DRMMesh_iface
;
1462 static HRESULT WINAPI
d3drm3_CreateMeshBuilder(IDirect3DRM3
*iface
, IDirect3DRMMeshBuilder3
**mesh_builder
)
1464 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1465 struct d3drm_mesh_builder
*object
;
1468 TRACE("iface %p, mesh_builder %p.\n", iface
, mesh_builder
);
1470 if (FAILED(hr
= d3drm_mesh_builder_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1473 *mesh_builder
= &object
->IDirect3DRMMeshBuilder3_iface
;
1478 static HRESULT WINAPI
d3drm3_CreateFace(IDirect3DRM3
*iface
, IDirect3DRMFace2
**face
)
1480 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1481 IDirect3DRMFace
*face1
;
1484 TRACE("iface %p, face %p.\n", iface
, face
);
1486 if (FAILED(hr
= IDirect3DRM_CreateFace(&d3drm
->IDirect3DRM_iface
, &face1
)))
1489 hr
= IDirect3DRMFace_QueryInterface(face1
, &IID_IDirect3DRMFace2
, (void **)face
);
1490 IDirect3DRMFace_Release(face1
);
1495 static HRESULT WINAPI
d3drm3_CreateAnimation(IDirect3DRM3
*iface
, IDirect3DRMAnimation2
**animation
)
1497 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1498 struct d3drm_animation
*object
;
1501 TRACE("iface %p, animation %p.\n", iface
, animation
);
1503 if (FAILED(hr
= d3drm_animation_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1506 *animation
= &object
->IDirect3DRMAnimation2_iface
;
1511 static HRESULT WINAPI
d3drm3_CreateAnimationSet(IDirect3DRM3
*iface
, IDirect3DRMAnimationSet2
**set
)
1513 FIXME("iface %p, set %p stub!\n", iface
, set
);
1518 static HRESULT WINAPI
d3drm3_CreateTexture(IDirect3DRM3
*iface
,
1519 D3DRMIMAGE
*image
, IDirect3DRMTexture3
**texture
)
1521 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1522 struct d3drm_texture
*object
;
1525 TRACE("iface %p, image %p, texture %p.\n", iface
, image
, texture
);
1528 return D3DRMERR_BADVALUE
;
1530 if (FAILED(hr
= d3drm_texture_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1533 *texture
= &object
->IDirect3DRMTexture3_iface
;
1535 if (FAILED(IDirect3DRMTexture3_InitFromImage(*texture
, image
)))
1537 IDirect3DRMTexture3_Release(*texture
);
1539 return D3DRMERR_BADVALUE
;
1545 static HRESULT WINAPI
d3drm3_CreateLight(IDirect3DRM3
*iface
,
1546 D3DRMLIGHTTYPE type
, D3DCOLOR color
, IDirect3DRMLight
**light
)
1548 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1549 struct d3drm_light
*object
;
1552 TRACE("iface %p, type %#x, color 0x%08x, light %p.\n", iface
, type
, color
, light
);
1554 if (SUCCEEDED(hr
= d3drm_light_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1556 IDirect3DRMLight_SetType(&object
->IDirect3DRMLight_iface
, type
);
1557 IDirect3DRMLight_SetColor(&object
->IDirect3DRMLight_iface
, color
);
1560 *light
= &object
->IDirect3DRMLight_iface
;
1565 static HRESULT WINAPI
d3drm3_CreateLightRGB(IDirect3DRM3
*iface
, D3DRMLIGHTTYPE type
,
1566 D3DVALUE red
, D3DVALUE green
, D3DVALUE blue
, IDirect3DRMLight
**light
)
1568 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1569 struct d3drm_light
*object
;
1572 TRACE("iface %p, type %#x, red %.8e, green %.8e, blue %.8e, light %p.\n",
1573 iface
, type
, red
, green
, blue
, light
);
1575 if (SUCCEEDED(hr
= d3drm_light_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1577 IDirect3DRMLight_SetType(&object
->IDirect3DRMLight_iface
, type
);
1578 IDirect3DRMLight_SetColorRGB(&object
->IDirect3DRMLight_iface
, red
, green
, blue
);
1581 *light
= &object
->IDirect3DRMLight_iface
;
1586 static HRESULT WINAPI
d3drm3_CreateMaterial(IDirect3DRM3
*iface
,
1587 D3DVALUE power
, IDirect3DRMMaterial2
**material
)
1589 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1590 struct d3drm_material
*object
;
1593 TRACE("iface %p, power %.8e, material %p.\n", iface
, power
, material
);
1595 if (SUCCEEDED(hr
= d3drm_material_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1596 IDirect3DRMMaterial2_SetPower(&object
->IDirect3DRMMaterial2_iface
, power
);
1598 *material
= &object
->IDirect3DRMMaterial2_iface
;
1603 static HRESULT WINAPI
d3drm3_CreateDevice(IDirect3DRM3
*iface
,
1604 DWORD width
, DWORD height
, IDirect3DRMDevice3
**device
)
1606 TRACE("iface %p, width %u, height %u, device %p.\n", iface
, width
, height
, device
);
1609 return D3DRMERR_BADVALUE
;
1612 return D3DRMERR_BADDEVICE
;
1615 static HRESULT WINAPI
d3drm3_CreateDeviceFromSurface(IDirect3DRM3
*iface
, GUID
*guid
,
1616 IDirectDraw
*ddraw
, IDirectDrawSurface
*backbuffer
, DWORD flags
, IDirect3DRMDevice3
**device
)
1618 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1619 struct d3drm_device
*object
;
1623 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p, flags %#x, device %p.\n",
1624 iface
, debugstr_guid(guid
), ddraw
, backbuffer
, flags
, device
);
1627 return D3DRMERR_BADVALUE
;
1630 if (!backbuffer
|| !ddraw
)
1631 return D3DRMERR_BADDEVICE
;
1633 if (FAILED(hr
= d3drm_device_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1636 use_z_surface
= !(flags
& D3DRMDEVICE_NOZBUFFER
);
1638 if (SUCCEEDED(hr
= d3drm_device_init(object
, 3, ddraw
, backbuffer
, use_z_surface
)))
1639 *device
= &object
->IDirect3DRMDevice3_iface
;
1641 d3drm_device_destroy(object
);
1646 static HRESULT WINAPI
d3drm3_CreateDeviceFromD3D(IDirect3DRM3
*iface
,
1647 IDirect3D2
*d3d
, IDirect3DDevice2
*d3d_device
, IDirect3DRMDevice3
**device
)
1649 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1650 struct d3drm_device
*object
;
1653 TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
1654 iface
, d3d
, d3d_device
, device
);
1657 return D3DRMERR_BADVALUE
;
1660 if (FAILED(hr
= d3drm_device_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1663 if (FAILED(hr
= IDirect3DRMDevice3_InitFromD3D2(&object
->IDirect3DRMDevice3_iface
, d3d
, d3d_device
)))
1665 d3drm_device_destroy(object
);
1668 *device
= &object
->IDirect3DRMDevice3_iface
;
1673 static HRESULT WINAPI
d3drm3_CreateDeviceFromClipper(IDirect3DRM3
*iface
,
1674 IDirectDrawClipper
*clipper
, GUID
*guid
, int width
, int height
,
1675 IDirect3DRMDevice3
**device
)
1677 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1678 struct d3drm_device
*object
;
1680 IDirectDrawSurface
*render_target
;
1683 TRACE("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
1684 iface
, clipper
, debugstr_guid(guid
), width
, height
, device
);
1687 return D3DRMERR_BADVALUE
;
1690 if (!clipper
|| !width
|| !height
)
1691 return D3DRMERR_BADVALUE
;
1693 hr
= DirectDrawCreate(NULL
, &ddraw
, NULL
);
1697 if (FAILED(hr
= d3drm_device_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1699 IDirectDraw_Release(ddraw
);
1703 hr
= d3drm_device_create_surfaces_from_clipper(object
, ddraw
, clipper
, width
, height
, &render_target
);
1706 IDirectDraw_Release(ddraw
);
1707 d3drm_device_destroy(object
);
1711 hr
= d3drm_device_init(object
, 3, ddraw
, render_target
, TRUE
);
1712 IDirectDraw_Release(ddraw
);
1713 IDirectDrawSurface_Release(render_target
);
1715 d3drm_device_destroy(object
);
1717 *device
= &object
->IDirect3DRMDevice3_iface
;
1722 static HRESULT WINAPI
d3drm3_CreateShadow(IDirect3DRM3
*iface
, IUnknown
*object
, IDirect3DRMLight
*light
,
1723 D3DVALUE px
, D3DVALUE py
, D3DVALUE pz
, D3DVALUE nx
, D3DVALUE ny
, D3DVALUE nz
, IDirect3DRMShadow2
**shadow
)
1725 FIXME("iface %p, object %p, light %p, px %.8e, py %.8e, pz %.8e, nx %.8e, ny %.8e, nz %.8e, shadow %p stub!\n",
1726 iface
, object
, light
, px
, py
, pz
, nx
, ny
, nz
, shadow
);
1731 static HRESULT WINAPI
d3drm3_CreateTextureFromSurface(IDirect3DRM3
*iface
,
1732 IDirectDrawSurface
*surface
, IDirect3DRMTexture3
**texture
)
1734 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1735 struct d3drm_texture
*object
;
1738 TRACE("iface %p, surface %p, texture %p.\n", iface
, surface
, texture
);
1741 return D3DRMERR_BADVALUE
;
1743 if (FAILED(hr
= d3drm_texture_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1746 *texture
= &object
->IDirect3DRMTexture3_iface
;
1748 if (FAILED(IDirect3DRMTexture3_InitFromSurface(*texture
, surface
)))
1750 IDirect3DRMTexture3_Release(*texture
);
1752 return D3DRMERR_BADVALUE
;
1758 static HRESULT WINAPI
d3drm3_CreateViewport(IDirect3DRM3
*iface
, IDirect3DRMDevice3
*device
,
1759 IDirect3DRMFrame3
*camera
, DWORD x
, DWORD y
, DWORD width
, DWORD height
, IDirect3DRMViewport2
**viewport
)
1761 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1762 struct d3drm_viewport
*object
;
1765 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u, viewport %p.\n",
1766 iface
, device
, camera
, x
, y
, width
, height
, viewport
);
1769 return D3DRMERR_BADVALUE
;
1772 if (!device
|| !camera
)
1773 return D3DRMERR_BADOBJECT
;
1775 if (FAILED(hr
= d3drm_viewport_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1778 *viewport
= &object
->IDirect3DRMViewport2_iface
;
1780 if (FAILED(hr
= IDirect3DRMViewport2_Init(*viewport
, device
, camera
, x
, y
, width
, height
)))
1782 IDirect3DRMViewport2_Release(*viewport
);
1784 return D3DRMERR_BADVALUE
;
1790 static HRESULT WINAPI
d3drm3_CreateWrap(IDirect3DRM3
*iface
, D3DRMWRAPTYPE type
, IDirect3DRMFrame3
*frame
,
1791 D3DVALUE ox
, D3DVALUE oy
, D3DVALUE oz
, D3DVALUE dx
, D3DVALUE dy
, D3DVALUE dz
,
1792 D3DVALUE ux
, D3DVALUE uy
, D3DVALUE uz
, D3DVALUE ou
, D3DVALUE ov
, D3DVALUE su
, D3DVALUE sv
,
1793 IDirect3DRMWrap
**wrap
)
1795 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1796 struct d3drm_wrap
*object
;
1799 FIXME("iface %p, type %#x, frame %p, ox %.8e, oy %.8e, oz %.8e, dx %.8e, dy %.8e, dz %.8e, "
1800 "ux %.8e, uy %.8e, uz %.8e, ou %.8e, ov %.8e, su %.8e, sv %.8e, wrap %p, semi-stub.\n",
1801 iface
, type
, frame
, ox
, oy
, oz
, dx
, dy
, dz
, ux
, uy
, uz
, ou
, ov
, su
, sv
, wrap
);
1804 return D3DRMERR_BADVALUE
;
1806 if (FAILED(hr
= d3drm_wrap_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1809 *wrap
= &object
->IDirect3DRMWrap_iface
;
1814 static HRESULT WINAPI
d3drm3_CreateUserVisual(IDirect3DRM3
*iface
,
1815 D3DRMUSERVISUALCALLBACK cb
, void *ctx
, IDirect3DRMUserVisual
**visual
)
1817 FIXME("iface %p, cb %p, ctx %p, visual %p stub!\n", iface
, cb
, ctx
, visual
);
1822 static HRESULT WINAPI
d3drm3_LoadTexture(IDirect3DRM3
*iface
,
1823 const char *filename
, IDirect3DRMTexture3
**texture
)
1825 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1826 struct d3drm_texture
*object
;
1829 TRACE("iface %p, filename %s, texture %p.\n", iface
, debugstr_a(filename
), texture
);
1832 return D3DRMERR_BADVALUE
;
1834 if (FAILED(hr
= d3drm_texture_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1837 *texture
= &object
->IDirect3DRMTexture3_iface
;
1838 if (FAILED(hr
= IDirect3DRMTexture3_InitFromFile(*texture
, filename
)))
1840 IDirect3DRMTexture3_Release(*texture
);
1842 return hr
== D3DRMERR_BADOBJECT
? D3DRMERR_FILENOTFOUND
: hr
;
1848 static HRESULT WINAPI
d3drm3_LoadTextureFromResource(IDirect3DRM3
*iface
, HMODULE module
,
1849 const char *resource_name
, const char *resource_type
, IDirect3DRMTexture3
**texture
)
1851 struct d3drm
*d3drm
= impl_from_IDirect3DRM3(iface
);
1852 struct d3drm_texture
*object
;
1855 FIXME("iface %p, module %p, resource_name %s, resource_type %s, texture %p stub!\n",
1856 iface
, module
, debugstr_a(resource_name
), debugstr_a(resource_type
), texture
);
1858 if (FAILED(hr
= d3drm_texture_create(&object
, &d3drm
->IDirect3DRM_iface
)))
1861 *texture
= &object
->IDirect3DRMTexture3_iface
;
1866 static HRESULT WINAPI
d3drm3_SetSearchPath(IDirect3DRM3
*iface
, const char *path
)
1868 FIXME("iface %p, path %s stub!\n", iface
, debugstr_a(path
));
1873 static HRESULT WINAPI
d3drm3_AddSearchPath(IDirect3DRM3
*iface
, const char *path
)
1875 FIXME("iface %p, path %s stub!\n", iface
, debugstr_a(path
));
1880 static HRESULT WINAPI
d3drm3_GetSearchPath(IDirect3DRM3
*iface
, DWORD
*size
, char *path
)
1882 FIXME("iface %p, size %p, path %p stub!\n", iface
, size
, path
);
1887 static HRESULT WINAPI
d3drm3_SetDefaultTextureColors(IDirect3DRM3
*iface
, DWORD color_count
)
1889 FIXME("iface %p, color_count %u stub!\n", iface
, color_count
);
1894 static HRESULT WINAPI
d3drm3_SetDefaultTextureShades(IDirect3DRM3
*iface
, DWORD shade_count
)
1896 FIXME("iface %p, shade_count %u stub!\n", iface
, shade_count
);
1901 static HRESULT WINAPI
d3drm3_GetDevices(IDirect3DRM3
*iface
, IDirect3DRMDeviceArray
**array
)
1903 FIXME("iface %p, array %p stub!\n", iface
, array
);
1908 static HRESULT WINAPI
d3drm3_GetNamedObject(IDirect3DRM3
*iface
,
1909 const char *name
, IDirect3DRMObject
**object
)
1911 FIXME("iface %p, name %s, object %p stub!\n", iface
, debugstr_a(name
), object
);
1916 static HRESULT WINAPI
d3drm3_EnumerateObjects(IDirect3DRM3
*iface
, D3DRMOBJECTCALLBACK cb
, void *ctx
)
1918 FIXME("iface %p, cb %p, ctx %p stub!\n", iface
, cb
, ctx
);
1923 static HRESULT
load_data(IDirect3DRM3
*iface
, IDirectXFileData
*data_object
, IID
**GUIDs
, DWORD nb_GUIDs
, D3DRMLOADCALLBACK LoadProc
,
1924 void *ArgLP
, D3DRMLOADTEXTURECALLBACK LoadTextureProc
, void *ArgLTP
, IDirect3DRMFrame3
*parent_frame
)
1926 HRESULT ret
= D3DRMERR_BADOBJECT
;
1930 BOOL requested
= FALSE
;
1932 hr
= IDirectXFileData_GetType(data_object
, &guid
);
1933 if (hr
!= DXFILE_OK
)
1936 TRACE("Found object type whose GUID = %s\n", debugstr_guid(guid
));
1938 /* Load object only if it is top level and requested or if it is part of another object */
1940 if (IsEqualGUID(guid
, &TID_D3DRMMesh
))
1942 TRACE("Found TID_D3DRMMesh\n");
1944 for (i
= 0; i
< nb_GUIDs
; i
++)
1945 if (IsEqualGUID(GUIDs
[i
], &IID_IDirect3DRMMeshBuilder
) ||
1946 IsEqualGUID(GUIDs
[i
], &IID_IDirect3DRMMeshBuilder2
) ||
1947 IsEqualGUID(GUIDs
[i
], &IID_IDirect3DRMMeshBuilder3
))
1953 if (requested
|| parent_frame
)
1955 IDirect3DRMMeshBuilder3
*meshbuilder
;
1957 TRACE("Load mesh data\n");
1959 hr
= IDirect3DRM3_CreateMeshBuilder(iface
, &meshbuilder
);
1962 hr
= load_mesh_data(meshbuilder
, data_object
, LoadTextureProc
, ArgLTP
);
1965 /* Only top level objects are notified */
1968 IDirect3DRMObject
*object
;
1970 hr
= IDirect3DRMMeshBuilder3_QueryInterface(meshbuilder
, GUIDs
[i
], (void**)&object
);
1973 LoadProc(object
, GUIDs
[i
], ArgLP
);
1974 IDirect3DRMObject_Release(object
);
1979 IDirect3DRMFrame3_AddVisual(parent_frame
, (IUnknown
*)meshbuilder
);
1982 IDirect3DRMMeshBuilder3_Release(meshbuilder
);
1986 ERR("Cannot process mesh\n");
1989 else if (IsEqualGUID(guid
, &TID_D3DRMFrame
))
1991 TRACE("Found TID_D3DRMFrame\n");
1993 for (i
= 0; i
< nb_GUIDs
; i
++)
1994 if (IsEqualGUID(GUIDs
[i
], &IID_IDirect3DRMFrame
) ||
1995 IsEqualGUID(GUIDs
[i
], &IID_IDirect3DRMFrame2
) ||
1996 IsEqualGUID(GUIDs
[i
], &IID_IDirect3DRMFrame3
))
2002 if (requested
|| parent_frame
)
2004 IDirect3DRMFrame3
*frame
;
2006 TRACE("Load frame data\n");
2008 hr
= IDirect3DRM3_CreateFrame(iface
, parent_frame
, &frame
);
2011 IDirectXFileObject
*child
;
2013 while (SUCCEEDED(hr
= IDirectXFileData_GetNextObject(data_object
, &child
)))
2015 IDirectXFileData
*data
;
2016 IDirectXFileDataReference
*reference
;
2017 IDirectXFileBinary
*binary
;
2019 if (SUCCEEDED(IDirectXFileObject_QueryInterface(child
,
2020 &IID_IDirectXFileBinary
, (void **)&binary
)))
2022 FIXME("Binary Object not supported yet\n");
2023 IDirectXFileBinary_Release(binary
);
2025 else if (SUCCEEDED(IDirectXFileObject_QueryInterface(child
,
2026 &IID_IDirectXFileData
, (void **)&data
)))
2028 TRACE("Found Data Object\n");
2029 hr
= load_data(iface
, data
, GUIDs
, nb_GUIDs
, LoadProc
, ArgLP
, LoadTextureProc
, ArgLTP
, frame
);
2030 IDirectXFileData_Release(data
);
2032 else if (SUCCEEDED(IDirectXFileObject_QueryInterface(child
,
2033 &IID_IDirectXFileDataReference
, (void **)&reference
)))
2035 TRACE("Found Data Object Reference\n");
2036 IDirectXFileDataReference_Resolve(reference
, &data
);
2037 hr
= load_data(iface
, data
, GUIDs
, nb_GUIDs
, LoadProc
, ArgLP
, LoadTextureProc
, ArgLTP
, frame
);
2038 IDirectXFileData_Release(data
);
2039 IDirectXFileDataReference_Release(reference
);
2041 IDirectXFileObject_Release(child
);
2044 if (hr
!= DXFILEERR_NOMOREOBJECTS
)
2046 IDirect3DRMFrame3_Release(frame
);
2051 /* Only top level objects are notified */
2054 IDirect3DRMObject
*object
;
2056 hr
= IDirect3DRMFrame3_QueryInterface(frame
, GUIDs
[i
], (void**)&object
);
2059 LoadProc(object
, GUIDs
[i
], ArgLP
);
2060 IDirect3DRMObject_Release(object
);
2063 IDirect3DRMFrame3_Release(frame
);
2067 ERR("Cannot process frame\n");
2070 else if (IsEqualGUID(guid
, &TID_D3DRMMaterial
))
2072 TRACE("Found TID_D3DRMMaterial\n");
2074 /* Cannot be requested so nothing to do */
2076 else if (IsEqualGUID(guid
, &TID_D3DRMFrameTransformMatrix
))
2078 TRACE("Found TID_D3DRMFrameTransformMatrix\n");
2080 /* Cannot be requested */
2083 D3DRMMATRIX4D
*matrix
;
2086 TRACE("Load Frame Transform Matrix data\n");
2088 hr
= IDirectXFileData_GetData(data_object
, NULL
, &size
, (void**)&matrix
);
2089 if ((hr
!= DXFILE_OK
) || (size
!= sizeof(matrix
)))
2092 hr
= IDirect3DRMFrame3_AddTransform(parent_frame
, D3DRMCOMBINE_REPLACE
, *matrix
);
2099 FIXME("Found unknown TID %s\n", debugstr_guid(guid
));
2109 static HRESULT WINAPI
d3drm3_Load(IDirect3DRM3
*iface
, void *source
, void *object_id
, IID
**iids
,
2110 DWORD iid_count
, D3DRMLOADOPTIONS flags
, D3DRMLOADCALLBACK load_cb
, void *load_ctx
,
2111 D3DRMLOADTEXTURECALLBACK load_tex_cb
, void *load_tex_ctx
, IDirect3DRMFrame3
*parent_frame
)
2113 DXFILELOADOPTIONS load_options
;
2114 IDirectXFile
*file
= NULL
;
2115 IDirectXFileEnumObject
*enum_object
= NULL
;
2116 IDirectXFileData
*data
= NULL
;
2120 struct d3drm_file_header
*header
;
2121 HRESULT ret
= D3DRMERR_BADOBJECT
;
2124 TRACE("iface %p, source %p, object_id %p, iids %p, iid_count %u, flags %#x, "
2125 "load_cb %p, load_ctx %p, load_tex_cb %p, load_tex_ctx %p, parent_frame %p.\n",
2126 iface
, source
, object_id
, iids
, iid_count
, flags
,
2127 load_cb
, load_ctx
, load_tex_cb
, load_tex_ctx
, parent_frame
);
2129 TRACE("Looking for GUIDs:\n");
2130 for (i
= 0; i
< iid_count
; ++i
)
2131 TRACE("- %s (%s)\n", debugstr_guid(iids
[i
]), get_IID_string(iids
[i
]));
2133 if (flags
== D3DRMLOAD_FROMMEMORY
)
2135 load_options
= DXFILELOAD_FROMMEMORY
;
2137 else if (flags
== D3DRMLOAD_FROMFILE
)
2139 load_options
= DXFILELOAD_FROMFILE
;
2140 TRACE("Loading from file %s\n", debugstr_a(source
));
2144 FIXME("Load options %#x not supported yet.\n", flags
);
2148 hr
= DirectXFileCreate(&file
);
2149 if (hr
!= DXFILE_OK
)
2152 hr
= IDirectXFile_RegisterTemplates(file
, templates
, strlen(templates
));
2153 if (hr
!= DXFILE_OK
)
2156 hr
= IDirectXFile_CreateEnumObject(file
, source
, load_options
, &enum_object
);
2157 if (hr
!= DXFILE_OK
)
2160 hr
= IDirectXFileEnumObject_GetNextDataObject(enum_object
, &data
);
2161 if (hr
!= DXFILE_OK
)
2164 hr
= IDirectXFileData_GetType(data
, &pGuid
);
2165 if (hr
!= DXFILE_OK
)
2168 TRACE("Found object type whose GUID = %s\n", debugstr_guid(pGuid
));
2170 if (!IsEqualGUID(pGuid
, &TID_DXFILEHeader
))
2172 ret
= D3DRMERR_BADFILE
;
2176 hr
= IDirectXFileData_GetData(data
, NULL
, &size
, (void **)&header
);
2177 if ((hr
!= DXFILE_OK
) || (size
!= sizeof(*header
)))
2180 TRACE("Version is %u.%u, flags %#x.\n", header
->major
, header
->minor
, header
->flags
);
2182 /* Version must be 1.0.x */
2183 if ((header
->major
!= 1) || (header
->minor
!= 0))
2185 ret
= D3DRMERR_BADFILE
;
2189 IDirectXFileData_Release(data
);
2194 hr
= IDirectXFileEnumObject_GetNextDataObject(enum_object
, &data
);
2195 if (hr
== DXFILEERR_NOMOREOBJECTS
)
2197 TRACE("No more object\n");
2200 else if (hr
!= DXFILE_OK
)
2202 ret
= D3DRMERR_BADFILE
;
2206 ret
= load_data(iface
, data
, iids
, iid_count
, load_cb
, load_ctx
, load_tex_cb
, load_tex_ctx
, parent_frame
);
2207 if (ret
!= D3DRM_OK
)
2210 IDirectXFileData_Release(data
);
2218 IDirectXFileData_Release(data
);
2220 IDirectXFileEnumObject_Release(enum_object
);
2222 IDirectXFile_Release(file
);
2227 static HRESULT WINAPI
d3drm3_Tick(IDirect3DRM3
*iface
, D3DVALUE tick
)
2229 FIXME("iface %p, tick %.8e stub!\n", iface
, tick
);
2234 static HRESULT WINAPI
d3drm3_CreateProgressiveMesh(IDirect3DRM3
*iface
, IDirect3DRMProgressiveMesh
**mesh
)
2236 FIXME("iface %p, mesh %p stub!\n", iface
, mesh
);
2241 static HRESULT WINAPI
d3drm3_RegisterClient(IDirect3DRM3
*iface
, REFGUID guid
, DWORD
*id
)
2243 FIXME("iface %p, guid %s, id %p stub!\n", iface
, debugstr_guid(guid
), id
);
2248 static HRESULT WINAPI
d3drm3_UnregisterClient(IDirect3DRM3
*iface
, REFGUID guid
)
2250 FIXME("iface %p, guid %s stub!\n", iface
, debugstr_guid(guid
));
2255 static HRESULT WINAPI
d3drm3_CreateClippedVisual(IDirect3DRM3
*iface
,
2256 IDirect3DRMVisual
*visual
, IDirect3DRMClippedVisual
**clipped_visual
)
2258 FIXME("iface %p, visual %p, clipped_visual %p stub!\n", iface
, visual
, clipped_visual
);
2263 static HRESULT WINAPI
d3drm3_SetOptions(IDirect3DRM3
*iface
, DWORD flags
)
2265 FIXME("iface %p, flags %#x stub!\n", iface
, flags
);
2270 static HRESULT WINAPI
d3drm3_GetOptions(IDirect3DRM3
*iface
, DWORD
*flags
)
2272 FIXME("iface %p, flags %p stub!\n", iface
, flags
);
2277 static const struct IDirect3DRM3Vtbl d3drm3_vtbl
=
2279 d3drm3_QueryInterface
,
2282 d3drm3_CreateObject
,
2285 d3drm3_CreateMeshBuilder
,
2287 d3drm3_CreateAnimation
,
2288 d3drm3_CreateAnimationSet
,
2289 d3drm3_CreateTexture
,
2291 d3drm3_CreateLightRGB
,
2292 d3drm3_CreateMaterial
,
2293 d3drm3_CreateDevice
,
2294 d3drm3_CreateDeviceFromSurface
,
2295 d3drm3_CreateDeviceFromD3D
,
2296 d3drm3_CreateDeviceFromClipper
,
2297 d3drm3_CreateTextureFromSurface
,
2298 d3drm3_CreateShadow
,
2299 d3drm3_CreateViewport
,
2301 d3drm3_CreateUserVisual
,
2303 d3drm3_LoadTextureFromResource
,
2304 d3drm3_SetSearchPath
,
2305 d3drm3_AddSearchPath
,
2306 d3drm3_GetSearchPath
,
2307 d3drm3_SetDefaultTextureColors
,
2308 d3drm3_SetDefaultTextureShades
,
2310 d3drm3_GetNamedObject
,
2311 d3drm3_EnumerateObjects
,
2314 d3drm3_CreateProgressiveMesh
,
2315 d3drm3_RegisterClient
,
2316 d3drm3_UnregisterClient
,
2317 d3drm3_CreateClippedVisual
,
2322 HRESULT WINAPI
Direct3DRMCreate(IDirect3DRM
**d3drm
)
2324 struct d3drm
*object
;
2326 TRACE("d3drm %p.\n", d3drm
);
2328 if (!(object
= heap_alloc_zero(sizeof(*object
))))
2329 return E_OUTOFMEMORY
;
2331 object
->IDirect3DRM_iface
.lpVtbl
= &d3drm1_vtbl
;
2332 object
->IDirect3DRM2_iface
.lpVtbl
= &d3drm2_vtbl
;
2333 object
->IDirect3DRM3_iface
.lpVtbl
= &d3drm3_vtbl
;
2335 object
->iface_count
= 1;
2337 *d3drm
= &object
->IDirect3DRM_iface
;
2342 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
2344 TRACE("(%s, %s, %p): stub\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
2347 return E_INVALIDARG
;
2349 return CLASS_E_CLASSNOTAVAILABLE
;