mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / d3drm / device.c
blob2e1b5f2d24fbde1efb923e65ffef21d43b015a40
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 "d3drm_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
25 static inline struct d3drm_device *impl_from_IDirect3DRMDevice(IDirect3DRMDevice *iface)
27 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice_iface);
30 static inline struct d3drm_device *impl_from_IDirect3DRMDevice2(IDirect3DRMDevice2 *iface)
32 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice2_iface);
35 static inline struct d3drm_device *impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface)
37 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice3_iface);
40 void d3drm_device_destroy(struct d3drm_device *device)
42 d3drm_object_cleanup((IDirect3DRMObject *)&device->IDirect3DRMDevice_iface, &device->obj);
43 if (device->device)
45 TRACE("Releasing attached ddraw interfaces.\n");
46 IDirect3DDevice_Release(device->device);
48 if (device->render_target)
49 IDirectDrawSurface_Release(device->render_target);
50 if (device->primary_surface)
52 TRACE("Releasing primary surface and attached clipper.\n");
53 IDirectDrawSurface_Release(device->primary_surface);
54 IDirectDrawClipper_Release(device->clipper);
56 if (device->ddraw)
58 IDirectDraw_Release(device->ddraw);
59 IDirect3DRM_Release(device->d3drm);
61 heap_free(device);
64 static inline struct d3drm_device *impl_from_IDirect3DRMWinDevice(IDirect3DRMWinDevice *iface)
66 return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMWinDevice_iface);
69 HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface)
71 DDSURFACEDESC surface_desc;
72 IDirectDrawSurface *primary_surface, *render_target;
73 HWND window;
74 HRESULT hr;
76 hr = IDirectDrawClipper_GetHWnd(clipper, &window);
77 if (FAILED(hr))
78 return hr;
80 hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
81 if (FAILED(hr))
82 return hr;
84 memset(&surface_desc, 0, sizeof(surface_desc));
85 surface_desc.dwSize = sizeof(surface_desc);
86 surface_desc.dwFlags = DDSD_CAPS;
87 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
88 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &primary_surface, NULL);
89 if (FAILED(hr))
90 return hr;
91 hr = IDirectDrawSurface_SetClipper(primary_surface, clipper);
92 if (FAILED(hr))
94 IDirectDrawSurface_Release(primary_surface);
95 return hr;
98 memset(&surface_desc, 0, sizeof(surface_desc));
99 surface_desc.dwSize = sizeof(surface_desc);
100 surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
101 surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
102 surface_desc.dwWidth = width;
103 surface_desc.dwHeight = height;
105 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &render_target, NULL);
106 if (FAILED(hr))
108 IDirectDrawSurface_Release(primary_surface);
109 return hr;
112 object->primary_surface = primary_surface;
113 object->clipper = clipper;
114 IDirectDrawClipper_AddRef(clipper);
115 *surface = render_target;
117 return D3DRM_OK;
120 HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw, IDirectDrawSurface *surface,
121 BOOL create_z_surface)
123 DDSCAPS caps = { DDSCAPS_ZBUFFER };
124 IDirectDrawSurface *ds = NULL;
125 IDirect3DDevice *device1 = NULL;
126 IDirect3DDevice2 *device2 = NULL;
127 IDirect3D2 *d3d2 = NULL;
128 DDSURFACEDESC desc, surface_desc;
129 HRESULT hr;
131 device->ddraw = ddraw;
132 IDirectDraw_AddRef(ddraw);
133 IDirect3DRM_AddRef(device->d3drm);
134 device->render_target = surface;
135 IDirectDrawSurface_AddRef(surface);
137 desc.dwSize = sizeof(desc);
138 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
139 if (FAILED(hr))
140 return hr;
142 if (!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))
143 return DDERR_INVALIDCAPS;
145 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
146 if (SUCCEEDED(hr))
148 create_z_surface = FALSE;
149 IDirectDrawSurface_Release(ds);
150 ds = NULL;
153 if (create_z_surface)
155 memset(&surface_desc, 0, sizeof(surface_desc));
156 surface_desc.dwSize = sizeof(surface_desc);
157 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
158 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
159 surface_desc.u2.dwZBufferBitDepth = 16;
160 surface_desc.dwWidth = desc.dwWidth;
161 surface_desc.dwHeight = desc.dwHeight;
162 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &ds, NULL);
163 if (FAILED(hr))
164 return hr;
166 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
167 IDirectDrawSurface_Release(ds);
168 if (FAILED(hr))
169 return hr;
172 if (version == 1)
173 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DRGBDevice, (void **)&device1);
174 else
176 IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D2, (void**)&d3d2);
177 hr = IDirect3D2_CreateDevice(d3d2, &IID_IDirect3DRGBDevice, surface, &device2);
178 IDirect3D2_Release(d3d2);
180 if (FAILED(hr))
182 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
183 return hr;
186 if (version != 1)
188 hr = IDirect3DDevice2_QueryInterface(device2, &IID_IDirect3DDevice, (void**)&device1);
189 IDirect3DDevice2_Release(device2);
190 if (FAILED(hr))
192 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
193 return hr;
196 device->device = device1;
197 device->width = desc.dwWidth;
198 device->height = desc.dwHeight;
200 return hr;
203 static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device)
205 IDirectDraw *ddraw;
206 IDirectDrawSurface *surface;
207 IDirect3DDevice2 *d3d_device2 = NULL;
208 DDSURFACEDESC desc;
209 HRESULT hr;
211 /* AddRef these interfaces beforehand for the intentional leak on reinitialization. */
212 if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&ddraw)))
213 return hr;
214 IDirect3DRM_AddRef(device->d3drm);
215 IDirect3DDevice_AddRef(d3d_device);
217 /* Fetch render target and get width/height from there */
218 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
220 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirect3DDevice2, (void **)&d3d_device2)))
221 return hr;
222 hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface);
223 IDirect3DDevice2_Release(d3d_device2);
224 if (FAILED(hr))
225 return hr;
228 if (device->ddraw)
230 if (d3d_device2)
231 IDirectDrawSurface_Release(surface);
232 return D3DRMERR_BADOBJECT;
235 desc.dwSize = sizeof(desc);
236 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
237 if (FAILED(hr))
239 IDirectDrawSurface_Release(surface);
240 return hr;
243 device->ddraw = ddraw;
244 device->width = desc.dwWidth;
245 device->height = desc.dwHeight;
246 device->device = d3d_device;
247 device->render_target = surface;
249 return hr;
252 static HRESULT WINAPI d3drm_device3_QueryInterface(IDirect3DRMDevice3 *iface, REFIID riid, void **out)
254 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
256 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
258 if (IsEqualGUID(riid, &IID_IDirect3DRMDevice)
259 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
260 || IsEqualGUID(riid, &IID_IUnknown))
262 *out = &device->IDirect3DRMDevice_iface;
264 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice2))
266 *out = &device->IDirect3DRMDevice2_iface;
268 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice3))
270 *out = &device->IDirect3DRMDevice3_iface;
272 else if (IsEqualGUID(riid, &IID_IDirect3DRMWinDevice))
274 *out = &device->IDirect3DRMWinDevice_iface;
276 else
278 *out = NULL;
279 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
280 return CLASS_E_CLASSNOTAVAILABLE;
283 IUnknown_AddRef((IUnknown *)*out);
284 return S_OK;
287 static HRESULT WINAPI d3drm_device2_QueryInterface(IDirect3DRMDevice2 *iface, REFIID riid, void **out)
289 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
291 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
293 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
296 static HRESULT WINAPI d3drm_device1_QueryInterface(IDirect3DRMDevice *iface, REFIID riid, void **out)
298 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
300 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
302 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
305 static ULONG WINAPI d3drm_device3_AddRef(IDirect3DRMDevice3 *iface)
307 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
308 ULONG refcount = InterlockedIncrement(&device->obj.ref);
310 TRACE("%p increasing refcount to %u.\n", iface, refcount);
312 return refcount;
315 static ULONG WINAPI d3drm_device2_AddRef(IDirect3DRMDevice2 *iface)
317 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
319 TRACE("iface %p.\n", iface);
321 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
324 static ULONG WINAPI d3drm_device1_AddRef(IDirect3DRMDevice *iface)
326 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
328 TRACE("iface %p.\n", iface);
330 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
333 static ULONG WINAPI d3drm_device3_Release(IDirect3DRMDevice3 *iface)
335 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
336 ULONG refcount = InterlockedDecrement(&device->obj.ref);
338 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
340 if (!refcount)
341 d3drm_device_destroy(device);
343 return refcount;
346 static ULONG WINAPI d3drm_device2_Release(IDirect3DRMDevice2 *iface)
348 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
350 TRACE("iface %p.\n", iface);
352 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
355 static ULONG WINAPI d3drm_device1_Release(IDirect3DRMDevice *iface)
357 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
359 TRACE("iface %p.\n", iface);
361 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
364 static HRESULT WINAPI d3drm_device3_Clone(IDirect3DRMDevice3 *iface,
365 IUnknown *outer, REFIID iid, void **out)
367 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
369 return E_NOTIMPL;
372 static HRESULT WINAPI d3drm_device2_Clone(IDirect3DRMDevice2 *iface,
373 IUnknown *outer, REFIID iid, void **out)
375 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
377 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out);
379 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
382 static HRESULT WINAPI d3drm_device1_Clone(IDirect3DRMDevice *iface,
383 IUnknown *outer, REFIID iid, void **out)
385 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
387 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
389 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
392 static HRESULT WINAPI d3drm_device3_AddDestroyCallback(IDirect3DRMDevice3 *iface,
393 D3DRMOBJECTCALLBACK cb, void *ctx)
395 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
397 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
399 return d3drm_object_add_destroy_callback(&device->obj, cb, ctx);
402 static HRESULT WINAPI d3drm_device2_AddDestroyCallback(IDirect3DRMDevice2 *iface,
403 D3DRMOBJECTCALLBACK cb, void *ctx)
405 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
407 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
409 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
412 static HRESULT WINAPI d3drm_device1_AddDestroyCallback(IDirect3DRMDevice *iface,
413 D3DRMOBJECTCALLBACK cb, void *ctx)
415 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
417 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
419 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
422 static HRESULT WINAPI d3drm_device3_DeleteDestroyCallback(IDirect3DRMDevice3 *iface,
423 D3DRMOBJECTCALLBACK cb, void *ctx)
425 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
427 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
429 return d3drm_object_delete_destroy_callback(&device->obj, cb, ctx);
432 static HRESULT WINAPI d3drm_device2_DeleteDestroyCallback(IDirect3DRMDevice2 *iface,
433 D3DRMOBJECTCALLBACK cb, void *ctx)
435 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
437 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
439 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
442 static HRESULT WINAPI d3drm_device1_DeleteDestroyCallback(IDirect3DRMDevice *iface,
443 D3DRMOBJECTCALLBACK cb, void *ctx)
445 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
447 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
449 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
452 static HRESULT WINAPI d3drm_device3_SetAppData(IDirect3DRMDevice3 *iface, DWORD data)
454 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
456 TRACE("iface %p, data %#x.\n", iface, data);
458 device->obj.appdata = data;
460 return D3DRM_OK;
463 static HRESULT WINAPI d3drm_device2_SetAppData(IDirect3DRMDevice2 *iface, DWORD data)
465 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
467 TRACE("iface %p, data %#x.\n", iface, data);
469 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
472 static HRESULT WINAPI d3drm_device1_SetAppData(IDirect3DRMDevice *iface, DWORD data)
474 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
476 TRACE("iface %p, data %#x.\n", iface, data);
478 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
481 static DWORD WINAPI d3drm_device3_GetAppData(IDirect3DRMDevice3 *iface)
483 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
485 TRACE("iface %p.\n", iface);
487 return device->obj.appdata;
490 static DWORD WINAPI d3drm_device2_GetAppData(IDirect3DRMDevice2 *iface)
492 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
494 TRACE("iface %p.\n", iface);
496 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
499 static DWORD WINAPI d3drm_device1_GetAppData(IDirect3DRMDevice *iface)
501 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
503 TRACE("iface %p.\n", iface);
505 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
508 static HRESULT WINAPI d3drm_device3_SetName(IDirect3DRMDevice3 *iface, const char *name)
510 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
512 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
514 return d3drm_object_set_name(&device->obj, name);
517 static HRESULT WINAPI d3drm_device2_SetName(IDirect3DRMDevice2 *iface, const char *name)
519 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
521 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
523 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
526 static HRESULT WINAPI d3drm_device1_SetName(IDirect3DRMDevice *iface, const char *name)
528 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
530 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
532 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
535 static HRESULT WINAPI d3drm_device3_GetName(IDirect3DRMDevice3 *iface, DWORD *size, char *name)
537 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
539 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
541 return d3drm_object_get_name(&device->obj, size, name);
544 static HRESULT WINAPI d3drm_device2_GetName(IDirect3DRMDevice2 *iface, DWORD *size, char *name)
546 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
548 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
550 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
553 static HRESULT WINAPI d3drm_device1_GetName(IDirect3DRMDevice *iface, DWORD *size, char *name)
555 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
557 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
559 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
562 static HRESULT WINAPI d3drm_device3_GetClassName(IDirect3DRMDevice3 *iface, DWORD *size, char *name)
564 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
566 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
568 return d3drm_object_get_class_name(&device->obj, size, name);
571 static HRESULT WINAPI d3drm_device2_GetClassName(IDirect3DRMDevice2 *iface, DWORD *size, char *name)
573 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
575 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
577 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
580 static HRESULT WINAPI d3drm_device1_GetClassName(IDirect3DRMDevice *iface, DWORD *size, char *name)
582 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
584 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
586 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
589 static HRESULT WINAPI d3drm_device3_Init(IDirect3DRMDevice3 *iface, ULONG width, ULONG height)
591 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
593 FIXME("iface %p, width %u, height %u stub!\n", iface, width, height);
595 device->height = height;
596 device->width = width;
598 return D3DRM_OK;
601 static HRESULT WINAPI d3drm_device2_Init(IDirect3DRMDevice2 *iface, ULONG width, ULONG height)
603 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
605 TRACE("iface %p, width %u, height %u.\n", iface, width, height);
607 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height);
610 static HRESULT WINAPI d3drm_device1_Init(IDirect3DRMDevice *iface, ULONG width, ULONG height)
612 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
614 TRACE("iface %p, width %u, height %u.\n", iface, width, height);
616 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height);
619 static HRESULT WINAPI d3drm_device3_InitFromD3D(IDirect3DRMDevice3 *iface,
620 IDirect3D *d3d, IDirect3DDevice *d3d_device)
622 FIXME("iface %p, d3d %p, d3d_device %p stub!\n", iface, d3d, d3d_device);
624 if (!d3d || !d3d_device)
625 return D3DRMERR_BADVALUE;
627 return E_NOINTERFACE;
630 static HRESULT WINAPI d3drm_device2_InitFromD3D(IDirect3DRMDevice2 *iface,
631 IDirect3D *d3d, IDirect3DDevice *d3d_device)
633 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
635 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
637 return d3drm_device3_InitFromD3D(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
640 static HRESULT WINAPI d3drm_device1_InitFromD3D(IDirect3DRMDevice *iface,
641 IDirect3D *d3d, IDirect3DDevice *d3d_device)
643 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
645 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
647 if (!d3d || !d3d_device)
648 return D3DRMERR_BADVALUE;
650 return d3drm_device_set_ddraw_device_d3d(device, d3d, d3d_device);
653 static HRESULT WINAPI d3drm_device3_InitFromClipper(IDirect3DRMDevice3 *iface,
654 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
656 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
658 FIXME("iface %p, clipper %p, guid %s, width %d, height %d stub!\n",
659 iface, clipper, debugstr_guid(guid), width, height);
661 device->height = height;
662 device->width = width;
664 return D3DRM_OK;
667 static HRESULT WINAPI d3drm_device2_InitFromClipper(IDirect3DRMDevice2 *iface,
668 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
670 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
672 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n",
673 iface, clipper, debugstr_guid(guid), width, height);
675 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface,
676 clipper, guid, width, height);
679 static HRESULT WINAPI d3drm_device1_InitFromClipper(IDirect3DRMDevice *iface,
680 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
682 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
684 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n",
685 iface, clipper, debugstr_guid(guid), width, height);
687 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface,
688 clipper, guid, width, height);
691 static HRESULT WINAPI d3drm_device3_Update(IDirect3DRMDevice3 *iface)
693 FIXME("iface %p stub!\n", iface);
695 return D3DRM_OK;
698 static HRESULT WINAPI d3drm_device2_Update(IDirect3DRMDevice2 *iface)
700 FIXME("iface %p stub!\n", iface);
702 return D3DRM_OK;
705 static HRESULT WINAPI d3drm_device1_Update(IDirect3DRMDevice *iface)
707 FIXME("iface %p stub!\n", iface);
709 return D3DRM_OK;
712 static HRESULT WINAPI d3drm_device3_AddUpdateCallback(IDirect3DRMDevice3 *iface,
713 D3DRMUPDATECALLBACK cb, void *ctx)
715 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
717 return E_NOTIMPL;
720 static HRESULT WINAPI d3drm_device2_AddUpdateCallback(IDirect3DRMDevice2 *iface,
721 D3DRMUPDATECALLBACK cb, void *ctx)
723 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
725 return E_NOTIMPL;
728 static HRESULT WINAPI d3drm_device1_AddUpdateCallback(IDirect3DRMDevice *iface,
729 D3DRMUPDATECALLBACK cb, void *ctx)
731 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
733 return E_NOTIMPL;
736 static HRESULT WINAPI d3drm_device3_DeleteUpdateCallback(IDirect3DRMDevice3 *iface,
737 D3DRMUPDATECALLBACK cb, void *ctx)
739 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
741 return E_NOTIMPL;
744 static HRESULT WINAPI d3drm_device2_DeleteUpdateCallback(IDirect3DRMDevice2 *iface,
745 D3DRMUPDATECALLBACK cb, void *ctx)
747 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
749 return E_NOTIMPL;
752 static HRESULT WINAPI d3drm_device1_DeleteUpdateCallback(IDirect3DRMDevice *iface,
753 D3DRMUPDATECALLBACK cb, void *ctx)
755 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
757 return E_NOTIMPL;
760 static HRESULT WINAPI d3drm_device3_SetBufferCount(IDirect3DRMDevice3 *iface, DWORD count)
762 FIXME("iface %p, count %u stub!\n", iface, count);
764 return E_NOTIMPL;
767 static HRESULT WINAPI d3drm_device2_SetBufferCount(IDirect3DRMDevice2 *iface, DWORD count)
769 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
771 TRACE("iface %p, count %u.\n", iface, count);
773 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count);
776 static HRESULT WINAPI d3drm_device1_SetBufferCount(IDirect3DRMDevice *iface, DWORD count)
778 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
780 TRACE("iface %p, count %u.\n", iface, count);
782 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count);
785 static DWORD WINAPI d3drm_device3_GetBufferCount(IDirect3DRMDevice3 *iface)
787 FIXME("iface %p stub!\n", iface);
789 return E_NOTIMPL;
792 static DWORD WINAPI d3drm_device2_GetBufferCount(IDirect3DRMDevice2 *iface)
794 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
796 TRACE("iface %p.\n", iface);
798 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface);
801 static DWORD WINAPI d3drm_device1_GetBufferCount(IDirect3DRMDevice *iface)
803 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
805 TRACE("iface %p.\n", iface);
807 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface);
810 static HRESULT WINAPI d3drm_device3_SetDither(IDirect3DRMDevice3 *iface, BOOL enable)
812 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
814 TRACE("iface %p, enable %#x.\n", iface, enable);
816 device->dither = enable;
818 return D3DRM_OK;
821 static HRESULT WINAPI d3drm_device2_SetDither(IDirect3DRMDevice2 *iface, BOOL enable)
823 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
825 TRACE("iface %p, enabled %#x.\n", iface, enable);
827 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable);
830 static HRESULT WINAPI d3drm_device1_SetDither(IDirect3DRMDevice *iface, BOOL enable)
832 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
834 TRACE("iface %p, enabled %#x.\n", iface, enable);
836 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable);
839 static HRESULT WINAPI d3drm_device3_SetShades(IDirect3DRMDevice3 *iface, DWORD count)
841 FIXME("iface %p, count %u stub!\n", iface, count);
843 return E_NOTIMPL;
846 static HRESULT WINAPI d3drm_device2_SetShades(IDirect3DRMDevice2 *iface, DWORD count)
848 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
850 TRACE("iface %p, count %u.\n", iface, count);
852 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count);
855 static HRESULT WINAPI d3drm_device1_SetShades(IDirect3DRMDevice *iface, DWORD count)
857 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
859 TRACE("iface %p, count %u.\n", iface, count);
861 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count);
864 static HRESULT WINAPI d3drm_device3_SetQuality(IDirect3DRMDevice3 *iface, D3DRMRENDERQUALITY quality)
866 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
868 TRACE("iface %p, quality %u.\n", iface, quality);
870 device->quality = quality;
872 return D3DRM_OK;
875 static HRESULT WINAPI d3drm_device2_SetQuality(IDirect3DRMDevice2 *iface, D3DRMRENDERQUALITY quality)
877 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
879 TRACE("iface %p, quality %u.\n", iface, quality);
881 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality);
884 static HRESULT WINAPI d3drm_device1_SetQuality(IDirect3DRMDevice *iface, D3DRMRENDERQUALITY quality)
886 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
888 TRACE("iface %p, quality %u.\n", iface, quality);
890 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality);
893 static HRESULT WINAPI d3drm_device3_SetTextureQuality(IDirect3DRMDevice3 *iface, D3DRMTEXTUREQUALITY quality)
895 FIXME("iface %p, quality %u stub!\n", iface, quality);
897 return E_NOTIMPL;
900 static HRESULT WINAPI d3drm_device2_SetTextureQuality(IDirect3DRMDevice2 *iface, D3DRMTEXTUREQUALITY quality)
902 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
904 TRACE("iface %p, quality %u.\n", iface, quality);
906 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality);
909 static HRESULT WINAPI d3drm_device1_SetTextureQuality(IDirect3DRMDevice *iface, D3DRMTEXTUREQUALITY quality)
911 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
913 TRACE("iface %p, quality %u.\n", iface, quality);
915 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality);
918 static HRESULT WINAPI d3drm_device3_GetViewports(IDirect3DRMDevice3 *iface, IDirect3DRMViewportArray **array)
920 FIXME("iface %p, array %p stub!\n", iface, array);
922 return E_NOTIMPL;
925 static HRESULT WINAPI d3drm_device2_GetViewports(IDirect3DRMDevice2 *iface, IDirect3DRMViewportArray **array)
927 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
929 TRACE("iface %p, array %p.\n", iface, array);
931 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array);
934 static HRESULT WINAPI d3drm_device1_GetViewports(IDirect3DRMDevice *iface, IDirect3DRMViewportArray **array)
936 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
938 TRACE("iface %p, array %p.\n", iface, array);
940 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array);
943 static BOOL WINAPI d3drm_device3_GetDither(IDirect3DRMDevice3 *iface)
945 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
947 TRACE("iface %p.\n", iface);
949 return device->dither;
952 static BOOL WINAPI d3drm_device2_GetDither(IDirect3DRMDevice2 *iface)
954 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
956 TRACE("iface %p.\n", iface);
958 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface);
961 static BOOL WINAPI d3drm_device1_GetDither(IDirect3DRMDevice *iface)
963 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
965 TRACE("iface %p.\n", iface);
967 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface);
970 static DWORD WINAPI d3drm_device3_GetShades(IDirect3DRMDevice3 *iface)
972 FIXME("iface %p stub!\n", iface);
974 return E_NOTIMPL;
977 static DWORD WINAPI d3drm_device2_GetShades(IDirect3DRMDevice2 *iface)
979 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
981 TRACE("iface %p.\n", iface);
983 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface);
986 static DWORD WINAPI d3drm_device1_GetShades(IDirect3DRMDevice *iface)
988 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
990 TRACE("iface %p.\n", iface);
992 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface);
995 static DWORD WINAPI d3drm_device3_GetHeight(IDirect3DRMDevice3 *iface)
997 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
999 TRACE("iface %p.\n", iface);
1001 return device->height;
1004 static DWORD WINAPI d3drm_device2_GetHeight(IDirect3DRMDevice2 *iface)
1006 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1008 TRACE("iface %p.\n", iface);
1010 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface);
1013 static DWORD WINAPI d3drm_device1_GetHeight(IDirect3DRMDevice *iface)
1015 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1017 TRACE("iface %p.\n", iface);
1019 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface);
1022 static DWORD WINAPI d3drm_device3_GetWidth(IDirect3DRMDevice3 *iface)
1024 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1026 TRACE("iface %p.\n", iface);
1028 return device->width;
1031 static DWORD WINAPI d3drm_device2_GetWidth(IDirect3DRMDevice2 *iface)
1033 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1035 TRACE("iface %p.\n", iface);
1037 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface);
1040 static DWORD WINAPI d3drm_device1_GetWidth(IDirect3DRMDevice *iface)
1042 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1044 TRACE("iface %p.\n", iface);
1046 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface);
1049 static DWORD WINAPI d3drm_device3_GetTrianglesDrawn(IDirect3DRMDevice3 *iface)
1051 FIXME("iface %p stub!\n", iface);
1053 return E_NOTIMPL;
1056 static DWORD WINAPI d3drm_device2_GetTrianglesDrawn(IDirect3DRMDevice2 *iface)
1058 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1060 TRACE("iface %p.\n", iface);
1062 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface);
1065 static DWORD WINAPI d3drm_device1_GetTrianglesDrawn(IDirect3DRMDevice *iface)
1067 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1069 TRACE("iface %p.\n", iface);
1071 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface);
1074 static DWORD WINAPI d3drm_device3_GetWireframeOptions(IDirect3DRMDevice3 *iface)
1076 FIXME("iface %p stub!\n", iface);
1078 return E_NOTIMPL;
1081 static DWORD WINAPI d3drm_device2_GetWireframeOptions(IDirect3DRMDevice2 *iface)
1083 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1085 TRACE("iface %p.\n", iface);
1087 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface);
1090 static DWORD WINAPI d3drm_device1_GetWireframeOptions(IDirect3DRMDevice *iface)
1092 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1094 TRACE("iface %p.\n", iface);
1096 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface);
1099 static D3DRMRENDERQUALITY WINAPI d3drm_device3_GetQuality(IDirect3DRMDevice3 *iface)
1101 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1103 TRACE("iface %p.\n", iface);
1105 return device->quality;
1108 static D3DRMRENDERQUALITY WINAPI d3drm_device2_GetQuality(IDirect3DRMDevice2 *iface)
1110 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1112 TRACE("iface %p.\n", iface);
1114 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface);
1117 static D3DRMRENDERQUALITY WINAPI d3drm_device1_GetQuality(IDirect3DRMDevice *iface)
1119 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1121 TRACE("iface %p.\n", iface);
1123 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface);
1126 static D3DCOLORMODEL WINAPI d3drm_device3_GetColorModel(IDirect3DRMDevice3 *iface)
1128 FIXME("iface %p stub!\n", iface);
1130 return E_NOTIMPL;
1133 static D3DCOLORMODEL WINAPI d3drm_device2_GetColorModel(IDirect3DRMDevice2 *iface)
1135 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1137 TRACE("iface %p.\n", iface);
1139 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
1142 static D3DCOLORMODEL WINAPI d3drm_device1_GetColorModel(IDirect3DRMDevice *iface)
1144 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1146 TRACE("iface %p.\n", iface);
1148 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
1151 static D3DRMTEXTUREQUALITY WINAPI d3drm_device3_GetTextureQuality(IDirect3DRMDevice3 *iface)
1153 FIXME("iface %p stub!\n", iface);
1155 return E_NOTIMPL;
1158 static D3DRMTEXTUREQUALITY WINAPI d3drm_device2_GetTextureQuality(IDirect3DRMDevice2 *iface)
1160 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1162 TRACE("iface %p.\n", iface);
1164 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface);
1167 static D3DRMTEXTUREQUALITY WINAPI d3drm_device1_GetTextureQuality(IDirect3DRMDevice *iface)
1169 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1171 TRACE("iface %p.\n", iface);
1173 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface);
1176 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice(IDirect3DRMDevice3 *iface, IDirect3DDevice **d3d_device)
1178 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1179 TRACE("iface %p, d3d_device %p!\n", iface, d3d_device);
1181 *d3d_device = device->device;
1182 IDirect3DDevice_AddRef(*d3d_device);
1184 return D3DRM_OK;
1187 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice(IDirect3DRMDevice2 *iface, IDirect3DDevice **d3d_device)
1189 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1191 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1193 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device);
1196 static HRESULT WINAPI d3drm_device1_GetDirect3DDevice(IDirect3DRMDevice *iface, IDirect3DDevice **d3d_device)
1198 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1200 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1202 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device);
1205 static HRESULT WINAPI d3drm_device3_InitFromD3D2(IDirect3DRMDevice3 *iface,
1206 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device)
1208 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1209 IDirect3D *d3d1;
1210 IDirect3DDevice *d3d_device1;
1211 HRESULT hr;
1213 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
1215 if (!d3d || !d3d_device)
1216 return D3DRMERR_BADVALUE;
1218 if (FAILED(hr = IDirect3D2_QueryInterface(d3d, &IID_IDirect3D, (void **)&d3d1)))
1219 return hr;
1220 if (FAILED(hr = IDirect3DDevice2_QueryInterface(d3d_device, &IID_IDirect3DDevice, (void **)&d3d_device1)))
1222 IDirect3D_Release(d3d1);
1223 return hr;
1226 hr = d3drm_device_set_ddraw_device_d3d(device, d3d1, d3d_device1);
1227 IDirect3D_Release(d3d1);
1228 IDirect3DDevice_Release(d3d_device1);
1230 return hr;
1233 static HRESULT WINAPI d3drm_device2_InitFromD3D2(IDirect3DRMDevice2 *iface,
1234 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device)
1236 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1238 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
1240 return d3drm_device3_InitFromD3D2(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
1243 static HRESULT WINAPI d3drm_device3_InitFromSurface(IDirect3DRMDevice3 *iface,
1244 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer)
1246 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p stub!\n",
1247 iface, debugstr_guid(guid), ddraw, backbuffer);
1249 return E_NOTIMPL;
1252 static HRESULT WINAPI d3drm_device2_InitFromSurface(IDirect3DRMDevice2 *iface,
1253 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer)
1255 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1257 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p.\n",
1258 iface, debugstr_guid(guid), ddraw, backbuffer);
1260 return d3drm_device3_InitFromSurface(&device->IDirect3DRMDevice3_iface, guid, ddraw, backbuffer);
1263 static HRESULT WINAPI d3drm_device3_SetRenderMode(IDirect3DRMDevice3 *iface, DWORD flags)
1265 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1267 TRACE("iface %p, flags %#x.\n", iface, flags);
1269 device->rendermode = flags;
1271 return D3DRM_OK;
1274 static HRESULT WINAPI d3drm_device2_SetRenderMode(IDirect3DRMDevice2 *iface, DWORD flags)
1276 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1278 TRACE("iface %p, flags %#x.\n", iface, flags);
1280 return d3drm_device3_SetRenderMode(&device->IDirect3DRMDevice3_iface, flags);
1283 static DWORD WINAPI d3drm_device3_GetRenderMode(IDirect3DRMDevice3 *iface)
1285 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1287 TRACE("iface %p.\n", iface);
1289 return device->rendermode;
1292 static DWORD WINAPI d3drm_device2_GetRenderMode(IDirect3DRMDevice2 *iface)
1294 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1296 TRACE("iface %p.\n", iface);
1298 return d3drm_device3_GetRenderMode(&device->IDirect3DRMDevice3_iface);
1301 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice2(IDirect3DRMDevice3 *iface, IDirect3DDevice2 **d3d_device)
1303 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1305 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1307 if (FAILED(IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device)))
1308 return D3DRMERR_BADOBJECT;
1310 return D3DRM_OK;
1313 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice2(IDirect3DRMDevice2 *iface, IDirect3DDevice2 **d3d_device)
1315 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1317 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1319 IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device);
1321 /* d3drm returns D3DRM_OK even if the call fails. */
1322 return D3DRM_OK;
1325 static HRESULT WINAPI d3drm_device3_FindPreferredTextureFormat(IDirect3DRMDevice3 *iface,
1326 DWORD bitdepths, DWORD flags, DDPIXELFORMAT *pf)
1328 FIXME("iface %p, bitdepths %u, flags %#x, pf %p stub!\n", iface, bitdepths, flags, pf);
1330 return E_NOTIMPL;
1333 static HRESULT WINAPI d3drm_device3_RenderStateChange(IDirect3DRMDevice3 *iface,
1334 D3DRENDERSTATETYPE state, DWORD value, DWORD flags)
1336 FIXME("iface %p, state %#x, value %#x, flags %#x stub!\n", iface, state, value, flags);
1338 return E_NOTIMPL;
1341 static HRESULT WINAPI d3drm_device3_LightStateChange(IDirect3DRMDevice3 *iface,
1342 D3DLIGHTSTATETYPE state, DWORD value, DWORD flags)
1344 FIXME("iface %p, state %#x, value %#x, flags %#x stub!\n", iface, state, value, flags);
1346 return E_NOTIMPL;
1349 static HRESULT WINAPI d3drm_device3_GetStateChangeOptions(IDirect3DRMDevice3 *iface,
1350 DWORD state_class, DWORD state_idx, DWORD *flags)
1352 FIXME("iface %p, state_class %#x, state_idx %#x, flags %p stub!\n",
1353 iface, state_class, state_idx, flags);
1355 return E_NOTIMPL;
1358 static HRESULT WINAPI d3drm_device3_SetStateChangeOptions(IDirect3DRMDevice3 *iface,
1359 DWORD state_class, DWORD state_idx, DWORD flags)
1361 FIXME("iface %p, state_class %#x, state_idx %#x, flags %#x stub!\n",
1362 iface, state_class, state_idx, flags);
1364 return E_NOTIMPL;
1367 static const struct IDirect3DRMDevice3Vtbl d3drm_device3_vtbl =
1369 d3drm_device3_QueryInterface,
1370 d3drm_device3_AddRef,
1371 d3drm_device3_Release,
1372 d3drm_device3_Clone,
1373 d3drm_device3_AddDestroyCallback,
1374 d3drm_device3_DeleteDestroyCallback,
1375 d3drm_device3_SetAppData,
1376 d3drm_device3_GetAppData,
1377 d3drm_device3_SetName,
1378 d3drm_device3_GetName,
1379 d3drm_device3_GetClassName,
1380 d3drm_device3_Init,
1381 d3drm_device3_InitFromD3D,
1382 d3drm_device3_InitFromClipper,
1383 d3drm_device3_Update,
1384 d3drm_device3_AddUpdateCallback,
1385 d3drm_device3_DeleteUpdateCallback,
1386 d3drm_device3_SetBufferCount,
1387 d3drm_device3_GetBufferCount,
1388 d3drm_device3_SetDither,
1389 d3drm_device3_SetShades,
1390 d3drm_device3_SetQuality,
1391 d3drm_device3_SetTextureQuality,
1392 d3drm_device3_GetViewports,
1393 d3drm_device3_GetDither,
1394 d3drm_device3_GetShades,
1395 d3drm_device3_GetHeight,
1396 d3drm_device3_GetWidth,
1397 d3drm_device3_GetTrianglesDrawn,
1398 d3drm_device3_GetWireframeOptions,
1399 d3drm_device3_GetQuality,
1400 d3drm_device3_GetColorModel,
1401 d3drm_device3_GetTextureQuality,
1402 d3drm_device3_GetDirect3DDevice,
1403 d3drm_device3_InitFromD3D2,
1404 d3drm_device3_InitFromSurface,
1405 d3drm_device3_SetRenderMode,
1406 d3drm_device3_GetRenderMode,
1407 d3drm_device3_GetDirect3DDevice2,
1408 d3drm_device3_FindPreferredTextureFormat,
1409 d3drm_device3_RenderStateChange,
1410 d3drm_device3_LightStateChange,
1411 d3drm_device3_GetStateChangeOptions,
1412 d3drm_device3_SetStateChangeOptions,
1415 static const struct IDirect3DRMDevice2Vtbl d3drm_device2_vtbl =
1417 d3drm_device2_QueryInterface,
1418 d3drm_device2_AddRef,
1419 d3drm_device2_Release,
1420 d3drm_device2_Clone,
1421 d3drm_device2_AddDestroyCallback,
1422 d3drm_device2_DeleteDestroyCallback,
1423 d3drm_device2_SetAppData,
1424 d3drm_device2_GetAppData,
1425 d3drm_device2_SetName,
1426 d3drm_device2_GetName,
1427 d3drm_device2_GetClassName,
1428 d3drm_device2_Init,
1429 d3drm_device2_InitFromD3D,
1430 d3drm_device2_InitFromClipper,
1431 d3drm_device2_Update,
1432 d3drm_device2_AddUpdateCallback,
1433 d3drm_device2_DeleteUpdateCallback,
1434 d3drm_device2_SetBufferCount,
1435 d3drm_device2_GetBufferCount,
1436 d3drm_device2_SetDither,
1437 d3drm_device2_SetShades,
1438 d3drm_device2_SetQuality,
1439 d3drm_device2_SetTextureQuality,
1440 d3drm_device2_GetViewports,
1441 d3drm_device2_GetDither,
1442 d3drm_device2_GetShades,
1443 d3drm_device2_GetHeight,
1444 d3drm_device2_GetWidth,
1445 d3drm_device2_GetTrianglesDrawn,
1446 d3drm_device2_GetWireframeOptions,
1447 d3drm_device2_GetQuality,
1448 d3drm_device2_GetColorModel,
1449 d3drm_device2_GetTextureQuality,
1450 d3drm_device2_GetDirect3DDevice,
1451 d3drm_device2_InitFromD3D2,
1452 d3drm_device2_InitFromSurface,
1453 d3drm_device2_SetRenderMode,
1454 d3drm_device2_GetRenderMode,
1455 d3drm_device2_GetDirect3DDevice2,
1458 static const struct IDirect3DRMDeviceVtbl d3drm_device1_vtbl =
1460 d3drm_device1_QueryInterface,
1461 d3drm_device1_AddRef,
1462 d3drm_device1_Release,
1463 d3drm_device1_Clone,
1464 d3drm_device1_AddDestroyCallback,
1465 d3drm_device1_DeleteDestroyCallback,
1466 d3drm_device1_SetAppData,
1467 d3drm_device1_GetAppData,
1468 d3drm_device1_SetName,
1469 d3drm_device1_GetName,
1470 d3drm_device1_GetClassName,
1471 d3drm_device1_Init,
1472 d3drm_device1_InitFromD3D,
1473 d3drm_device1_InitFromClipper,
1474 d3drm_device1_Update,
1475 d3drm_device1_AddUpdateCallback,
1476 d3drm_device1_DeleteUpdateCallback,
1477 d3drm_device1_SetBufferCount,
1478 d3drm_device1_GetBufferCount,
1479 d3drm_device1_SetDither,
1480 d3drm_device1_SetShades,
1481 d3drm_device1_SetQuality,
1482 d3drm_device1_SetTextureQuality,
1483 d3drm_device1_GetViewports,
1484 d3drm_device1_GetDither,
1485 d3drm_device1_GetShades,
1486 d3drm_device1_GetHeight,
1487 d3drm_device1_GetWidth,
1488 d3drm_device1_GetTrianglesDrawn,
1489 d3drm_device1_GetWireframeOptions,
1490 d3drm_device1_GetQuality,
1491 d3drm_device1_GetColorModel,
1492 d3drm_device1_GetTextureQuality,
1493 d3drm_device1_GetDirect3DDevice,
1496 static HRESULT WINAPI d3drm_device_win_QueryInterface(IDirect3DRMWinDevice *iface, REFIID riid, void **out)
1498 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1500 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
1502 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
1505 static ULONG WINAPI d3drm_device_win_AddRef(IDirect3DRMWinDevice *iface)
1507 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1509 TRACE("iface %p.\n", iface);
1511 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
1514 static ULONG WINAPI d3drm_device_win_Release(IDirect3DRMWinDevice *iface)
1516 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1518 TRACE("iface %p.\n", iface);
1520 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
1523 static HRESULT WINAPI d3drm_device_win_Clone(IDirect3DRMWinDevice *iface,
1524 IUnknown *outer, REFIID iid, void **out)
1526 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1528 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out);
1530 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
1533 static HRESULT WINAPI d3drm_device_win_AddDestroyCallback(IDirect3DRMWinDevice *iface,
1534 D3DRMOBJECTCALLBACK cb, void *ctx)
1536 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1538 return E_NOTIMPL;
1541 static HRESULT WINAPI d3drm_device_win_DeleteDestroyCallback(IDirect3DRMWinDevice *iface,
1542 D3DRMOBJECTCALLBACK cb, void *ctx)
1544 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1546 return E_NOTIMPL;
1549 static HRESULT WINAPI d3drm_device_win_SetAppData(IDirect3DRMWinDevice *iface, DWORD data)
1551 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1553 TRACE("iface %p, data %#x.\n", iface, data);
1555 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
1558 static DWORD WINAPI d3drm_device_win_GetAppData(IDirect3DRMWinDevice *iface)
1560 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1562 TRACE("iface %p.\n", iface);
1564 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
1567 static HRESULT WINAPI d3drm_device_win_SetName(IDirect3DRMWinDevice *iface, const char *name)
1569 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1571 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1573 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
1576 static HRESULT WINAPI d3drm_device_win_GetName(IDirect3DRMWinDevice *iface, DWORD *size, char *name)
1578 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1580 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1582 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
1585 static HRESULT WINAPI d3drm_device_win_GetClassName(IDirect3DRMWinDevice *iface, DWORD *size, char *name)
1587 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1589 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1591 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
1594 static HRESULT WINAPI d3drm_device_win_HandlePaint(IDirect3DRMWinDevice *iface, HDC dc)
1596 FIXME("iface %p, dc %p stub!\n", iface, dc);
1598 return D3DRM_OK;
1601 static HRESULT WINAPI d3drm_device_win_HandleActivate(IDirect3DRMWinDevice *iface, WORD wparam)
1603 FIXME("iface %p, wparam %#x stub!\n", iface, wparam);
1605 return D3DRM_OK;
1608 static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl =
1610 d3drm_device_win_QueryInterface,
1611 d3drm_device_win_AddRef,
1612 d3drm_device_win_Release,
1613 d3drm_device_win_Clone,
1614 d3drm_device_win_AddDestroyCallback,
1615 d3drm_device_win_DeleteDestroyCallback,
1616 d3drm_device_win_SetAppData,
1617 d3drm_device_win_GetAppData,
1618 d3drm_device_win_SetName,
1619 d3drm_device_win_GetName,
1620 d3drm_device_win_GetClassName,
1621 d3drm_device_win_HandlePaint,
1622 d3drm_device_win_HandleActivate,
1625 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface)
1627 if (!iface)
1628 return NULL;
1629 assert(iface->lpVtbl == &d3drm_device3_vtbl);
1631 return impl_from_IDirect3DRMDevice3(iface);
1634 HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm)
1636 static const char classname[] = "Device";
1637 struct d3drm_device *object;
1639 TRACE("device %p, d3drm %p.\n", device, d3drm);
1641 if (!(object = heap_alloc_zero(sizeof(*object))))
1642 return E_OUTOFMEMORY;
1644 object->IDirect3DRMDevice_iface.lpVtbl = &d3drm_device1_vtbl;
1645 object->IDirect3DRMDevice2_iface.lpVtbl = &d3drm_device2_vtbl;
1646 object->IDirect3DRMDevice3_iface.lpVtbl = &d3drm_device3_vtbl;
1647 object->IDirect3DRMWinDevice_iface.lpVtbl = &d3drm_device_win_vtbl;
1648 object->d3drm = d3drm;
1649 d3drm_object_init(&object->obj, classname);
1651 *device = object;
1653 return D3DRM_OK;