uiautomationcore: Add support for UIA_ProviderDescriptionPropertyId.
[wine.git] / dlls / d3drm / device.c
blob3be3cbdf68ea6b6066ccb08ae6772fc03dc0e654
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 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 IDirect3DDevice3 *device3 = NULL;
128 IDirect3D2 *d3d2 = NULL;
129 IDirect3D3 *d3d3 = NULL;
130 DDSURFACEDESC desc, surface_desc;
131 HRESULT hr;
133 device->ddraw = ddraw;
134 IDirectDraw_AddRef(ddraw);
135 IDirect3DRM_AddRef(device->d3drm);
136 device->render_target = surface;
137 IDirectDrawSurface_AddRef(surface);
139 desc.dwSize = sizeof(desc);
140 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
141 if (FAILED(hr))
142 return hr;
144 if (!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE))
145 return DDERR_INVALIDCAPS;
147 hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
148 if (SUCCEEDED(hr))
150 create_z_surface = FALSE;
151 IDirectDrawSurface_Release(ds);
152 ds = NULL;
155 if (create_z_surface)
157 memset(&surface_desc, 0, sizeof(surface_desc));
158 surface_desc.dwSize = sizeof(surface_desc);
159 surface_desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
160 surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
161 surface_desc.u2.dwZBufferBitDepth = 16;
162 surface_desc.dwWidth = desc.dwWidth;
163 surface_desc.dwHeight = desc.dwHeight;
164 hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &ds, NULL);
165 if (FAILED(hr))
166 return hr;
168 hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
169 IDirectDrawSurface_Release(ds);
170 if (FAILED(hr))
171 return hr;
174 if (version == 1)
175 hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DRGBDevice, (void **)&device1);
176 else if (version == 2)
178 IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D2, (void**)&d3d2);
179 hr = IDirect3D2_CreateDevice(d3d2, &IID_IDirect3DRGBDevice, surface, &device2);
180 IDirect3D2_Release(d3d2);
182 else
184 IDirectDrawSurface4 *surface4 = NULL;
186 IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface4, (void**)&surface4);
187 IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D3, (void**)&d3d3);
188 hr = IDirect3D3_CreateDevice(d3d3, &IID_IDirect3DRGBDevice, surface4, &device3, NULL);
189 IDirectDrawSurface4_Release(surface4);
190 IDirect3D3_Release(d3d3);
192 if (FAILED(hr))
194 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
195 return hr;
198 if (version == 2)
200 hr = IDirect3DDevice2_QueryInterface(device2, &IID_IDirect3DDevice, (void**)&device1);
201 IDirect3DDevice2_Release(device2);
202 if (FAILED(hr))
204 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
205 return hr;
208 else if (version == 3)
210 hr = IDirect3DDevice3_QueryInterface(device3, &IID_IDirect3DDevice, (void**)&device1);
211 IDirect3DDevice3_Release(device3);
212 if (FAILED(hr))
214 IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
215 return hr;
218 device->device = device1;
219 device->width = desc.dwWidth;
220 device->height = desc.dwHeight;
222 return hr;
225 static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device)
227 IDirectDraw *ddraw;
228 IDirectDrawSurface *surface;
229 IDirect3DDevice2 *d3d_device2 = NULL;
230 DDSURFACEDESC desc;
231 HRESULT hr;
233 /* AddRef these interfaces beforehand for the intentional leak on reinitialization. */
234 if (FAILED(hr = IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&ddraw)))
235 return hr;
236 IDirect3DRM_AddRef(device->d3drm);
237 IDirect3DDevice_AddRef(d3d_device);
239 /* Fetch render target and get width/height from there */
240 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
242 if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirect3DDevice2, (void **)&d3d_device2)))
243 return hr;
244 hr = IDirect3DDevice2_GetRenderTarget(d3d_device2, &surface);
245 IDirect3DDevice2_Release(d3d_device2);
246 if (FAILED(hr))
247 return hr;
250 if (device->ddraw)
252 if (d3d_device2)
253 IDirectDrawSurface_Release(surface);
254 return D3DRMERR_BADOBJECT;
257 desc.dwSize = sizeof(desc);
258 hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
259 if (FAILED(hr))
261 IDirectDrawSurface_Release(surface);
262 return hr;
265 device->ddraw = ddraw;
266 device->width = desc.dwWidth;
267 device->height = desc.dwHeight;
268 device->device = d3d_device;
269 device->render_target = surface;
271 return hr;
274 static HRESULT WINAPI d3drm_device3_QueryInterface(IDirect3DRMDevice3 *iface, REFIID riid, void **out)
276 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
278 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
280 if (IsEqualGUID(riid, &IID_IDirect3DRMDevice)
281 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
282 || IsEqualGUID(riid, &IID_IUnknown))
284 *out = &device->IDirect3DRMDevice_iface;
286 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice2))
288 *out = &device->IDirect3DRMDevice2_iface;
290 else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice3))
292 *out = &device->IDirect3DRMDevice3_iface;
294 else if (IsEqualGUID(riid, &IID_IDirect3DRMWinDevice))
296 *out = &device->IDirect3DRMWinDevice_iface;
298 else
300 *out = NULL;
301 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
302 return CLASS_E_CLASSNOTAVAILABLE;
305 IUnknown_AddRef((IUnknown *)*out);
306 return S_OK;
309 static HRESULT WINAPI d3drm_device2_QueryInterface(IDirect3DRMDevice2 *iface, REFIID riid, void **out)
311 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
313 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
315 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
318 static HRESULT WINAPI d3drm_device1_QueryInterface(IDirect3DRMDevice *iface, REFIID riid, void **out)
320 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
322 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
324 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
327 static ULONG WINAPI d3drm_device3_AddRef(IDirect3DRMDevice3 *iface)
329 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
330 ULONG refcount = InterlockedIncrement(&device->obj.ref);
332 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
334 return refcount;
337 static ULONG WINAPI d3drm_device2_AddRef(IDirect3DRMDevice2 *iface)
339 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
341 TRACE("iface %p.\n", iface);
343 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
346 static ULONG WINAPI d3drm_device1_AddRef(IDirect3DRMDevice *iface)
348 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
350 TRACE("iface %p.\n", iface);
352 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
355 static ULONG WINAPI d3drm_device3_Release(IDirect3DRMDevice3 *iface)
357 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
358 ULONG refcount = InterlockedDecrement(&device->obj.ref);
360 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
362 if (!refcount)
363 d3drm_device_destroy(device);
365 return refcount;
368 static ULONG WINAPI d3drm_device2_Release(IDirect3DRMDevice2 *iface)
370 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
372 TRACE("iface %p.\n", iface);
374 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
377 static ULONG WINAPI d3drm_device1_Release(IDirect3DRMDevice *iface)
379 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
381 TRACE("iface %p.\n", iface);
383 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
386 static HRESULT WINAPI d3drm_device3_Clone(IDirect3DRMDevice3 *iface,
387 IUnknown *outer, REFIID iid, void **out)
389 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
391 return E_NOTIMPL;
394 static HRESULT WINAPI d3drm_device2_Clone(IDirect3DRMDevice2 *iface,
395 IUnknown *outer, REFIID iid, void **out)
397 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
399 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out);
401 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
404 static HRESULT WINAPI d3drm_device1_Clone(IDirect3DRMDevice *iface,
405 IUnknown *outer, REFIID iid, void **out)
407 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
409 TRACE("iface %p, outer %p, iid %s, out %p.\n", iface, outer, debugstr_guid(iid), out);
411 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
414 static HRESULT WINAPI d3drm_device3_AddDestroyCallback(IDirect3DRMDevice3 *iface,
415 D3DRMOBJECTCALLBACK cb, void *ctx)
417 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
419 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
421 return d3drm_object_add_destroy_callback(&device->obj, cb, ctx);
424 static HRESULT WINAPI d3drm_device2_AddDestroyCallback(IDirect3DRMDevice2 *iface,
425 D3DRMOBJECTCALLBACK cb, void *ctx)
427 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
429 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
431 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
434 static HRESULT WINAPI d3drm_device1_AddDestroyCallback(IDirect3DRMDevice *iface,
435 D3DRMOBJECTCALLBACK cb, void *ctx)
437 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
439 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
441 return d3drm_device3_AddDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
444 static HRESULT WINAPI d3drm_device3_DeleteDestroyCallback(IDirect3DRMDevice3 *iface,
445 D3DRMOBJECTCALLBACK cb, void *ctx)
447 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
449 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
451 return d3drm_object_delete_destroy_callback(&device->obj, cb, ctx);
454 static HRESULT WINAPI d3drm_device2_DeleteDestroyCallback(IDirect3DRMDevice2 *iface,
455 D3DRMOBJECTCALLBACK cb, void *ctx)
457 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
459 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
461 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
464 static HRESULT WINAPI d3drm_device1_DeleteDestroyCallback(IDirect3DRMDevice *iface,
465 D3DRMOBJECTCALLBACK cb, void *ctx)
467 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
469 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
471 return d3drm_device3_DeleteDestroyCallback(&device->IDirect3DRMDevice3_iface, cb, ctx);
474 static HRESULT WINAPI d3drm_device3_SetAppData(IDirect3DRMDevice3 *iface, DWORD data)
476 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
478 TRACE("iface %p, data %#lx.\n", iface, data);
480 device->obj.appdata = data;
482 return D3DRM_OK;
485 static HRESULT WINAPI d3drm_device2_SetAppData(IDirect3DRMDevice2 *iface, DWORD data)
487 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
489 TRACE("iface %p, data %#lx.\n", iface, data);
491 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
494 static HRESULT WINAPI d3drm_device1_SetAppData(IDirect3DRMDevice *iface, DWORD data)
496 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
498 TRACE("iface %p, data %#lx.\n", iface, data);
500 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
503 static DWORD WINAPI d3drm_device3_GetAppData(IDirect3DRMDevice3 *iface)
505 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
507 TRACE("iface %p.\n", iface);
509 return device->obj.appdata;
512 static DWORD WINAPI d3drm_device2_GetAppData(IDirect3DRMDevice2 *iface)
514 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
516 TRACE("iface %p.\n", iface);
518 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
521 static DWORD WINAPI d3drm_device1_GetAppData(IDirect3DRMDevice *iface)
523 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
525 TRACE("iface %p.\n", iface);
527 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
530 static HRESULT WINAPI d3drm_device3_SetName(IDirect3DRMDevice3 *iface, const char *name)
532 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
534 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
536 return d3drm_object_set_name(&device->obj, name);
539 static HRESULT WINAPI d3drm_device2_SetName(IDirect3DRMDevice2 *iface, const char *name)
541 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
543 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
545 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
548 static HRESULT WINAPI d3drm_device1_SetName(IDirect3DRMDevice *iface, const char *name)
550 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
552 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
554 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
557 static HRESULT WINAPI d3drm_device3_GetName(IDirect3DRMDevice3 *iface, DWORD *size, char *name)
559 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
561 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
563 return d3drm_object_get_name(&device->obj, size, name);
566 static HRESULT WINAPI d3drm_device2_GetName(IDirect3DRMDevice2 *iface, DWORD *size, char *name)
568 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
570 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
572 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
575 static HRESULT WINAPI d3drm_device1_GetName(IDirect3DRMDevice *iface, DWORD *size, char *name)
577 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
579 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
581 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
584 static HRESULT WINAPI d3drm_device3_GetClassName(IDirect3DRMDevice3 *iface, DWORD *size, char *name)
586 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
588 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
590 return d3drm_object_get_class_name(&device->obj, size, name);
593 static HRESULT WINAPI d3drm_device2_GetClassName(IDirect3DRMDevice2 *iface, DWORD *size, char *name)
595 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
597 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
599 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
602 static HRESULT WINAPI d3drm_device1_GetClassName(IDirect3DRMDevice *iface, DWORD *size, char *name)
604 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
606 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
608 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
611 static HRESULT WINAPI d3drm_device3_Init(IDirect3DRMDevice3 *iface, ULONG width, ULONG height)
613 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
615 FIXME("iface %p, width %lu, height %lu stub!\n", iface, width, height);
617 device->height = height;
618 device->width = width;
620 return D3DRM_OK;
623 static HRESULT WINAPI d3drm_device2_Init(IDirect3DRMDevice2 *iface, ULONG width, ULONG height)
625 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
627 TRACE("iface %p, width %lu, height %lu.\n", iface, width, height);
629 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height);
632 static HRESULT WINAPI d3drm_device1_Init(IDirect3DRMDevice *iface, ULONG width, ULONG height)
634 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
636 TRACE("iface %p, width %lu, height %lu.\n", iface, width, height);
638 return d3drm_device3_Init(&device->IDirect3DRMDevice3_iface, width, height);
641 static HRESULT WINAPI d3drm_device3_InitFromD3D(IDirect3DRMDevice3 *iface,
642 IDirect3D *d3d, IDirect3DDevice *d3d_device)
644 FIXME("iface %p, d3d %p, d3d_device %p stub!\n", iface, d3d, d3d_device);
646 if (!d3d || !d3d_device)
647 return D3DRMERR_BADVALUE;
649 return E_NOINTERFACE;
652 static HRESULT WINAPI d3drm_device2_InitFromD3D(IDirect3DRMDevice2 *iface,
653 IDirect3D *d3d, IDirect3DDevice *d3d_device)
655 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
657 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
659 return d3drm_device3_InitFromD3D(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
662 static HRESULT WINAPI d3drm_device1_InitFromD3D(IDirect3DRMDevice *iface,
663 IDirect3D *d3d, IDirect3DDevice *d3d_device)
665 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
667 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
669 if (!d3d || !d3d_device)
670 return D3DRMERR_BADVALUE;
672 return d3drm_device_set_ddraw_device_d3d(device, d3d, d3d_device);
675 static HRESULT WINAPI d3drm_device3_InitFromClipper(IDirect3DRMDevice3 *iface,
676 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
678 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
680 FIXME("iface %p, clipper %p, guid %s, width %d, height %d stub!\n",
681 iface, clipper, debugstr_guid(guid), width, height);
683 device->height = height;
684 device->width = width;
686 return D3DRM_OK;
689 static HRESULT WINAPI d3drm_device2_InitFromClipper(IDirect3DRMDevice2 *iface,
690 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
692 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
694 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n",
695 iface, clipper, debugstr_guid(guid), width, height);
697 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface,
698 clipper, guid, width, height);
701 static HRESULT WINAPI d3drm_device1_InitFromClipper(IDirect3DRMDevice *iface,
702 IDirectDrawClipper *clipper, GUID *guid, int width, int height)
704 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
706 TRACE("iface %p, clipper %p, guid %s, width %d, height %d.\n",
707 iface, clipper, debugstr_guid(guid), width, height);
709 return d3drm_device3_InitFromClipper(&device->IDirect3DRMDevice3_iface,
710 clipper, guid, width, height);
713 static HRESULT WINAPI d3drm_device3_Update(IDirect3DRMDevice3 *iface)
715 FIXME("iface %p stub!\n", iface);
717 return D3DRM_OK;
720 static HRESULT WINAPI d3drm_device2_Update(IDirect3DRMDevice2 *iface)
722 FIXME("iface %p stub!\n", iface);
724 return D3DRM_OK;
727 static HRESULT WINAPI d3drm_device1_Update(IDirect3DRMDevice *iface)
729 FIXME("iface %p stub!\n", iface);
731 return D3DRM_OK;
734 static HRESULT WINAPI d3drm_device3_AddUpdateCallback(IDirect3DRMDevice3 *iface,
735 D3DRMUPDATECALLBACK cb, void *ctx)
737 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
739 return E_NOTIMPL;
742 static HRESULT WINAPI d3drm_device2_AddUpdateCallback(IDirect3DRMDevice2 *iface,
743 D3DRMUPDATECALLBACK cb, void *ctx)
745 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
747 return E_NOTIMPL;
750 static HRESULT WINAPI d3drm_device1_AddUpdateCallback(IDirect3DRMDevice *iface,
751 D3DRMUPDATECALLBACK cb, void *ctx)
753 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
755 return E_NOTIMPL;
758 static HRESULT WINAPI d3drm_device3_DeleteUpdateCallback(IDirect3DRMDevice3 *iface,
759 D3DRMUPDATECALLBACK cb, void *ctx)
761 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
763 return E_NOTIMPL;
766 static HRESULT WINAPI d3drm_device2_DeleteUpdateCallback(IDirect3DRMDevice2 *iface,
767 D3DRMUPDATECALLBACK cb, void *ctx)
769 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
771 return E_NOTIMPL;
774 static HRESULT WINAPI d3drm_device1_DeleteUpdateCallback(IDirect3DRMDevice *iface,
775 D3DRMUPDATECALLBACK cb, void *ctx)
777 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
779 return E_NOTIMPL;
782 static HRESULT WINAPI d3drm_device3_SetBufferCount(IDirect3DRMDevice3 *iface, DWORD count)
784 FIXME("iface %p, count %lu stub!\n", iface, count);
786 return E_NOTIMPL;
789 static HRESULT WINAPI d3drm_device2_SetBufferCount(IDirect3DRMDevice2 *iface, DWORD count)
791 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
793 TRACE("iface %p, count %lu.\n", iface, count);
795 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count);
798 static HRESULT WINAPI d3drm_device1_SetBufferCount(IDirect3DRMDevice *iface, DWORD count)
800 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
802 TRACE("iface %p, count %lu.\n", iface, count);
804 return d3drm_device3_SetBufferCount(&device->IDirect3DRMDevice3_iface, count);
807 static DWORD WINAPI d3drm_device3_GetBufferCount(IDirect3DRMDevice3 *iface)
809 FIXME("iface %p stub!\n", iface);
811 return E_NOTIMPL;
814 static DWORD WINAPI d3drm_device2_GetBufferCount(IDirect3DRMDevice2 *iface)
816 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
818 TRACE("iface %p.\n", iface);
820 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface);
823 static DWORD WINAPI d3drm_device1_GetBufferCount(IDirect3DRMDevice *iface)
825 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
827 TRACE("iface %p.\n", iface);
829 return d3drm_device3_GetBufferCount(&device->IDirect3DRMDevice3_iface);
832 static HRESULT WINAPI d3drm_device3_SetDither(IDirect3DRMDevice3 *iface, BOOL enable)
834 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
836 TRACE("iface %p, enable %#x.\n", iface, enable);
838 device->dither = enable;
840 return D3DRM_OK;
843 static HRESULT WINAPI d3drm_device2_SetDither(IDirect3DRMDevice2 *iface, BOOL enable)
845 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
847 TRACE("iface %p, enabled %#x.\n", iface, enable);
849 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable);
852 static HRESULT WINAPI d3drm_device1_SetDither(IDirect3DRMDevice *iface, BOOL enable)
854 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
856 TRACE("iface %p, enabled %#x.\n", iface, enable);
858 return d3drm_device3_SetDither(&device->IDirect3DRMDevice3_iface, enable);
861 static HRESULT WINAPI d3drm_device3_SetShades(IDirect3DRMDevice3 *iface, DWORD count)
863 FIXME("iface %p, count %lu stub!\n", iface, count);
865 return E_NOTIMPL;
868 static HRESULT WINAPI d3drm_device2_SetShades(IDirect3DRMDevice2 *iface, DWORD count)
870 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
872 TRACE("iface %p, count %lu.\n", iface, count);
874 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count);
877 static HRESULT WINAPI d3drm_device1_SetShades(IDirect3DRMDevice *iface, DWORD count)
879 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
881 TRACE("iface %p, count %lu.\n", iface, count);
883 return d3drm_device3_SetShades(&device->IDirect3DRMDevice3_iface, count);
886 static HRESULT WINAPI d3drm_device3_SetQuality(IDirect3DRMDevice3 *iface, D3DRMRENDERQUALITY quality)
888 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
890 TRACE("iface %p, quality %lu.\n", iface, quality);
892 device->quality = quality;
894 return D3DRM_OK;
897 static HRESULT WINAPI d3drm_device2_SetQuality(IDirect3DRMDevice2 *iface, D3DRMRENDERQUALITY quality)
899 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
901 TRACE("iface %p, quality %lu.\n", iface, quality);
903 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality);
906 static HRESULT WINAPI d3drm_device1_SetQuality(IDirect3DRMDevice *iface, D3DRMRENDERQUALITY quality)
908 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
910 TRACE("iface %p, quality %lu.\n", iface, quality);
912 return d3drm_device3_SetQuality(&device->IDirect3DRMDevice3_iface, quality);
915 static HRESULT WINAPI d3drm_device3_SetTextureQuality(IDirect3DRMDevice3 *iface, D3DRMTEXTUREQUALITY quality)
917 FIXME("iface %p, quality %u stub!\n", iface, quality);
919 return E_NOTIMPL;
922 static HRESULT WINAPI d3drm_device2_SetTextureQuality(IDirect3DRMDevice2 *iface, D3DRMTEXTUREQUALITY quality)
924 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
926 TRACE("iface %p, quality %u.\n", iface, quality);
928 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality);
931 static HRESULT WINAPI d3drm_device1_SetTextureQuality(IDirect3DRMDevice *iface, D3DRMTEXTUREQUALITY quality)
933 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
935 TRACE("iface %p, quality %u.\n", iface, quality);
937 return d3drm_device3_SetTextureQuality(&device->IDirect3DRMDevice3_iface, quality);
940 static HRESULT WINAPI d3drm_device3_GetViewports(IDirect3DRMDevice3 *iface, IDirect3DRMViewportArray **array)
942 FIXME("iface %p, array %p stub!\n", iface, array);
944 return E_NOTIMPL;
947 static HRESULT WINAPI d3drm_device2_GetViewports(IDirect3DRMDevice2 *iface, IDirect3DRMViewportArray **array)
949 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
951 TRACE("iface %p, array %p.\n", iface, array);
953 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array);
956 static HRESULT WINAPI d3drm_device1_GetViewports(IDirect3DRMDevice *iface, IDirect3DRMViewportArray **array)
958 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
960 TRACE("iface %p, array %p.\n", iface, array);
962 return d3drm_device3_GetViewports(&device->IDirect3DRMDevice3_iface, array);
965 static BOOL WINAPI d3drm_device3_GetDither(IDirect3DRMDevice3 *iface)
967 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
969 TRACE("iface %p.\n", iface);
971 return device->dither;
974 static BOOL WINAPI d3drm_device2_GetDither(IDirect3DRMDevice2 *iface)
976 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
978 TRACE("iface %p.\n", iface);
980 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface);
983 static BOOL WINAPI d3drm_device1_GetDither(IDirect3DRMDevice *iface)
985 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
987 TRACE("iface %p.\n", iface);
989 return d3drm_device3_GetDither(&device->IDirect3DRMDevice3_iface);
992 static DWORD WINAPI d3drm_device3_GetShades(IDirect3DRMDevice3 *iface)
994 FIXME("iface %p stub!\n", iface);
996 return E_NOTIMPL;
999 static DWORD WINAPI d3drm_device2_GetShades(IDirect3DRMDevice2 *iface)
1001 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1003 TRACE("iface %p.\n", iface);
1005 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface);
1008 static DWORD WINAPI d3drm_device1_GetShades(IDirect3DRMDevice *iface)
1010 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1012 TRACE("iface %p.\n", iface);
1014 return d3drm_device3_GetShades(&device->IDirect3DRMDevice3_iface);
1017 static DWORD WINAPI d3drm_device3_GetHeight(IDirect3DRMDevice3 *iface)
1019 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1021 TRACE("iface %p.\n", iface);
1023 return device->height;
1026 static DWORD WINAPI d3drm_device2_GetHeight(IDirect3DRMDevice2 *iface)
1028 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1030 TRACE("iface %p.\n", iface);
1032 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface);
1035 static DWORD WINAPI d3drm_device1_GetHeight(IDirect3DRMDevice *iface)
1037 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1039 TRACE("iface %p.\n", iface);
1041 return d3drm_device3_GetHeight(&device->IDirect3DRMDevice3_iface);
1044 static DWORD WINAPI d3drm_device3_GetWidth(IDirect3DRMDevice3 *iface)
1046 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1048 TRACE("iface %p.\n", iface);
1050 return device->width;
1053 static DWORD WINAPI d3drm_device2_GetWidth(IDirect3DRMDevice2 *iface)
1055 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1057 TRACE("iface %p.\n", iface);
1059 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface);
1062 static DWORD WINAPI d3drm_device1_GetWidth(IDirect3DRMDevice *iface)
1064 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1066 TRACE("iface %p.\n", iface);
1068 return d3drm_device3_GetWidth(&device->IDirect3DRMDevice3_iface);
1071 static DWORD WINAPI d3drm_device3_GetTrianglesDrawn(IDirect3DRMDevice3 *iface)
1073 FIXME("iface %p stub!\n", iface);
1075 return E_NOTIMPL;
1078 static DWORD WINAPI d3drm_device2_GetTrianglesDrawn(IDirect3DRMDevice2 *iface)
1080 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1082 TRACE("iface %p.\n", iface);
1084 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface);
1087 static DWORD WINAPI d3drm_device1_GetTrianglesDrawn(IDirect3DRMDevice *iface)
1089 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1091 TRACE("iface %p.\n", iface);
1093 return d3drm_device3_GetTrianglesDrawn(&device->IDirect3DRMDevice3_iface);
1096 static DWORD WINAPI d3drm_device3_GetWireframeOptions(IDirect3DRMDevice3 *iface)
1098 FIXME("iface %p stub!\n", iface);
1100 return E_NOTIMPL;
1103 static DWORD WINAPI d3drm_device2_GetWireframeOptions(IDirect3DRMDevice2 *iface)
1105 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1107 TRACE("iface %p.\n", iface);
1109 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface);
1112 static DWORD WINAPI d3drm_device1_GetWireframeOptions(IDirect3DRMDevice *iface)
1114 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1116 TRACE("iface %p.\n", iface);
1118 return d3drm_device3_GetWireframeOptions(&device->IDirect3DRMDevice3_iface);
1121 static D3DRMRENDERQUALITY WINAPI d3drm_device3_GetQuality(IDirect3DRMDevice3 *iface)
1123 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1125 TRACE("iface %p.\n", iface);
1127 return device->quality;
1130 static D3DRMRENDERQUALITY WINAPI d3drm_device2_GetQuality(IDirect3DRMDevice2 *iface)
1132 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1134 TRACE("iface %p.\n", iface);
1136 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface);
1139 static D3DRMRENDERQUALITY WINAPI d3drm_device1_GetQuality(IDirect3DRMDevice *iface)
1141 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1143 TRACE("iface %p.\n", iface);
1145 return d3drm_device3_GetQuality(&device->IDirect3DRMDevice3_iface);
1148 static D3DCOLORMODEL WINAPI d3drm_device3_GetColorModel(IDirect3DRMDevice3 *iface)
1150 FIXME("iface %p stub!\n", iface);
1152 return E_NOTIMPL;
1155 static D3DCOLORMODEL WINAPI d3drm_device2_GetColorModel(IDirect3DRMDevice2 *iface)
1157 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1159 TRACE("iface %p.\n", iface);
1161 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
1164 static D3DCOLORMODEL WINAPI d3drm_device1_GetColorModel(IDirect3DRMDevice *iface)
1166 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1168 TRACE("iface %p.\n", iface);
1170 return d3drm_device3_GetColorModel(&device->IDirect3DRMDevice3_iface);
1173 static D3DRMTEXTUREQUALITY WINAPI d3drm_device3_GetTextureQuality(IDirect3DRMDevice3 *iface)
1175 FIXME("iface %p stub!\n", iface);
1177 return E_NOTIMPL;
1180 static D3DRMTEXTUREQUALITY WINAPI d3drm_device2_GetTextureQuality(IDirect3DRMDevice2 *iface)
1182 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1184 TRACE("iface %p.\n", iface);
1186 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface);
1189 static D3DRMTEXTUREQUALITY WINAPI d3drm_device1_GetTextureQuality(IDirect3DRMDevice *iface)
1191 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1193 TRACE("iface %p.\n", iface);
1195 return d3drm_device3_GetTextureQuality(&device->IDirect3DRMDevice3_iface);
1198 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice(IDirect3DRMDevice3 *iface, IDirect3DDevice **d3d_device)
1200 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1201 TRACE("iface %p, d3d_device %p!\n", iface, d3d_device);
1203 *d3d_device = device->device;
1204 IDirect3DDevice_AddRef(*d3d_device);
1206 return D3DRM_OK;
1209 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice(IDirect3DRMDevice2 *iface, IDirect3DDevice **d3d_device)
1211 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1213 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1215 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device);
1218 static HRESULT WINAPI d3drm_device1_GetDirect3DDevice(IDirect3DRMDevice *iface, IDirect3DDevice **d3d_device)
1220 struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
1222 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1224 return d3drm_device3_GetDirect3DDevice(&device->IDirect3DRMDevice3_iface, d3d_device);
1227 static HRESULT WINAPI d3drm_device3_InitFromD3D2(IDirect3DRMDevice3 *iface,
1228 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device)
1230 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1231 IDirect3D *d3d1;
1232 IDirect3DDevice *d3d_device1;
1233 HRESULT hr;
1235 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
1237 if (!d3d || !d3d_device)
1238 return D3DRMERR_BADVALUE;
1240 if (FAILED(hr = IDirect3D2_QueryInterface(d3d, &IID_IDirect3D, (void **)&d3d1)))
1241 return hr;
1242 if (FAILED(hr = IDirect3DDevice2_QueryInterface(d3d_device, &IID_IDirect3DDevice, (void **)&d3d_device1)))
1244 IDirect3D_Release(d3d1);
1245 return hr;
1248 hr = d3drm_device_set_ddraw_device_d3d(device, d3d1, d3d_device1);
1249 IDirect3D_Release(d3d1);
1250 IDirect3DDevice_Release(d3d_device1);
1252 return hr;
1255 static HRESULT WINAPI d3drm_device2_InitFromD3D2(IDirect3DRMDevice2 *iface,
1256 IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device)
1258 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1260 TRACE("iface %p, d3d %p, d3d_device %p.\n", iface, d3d, d3d_device);
1262 return d3drm_device3_InitFromD3D2(&device->IDirect3DRMDevice3_iface, d3d, d3d_device);
1265 static HRESULT WINAPI d3drm_device3_InitFromSurface(IDirect3DRMDevice3 *iface,
1266 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer)
1268 FIXME("iface %p, guid %s, ddraw %p, backbuffer %p stub!\n",
1269 iface, debugstr_guid(guid), ddraw, backbuffer);
1271 return E_NOTIMPL;
1274 static HRESULT WINAPI d3drm_device2_InitFromSurface(IDirect3DRMDevice2 *iface,
1275 GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer)
1277 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1279 TRACE("iface %p, guid %s, ddraw %p, backbuffer %p.\n",
1280 iface, debugstr_guid(guid), ddraw, backbuffer);
1282 return d3drm_device3_InitFromSurface(&device->IDirect3DRMDevice3_iface, guid, ddraw, backbuffer);
1285 static HRESULT WINAPI d3drm_device3_SetRenderMode(IDirect3DRMDevice3 *iface, DWORD flags)
1287 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1289 TRACE("iface %p, flags %#lx.\n", iface, flags);
1291 device->rendermode = flags;
1293 return D3DRM_OK;
1296 static HRESULT WINAPI d3drm_device2_SetRenderMode(IDirect3DRMDevice2 *iface, DWORD flags)
1298 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1300 TRACE("iface %p, flags %#lx.\n", iface, flags);
1302 return d3drm_device3_SetRenderMode(&device->IDirect3DRMDevice3_iface, flags);
1305 static DWORD WINAPI d3drm_device3_GetRenderMode(IDirect3DRMDevice3 *iface)
1307 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1309 TRACE("iface %p.\n", iface);
1311 return device->rendermode;
1314 static DWORD WINAPI d3drm_device2_GetRenderMode(IDirect3DRMDevice2 *iface)
1316 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1318 TRACE("iface %p.\n", iface);
1320 return d3drm_device3_GetRenderMode(&device->IDirect3DRMDevice3_iface);
1323 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice2(IDirect3DRMDevice3 *iface, IDirect3DDevice2 **d3d_device)
1325 struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
1327 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1329 if (FAILED(IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device)))
1330 return D3DRMERR_BADOBJECT;
1332 return D3DRM_OK;
1335 static HRESULT WINAPI d3drm_device2_GetDirect3DDevice2(IDirect3DRMDevice2 *iface, IDirect3DDevice2 **d3d_device)
1337 struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
1339 TRACE("iface %p, d3d_device %p.\n", iface, d3d_device);
1341 IDirect3DDevice_QueryInterface(device->device, &IID_IDirect3DDevice2, (void**)d3d_device);
1343 /* d3drm returns D3DRM_OK even if the call fails. */
1344 return D3DRM_OK;
1347 static HRESULT WINAPI d3drm_device3_FindPreferredTextureFormat(IDirect3DRMDevice3 *iface,
1348 DWORD bitdepths, DWORD flags, DDPIXELFORMAT *pf)
1350 FIXME("iface %p, bitdepths %lu, flags %#lx, pf %p stub!\n", iface, bitdepths, flags, pf);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI d3drm_device3_RenderStateChange(IDirect3DRMDevice3 *iface,
1356 D3DRENDERSTATETYPE state, DWORD value, DWORD flags)
1358 FIXME("iface %p, state %#x, value %#lx, flags %#lx stub!\n", iface, state, value, flags);
1360 return E_NOTIMPL;
1363 static HRESULT WINAPI d3drm_device3_LightStateChange(IDirect3DRMDevice3 *iface,
1364 D3DLIGHTSTATETYPE state, DWORD value, DWORD flags)
1366 FIXME("iface %p, state %#x, value %#lx, flags %#lx stub!\n", iface, state, value, flags);
1368 return E_NOTIMPL;
1371 static HRESULT WINAPI d3drm_device3_GetStateChangeOptions(IDirect3DRMDevice3 *iface,
1372 DWORD state_class, DWORD state_idx, DWORD *flags)
1374 FIXME("iface %p, state_class %#lx, state_idx %#lx, flags %p stub!\n",
1375 iface, state_class, state_idx, flags);
1377 return E_NOTIMPL;
1380 static HRESULT WINAPI d3drm_device3_SetStateChangeOptions(IDirect3DRMDevice3 *iface,
1381 DWORD state_class, DWORD state_idx, DWORD flags)
1383 FIXME("iface %p, state_class %#lx, state_idx %#lx, flags %#lx stub!\n",
1384 iface, state_class, state_idx, flags);
1386 return E_NOTIMPL;
1389 static const struct IDirect3DRMDevice3Vtbl d3drm_device3_vtbl =
1391 d3drm_device3_QueryInterface,
1392 d3drm_device3_AddRef,
1393 d3drm_device3_Release,
1394 d3drm_device3_Clone,
1395 d3drm_device3_AddDestroyCallback,
1396 d3drm_device3_DeleteDestroyCallback,
1397 d3drm_device3_SetAppData,
1398 d3drm_device3_GetAppData,
1399 d3drm_device3_SetName,
1400 d3drm_device3_GetName,
1401 d3drm_device3_GetClassName,
1402 d3drm_device3_Init,
1403 d3drm_device3_InitFromD3D,
1404 d3drm_device3_InitFromClipper,
1405 d3drm_device3_Update,
1406 d3drm_device3_AddUpdateCallback,
1407 d3drm_device3_DeleteUpdateCallback,
1408 d3drm_device3_SetBufferCount,
1409 d3drm_device3_GetBufferCount,
1410 d3drm_device3_SetDither,
1411 d3drm_device3_SetShades,
1412 d3drm_device3_SetQuality,
1413 d3drm_device3_SetTextureQuality,
1414 d3drm_device3_GetViewports,
1415 d3drm_device3_GetDither,
1416 d3drm_device3_GetShades,
1417 d3drm_device3_GetHeight,
1418 d3drm_device3_GetWidth,
1419 d3drm_device3_GetTrianglesDrawn,
1420 d3drm_device3_GetWireframeOptions,
1421 d3drm_device3_GetQuality,
1422 d3drm_device3_GetColorModel,
1423 d3drm_device3_GetTextureQuality,
1424 d3drm_device3_GetDirect3DDevice,
1425 d3drm_device3_InitFromD3D2,
1426 d3drm_device3_InitFromSurface,
1427 d3drm_device3_SetRenderMode,
1428 d3drm_device3_GetRenderMode,
1429 d3drm_device3_GetDirect3DDevice2,
1430 d3drm_device3_FindPreferredTextureFormat,
1431 d3drm_device3_RenderStateChange,
1432 d3drm_device3_LightStateChange,
1433 d3drm_device3_GetStateChangeOptions,
1434 d3drm_device3_SetStateChangeOptions,
1437 static const struct IDirect3DRMDevice2Vtbl d3drm_device2_vtbl =
1439 d3drm_device2_QueryInterface,
1440 d3drm_device2_AddRef,
1441 d3drm_device2_Release,
1442 d3drm_device2_Clone,
1443 d3drm_device2_AddDestroyCallback,
1444 d3drm_device2_DeleteDestroyCallback,
1445 d3drm_device2_SetAppData,
1446 d3drm_device2_GetAppData,
1447 d3drm_device2_SetName,
1448 d3drm_device2_GetName,
1449 d3drm_device2_GetClassName,
1450 d3drm_device2_Init,
1451 d3drm_device2_InitFromD3D,
1452 d3drm_device2_InitFromClipper,
1453 d3drm_device2_Update,
1454 d3drm_device2_AddUpdateCallback,
1455 d3drm_device2_DeleteUpdateCallback,
1456 d3drm_device2_SetBufferCount,
1457 d3drm_device2_GetBufferCount,
1458 d3drm_device2_SetDither,
1459 d3drm_device2_SetShades,
1460 d3drm_device2_SetQuality,
1461 d3drm_device2_SetTextureQuality,
1462 d3drm_device2_GetViewports,
1463 d3drm_device2_GetDither,
1464 d3drm_device2_GetShades,
1465 d3drm_device2_GetHeight,
1466 d3drm_device2_GetWidth,
1467 d3drm_device2_GetTrianglesDrawn,
1468 d3drm_device2_GetWireframeOptions,
1469 d3drm_device2_GetQuality,
1470 d3drm_device2_GetColorModel,
1471 d3drm_device2_GetTextureQuality,
1472 d3drm_device2_GetDirect3DDevice,
1473 d3drm_device2_InitFromD3D2,
1474 d3drm_device2_InitFromSurface,
1475 d3drm_device2_SetRenderMode,
1476 d3drm_device2_GetRenderMode,
1477 d3drm_device2_GetDirect3DDevice2,
1480 static const struct IDirect3DRMDeviceVtbl d3drm_device1_vtbl =
1482 d3drm_device1_QueryInterface,
1483 d3drm_device1_AddRef,
1484 d3drm_device1_Release,
1485 d3drm_device1_Clone,
1486 d3drm_device1_AddDestroyCallback,
1487 d3drm_device1_DeleteDestroyCallback,
1488 d3drm_device1_SetAppData,
1489 d3drm_device1_GetAppData,
1490 d3drm_device1_SetName,
1491 d3drm_device1_GetName,
1492 d3drm_device1_GetClassName,
1493 d3drm_device1_Init,
1494 d3drm_device1_InitFromD3D,
1495 d3drm_device1_InitFromClipper,
1496 d3drm_device1_Update,
1497 d3drm_device1_AddUpdateCallback,
1498 d3drm_device1_DeleteUpdateCallback,
1499 d3drm_device1_SetBufferCount,
1500 d3drm_device1_GetBufferCount,
1501 d3drm_device1_SetDither,
1502 d3drm_device1_SetShades,
1503 d3drm_device1_SetQuality,
1504 d3drm_device1_SetTextureQuality,
1505 d3drm_device1_GetViewports,
1506 d3drm_device1_GetDither,
1507 d3drm_device1_GetShades,
1508 d3drm_device1_GetHeight,
1509 d3drm_device1_GetWidth,
1510 d3drm_device1_GetTrianglesDrawn,
1511 d3drm_device1_GetWireframeOptions,
1512 d3drm_device1_GetQuality,
1513 d3drm_device1_GetColorModel,
1514 d3drm_device1_GetTextureQuality,
1515 d3drm_device1_GetDirect3DDevice,
1518 static HRESULT WINAPI d3drm_device_win_QueryInterface(IDirect3DRMWinDevice *iface, REFIID riid, void **out)
1520 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1522 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
1524 return d3drm_device3_QueryInterface(&device->IDirect3DRMDevice3_iface, riid, out);
1527 static ULONG WINAPI d3drm_device_win_AddRef(IDirect3DRMWinDevice *iface)
1529 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1531 TRACE("iface %p.\n", iface);
1533 return d3drm_device3_AddRef(&device->IDirect3DRMDevice3_iface);
1536 static ULONG WINAPI d3drm_device_win_Release(IDirect3DRMWinDevice *iface)
1538 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1540 TRACE("iface %p.\n", iface);
1542 return d3drm_device3_Release(&device->IDirect3DRMDevice3_iface);
1545 static HRESULT WINAPI d3drm_device_win_Clone(IDirect3DRMWinDevice *iface,
1546 IUnknown *outer, REFIID iid, void **out)
1548 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1550 TRACE("iface %p, outer %p, iid %s, out %p\n", iface, outer, debugstr_guid(iid), out);
1552 return d3drm_device3_Clone(&device->IDirect3DRMDevice3_iface, outer, iid, out);
1555 static HRESULT WINAPI d3drm_device_win_AddDestroyCallback(IDirect3DRMWinDevice *iface,
1556 D3DRMOBJECTCALLBACK cb, void *ctx)
1558 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1560 return E_NOTIMPL;
1563 static HRESULT WINAPI d3drm_device_win_DeleteDestroyCallback(IDirect3DRMWinDevice *iface,
1564 D3DRMOBJECTCALLBACK cb, void *ctx)
1566 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1568 return E_NOTIMPL;
1571 static HRESULT WINAPI d3drm_device_win_SetAppData(IDirect3DRMWinDevice *iface, DWORD data)
1573 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1575 TRACE("iface %p, data %#lx.\n", iface, data);
1577 return d3drm_device3_SetAppData(&device->IDirect3DRMDevice3_iface, data);
1580 static DWORD WINAPI d3drm_device_win_GetAppData(IDirect3DRMWinDevice *iface)
1582 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1584 TRACE("iface %p.\n", iface);
1586 return d3drm_device3_GetAppData(&device->IDirect3DRMDevice3_iface);
1589 static HRESULT WINAPI d3drm_device_win_SetName(IDirect3DRMWinDevice *iface, const char *name)
1591 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1593 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
1595 return d3drm_device3_SetName(&device->IDirect3DRMDevice3_iface, name);
1598 static HRESULT WINAPI d3drm_device_win_GetName(IDirect3DRMWinDevice *iface, DWORD *size, char *name)
1600 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1602 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1604 return d3drm_device3_GetName(&device->IDirect3DRMDevice3_iface, size, name);
1607 static HRESULT WINAPI d3drm_device_win_GetClassName(IDirect3DRMWinDevice *iface, DWORD *size, char *name)
1609 struct d3drm_device *device = impl_from_IDirect3DRMWinDevice(iface);
1611 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
1613 return d3drm_device3_GetClassName(&device->IDirect3DRMDevice3_iface, size, name);
1616 static HRESULT WINAPI d3drm_device_win_HandlePaint(IDirect3DRMWinDevice *iface, HDC dc)
1618 FIXME("iface %p, dc %p stub!\n", iface, dc);
1620 return D3DRM_OK;
1623 static HRESULT WINAPI d3drm_device_win_HandleActivate(IDirect3DRMWinDevice *iface, WORD wparam)
1625 FIXME("iface %p, wparam %#x stub!\n", iface, wparam);
1627 return D3DRM_OK;
1630 static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl =
1632 d3drm_device_win_QueryInterface,
1633 d3drm_device_win_AddRef,
1634 d3drm_device_win_Release,
1635 d3drm_device_win_Clone,
1636 d3drm_device_win_AddDestroyCallback,
1637 d3drm_device_win_DeleteDestroyCallback,
1638 d3drm_device_win_SetAppData,
1639 d3drm_device_win_GetAppData,
1640 d3drm_device_win_SetName,
1641 d3drm_device_win_GetName,
1642 d3drm_device_win_GetClassName,
1643 d3drm_device_win_HandlePaint,
1644 d3drm_device_win_HandleActivate,
1647 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface)
1649 if (!iface)
1650 return NULL;
1651 assert(iface->lpVtbl == &d3drm_device3_vtbl);
1653 return impl_from_IDirect3DRMDevice3(iface);
1656 HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm)
1658 static const char classname[] = "Device";
1659 struct d3drm_device *object;
1661 TRACE("device %p, d3drm %p.\n", device, d3drm);
1663 if (!(object = calloc(1, sizeof(*object))))
1664 return E_OUTOFMEMORY;
1666 object->IDirect3DRMDevice_iface.lpVtbl = &d3drm_device1_vtbl;
1667 object->IDirect3DRMDevice2_iface.lpVtbl = &d3drm_device2_vtbl;
1668 object->IDirect3DRMDevice3_iface.lpVtbl = &d3drm_device3_vtbl;
1669 object->IDirect3DRMWinDevice_iface.lpVtbl = &d3drm_device_win_vtbl;
1670 object->d3drm = d3drm;
1671 d3drm_object_init(&object->obj, classname);
1673 *device = object;
1675 return D3DRM_OK;