reg/tests: Test import with non-standard registry file headers.
[wine.git] / dlls / d3drm / viewport.c
blob183588a7fcf1750c0a0c04d836dea620f00edfb9
1 /*
2 * Implementation of IDirect3DRMViewport Interface
4 * Copyright 2012 André Hentschel
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "d3drm_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
28 static inline struct d3drm_viewport *impl_from_IDirect3DRMViewport(IDirect3DRMViewport *iface)
30 return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport_iface);
33 static inline struct d3drm_viewport *impl_from_IDirect3DRMViewport2(IDirect3DRMViewport2 *iface)
35 return CONTAINING_RECORD(iface, struct d3drm_viewport, IDirect3DRMViewport2_iface);
38 static inline void d3drm_normalize_d3d_color(D3DCOLORVALUE *color_value, D3DCOLOR color)
40 color_value->u1.r = RGBA_GETRED(color) / 255.0f;
41 color_value->u2.g = RGBA_GETGREEN(color) / 255.0f;
42 color_value->u3.b = RGBA_GETBLUE(color) / 255.0f;
43 color_value->u4.a = RGBA_GETALPHA(color) / 255.0f;
46 static HRESULT d3drm_update_background_material(struct d3drm_viewport *viewport)
48 IDirect3DRMFrame *root_frame;
49 D3DCOLOR color;
50 D3DMATERIAL mat;
51 HRESULT hr;
53 if (FAILED(hr = IDirect3DRMFrame_GetScene(viewport->camera, &root_frame)))
54 return hr;
55 color = IDirect3DRMFrame_GetSceneBackground(root_frame);
57 memset(&mat, 0, sizeof(mat));
58 mat.dwSize = sizeof(mat);
59 d3drm_normalize_d3d_color(&mat.u.diffuse, color);
61 return IDirect3DMaterial_SetMaterial(viewport->material, &mat);
64 static void d3drm_viewport_destroy(struct d3drm_viewport *viewport)
66 TRACE("viewport %p releasing attached interfaces.\n", viewport);
68 d3drm_object_cleanup((IDirect3DRMObject *)&viewport->IDirect3DRMViewport_iface, &viewport->obj);
70 if (viewport->d3d_viewport)
72 IDirect3DViewport_Release(viewport->d3d_viewport);
73 IDirect3DMaterial_Release(viewport->material);
74 IDirect3DRMFrame_Release(viewport->camera);
75 IDirect3DRM_Release(viewport->d3drm);
78 HeapFree(GetProcessHeap(), 0, viewport);
81 static HRESULT WINAPI d3drm_viewport2_QueryInterface(IDirect3DRMViewport2 *iface, REFIID riid, void **out)
83 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
85 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
87 if (IsEqualGUID(riid, &IID_IDirect3DRMViewport)
88 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
89 || IsEqualGUID(riid, &IID_IUnknown))
91 *out = &viewport->IDirect3DRMViewport_iface;
93 else if (IsEqualGUID(riid, &IID_IDirect3DRMViewport2))
95 *out = &viewport->IDirect3DRMViewport2_iface;
97 else
99 *out = NULL;
100 WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
101 return CLASS_E_CLASSNOTAVAILABLE;
104 IUnknown_AddRef((IUnknown *)*out);
105 return S_OK;
108 static HRESULT WINAPI d3drm_viewport1_QueryInterface(IDirect3DRMViewport *iface, REFIID riid, void **out)
110 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
112 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
114 return d3drm_viewport2_QueryInterface(&viewport->IDirect3DRMViewport2_iface, riid, out);
117 static ULONG WINAPI d3drm_viewport2_AddRef(IDirect3DRMViewport2 *iface)
119 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
120 ULONG refcount = InterlockedIncrement(&viewport->obj.ref);
122 TRACE("%p increasing refcount to %u.\n", iface, refcount);
124 return refcount;
127 static ULONG WINAPI d3drm_viewport1_AddRef(IDirect3DRMViewport *iface)
129 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
131 TRACE("iface %p.\n", iface);
133 return d3drm_viewport2_AddRef(&viewport->IDirect3DRMViewport2_iface);
136 static ULONG WINAPI d3drm_viewport2_Release(IDirect3DRMViewport2 *iface)
138 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
139 ULONG refcount = InterlockedDecrement(&viewport->obj.ref);
141 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
143 if (!refcount)
144 d3drm_viewport_destroy(viewport);
146 return refcount;
149 static ULONG WINAPI d3drm_viewport1_Release(IDirect3DRMViewport *iface)
151 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
153 TRACE("iface %p.\n", iface);
155 return d3drm_viewport2_Release(&viewport->IDirect3DRMViewport2_iface);
158 static HRESULT WINAPI d3drm_viewport2_Clone(IDirect3DRMViewport2 *iface,
159 IUnknown *outer, REFIID iid, void **out)
161 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
163 return E_NOTIMPL;
166 static HRESULT WINAPI d3drm_viewport1_Clone(IDirect3DRMViewport *iface,
167 IUnknown *outer, REFIID iid, void **out)
169 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
171 return E_NOTIMPL;
174 static HRESULT WINAPI d3drm_viewport2_AddDestroyCallback(IDirect3DRMViewport2 *iface,
175 D3DRMOBJECTCALLBACK cb, void *ctx)
177 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
179 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
181 return d3drm_object_add_destroy_callback(&viewport->obj, cb, ctx);
184 static HRESULT WINAPI d3drm_viewport1_AddDestroyCallback(IDirect3DRMViewport *iface,
185 D3DRMOBJECTCALLBACK cb, void *ctx)
187 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
189 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
191 return d3drm_viewport2_AddDestroyCallback(&viewport->IDirect3DRMViewport2_iface, cb, ctx);
194 static HRESULT WINAPI d3drm_viewport2_DeleteDestroyCallback(IDirect3DRMViewport2 *iface,
195 D3DRMOBJECTCALLBACK cb, void *ctx)
197 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
199 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
201 return d3drm_object_delete_destroy_callback(&viewport->obj, cb, ctx);
204 static HRESULT WINAPI d3drm_viewport1_DeleteDestroyCallback(IDirect3DRMViewport *iface,
205 D3DRMOBJECTCALLBACK cb, void *ctx)
207 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
209 TRACE("iface %p, cb %p, ctx %p\n", iface, cb, ctx);
211 return d3drm_viewport2_DeleteDestroyCallback(&viewport->IDirect3DRMViewport2_iface, cb, ctx);
214 static HRESULT WINAPI d3drm_viewport2_SetAppData(IDirect3DRMViewport2 *iface, DWORD data)
216 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
218 TRACE("iface %p, data %#x\n", iface, data);
220 viewport->obj.appdata = data;
221 return S_OK;
224 static HRESULT WINAPI d3drm_viewport1_SetAppData(IDirect3DRMViewport *iface, DWORD data)
226 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
228 TRACE("iface %p, data %#x\n", iface, data);
230 return d3drm_viewport2_SetAppData(&viewport->IDirect3DRMViewport2_iface, data);
233 static DWORD WINAPI d3drm_viewport2_GetAppData(IDirect3DRMViewport2 *iface)
235 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
237 TRACE("iface %p\n", iface);
239 return viewport->obj.appdata;
242 static DWORD WINAPI d3drm_viewport1_GetAppData(IDirect3DRMViewport *iface)
244 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
246 TRACE("iface %p.\n", iface);
248 return d3drm_viewport2_GetAppData(&viewport->IDirect3DRMViewport2_iface);
251 static HRESULT WINAPI d3drm_viewport2_SetName(IDirect3DRMViewport2 *iface, const char *name)
253 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
255 return E_NOTIMPL;
258 static HRESULT WINAPI d3drm_viewport1_SetName(IDirect3DRMViewport *iface, const char *name)
260 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
262 return E_NOTIMPL;
265 static HRESULT WINAPI d3drm_viewport2_GetName(IDirect3DRMViewport2 *iface, DWORD *size, char *name)
267 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
269 return E_NOTIMPL;
272 static HRESULT WINAPI d3drm_viewport1_GetName(IDirect3DRMViewport *iface, DWORD *size, char *name)
274 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
276 return E_NOTIMPL;
279 static HRESULT WINAPI d3drm_viewport2_GetClassName(IDirect3DRMViewport2 *iface, DWORD *size, char *name)
281 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
283 if (!size || *size < strlen("Viewport") || !name)
284 return E_INVALIDARG;
286 strcpy(name, "Viewport");
287 *size = sizeof("Viewport");
289 return D3DRM_OK;
292 static HRESULT WINAPI d3drm_viewport1_GetClassName(IDirect3DRMViewport *iface, DWORD *size, char *name)
294 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
296 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
298 return d3drm_viewport2_GetClassName(&viewport->IDirect3DRMViewport2_iface, size, name);
301 static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 *device,
302 IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height)
304 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
305 struct d3drm_device *device_obj = unsafe_impl_from_IDirect3DRMDevice3(device);
306 D3DVIEWPORT vp;
307 D3DVALUE scale;
308 IDirect3D *d3d1 = NULL;
309 IDirect3DDevice *d3d_device = NULL;
310 IDirect3DMaterial *material = NULL;
311 D3DMATERIALHANDLE hmat;
312 HRESULT hr = D3DRM_OK;
314 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u.\n",
315 iface, device, camera, x, y, width, height);
317 if (!device_obj || !camera
318 || width > device_obj->width
319 || height > device_obj->height)
321 return D3DRMERR_BADOBJECT;
324 if (viewport->d3d_viewport)
325 return D3DRMERR_BADOBJECT;
327 IDirect3DRM_AddRef(viewport->d3drm);
329 if (FAILED(hr = IDirect3DRMDevice3_GetDirect3DDevice(device, &d3d_device)))
330 goto cleanup;
332 if (FAILED(hr = IDirect3DDevice_GetDirect3D(d3d_device, &d3d1)))
333 goto cleanup;
335 if (FAILED(hr = IDirect3D_CreateViewport(d3d1, &viewport->d3d_viewport, NULL)))
336 goto cleanup;
338 vp.dwSize = sizeof(vp);
339 vp.dwWidth = width;
340 vp.dwHeight = height;
341 vp.dwX = x;
342 vp.dwY = y;
343 scale = width > height ? (float)width / 2.0f : (float)height / 2.0f;
344 vp.dvScaleX = scale;
345 vp.dvScaleY = scale;
346 vp.dvMaxX = vp.dwWidth / (2.0f * vp.dvScaleX);
347 vp.dvMaxY = vp.dwHeight / (2.0f * vp.dvScaleY);
348 vp.dvMinZ = 0.0f;
349 vp.dvMaxZ = 1.0f;
351 if (FAILED(hr = IDirect3DViewport_SetViewport(viewport->d3d_viewport, &vp)))
352 goto cleanup;
354 if (FAILED(hr = IDirect3DDevice_AddViewport(d3d_device, viewport->d3d_viewport)))
355 goto cleanup;
357 if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(camera, &IID_IDirect3DRMFrame, (void **)&viewport->camera)))
358 goto cleanup;
360 if (FAILED(hr = IDirect3D_CreateMaterial(d3d1, &material, NULL)))
361 goto cleanup;
363 if (FAILED(hr = IDirect3DMaterial_GetHandle(material, d3d_device, &hmat)))
364 goto cleanup;
366 hr = IDirect3DViewport_SetBackground(viewport->d3d_viewport, hmat);
367 viewport->material = material;
368 viewport->device = device_obj;
370 cleanup:
372 if (FAILED(hr))
374 if (viewport->d3d_viewport)
376 IDirect3DViewport_Release(viewport->d3d_viewport);
377 viewport->d3d_viewport = NULL;
379 if (viewport->camera)
380 IDirect3DRMFrame_Release(viewport->camera);
381 if (material)
382 IDirect3DMaterial_Release(material);
383 IDirect3DRM_Release(viewport->d3drm);
385 if (d3d_device)
386 IDirect3DDevice_Release(d3d_device);
387 if (d3d1)
388 IDirect3D_Release(d3d1);
390 return hr;
393 static HRESULT WINAPI d3drm_viewport1_Init(IDirect3DRMViewport *iface, IDirect3DRMDevice *device,
394 IDirect3DRMFrame *camera, DWORD x, DWORD y, DWORD width, DWORD height)
396 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
397 struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
398 IDirect3DRMDevice3 *device3;
399 HRESULT hr;
401 TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u.\n",
402 iface, device, camera, x, y, width, height);
404 if (!device || !frame)
405 return D3DRMERR_BADOBJECT;
407 if (FAILED(hr = IDirect3DRMDevice_QueryInterface(device, &IID_IDirect3DRMDevice3, (void **)&device3)))
408 return hr;
410 hr = d3drm_viewport2_Init(&viewport->IDirect3DRMViewport2_iface, device3, &frame->IDirect3DRMFrame3_iface,
411 x, y, width, height);
412 IDirect3DRMDevice3_Release(device3);
414 return hr;
417 static HRESULT WINAPI d3drm_viewport2_Clear(IDirect3DRMViewport2 *iface, DWORD flags)
419 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
420 DDSCAPS caps = { DDSCAPS_ZBUFFER };
421 HRESULT hr;
422 D3DRECT clear_rect;
423 IDirectDrawSurface *ds;
424 DWORD clear_flags = 0;
426 TRACE("iface %p, flags %#x.\n", iface, flags);
428 clear_rect.u1.x1 = clear_rect.u2.y1 = 0;
429 clear_rect.u3.x2 = viewport->device->width;
430 clear_rect.u4.y2 = viewport->device->height;
432 if (flags & D3DRMCLEAR_TARGET)
434 clear_flags |= D3DCLEAR_TARGET;
435 d3drm_update_background_material(viewport);
437 if (flags & D3DRMCLEAR_ZBUFFER)
439 hr = IDirectDrawSurface_GetAttachedSurface(viewport->device->render_target, &caps, &ds);
440 if (SUCCEEDED(hr))
442 clear_flags |= D3DCLEAR_ZBUFFER;
443 IDirectDrawSurface_Release(ds);
446 if (flags & D3DRMCLEAR_DIRTYRECTS)
447 FIXME("Flag D3DRMCLEAR_DIRTYRECT not implemented yet.\n");
449 if (FAILED(hr = IDirect3DViewport_Clear(viewport->d3d_viewport, 1, &clear_rect, clear_flags)))
450 return hr;
452 return D3DRM_OK;
455 static HRESULT WINAPI d3drm_viewport1_Clear(IDirect3DRMViewport *iface)
457 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
459 TRACE("iface %p.\n", iface);
461 return d3drm_viewport2_Clear(&viewport->IDirect3DRMViewport2_iface, D3DRMCLEAR_ALL);
464 static HRESULT WINAPI d3drm_viewport2_Render(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *frame)
466 FIXME("iface %p, frame %p stub!\n", iface, frame);
468 return D3DRM_OK;
471 static HRESULT WINAPI d3drm_viewport1_Render(IDirect3DRMViewport *iface, IDirect3DRMFrame *frame)
473 FIXME("iface %p, frame %p stub!\n", iface, frame);
475 return D3DRM_OK;
478 static HRESULT WINAPI d3drm_viewport2_SetFront(IDirect3DRMViewport2 *iface, D3DVALUE front)
480 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
482 TRACE("iface %p, front %.8e.\n", iface, front);
484 viewport->front = front;
486 return D3DRM_OK;
489 static HRESULT WINAPI d3drm_viewport1_SetFront(IDirect3DRMViewport *iface, D3DVALUE front)
491 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
493 TRACE("iface %p, front %.8e.\n", iface, front);
495 return d3drm_viewport2_SetFront(&viewport->IDirect3DRMViewport2_iface, front);
498 static HRESULT WINAPI d3drm_viewport2_SetBack(IDirect3DRMViewport2 *iface, D3DVALUE back)
500 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
502 TRACE("iface %p, back %.8e.\n", iface, back);
504 viewport->back = back;
506 return D3DRM_OK;
509 static HRESULT WINAPI d3drm_viewport1_SetBack(IDirect3DRMViewport *iface, D3DVALUE back)
511 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
513 TRACE("iface %p, back %.8e.\n", iface, back);
515 return d3drm_viewport2_SetBack(&viewport->IDirect3DRMViewport2_iface, back);
518 static HRESULT WINAPI d3drm_viewport2_SetField(IDirect3DRMViewport2 *iface, D3DVALUE field)
520 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
522 TRACE("iface %p, field %.8e.\n", iface, field);
524 viewport->field = field;
526 return D3DRM_OK;
529 static HRESULT WINAPI d3drm_viewport1_SetField(IDirect3DRMViewport *iface, D3DVALUE field)
531 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
533 TRACE("iface %p, field %.8e.\n", iface, field);
535 return d3drm_viewport2_SetField(&viewport->IDirect3DRMViewport2_iface, field);
538 static HRESULT WINAPI d3drm_viewport2_SetUniformScaling(IDirect3DRMViewport2 *iface, BOOL b)
540 FIXME("iface %p, b %#x stub!\n", iface, b);
542 return E_NOTIMPL;
545 static HRESULT WINAPI d3drm_viewport1_SetUniformScaling(IDirect3DRMViewport *iface, BOOL b)
547 FIXME("iface %p, b %#x stub!\n", iface, b);
549 return E_NOTIMPL;
552 static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera)
554 FIXME("iface %p, camera %p stub!\n", iface, camera);
556 return E_NOTIMPL;
559 static HRESULT WINAPI d3drm_viewport1_SetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame *camera)
561 FIXME("iface %p, camera %p stub!\n", iface, camera);
563 return E_NOTIMPL;
566 static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type)
568 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
570 TRACE("iface %p, type %#x.\n", iface, type);
572 viewport->projection = type;
574 return D3DRM_OK;
577 static HRESULT WINAPI d3drm_viewport1_SetProjection(IDirect3DRMViewport *iface, D3DRMPROJECTIONTYPE type)
579 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
581 TRACE("iface %p, type %#x.\n", iface, type);
583 return d3drm_viewport2_SetProjection(&viewport->IDirect3DRMViewport2_iface, type);
586 static HRESULT WINAPI d3drm_viewport2_Transform(IDirect3DRMViewport2 *iface, D3DRMVECTOR4D *d, D3DVECTOR *s)
588 FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
590 return E_NOTIMPL;
593 static HRESULT WINAPI d3drm_viewport1_Transform(IDirect3DRMViewport *iface, D3DRMVECTOR4D *d, D3DVECTOR *s)
595 FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
597 return E_NOTIMPL;
600 static HRESULT WINAPI d3drm_viewport2_InverseTransform(IDirect3DRMViewport2 *iface, D3DVECTOR *d, D3DRMVECTOR4D *s)
602 FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
604 return E_NOTIMPL;
607 static HRESULT WINAPI d3drm_viewport1_InverseTransform(IDirect3DRMViewport *iface, D3DVECTOR *d, D3DRMVECTOR4D *s)
609 FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
611 return E_NOTIMPL;
614 static HRESULT WINAPI d3drm_viewport2_Configure(IDirect3DRMViewport2 *iface,
615 LONG x, LONG y, DWORD width, DWORD height)
617 FIXME("iface %p, x %d, y %d, width %u, height %u stub!\n", iface, x, y, width, height);
619 return E_NOTIMPL;
622 static HRESULT WINAPI d3drm_viewport1_Configure(IDirect3DRMViewport *iface,
623 LONG x, LONG y, DWORD width, DWORD height)
625 FIXME("iface %p, x %d, y %d, width %u, height %u stub!\n", iface, x, y, width, height);
627 return E_NOTIMPL;
630 static HRESULT WINAPI d3drm_viewport2_ForceUpdate(IDirect3DRMViewport2* iface,
631 DWORD x1, DWORD y1, DWORD x2, DWORD y2)
633 FIXME("iface %p, x1 %u, y1 %u, x2 %u, y2 %u stub!\n", iface, x1, y1, x2, y2);
635 return E_NOTIMPL;
638 static HRESULT WINAPI d3drm_viewport1_ForceUpdate(IDirect3DRMViewport *iface,
639 DWORD x1, DWORD y1, DWORD x2, DWORD y2)
641 FIXME("iface %p, x1 %u, y1 %u, x2 %u, y2 %u stub!\n", iface, x1, y1, x2, y2);
643 return E_NOTIMPL;
646 static HRESULT WINAPI d3drm_viewport2_SetPlane(IDirect3DRMViewport2 *iface,
647 D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
649 FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n",
650 iface, left, right, bottom, top);
652 return E_NOTIMPL;
655 static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface,
656 D3DVALUE left, D3DVALUE right, D3DVALUE bottom, D3DVALUE top)
658 FIXME("iface %p, left %.8e, right %.8e, bottom %.8e, top %.8e stub!\n",
659 iface, left, right, bottom, top);
661 return E_NOTIMPL;
664 static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera)
666 FIXME("iface %p, camera %p stub!\n", iface, camera);
668 return E_NOTIMPL;
671 static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame **camera)
673 FIXME("iface %p, camera %p stub!\n", iface, camera);
675 return E_NOTIMPL;
678 static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
680 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
682 TRACE("iface %p, device %p.\n", iface, device);
684 if (!viewport->device)
685 return D3DRMERR_BADOBJECT;
687 *device = &viewport->device->IDirect3DRMDevice3_iface;
688 IDirect3DRMDevice3_AddRef(*device);
690 return D3DRM_OK;
693 static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDirect3DRMDevice **device)
695 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
697 TRACE("iface %p, device %p.\n\n", iface, device);
699 if (!viewport->device)
700 return D3DRMERR_BADOBJECT;
702 *device = &viewport->device->IDirect3DRMDevice_iface;
703 IDirect3DRMDevice_AddRef(*device);
705 return D3DRM_OK;
708 static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface,
709 D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
711 FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
712 iface, left, right, bottom, top);
714 return E_NOTIMPL;
717 static HRESULT WINAPI d3drm_viewport1_GetPlane(IDirect3DRMViewport *iface,
718 D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
720 FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
721 iface, left, right, bottom, top);
723 return E_NOTIMPL;
726 static HRESULT WINAPI d3drm_viewport2_Pick(IDirect3DRMViewport2 *iface,
727 LONG x, LONG y, IDirect3DRMPickedArray **visuals)
729 FIXME("iface %p, x %d, y %d, visuals %p stub!\n", iface, x, y, visuals);
731 return E_NOTIMPL;
734 static HRESULT WINAPI d3drm_viewport1_Pick(IDirect3DRMViewport *iface,
735 LONG x, LONG y, IDirect3DRMPickedArray **visuals)
737 FIXME("iface %p, x %d, y %d, visuals %p stub!\n", iface, x, y, visuals);
739 return E_NOTIMPL;
742 static BOOL WINAPI d3drm_viewport2_GetUniformScaling(IDirect3DRMViewport2 *iface)
744 FIXME("iface %p stub!\n", iface);
746 return FALSE;
749 static BOOL WINAPI d3drm_viewport1_GetUniformScaling(IDirect3DRMViewport *iface)
751 FIXME("iface %p stub!\n", iface);
753 return FALSE;
756 static LONG WINAPI d3drm_viewport2_GetX(IDirect3DRMViewport2 *iface)
758 FIXME("iface %p stub!\n", iface);
760 return E_NOTIMPL;
763 static LONG WINAPI d3drm_viewport1_GetX(IDirect3DRMViewport *iface)
765 FIXME("iface %p stub!\n", iface);
767 return E_NOTIMPL;
770 static LONG WINAPI d3drm_viewport2_GetY(IDirect3DRMViewport2 *iface)
772 FIXME("iface %p stub!\n", iface);
774 return E_NOTIMPL;
777 static LONG WINAPI d3drm_viewport1_GetY(IDirect3DRMViewport *iface)
779 FIXME("iface %p stub!\n", iface);
781 return E_NOTIMPL;
784 static DWORD WINAPI d3drm_viewport2_GetWidth(IDirect3DRMViewport2 *iface)
786 FIXME("iface %p stub!\n", iface);
788 return E_NOTIMPL;
791 static DWORD WINAPI d3drm_viewport1_GetWidth(IDirect3DRMViewport *iface)
793 FIXME("iface %p stub!\n", iface);
795 return E_NOTIMPL;
798 static DWORD WINAPI d3drm_viewport2_GetHeight(IDirect3DRMViewport2 *iface)
800 FIXME("iface %p stub!\n", iface);
802 return E_NOTIMPL;
805 static DWORD WINAPI d3drm_viewport1_GetHeight(IDirect3DRMViewport *iface)
807 FIXME("iface %p stub!\n", iface);
809 return E_NOTIMPL;
812 static D3DVALUE WINAPI d3drm_viewport2_GetField(IDirect3DRMViewport2 *iface)
814 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
816 TRACE("iface %p.\n", iface);
818 return viewport->field;
821 static D3DVALUE WINAPI d3drm_viewport1_GetField(IDirect3DRMViewport *iface)
823 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
825 TRACE("iface %p.\n", iface);
827 return d3drm_viewport2_GetField(&viewport->IDirect3DRMViewport2_iface);
830 static D3DVALUE WINAPI d3drm_viewport2_GetBack(IDirect3DRMViewport2 *iface)
832 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
834 TRACE("iface %p.\n", iface);
836 return viewport->back;
839 static D3DVALUE WINAPI d3drm_viewport1_GetBack(IDirect3DRMViewport *iface)
841 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
843 TRACE("iface %p.\n", iface);
845 return d3drm_viewport2_GetBack(&viewport->IDirect3DRMViewport2_iface);
848 static D3DVALUE WINAPI d3drm_viewport2_GetFront(IDirect3DRMViewport2 *iface)
850 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
852 TRACE("iface %p.\n", iface);
854 return viewport->front;
857 static D3DVALUE WINAPI d3drm_viewport1_GetFront(IDirect3DRMViewport *iface)
859 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
861 TRACE("iface %p.\n", iface);
863 return d3drm_viewport2_GetFront(&viewport->IDirect3DRMViewport2_iface);
866 static D3DRMPROJECTIONTYPE WINAPI d3drm_viewport2_GetProjection(IDirect3DRMViewport2 *iface)
868 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
870 TRACE("iface %p.\n", iface);
872 return viewport->projection;
875 static D3DRMPROJECTIONTYPE WINAPI d3drm_viewport1_GetProjection(IDirect3DRMViewport *iface)
877 struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
879 TRACE("iface %p.\n", iface);
881 return d3drm_viewport2_GetProjection(&viewport->IDirect3DRMViewport2_iface);
884 static HRESULT WINAPI d3drm_viewport2_GetDirect3DViewport(IDirect3DRMViewport2 *iface,
885 IDirect3DViewport **viewport)
887 struct d3drm_viewport *viewport_object = impl_from_IDirect3DRMViewport2(iface);
889 TRACE("iface %p, viewport %p.\n", iface, viewport);
891 if (!viewport_object->d3d_viewport)
892 return D3DRMERR_BADOBJECT;
894 *viewport = viewport_object->d3d_viewport;
895 IDirect3DViewport_AddRef(*viewport);
897 return D3DRM_OK;
900 static HRESULT WINAPI d3drm_viewport1_GetDirect3DViewport(IDirect3DRMViewport *iface,
901 IDirect3DViewport **viewport)
903 struct d3drm_viewport *viewport_object = impl_from_IDirect3DRMViewport(iface);
905 TRACE("iface %p, viewport %p.\n", iface, viewport);
907 return d3drm_viewport2_GetDirect3DViewport(&viewport_object->IDirect3DRMViewport2_iface, viewport);
910 static HRESULT WINAPI d3drm_viewport2_TransformVectors(IDirect3DRMViewport2 *iface,
911 DWORD vector_count, D3DRMVECTOR4D *dst, D3DVECTOR *src)
913 FIXME("iface %p, vector_count %u, dst %p, src %p stub!\n", iface, vector_count, dst, src);
915 return E_NOTIMPL;
918 static HRESULT WINAPI d3drm_viewport2_InverseTransformVectors(IDirect3DRMViewport2 *iface,
919 DWORD vector_count, D3DVECTOR *dst, D3DRMVECTOR4D *src)
921 FIXME("iface %p, vector_count %u, dst %p, src %p stub!\n", iface, vector_count, dst, src);
923 return E_NOTIMPL;
926 static const struct IDirect3DRMViewport2Vtbl d3drm_viewport2_vtbl =
928 d3drm_viewport2_QueryInterface,
929 d3drm_viewport2_AddRef,
930 d3drm_viewport2_Release,
931 d3drm_viewport2_Clone,
932 d3drm_viewport2_AddDestroyCallback,
933 d3drm_viewport2_DeleteDestroyCallback,
934 d3drm_viewport2_SetAppData,
935 d3drm_viewport2_GetAppData,
936 d3drm_viewport2_SetName,
937 d3drm_viewport2_GetName,
938 d3drm_viewport2_GetClassName,
939 d3drm_viewport2_Init,
940 d3drm_viewport2_Clear,
941 d3drm_viewport2_Render,
942 d3drm_viewport2_SetFront,
943 d3drm_viewport2_SetBack,
944 d3drm_viewport2_SetField,
945 d3drm_viewport2_SetUniformScaling,
946 d3drm_viewport2_SetCamera,
947 d3drm_viewport2_SetProjection,
948 d3drm_viewport2_Transform,
949 d3drm_viewport2_InverseTransform,
950 d3drm_viewport2_Configure,
951 d3drm_viewport2_ForceUpdate,
952 d3drm_viewport2_SetPlane,
953 d3drm_viewport2_GetCamera,
954 d3drm_viewport2_GetDevice,
955 d3drm_viewport2_GetPlane,
956 d3drm_viewport2_Pick,
957 d3drm_viewport2_GetUniformScaling,
958 d3drm_viewport2_GetX,
959 d3drm_viewport2_GetY,
960 d3drm_viewport2_GetWidth,
961 d3drm_viewport2_GetHeight,
962 d3drm_viewport2_GetField,
963 d3drm_viewport2_GetBack,
964 d3drm_viewport2_GetFront,
965 d3drm_viewport2_GetProjection,
966 d3drm_viewport2_GetDirect3DViewport,
967 d3drm_viewport2_TransformVectors,
968 d3drm_viewport2_InverseTransformVectors,
971 static const struct IDirect3DRMViewportVtbl d3drm_viewport1_vtbl =
973 d3drm_viewport1_QueryInterface,
974 d3drm_viewport1_AddRef,
975 d3drm_viewport1_Release,
976 d3drm_viewport1_Clone,
977 d3drm_viewport1_AddDestroyCallback,
978 d3drm_viewport1_DeleteDestroyCallback,
979 d3drm_viewport1_SetAppData,
980 d3drm_viewport1_GetAppData,
981 d3drm_viewport1_SetName,
982 d3drm_viewport1_GetName,
983 d3drm_viewport1_GetClassName,
984 d3drm_viewport1_Init,
985 d3drm_viewport1_Clear,
986 d3drm_viewport1_Render,
987 d3drm_viewport1_SetFront,
988 d3drm_viewport1_SetBack,
989 d3drm_viewport1_SetField,
990 d3drm_viewport1_SetUniformScaling,
991 d3drm_viewport1_SetCamera,
992 d3drm_viewport1_SetProjection,
993 d3drm_viewport1_Transform,
994 d3drm_viewport1_InverseTransform,
995 d3drm_viewport1_Configure,
996 d3drm_viewport1_ForceUpdate,
997 d3drm_viewport1_SetPlane,
998 d3drm_viewport1_GetCamera,
999 d3drm_viewport1_GetDevice,
1000 d3drm_viewport1_GetPlane,
1001 d3drm_viewport1_Pick,
1002 d3drm_viewport1_GetUniformScaling,
1003 d3drm_viewport1_GetX,
1004 d3drm_viewport1_GetY,
1005 d3drm_viewport1_GetWidth,
1006 d3drm_viewport1_GetHeight,
1007 d3drm_viewport1_GetField,
1008 d3drm_viewport1_GetBack,
1009 d3drm_viewport1_GetFront,
1010 d3drm_viewport1_GetProjection,
1011 d3drm_viewport1_GetDirect3DViewport,
1014 HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm)
1016 struct d3drm_viewport *object;
1018 TRACE("viewport %p, d3drm %p.\n", viewport, d3drm);
1020 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
1021 return E_OUTOFMEMORY;
1023 object->IDirect3DRMViewport_iface.lpVtbl = &d3drm_viewport1_vtbl;
1024 object->IDirect3DRMViewport2_iface.lpVtbl = &d3drm_viewport2_vtbl;
1025 object->d3drm = d3drm;
1026 d3drm_object_init(&object->obj);
1028 *viewport = object;
1030 return S_OK;