Release 2.9.
[wine.git] / dlls / d3drm / device.c
bloba774ae58275de6d854b197ebeb0c676b55c8713a
1 /*
2 * Implementation of IDirect3DRMDevice Interface
4 * Copyright 2011, 2012 André Hentschel
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "d3drm_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
28 static inline struct d3drm_device *impl_from_IDirect3DRMDevice(IDirect3DRMDevice *iface)
30 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice_iface);
33 static inline struct d3drm_device *impl_from_IDirect3DRMDevice2(IDirect3DRMDevice2 *iface)
35 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice2_iface);
38 static inline struct d3drm_device *impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface)
40 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice3_iface);
43 void d3drm_device_destroy(struct d3drm_device *device)
45 d3drm_object_cleanup((IDirect3DRMObject *)&device->IDirect3DRMDevice_iface, &device->obj);
46 if (device->device)
48 TRACE("Releasing attached ddraw interfaces.\n");
49 IDirect3DDevice_Release(device->device);
51 if (device->render_target)
52 IDirectDrawSurface_Release(device->render_target);
53 if (device->primary_surface)
55 TRACE("Releasing primary surface and attached clipper.\n");
56 IDirectDrawSurface_Release(device->primary_surface);
57 IDirectDrawClipper_Release(device->clipper);
59 if (device->ddraw)
61 IDirectDraw_Release(device->ddraw);
62 IDirect3DRM_Release(device->d3drm);
64 HeapFree(GetProcessHeap(), 0, device);
67 static inline struct d3drm_device *impl_from_IDirect3DRMWinDevice(IDirect3DRMWinDevice *iface)
69 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMWinDevice_iface);
72 HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface)
74 DDSURFACEDESC surface_desc;
75 IDirectDrawSurface *primary_surface, *render_target;
76 HWND window;
77 HRESULT hr;
79 hr = IDirectDrawClipper_GetHWnd(clipper, &window);
80 if (FAILED(hr))
81 return hr;
83 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
84 if (FAILED(hr))
85 return hr;
87 memset(&surface_desc, 0, sizeof(surface_desc));
88 surface_desc.dwSize = sizeof(surface_desc);
89 surface_desc.dwFlags = DDSD_CAPS;
90 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
91 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary_surface, NULL);
92 if (FAILED(hr))
93 return hr;
94 hr = IDirectDrawSurface_SetClipper(primary_surface, clipper);
95 if (FAILED(hr))
97 IDirectDrawSurface_Release(primary_surface);
98 return hr;
101 memset(&surface_desc, 0, sizeof(surface_desc));
102 surface_desc.dwSize = sizeof(surface_desc);
103 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
104 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
105 surface_desc.dwWidth = width;
106 surface_desc.dwHeight = height;
108 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &render_target, NULL);
109 if (FAILED(hr))
111 IDirectDrawSurface_Release(primary_surface);
112 return hr;
115 object->primary_surface = primary_surface;
116 object->clipper = clipper;
117 IDirectDrawClipper_AddRef(clipper);
118 *surface = render_target;
120 return D3DRM_OK;
123 HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw, IDirectDrawSurface *surface,
124 BOOL create_z_surface)
126 DDSCAPS caps = { DDSCAPS_ZBUFFER };
127 IDirectDrawSurface *ds = NULL;
128 IDirect3DDevice *device1 = NULL;
129 IDirect3DDevice2 *device2 = NULL;
130 IDirect3D2 *d3d2 = NULL;
131 DDSURFACEDESC desc, surface_desc;
132 HRESULT hr;
134 device->ddraw = ddraw;
135 IDirectDraw_AddRef(ddraw);
136 IDirect3DRM_AddRef(device->d3drm);
137 device->render_target = surface;
138 IDirectDrawSurface_AddRef(surface);
140 desc.dwSize = sizeof(desc);
141 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
142 if (FAILED(hr))
143 return hr;
145 if (!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))
146 return DDERR_INVALIDCAPS;
148 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
149 if (SUCCEEDED(hr))
151 create_z_surface = FALSE;
152 IDirectDrawSurface_Release(ds);
153 ds = NULL;
156 if (create_z_surface)
158 memset(&surface_desc, 0, sizeof(surface_desc));
159 surface_desc.dwSize = sizeof(surface_desc);
160 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
161 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
162 surface_desc.u2.dwZBufferBitDepth = 16;
163 surface_desc.dwWidth = desc.dwWidth;
164 surface_desc.dwHeight = desc.dwHeight;
165 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &ds, NULL);
166 if (FAILED(hr))
167 return hr;
169 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
170 IDirectDrawSurface_Release(ds);
171 if (FAILED(hr))
172 return hr;
175 if (version == 1)
176 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DRGBDevice, (void **)&device1);
177 else
179 IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D2, (void**)&d3d2);
180 hr = IDirect3D2_CreateDevice(d3d2, &IID_IDirect3DRGBDevice, surface, &device2);
181 IDirect3D2_Release(d3d2);
183 if (FAILED(hr))
185 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
186 return hr;
189 if (version != 1)
191 hr = IDirect3DDevice2_QueryInterface(device2, &IID_IDirect3DDevice, (void**)&device1);
192 IDirect3DDevice2_Release(device2);
193 if (FAILED(hr))
195 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
196 return hr;
199 device->device = device1;
200 device->width = desc.dwWidth;
201 device->height = desc.dwHeight;
203 return hr;
206 static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device)
208 IDirectDraw *ddraw;
209 IDirectDrawSurface *surface;
210 IDirect3DDevice2 *d3d_device2 = NULL;
211 DDSURFACEDESC desc;
212 HRESULT hr;
214 /* AddRef these interfaces beforehand for the intentional leak on reinitialization. */
215 if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&ddraw)))
216 return hr;
217 IDirect3DRM_AddRef(device->d3drm);
218 IDirect3DDevice_AddRef(d3d_device);
220 /* Fetch render target and get width/height from there */
221 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
223 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirect3DDevice2, (void **)&d3d_device2)))
224 return hr;
225 hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface);
226 IDirect3DDevice2_Release(d3d_device2);
227 if (FAILED(hr))
228 return hr;
231 if (device->ddraw)
233 if (d3d_device2)
234 IDirectDrawSurface_Release(surface);
235 return D3DRMERR_BADOBJECT;
238 desc.dwSize = sizeof(desc);
239 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
240 if (FAILED(hr))
242 IDirectDrawSurface_Release(surface);
243 return hr;
246 device->ddraw = ddraw;
247 device->width = desc.dwWidth;
248 device->height = desc.dwHeight;
249 device->device = d3d_device;
250 device->render_target = surface;
252 return hr;
255 static HRESULT WINAPI d3drm_device3_QueryInterface(IDirect3DRMDevice3 *iface, REFIID riid, void **out)
257 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
259 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
261 if (IsEqualGUID(riid, &IID_IDirect3DRMDevice)
262 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
263 || IsEqualGUID(riid, &IID_IUnknown))
265 *out = &device->IDirect3DRMDevice_iface;
267 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice2))
269 *out = &device->IDirect3DRMDevice2_iface;
271 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice3))
273 *out = &device->IDirect3DRMDevice3_iface;
275 else if (IsEqualGUID(riid, &IID_IDirect3DRMWinDevice))
277 *out = &device->IDirect3DRMWinDevice_iface;
279 else
281 *out = NULL;
282 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
283 return CLASS_E_CLASSNOTAVAILABLE;
286 IUnknown_AddRef((IUnknown *)*out);
287 return S_OK;
290 static HRESULT WINAPI d3drm_device2_QueryInterface(IDirect3DRMDevice2 *iface, REFIID riid, void **out)
292 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
294 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
296 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
299 static HRESULT WINAPI d3drm_device1_QueryInterface(IDirect3DRMDevice *iface, REFIID riid, void **out)
301 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
303 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
305 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
308 static ULONG WINAPI d3drm_device3_AddRef(IDirect3DRMDevice3 *iface)
310 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
311 ULONG refcount = InterlockedIncrement(&device->obj.ref);
313 TRACE("%p increasing refcount to %u.\n", iface, refcount);
315 return refcount;
318 static ULONG WINAPI d3drm_device2_AddRef(IDirect3DRMDevice2 *iface)
320 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
322 TRACE("iface %p.\n", iface);
324 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
327 static ULONG WINAPI d3drm_device1_AddRef(IDirect3DRMDevice *iface)
329 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
331 TRACE("iface %p.\n", iface);
333 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
336 static ULONG WINAPI d3drm_device3_Release(IDirect3DRMDevice3 *iface)
338 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
339 ULONG refcount = InterlockedDecrement(&device->obj.ref);
341 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
343 if (!refcount)
344 d3drm_device_destroy(device);
346 return refcount;
349 static ULONG WINAPI d3drm_device2_Release(IDirect3DRMDevice2 *iface)
351 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
353 TRACE("iface %p.\n", iface);
355 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
358 static ULONG WINAPI d3drm_device1_Release(IDirect3DRMDevice *iface)
360 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
362 TRACE("iface %p.\n", iface);
364 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
367 static HRESULT WINAPI d3drm_device3_Clone(IDirect3DRMDevice3 *iface,
368 IUnknown *outer, REFIID iid, void **out)
370 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
372 return E_NOTIMPL;
375 static HRESULT WINAPI d3drm_device2_Clone(IDirect3DRMDevice2 *iface,
376 IUnknown *outer, REFIID iid, void **out)
378 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
380 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out);
382 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
385 static HRESULT WINAPI d3drm_device1_Clone(IDirect3DRMDevice *iface,
386 IUnknown *outer, REFIID iid, void **out)
388 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
390 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
392 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
395 static HRESULT WINAPI d3drm_device3_AddDestroyCallback(IDirect3DRMDevice3 *iface,
396 D3DRMOBJECTCALLBACK cb, void *ctx)
398 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
400 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
402 return d3drm_object_add_destroy_callback(&device->obj, cb, ctx);
405 static HRESULT WINAPI d3drm_device2_AddDestroyCallback(IDirect3DRMDevice2 *iface,
406 D3DRMOBJECTCALLBACK cb, void *ctx)
408 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
410 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
412 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
415 static HRESULT WINAPI d3drm_device1_AddDestroyCallback(IDirect3DRMDevice *iface,
416 D3DRMOBJECTCALLBACK cb, void *ctx)
418 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
420 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
422 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
425 static HRESULT WINAPI d3drm_device3_DeleteDestroyCallback(IDirect3DRMDevice3 *iface,
426 D3DRMOBJECTCALLBACK cb, void *ctx)
428 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
430 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
432 return d3drm_object_delete_destroy_callback(&device->obj, cb, ctx);
435 static HRESULT WINAPI d3drm_device2_DeleteDestroyCallback(IDirect3DRMDevice2 *iface,
436 D3DRMOBJECTCALLBACK cb, void *ctx)
438 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
440 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
442 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
445 static HRESULT WINAPI d3drm_device1_DeleteDestroyCallback(IDirect3DRMDevice *iface,
446 D3DRMOBJECTCALLBACK cb, void *ctx)
448 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
450 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
452 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
455 static HRESULT WINAPI d3drm_device3_SetAppData(IDirect3DRMDevice3 *iface, DWORD data)
457 FIXME("iface %p, data %#x stub!\n", iface, data);
459 return E_NOTIMPL;
462 static HRESULT WINAPI d3drm_device2_SetAppData(IDirect3DRMDevice2 *iface, DWORD data)
464 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
466 TRACE("iface %p, data %#x.\n", iface, data);
468 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
471 static HRESULT WINAPI d3drm_device1_SetAppData(IDirect3DRMDevice *iface, DWORD data)
473 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
475 TRACE("iface %p, data %#x.\n", iface, data);
477 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
480 static DWORD WINAPI d3drm_device3_GetAppData(IDirect3DRMDevice3 *iface)
482 FIXME("iface %p stub!\n", iface);
484 return 0;
487 static DWORD WINAPI d3drm_device2_GetAppData(IDirect3DRMDevice2 *iface)
489 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
491 TRACE("iface %p.\n", iface);
493 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
496 static DWORD WINAPI d3drm_device1_GetAppData(IDirect3DRMDevice *iface)
498 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
500 TRACE("iface %p.\n", iface);
502 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
505 static HRESULT WINAPI d3drm_device3_SetName(IDirect3DRMDevice3 *iface, const char *name)
507 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
509 return E_NOTIMPL;
512 static HRESULT WINAPI d3drm_device2_SetName(IDirect3DRMDevice2 *iface, const char *name)
514 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
516 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
518 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
521 static HRESULT WINAPI d3drm_device1_SetName(IDirect3DRMDevice *iface, const char *name)
523 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
525 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
527 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
530 static HRESULT WINAPI d3drm_device3_GetName(IDirect3DRMDevice3 *iface, DWORD *size, char *name)
532 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
534 return E_NOTIMPL;
537 static HRESULT WINAPI d3drm_device2_GetName(IDirect3DRMDevice2 *iface, DWORD *size, char *name)
539 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
541 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
543 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
546 static HRESULT WINAPI d3drm_device1_GetName(IDirect3DRMDevice *iface, DWORD *size, char *name)
548 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
550 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
552 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
555 static HRESULT WINAPI d3drm_device3_GetClassName(IDirect3DRMDevice3 *iface, DWORD *size, char *name)
557 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
559 if (!size || *size < strlen("Device") || !name)
560 return E_INVALIDARG;
562 strcpy(name, "Device");
563 *size = sizeof("Device");
565 return D3DRM_OK;
568 static HRESULT WINAPI d3drm_device2_GetClassName(IDirect3DRMDevice2 *iface, DWORD *size, char *name)
570 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
572 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
574 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
577 static HRESULT WINAPI d3drm_device1_GetClassName(IDirect3DRMDevice *iface, DWORD *size, char *name)
579 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
581 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
583 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
586 static HRESULT WINAPI d3drm_device3_Init(IDirect3DRMDevice3 *iface, ULONG width, ULONG height)
588 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
590 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
592 device->height = height;
593 device->width = width;
595 return D3DRM_OK;
598 static HRESULT WINAPI d3drm_device2_Init(IDirect3DRMDevice2 *iface, ULONG width, ULONG height)
600 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
602 TRACE("iface %p, width %u, height %u.\n", iface, width, height);
604 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height);
607 static HRESULT WINAPI d3drm_device1_Init(IDirect3DRMDevice *iface, ULONG width, ULONG height)
609 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
611 TRACE("iface %p, width %u, height %u.\n", iface, width, height);
613 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height);
616 static HRESULT WINAPI d3drm_device3_InitFromD3D(IDirect3DRMDevice3 *iface,
617 IDirect3D *d3d, IDirect3DDevice *d3d_device)
619 FIXME("iface %p, d3d %p, d3d_device %p stub!\n", iface, d3d, d3d_device);
621 if (!d3d || !d3d_device)
622 return D3DRMERR_BADVALUE;
624 return E_NOINTERFACE;
627 static HRESULT WINAPI d3drm_device2_InitFromD3D(IDirect3DRMDevice2 *iface,
628 IDirect3D *d3d, IDirect3DDevice *d3d_device)
630 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
632 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
634 return d3drm_device3_InitFromD3D(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
637 static HRESULT WINAPI d3drm_device1_InitFromD3D(IDirect3DRMDevice *iface,
638 IDirect3D *d3d, IDirect3DDevice *d3d_device)
640 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
642 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
644 if (!d3d || !d3d_device)
645 return D3DRMERR_BADVALUE;
647 return d3drm_device_set_ddraw_device_d3d(device, d3d, d3d_device);
650 static HRESULT WINAPI d3drm_device3_InitFromClipper(IDirect3DRMDevice3 *iface,
651 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
653 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
655 FIXME("iface %p, clipper %p, guid %s, width %d, height %d stub!\n",
656 iface, clipper, debugstr_guid(guid), width, height);
658 device->height = height;
659 device->width = width;
661 return D3DRM_OK;
664 static HRESULT WINAPI d3drm_device2_InitFromClipper(IDirect3DRMDevice2 *iface,
665 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
667 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
669 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n",
670 iface, clipper, debugstr_guid(guid), width, height);
672 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface,
673 clipper, guid, width, height);
676 static HRESULT WINAPI d3drm_device1_InitFromClipper(IDirect3DRMDevice *iface,
677 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
679 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
681 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n",
682 iface, clipper, debugstr_guid(guid), width, height);
684 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface,
685 clipper, guid, width, height);
688 static HRESULT WINAPI d3drm_device3_Update(IDirect3DRMDevice3 *iface)
690 FIXME("iface %p stub!\n", iface);
692 return D3DRM_OK;
695 static HRESULT WINAPI d3drm_device2_Update(IDirect3DRMDevice2 *iface)
697 FIXME("iface %p stub!\n", iface);
699 return D3DRM_OK;
702 static HRESULT WINAPI d3drm_device1_Update(IDirect3DRMDevice *iface)
704 FIXME("iface %p stub!\n", iface);
706 return D3DRM_OK;
709 static HRESULT WINAPI d3drm_device3_AddUpdateCallback(IDirect3DRMDevice3 *iface,
710 D3DRMUPDATECALLBACK cb, void *ctx)
712 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
714 return E_NOTIMPL;
717 static HRESULT WINAPI d3drm_device2_AddUpdateCallback(IDirect3DRMDevice2 *iface,
718 D3DRMUPDATECALLBACK cb, void *ctx)
720 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
722 return E_NOTIMPL;
725 static HRESULT WINAPI d3drm_device1_AddUpdateCallback(IDirect3DRMDevice *iface,
726 D3DRMUPDATECALLBACK cb, void *ctx)
728 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
730 return E_NOTIMPL;
733 static HRESULT WINAPI d3drm_device3_DeleteUpdateCallback(IDirect3DRMDevice3 *iface,
734 D3DRMUPDATECALLBACK cb, void *ctx)
736 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
738 return E_NOTIMPL;
741 static HRESULT WINAPI d3drm_device2_DeleteUpdateCallback(IDirect3DRMDevice2 *iface,
742 D3DRMUPDATECALLBACK cb, void *ctx)
744 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
746 return E_NOTIMPL;
749 static HRESULT WINAPI d3drm_device1_DeleteUpdateCallback(IDirect3DRMDevice *iface,
750 D3DRMUPDATECALLBACK cb, void *ctx)
752 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
754 return E_NOTIMPL;
757 static HRESULT WINAPI d3drm_device3_SetBufferCount(IDirect3DRMDevice3 *iface, DWORD count)
759 FIXME("iface %p, count %u stub!\n", iface, count);
761 return E_NOTIMPL;
764 static HRESULT WINAPI d3drm_device2_SetBufferCount(IDirect3DRMDevice2 *iface, DWORD count)
766 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
768 TRACE("iface %p, count %u.\n", iface, count);
770 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count);
773 static HRESULT WINAPI d3drm_device1_SetBufferCount(IDirect3DRMDevice *iface, DWORD count)
775 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
777 TRACE("iface %p, count %u.\n", iface, count);
779 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count);
782 static DWORD WINAPI d3drm_device3_GetBufferCount(IDirect3DRMDevice3 *iface)
784 FIXME("iface %p stub!\n", iface);
786 return E_NOTIMPL;
789 static DWORD WINAPI d3drm_device2_GetBufferCount(IDirect3DRMDevice2 *iface)
791 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
793 TRACE("iface %p.\n", iface);
795 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface);
798 static DWORD WINAPI d3drm_device1_GetBufferCount(IDirect3DRMDevice *iface)
800 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
802 TRACE("iface %p.\n", iface);
804 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface);
807 static HRESULT WINAPI d3drm_device3_SetDither(IDirect3DRMDevice3 *iface, BOOL enable)
809 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
811 TRACE("iface %p, enable %#x.\n", iface, enable);
813 device->dither = enable;
815 return D3DRM_OK;
818 static HRESULT WINAPI d3drm_device2_SetDither(IDirect3DRMDevice2 *iface, BOOL enable)
820 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
822 TRACE("iface %p, enabled %#x.\n", iface, enable);
824 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable);
827 static HRESULT WINAPI d3drm_device1_SetDither(IDirect3DRMDevice *iface, BOOL enable)
829 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
831 TRACE("iface %p, enabled %#x.\n", iface, enable);
833 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable);
836 static HRESULT WINAPI d3drm_device3_SetShades(IDirect3DRMDevice3 *iface, DWORD count)
838 FIXME("iface %p, count %u stub!\n", iface, count);
840 return E_NOTIMPL;
843 static HRESULT WINAPI d3drm_device2_SetShades(IDirect3DRMDevice2 *iface, DWORD count)
845 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
847 TRACE("iface %p, count %u.\n", iface, count);
849 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count);
852 static HRESULT WINAPI d3drm_device1_SetShades(IDirect3DRMDevice *iface, DWORD count)
854 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
856 TRACE("iface %p, count %u.\n", iface, count);
858 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count);
861 static HRESULT WINAPI d3drm_device3_SetQuality(IDirect3DRMDevice3 *iface, D3DRMRENDERQUALITY quality)
863 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
865 TRACE("iface %p, quality %u.\n", iface, quality);
867 device->quality = quality;
869 return D3DRM_OK;
872 static HRESULT WINAPI d3drm_device2_SetQuality(IDirect3DRMDevice2 *iface, D3DRMRENDERQUALITY quality)
874 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
876 TRACE("iface %p, quality %u.\n", iface, quality);
878 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality);
881 static HRESULT WINAPI d3drm_device1_SetQuality(IDirect3DRMDevice *iface, D3DRMRENDERQUALITY quality)
883 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
885 TRACE("iface %p, quality %u.\n", iface, quality);
887 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality);
890 static HRESULT WINAPI d3drm_device3_SetTextureQuality(IDirect3DRMDevice3 *iface, D3DRMTEXTUREQUALITY quality)
892 FIXME("iface %p, quality %u stub!\n", iface, quality);
894 return E_NOTIMPL;
897 static HRESULT WINAPI d3drm_device2_SetTextureQuality(IDirect3DRMDevice2 *iface, D3DRMTEXTUREQUALITY quality)
899 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
901 TRACE("iface %p, quality %u.\n", iface, quality);
903 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality);
906 static HRESULT WINAPI d3drm_device1_SetTextureQuality(IDirect3DRMDevice *iface, D3DRMTEXTUREQUALITY quality)
908 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
910 TRACE("iface %p, quality %u.\n", iface, quality);
912 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality);
915 static HRESULT WINAPI d3drm_device3_GetViewports(IDirect3DRMDevice3 *iface, IDirect3DRMViewportArray **array)
917 FIXME("iface %p, array %p stub!\n", iface, array);
919 return E_NOTIMPL;
922 static HRESULT WINAPI d3drm_device2_GetViewports(IDirect3DRMDevice2 *iface, IDirect3DRMViewportArray **array)
924 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
926 TRACE("iface %p, array %p.\n", iface, array);
928 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array);
931 static HRESULT WINAPI d3drm_device1_GetViewports(IDirect3DRMDevice *iface, IDirect3DRMViewportArray **array)
933 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
935 TRACE("iface %p, array %p.\n", iface, array);
937 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array);
940 static BOOL WINAPI d3drm_device3_GetDither(IDirect3DRMDevice3 *iface)
942 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
944 TRACE("iface %p.\n", iface);
946 return device->dither;
949 static BOOL WINAPI d3drm_device2_GetDither(IDirect3DRMDevice2 *iface)
951 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
953 TRACE("iface %p.\n", iface);
955 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface);
958 static BOOL WINAPI d3drm_device1_GetDither(IDirect3DRMDevice *iface)
960 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
962 TRACE("iface %p.\n", iface);
964 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface);
967 static DWORD WINAPI d3drm_device3_GetShades(IDirect3DRMDevice3 *iface)
969 FIXME("iface %p stub!\n", iface);
971 return E_NOTIMPL;
974 static DWORD WINAPI d3drm_device2_GetShades(IDirect3DRMDevice2 *iface)
976 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
978 TRACE("iface %p.\n", iface);
980 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface);
983 static DWORD WINAPI d3drm_device1_GetShades(IDirect3DRMDevice *iface)
985 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
987 TRACE("iface %p.\n", iface);
989 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface);
992 static DWORD WINAPI d3drm_device3_GetHeight(IDirect3DRMDevice3 *iface)
994 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
996 TRACE("iface %p.\n", iface);
998 return device->height;
1001 static DWORD WINAPI d3drm_device2_GetHeight(IDirect3DRMDevice2 *iface)
1003 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1005 TRACE("iface %p.\n", iface);
1007 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface);
1010 static DWORD WINAPI d3drm_device1_GetHeight(IDirect3DRMDevice *iface)
1012 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1014 TRACE("iface %p.\n", iface);
1016 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface);
1019 static DWORD WINAPI d3drm_device3_GetWidth(IDirect3DRMDevice3 *iface)
1021 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1023 TRACE("iface %p.\n", iface);
1025 return device->width;
1028 static DWORD WINAPI d3drm_device2_GetWidth(IDirect3DRMDevice2 *iface)
1030 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1032 TRACE("iface %p.\n", iface);
1034 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface);
1037 static DWORD WINAPI d3drm_device1_GetWidth(IDirect3DRMDevice *iface)
1039 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1041 TRACE("iface %p.\n", iface);
1043 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface);
1046 static DWORD WINAPI d3drm_device3_GetTrianglesDrawn(IDirect3DRMDevice3 *iface)
1048 FIXME("iface %p stub!\n", iface);
1050 return E_NOTIMPL;
1053 static DWORD WINAPI d3drm_device2_GetTrianglesDrawn(IDirect3DRMDevice2 *iface)
1055 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1057 TRACE("iface %p.\n", iface);
1059 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface);
1062 static DWORD WINAPI d3drm_device1_GetTrianglesDrawn(IDirect3DRMDevice *iface)
1064 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1066 TRACE("iface %p.\n", iface);
1068 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface);
1071 static DWORD WINAPI d3drm_device3_GetWireframeOptions(IDirect3DRMDevice3 *iface)
1073 FIXME("iface %p stub!\n", iface);
1075 return E_NOTIMPL;
1078 static DWORD WINAPI d3drm_device2_GetWireframeOptions(IDirect3DRMDevice2 *iface)
1080 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1082 TRACE("iface %p.\n", iface);
1084 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface);
1087 static DWORD WINAPI d3drm_device1_GetWireframeOptions(IDirect3DRMDevice *iface)
1089 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1091 TRACE("iface %p.\n", iface);
1093 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface);
1096 static D3DRMRENDERQUALITY WINAPI d3drm_device3_GetQuality(IDirect3DRMDevice3 *iface)
1098 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1100 TRACE("iface %p.\n", iface);
1102 return device->quality;
1105 static D3DRMRENDERQUALITY WINAPI d3drm_device2_GetQuality(IDirect3DRMDevice2 *iface)
1107 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1109 TRACE("iface %p.\n", iface);
1111 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface);
1114 static D3DRMRENDERQUALITY WINAPI d3drm_device1_GetQuality(IDirect3DRMDevice *iface)
1116 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1118 TRACE("iface %p.\n", iface);
1120 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface);
1123 static D3DCOLORMODEL WINAPI d3drm_device3_GetColorModel(IDirect3DRMDevice3 *iface)
1125 FIXME("iface %p stub!\n", iface);
1127 return E_NOTIMPL;
1130 static D3DCOLORMODEL WINAPI d3drm_device2_GetColorModel(IDirect3DRMDevice2 *iface)
1132 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1134 TRACE("iface %p.\n", iface);
1136 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
1139 static D3DCOLORMODEL WINAPI d3drm_device1_GetColorModel(IDirect3DRMDevice *iface)
1141 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1143 TRACE("iface %p.\n", iface);
1145 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
1148 static D3DRMTEXTUREQUALITY WINAPI d3drm_device3_GetTextureQuality(IDirect3DRMDevice3 *iface)
1150 FIXME("iface %p stub!\n", iface);
1152 return E_NOTIMPL;
1155 static D3DRMTEXTUREQUALITY WINAPI d3drm_device2_GetTextureQuality(IDirect3DRMDevice2 *iface)
1157 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1159 TRACE("iface %p.\n", iface);
1161 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface);
1164 static D3DRMTEXTUREQUALITY WINAPI d3drm_device1_GetTextureQuality(IDirect3DRMDevice *iface)
1166 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1168 TRACE("iface %p.\n", iface);
1170 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface);
1173 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice(IDirect3DRMDevice3 *iface, IDirect3DDevice **d3d_device)
1175 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1176 TRACE("iface %p, d3d_device %p!\n", iface, d3d_device);
1178 *d3d_device = device->device;
1179 IDirect3DDevice_AddRef(*d3d_device);
1181 return D3DRM_OK;
1184 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice(IDirect3DRMDevice2 *iface, IDirect3DDevice **d3d_device)
1186 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1188 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1190 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device);
1193 static HRESULT WINAPI d3drm_device1_GetDirect3DDevice(IDirect3DRMDevice *iface, IDirect3DDevice **d3d_device)
1195 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1197 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1199 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device);
1202 static HRESULT WINAPI d3drm_device3_InitFromD3D2(IDirect3DRMDevice3 *iface,
1203 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device)
1205 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1206 IDirect3D *d3d1;
1207 IDirect3DDevice *d3d_device1;
1208 HRESULT hr;
1210 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
1212 if (!d3d || !d3d_device)
1213 return D3DRMERR_BADVALUE;
1215 if (FAILED(hr = IDirect3D2_QueryInterface(d3d, &IID_IDirect3D, (void **)&d3d1)))
1216 return hr;
1217 if (FAILED(hr = IDirect3DDevice2_QueryInterface(d3d_device, &IID_IDirect3DDevice, (void **)&d3d_device1)))
1219 IDirect3D_Release(d3d1);
1220 return hr;
1223 hr = d3drm_device_set_ddraw_device_d3d(device, d3d1, d3d_device1);
1224 IDirect3D_Release(d3d1);
1225 IDirect3DDevice_Release(d3d_device1);
1227 return hr;
1230 static HRESULT WINAPI d3drm_device2_InitFromD3D2(IDirect3DRMDevice2 *iface,
1231 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device)
1233 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1235 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
1237 return d3drm_device3_InitFromD3D2(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
1240 static HRESULT WINAPI d3drm_device3_InitFromSurface(IDirect3DRMDevice3 *iface,
1241 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer)
1243 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p stub!\n",
1244 iface, debugstr_guid(guid), ddraw, backbuffer);
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI d3drm_device2_InitFromSurface(IDirect3DRMDevice2 *iface,
1250 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer)
1252 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1254 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p.\n",
1255 iface, debugstr_guid(guid), ddraw, backbuffer);
1257 return d3drm_device3_InitFromSurface(&device->IDirect3DRMDevice3_iface, guid, ddraw, backbuffer);
1260 static HRESULT WINAPI d3drm_device3_SetRenderMode(IDirect3DRMDevice3 *iface, DWORD flags)
1262 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1264 TRACE("iface %p, flags %#x.\n", iface, flags);
1266 device->rendermode = flags;
1268 return D3DRM_OK;
1271 static HRESULT WINAPI d3drm_device2_SetRenderMode(IDirect3DRMDevice2 *iface, DWORD flags)
1273 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1275 TRACE("iface %p, flags %#x.\n", iface, flags);
1277 return d3drm_device3_SetRenderMode(&device->IDirect3DRMDevice3_iface, flags);
1280 static DWORD WINAPI d3drm_device3_GetRenderMode(IDirect3DRMDevice3 *iface)
1282 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1284 TRACE("iface %p.\n", iface);
1286 return device->rendermode;
1289 static DWORD WINAPI d3drm_device2_GetRenderMode(IDirect3DRMDevice2 *iface)
1291 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1293 TRACE("iface %p.\n", iface);
1295 return d3drm_device3_GetRenderMode(&device->IDirect3DRMDevice3_iface);
1298 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice2(IDirect3DRMDevice3 *iface, IDirect3DDevice2 **d3d_device)
1300 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1302 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1304 if (FAILED(IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device)))
1305 return D3DRMERR_BADOBJECT;
1307 return D3DRM_OK;
1310 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice2(IDirect3DRMDevice2 *iface, IDirect3DDevice2 **d3d_device)
1312 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1314 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1316 IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device);
1318 /* d3drm returns D3DRM_OK even if the call fails. */
1319 return D3DRM_OK;
1322 static HRESULT WINAPI d3drm_device3_FindPreferredTextureFormat(IDirect3DRMDevice3 *iface,
1323 DWORD bitdepths, DWORD flags, DDPIXELFORMAT *pf)
1325 FIXME("iface %p, bitdepths %u, flags %#x, pf %p stub!\n", iface, bitdepths, flags, pf);
1327 return E_NOTIMPL;
1330 static HRESULT WINAPI d3drm_device3_RenderStateChange(IDirect3DRMDevice3 *iface,
1331 D3DRENDERSTATETYPE state, DWORD value, DWORD flags)
1333 FIXME("iface %p, state %#x, value %#x, flags %#x stub!\n", iface, state, value, flags);
1335 return E_NOTIMPL;
1338 static HRESULT WINAPI d3drm_device3_LightStateChange(IDirect3DRMDevice3 *iface,
1339 D3DLIGHTSTATETYPE state, DWORD value, DWORD flags)
1341 FIXME("iface %p, state %#x, value %#x, flags %#x stub!\n", iface, state, value, flags);
1343 return E_NOTIMPL;
1346 static HRESULT WINAPI d3drm_device3_GetStateChangeOptions(IDirect3DRMDevice3 *iface,
1347 DWORD state_class, DWORD state_idx, DWORD *flags)
1349 FIXME("iface %p, state_class %#x, state_idx %#x, flags %p stub!\n",
1350 iface, state_class, state_idx, flags);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI d3drm_device3_SetStateChangeOptions(IDirect3DRMDevice3 *iface,
1356 DWORD state_class, DWORD state_idx, DWORD flags)
1358 FIXME("iface %p, state_class %#x, state_idx %#x, flags %#x stub!\n",
1359 iface, state_class, state_idx, flags);
1361 return E_NOTIMPL;
1364 static const struct IDirect3DRMDevice3Vtbl d3drm_device3_vtbl =
1366 d3drm_device3_QueryInterface,
1367 d3drm_device3_AddRef,
1368 d3drm_device3_Release,
1369 d3drm_device3_Clone,
1370 d3drm_device3_AddDestroyCallback,
1371 d3drm_device3_DeleteDestroyCallback,
1372 d3drm_device3_SetAppData,
1373 d3drm_device3_GetAppData,
1374 d3drm_device3_SetName,
1375 d3drm_device3_GetName,
1376 d3drm_device3_GetClassName,
1377 d3drm_device3_Init,
1378 d3drm_device3_InitFromD3D,
1379 d3drm_device3_InitFromClipper,
1380 d3drm_device3_Update,
1381 d3drm_device3_AddUpdateCallback,
1382 d3drm_device3_DeleteUpdateCallback,
1383 d3drm_device3_SetBufferCount,
1384 d3drm_device3_GetBufferCount,
1385 d3drm_device3_SetDither,
1386 d3drm_device3_SetShades,
1387 d3drm_device3_SetQuality,
1388 d3drm_device3_SetTextureQuality,
1389 d3drm_device3_GetViewports,
1390 d3drm_device3_GetDither,
1391 d3drm_device3_GetShades,
1392 d3drm_device3_GetHeight,
1393 d3drm_device3_GetWidth,
1394 d3drm_device3_GetTrianglesDrawn,
1395 d3drm_device3_GetWireframeOptions,
1396 d3drm_device3_GetQuality,
1397 d3drm_device3_GetColorModel,
1398 d3drm_device3_GetTextureQuality,
1399 d3drm_device3_GetDirect3DDevice,
1400 d3drm_device3_InitFromD3D2,
1401 d3drm_device3_InitFromSurface,
1402 d3drm_device3_SetRenderMode,
1403 d3drm_device3_GetRenderMode,
1404 d3drm_device3_GetDirect3DDevice2,
1405 d3drm_device3_FindPreferredTextureFormat,
1406 d3drm_device3_RenderStateChange,
1407 d3drm_device3_LightStateChange,
1408 d3drm_device3_GetStateChangeOptions,
1409 d3drm_device3_SetStateChangeOptions,
1412 static const struct IDirect3DRMDevice2Vtbl d3drm_device2_vtbl =
1414 d3drm_device2_QueryInterface,
1415 d3drm_device2_AddRef,
1416 d3drm_device2_Release,
1417 d3drm_device2_Clone,
1418 d3drm_device2_AddDestroyCallback,
1419 d3drm_device2_DeleteDestroyCallback,
1420 d3drm_device2_SetAppData,
1421 d3drm_device2_GetAppData,
1422 d3drm_device2_SetName,
1423 d3drm_device2_GetName,
1424 d3drm_device2_GetClassName,
1425 d3drm_device2_Init,
1426 d3drm_device2_InitFromD3D,
1427 d3drm_device2_InitFromClipper,
1428 d3drm_device2_Update,
1429 d3drm_device2_AddUpdateCallback,
1430 d3drm_device2_DeleteUpdateCallback,
1431 d3drm_device2_SetBufferCount,
1432 d3drm_device2_GetBufferCount,
1433 d3drm_device2_SetDither,
1434 d3drm_device2_SetShades,
1435 d3drm_device2_SetQuality,
1436 d3drm_device2_SetTextureQuality,
1437 d3drm_device2_GetViewports,
1438 d3drm_device2_GetDither,
1439 d3drm_device2_GetShades,
1440 d3drm_device2_GetHeight,
1441 d3drm_device2_GetWidth,
1442 d3drm_device2_GetTrianglesDrawn,
1443 d3drm_device2_GetWireframeOptions,
1444 d3drm_device2_GetQuality,
1445 d3drm_device2_GetColorModel,
1446 d3drm_device2_GetTextureQuality,
1447 d3drm_device2_GetDirect3DDevice,
1448 d3drm_device2_InitFromD3D2,
1449 d3drm_device2_InitFromSurface,
1450 d3drm_device2_SetRenderMode,
1451 d3drm_device2_GetRenderMode,
1452 d3drm_device2_GetDirect3DDevice2,
1455 static const struct IDirect3DRMDeviceVtbl d3drm_device1_vtbl =
1457 d3drm_device1_QueryInterface,
1458 d3drm_device1_AddRef,
1459 d3drm_device1_Release,
1460 d3drm_device1_Clone,
1461 d3drm_device1_AddDestroyCallback,
1462 d3drm_device1_DeleteDestroyCallback,
1463 d3drm_device1_SetAppData,
1464 d3drm_device1_GetAppData,
1465 d3drm_device1_SetName,
1466 d3drm_device1_GetName,
1467 d3drm_device1_GetClassName,
1468 d3drm_device1_Init,
1469 d3drm_device1_InitFromD3D,
1470 d3drm_device1_InitFromClipper,
1471 d3drm_device1_Update,
1472 d3drm_device1_AddUpdateCallback,
1473 d3drm_device1_DeleteUpdateCallback,
1474 d3drm_device1_SetBufferCount,
1475 d3drm_device1_GetBufferCount,
1476 d3drm_device1_SetDither,
1477 d3drm_device1_SetShades,
1478 d3drm_device1_SetQuality,
1479 d3drm_device1_SetTextureQuality,
1480 d3drm_device1_GetViewports,
1481 d3drm_device1_GetDither,
1482 d3drm_device1_GetShades,
1483 d3drm_device1_GetHeight,
1484 d3drm_device1_GetWidth,
1485 d3drm_device1_GetTrianglesDrawn,
1486 d3drm_device1_GetWireframeOptions,
1487 d3drm_device1_GetQuality,
1488 d3drm_device1_GetColorModel,
1489 d3drm_device1_GetTextureQuality,
1490 d3drm_device1_GetDirect3DDevice,
1493 static HRESULT WINAPI d3drm_device_win_QueryInterface(IDirect3DRMWinDevice *iface, REFIID riid, void **out)
1495 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1497 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
1499 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
1502 static ULONG WINAPI d3drm_device_win_AddRef(IDirect3DRMWinDevice *iface)
1504 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1506 TRACE("iface %p.\n", iface);
1508 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
1511 static ULONG WINAPI d3drm_device_win_Release(IDirect3DRMWinDevice *iface)
1513 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1515 TRACE("iface %p.\n", iface);
1517 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
1520 static HRESULT WINAPI d3drm_device_win_Clone(IDirect3DRMWinDevice *iface,
1521 IUnknown *outer, REFIID iid, void **out)
1523 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1525 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out);
1527 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
1530 static HRESULT WINAPI d3drm_device_win_AddDestroyCallback(IDirect3DRMWinDevice *iface,
1531 D3DRMOBJECTCALLBACK cb, void *ctx)
1533 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1535 return E_NOTIMPL;
1538 static HRESULT WINAPI d3drm_device_win_DeleteDestroyCallback(IDirect3DRMWinDevice *iface,
1539 D3DRMOBJECTCALLBACK cb, void *ctx)
1541 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1543 return E_NOTIMPL;
1546 static HRESULT WINAPI d3drm_device_win_SetAppData(IDirect3DRMWinDevice *iface, DWORD data)
1548 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1550 TRACE("iface %p, data %#x.\n", iface, data);
1552 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
1555 static DWORD WINAPI d3drm_device_win_GetAppData(IDirect3DRMWinDevice *iface)
1557 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1559 TRACE("iface %p.\n", iface);
1561 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
1564 static HRESULT WINAPI d3drm_device_win_SetName(IDirect3DRMWinDevice *iface, const char *name)
1566 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1568 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1570 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
1573 static HRESULT WINAPI d3drm_device_win_GetName(IDirect3DRMWinDevice *iface, DWORD *size, char *name)
1575 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1577 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1579 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
1582 static HRESULT WINAPI d3drm_device_win_GetClassName(IDirect3DRMWinDevice *iface, DWORD *size, char *name)
1584 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1586 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1588 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
1591 static HRESULT WINAPI d3drm_device_win_HandlePaint(IDirect3DRMWinDevice *iface, HDC dc)
1593 FIXME("iface %p, dc %p stub!\n", iface, dc);
1595 return D3DRM_OK;
1598 static HRESULT WINAPI d3drm_device_win_HandleActivate(IDirect3DRMWinDevice *iface, WORD wparam)
1600 FIXME("iface %p, wparam %#x stub!\n", iface, wparam);
1602 return D3DRM_OK;
1605 static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl =
1607 d3drm_device_win_QueryInterface,
1608 d3drm_device_win_AddRef,
1609 d3drm_device_win_Release,
1610 d3drm_device_win_Clone,
1611 d3drm_device_win_AddDestroyCallback,
1612 d3drm_device_win_DeleteDestroyCallback,
1613 d3drm_device_win_SetAppData,
1614 d3drm_device_win_GetAppData,
1615 d3drm_device_win_SetName,
1616 d3drm_device_win_GetName,
1617 d3drm_device_win_GetClassName,
1618 d3drm_device_win_HandlePaint,
1619 d3drm_device_win_HandleActivate,
1622 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface)
1624 if (!iface)
1625 return NULL;
1626 assert(iface->lpVtbl == &d3drm_device3_vtbl);
1628 return impl_from_IDirect3DRMDevice3(iface);
1631 HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm)
1633 struct d3drm_device *object;
1635 TRACE("device %p, d3drm %p.\n", device, d3drm);
1637 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1638 return E_OUTOFMEMORY;
1640 object->IDirect3DRMDevice_iface.lpVtbl = &d3drm_device1_vtbl;
1641 object->IDirect3DRMDevice2_iface.lpVtbl = &d3drm_device2_vtbl;
1642 object->IDirect3DRMDevice3_iface.lpVtbl = &d3drm_device3_vtbl;
1643 object->IDirect3DRMWinDevice_iface.lpVtbl = &d3drm_device_win_vtbl;
1644 object->d3drm = d3drm;
1645 d3drm_object_init(&object->obj);
1647 *device = object;
1649 return D3DRM_OK;