2 * Copyright (c) 1998 Lionel ULMER
3 * Copyright (c) 2006 Stefan DÖSINGER
5 * This file contains the implementation of Direct3DViewport2.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
31 #define NONAMELESSUNION
38 #include "wine/exception.h"
44 #include "ddraw_private.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(d3d7
);
49 /*****************************************************************************
51 *****************************************************************************/
53 /*****************************************************************************
56 * activates the viewport using IDirect3DDevice7::SetViewport
58 *****************************************************************************/
59 void viewport_activate(IDirect3DViewportImpl
* This
) {
60 IDirect3DLightImpl
* light
;
63 /* Activate all the lights associated with this context */
66 while (light
!= NULL
) {
67 light
->activate(light
);
71 /* And copy the values in the structure used by the device */
73 vp
.dwX
= This
->viewports
.vp2
.dwX
;
74 vp
.dwY
= This
->viewports
.vp2
.dwY
;
75 vp
.dwHeight
= This
->viewports
.vp2
.dwHeight
;
76 vp
.dwWidth
= This
->viewports
.vp2
.dwWidth
;
77 vp
.dvMinZ
= This
->viewports
.vp2
.dvMinZ
;
78 vp
.dvMaxZ
= This
->viewports
.vp2
.dvMaxZ
;
80 vp
.dwX
= This
->viewports
.vp1
.dwX
;
81 vp
.dwY
= This
->viewports
.vp1
.dwY
;
82 vp
.dwHeight
= This
->viewports
.vp1
.dwHeight
;
83 vp
.dwWidth
= This
->viewports
.vp1
.dwWidth
;
84 vp
.dvMinZ
= This
->viewports
.vp1
.dvMinZ
;
85 vp
.dvMaxZ
= This
->viewports
.vp1
.dvMaxZ
;
88 /* And also set the viewport */
89 IDirect3DDevice7_SetViewport(ICOM_INTERFACE(This
->active_device
, IDirect3DDevice7
), &vp
);
92 /*****************************************************************************
93 * _dump_D3DVIEWPORT, _dump_D3DVIEWPORT2
95 * Writes viewport information to TRACE
97 *****************************************************************************/
98 static void _dump_D3DVIEWPORT(D3DVIEWPORT
*lpvp
)
100 TRACE(" - dwSize = %ld dwX = %ld dwY = %ld\n",
101 lpvp
->dwSize
, lpvp
->dwX
, lpvp
->dwY
);
102 TRACE(" - dwWidth = %ld dwHeight = %ld\n",
103 lpvp
->dwWidth
, lpvp
->dwHeight
);
104 TRACE(" - dvScaleX = %f dvScaleY = %f\n",
105 lpvp
->dvScaleX
, lpvp
->dvScaleY
);
106 TRACE(" - dvMaxX = %f dvMaxY = %f\n",
107 lpvp
->dvMaxX
, lpvp
->dvMaxY
);
108 TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
109 lpvp
->dvMinZ
, lpvp
->dvMaxZ
);
112 static void _dump_D3DVIEWPORT2(D3DVIEWPORT2
*lpvp
)
114 TRACE(" - dwSize = %ld dwX = %ld dwY = %ld\n",
115 lpvp
->dwSize
, lpvp
->dwX
, lpvp
->dwY
);
116 TRACE(" - dwWidth = %ld dwHeight = %ld\n",
117 lpvp
->dwWidth
, lpvp
->dwHeight
);
118 TRACE(" - dvClipX = %f dvClipY = %f\n",
119 lpvp
->dvClipX
, lpvp
->dvClipY
);
120 TRACE(" - dvClipWidth = %f dvClipHeight = %f\n",
121 lpvp
->dvClipWidth
, lpvp
->dvClipHeight
);
122 TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
123 lpvp
->dvMinZ
, lpvp
->dvMaxZ
);
126 /*****************************************************************************
128 *****************************************************************************/
130 /*****************************************************************************
131 * IDirect3DViewport3::QueryInterface
133 * A normal QueryInterface. Can query all interface versions and the
134 * IUnknown interface. The VTables of the different versions
138 * refiid: Interface id queried for
139 * obj: Address to write the interface pointer to
143 * E_NOINTERFACE if the requested interface wasn't found
145 *****************************************************************************/
146 static HRESULT WINAPI
147 IDirect3DViewportImpl_QueryInterface(IDirect3DViewport3
*iface
,
151 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
152 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), obp
);
156 if ( IsEqualGUID(&IID_IUnknown
, riid
) ||
157 IsEqualGUID(&IID_IDirect3DViewport
, riid
) ||
158 IsEqualGUID(&IID_IDirect3DViewport2
, riid
) ||
159 IsEqualGUID(&IID_IDirect3DViewport3
, riid
) ) {
160 IDirect3DViewport3_AddRef(ICOM_INTERFACE(This
, IDirect3DViewport3
));
161 *obp
= ICOM_INTERFACE(This
, IDirect3DViewport3
);
162 TRACE(" Creating IDirect3DViewport1/2/3 interface %p\n", *obp
);
165 FIXME("(%p): interface for IID %s NOT found!\n", This
, debugstr_guid(riid
));
166 return E_NOINTERFACE
;
169 /*****************************************************************************
170 * IDirect3DViewport3::AddRef
172 * Increases the refcount.
177 *****************************************************************************/
179 IDirect3DViewportImpl_AddRef(IDirect3DViewport3
*iface
)
181 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
182 ULONG ref
= InterlockedIncrement(&This
->ref
);
184 TRACE("(%p)->() incrementing from %lu.\n", This
, ref
- 1);
189 /*****************************************************************************
190 * IDirect3DViewport3::Release
192 * Reduces the refcount. If it falls to 0, the interface is released
197 *****************************************************************************/
199 IDirect3DViewportImpl_Release(IDirect3DViewport3
*iface
)
201 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
202 ULONG ref
= InterlockedDecrement(&This
->ref
);
204 TRACE("(%p)->() decrementing from %lu.\n", This
, ref
+ 1);
207 HeapFree(GetProcessHeap(), 0, This
);
213 /*****************************************************************************
214 * IDirect3DViewport Methods.
215 *****************************************************************************/
217 /*****************************************************************************
218 * IDirect3DViewport3::Initialize
220 * No-op initialization.
223 * Direct3D: The direct3D device this viewport is assigned to
226 * DDERR_ALREADYINITIALIZED
228 *****************************************************************************/
229 static HRESULT WINAPI
230 IDirect3DViewportImpl_Initialize(IDirect3DViewport3
*iface
,
233 TRACE("(%p)->(%p) no-op...\n", iface
, Direct3D
);
234 return DDERR_ALREADYINITIALIZED
;
237 /*****************************************************************************
238 * IDirect3DViewport3::GetViewport
240 * Returns the viewport data assigned to this viewport interface
243 * Data: Address to store the data
247 * DDERR_INVALIDPARAMS if Data is NULL
249 *****************************************************************************/
250 static HRESULT WINAPI
251 IDirect3DViewportImpl_GetViewport(IDirect3DViewport3
*iface
,
254 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
256 TRACE("(%p/%p)->(%p)\n", This
, iface
, lpData
);
257 if (This
->use_vp2
!= 0) {
258 ERR(" Requesting to get a D3DVIEWPORT struct where a D3DVIEWPORT2 was set !\n");
259 return DDERR_INVALIDPARAMS
;
261 dwSize
= lpData
->dwSize
;
262 memset(lpData
, 0, dwSize
);
263 memcpy(lpData
, &(This
->viewports
.vp1
), dwSize
);
265 if (TRACE_ON(d3d7
)) {
266 TRACE(" returning D3DVIEWPORT :\n");
267 _dump_D3DVIEWPORT(lpData
);
273 /*****************************************************************************
274 * IDirect3DViewport3::SetViewport
276 * Sets the viewport information for this interface
279 * lpData: Viewport to set
283 * DDERR_INVALIDPARAMS if Data is NULL
285 *****************************************************************************/
286 static HRESULT WINAPI
287 IDirect3DViewportImpl_SetViewport(IDirect3DViewport3
*iface
,
290 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
291 LPDIRECT3DVIEWPORT3 current_viewport
;
292 TRACE("(%p/%p)->(%p)\n", This
, iface
, lpData
);
294 if (TRACE_ON(d3d7
)) {
295 TRACE(" getting D3DVIEWPORT :\n");
296 _dump_D3DVIEWPORT(lpData
);
300 memset(&(This
->viewports
.vp1
), 0, sizeof(This
->viewports
.vp1
));
301 memcpy(&(This
->viewports
.vp1
), lpData
, lpData
->dwSize
);
303 /* Tests on two games show that these values are never used properly so override
304 them with proper ones :-)
306 This
->viewports
.vp1
.dvMinZ
= 0.0;
307 This
->viewports
.vp1
.dvMaxZ
= 1.0;
309 if (This
->active_device
) {
310 IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
->active_device
, IDirect3DDevice3
), ¤t_viewport
);
311 if (ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, current_viewport
) == This
)
312 This
->activate(This
);
313 IDirect3DViewport3_Release(current_viewport
);
319 /*****************************************************************************
320 * IDirect3DViewport3::TransformVertices
322 * Transforms vertices by the transformation matrix.
325 * dwVertexCount: The number of vertices to be transformed
326 * lpData: Pointer to the vertex data
327 * dwFlags: D3DTRANSFORM_CLIPPED or D3DTRANSFORM_UNCLIPPED
328 * lpOffScreen: Is set to nonzero if all vertices are off-screen
331 * D3D_OK because it's a stub
333 *****************************************************************************/
334 static HRESULT WINAPI
335 IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3
*iface
,
337 D3DTRANSFORMDATA
*lpData
,
341 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
342 FIXME("(%p)->(%08lx,%p,%08lx,%p): stub!\n", This
, dwVertexCount
, lpData
, dwFlags
, lpOffScreen
);
348 /*****************************************************************************
349 * IDirect3DViewport3::LightElements
351 * The DirectX 5.0 sdk says that it's not implemented
359 *****************************************************************************/
360 static HRESULT WINAPI
361 IDirect3DViewportImpl_LightElements(IDirect3DViewport3
*iface
,
362 DWORD dwElementCount
,
363 LPD3DLIGHTDATA lpData
)
365 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
366 TRACE("(%p)->(%08lx,%p): Unimplemented!\n", This
, dwElementCount
, lpData
);
367 return DDERR_UNSUPPORTED
;
370 /*****************************************************************************
371 * IDirect3DViewport3::SetBackground
373 * Sets tje background material
376 * hMat: Handle from a IDirect3DMaterial interface
381 *****************************************************************************/
382 static HRESULT WINAPI
383 IDirect3DViewportImpl_SetBackground(IDirect3DViewport3
*iface
,
384 D3DMATERIALHANDLE hMat
)
386 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
387 TRACE("(%p)->(%ld)\n", This
, (DWORD
) hMat
);
389 if(hMat
&& hMat
> This
->ddraw
->d3ddevice
->numHandles
)
391 WARN("Specified Handle %ld out of range\n", hMat
);
392 return DDERR_INVALIDPARAMS
;
394 else if(hMat
&& This
->ddraw
->d3ddevice
->Handles
[hMat
- 1].type
!= DDrawHandle_Material
)
396 WARN("Handle %ld is not a material handle\n", hMat
);
397 return DDERR_INVALIDPARAMS
;
402 This
->background
= (IDirect3DMaterialImpl
*) This
->ddraw
->d3ddevice
->Handles
[hMat
- 1].ptr
;
403 TRACE(" setting background color : %f %f %f %f\n",
404 This
->background
->mat
.u
.diffuse
.u1
.r
,
405 This
->background
->mat
.u
.diffuse
.u2
.g
,
406 This
->background
->mat
.u
.diffuse
.u3
.b
,
407 This
->background
->mat
.u
.diffuse
.u4
.a
);
411 This
->background
= NULL
;
412 TRACE("Setting background to NULL\n");
418 /*****************************************************************************
419 * IDirect3DViewport3::GetBackground
421 * Returns the material handle assigned to the background of the viewport
424 * lphMat: Address to store the handle
425 * lpValid: is set to FALSE if no background is set, TRUE if one is set
430 *****************************************************************************/
431 static HRESULT WINAPI
432 IDirect3DViewportImpl_GetBackground(IDirect3DViewport3
*iface
,
433 D3DMATERIALHANDLE
*lphMat
,
436 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
437 TRACE("(%p)->(%p,%p)\n", This
, lphMat
, lpValid
);
441 *lpValid
= This
->background
!= NULL
;
447 *lphMat
= This
->background
->Handle
;
458 /*****************************************************************************
459 * IDirect3DViewport3::SetBackgroundDepth
461 * Sets a surface that represents the background depth. It's contents are
462 * used to set the depth buffer in IDirect3DViewport3::Clear
465 * lpDDSurface: Surface to set
467 * Returns: D3D_OK, because it's a stub
469 *****************************************************************************/
470 static HRESULT WINAPI
471 IDirect3DViewportImpl_SetBackgroundDepth(IDirect3DViewport3
*iface
,
472 IDirectDrawSurface
*lpDDSurface
)
474 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
475 FIXME("(%p)->(%p): stub!\n", This
, lpDDSurface
);
479 /*****************************************************************************
480 * IDirect3DViewport3::GetBackgroundDepth
482 * Returns the surface that represents the depth field
485 * lplpDDSurface: Address to store the interface pointer
486 * lpValid: Set to TRUE if a depth is asigned, FALSE otherwise
489 * D3D_OK, because it's a stub
490 * (DDERR_INVALIDPARAMS if DDSurface of Valid is NULL)
492 *****************************************************************************/
493 static HRESULT WINAPI
494 IDirect3DViewportImpl_GetBackgroundDepth(IDirect3DViewport3
*iface
,
495 IDirectDrawSurface
**lplpDDSurface
,
498 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
499 FIXME("(%p)->(%p,%p): stub!\n", This
, lplpDDSurface
, lpValid
);
503 /*****************************************************************************
504 * IDirect3DViewport3::Clear
506 * Clears the render target and / or the z buffer
509 * dwCount: The amount of rectangles to clear. If 0, the whole buffer is
511 * lpRects: Pointer to the array of rectangles. If NULL, Count must be 0
512 * dwFlags: D3DCLEAR_ZBUFFER and / or D3DCLEAR_TARGET
516 * D3DERR_VIEWPORTHASNODEVICE if there's no active device
517 * The return value of IDirect3DDevice7::Clear
519 *****************************************************************************/
520 static HRESULT WINAPI
521 IDirect3DViewportImpl_Clear(IDirect3DViewport3
*iface
,
526 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
527 DWORD color
= 0x00000000;
529 TRACE("(%p/%p)->(%08lx,%p,%08lx)\n", This
, iface
, dwCount
, lpRects
, dwFlags
);
530 if (This
->active_device
== NULL
) {
531 ERR(" Trying to clear a viewport not attached to a device !\n");
532 return D3DERR_VIEWPORTHASNODEVICE
;
534 if (dwFlags
& D3DCLEAR_TARGET
) {
535 if (This
->background
== NULL
) {
536 ERR(" Trying to clear the color buffer without background material !\n");
539 ((int) ((This
->background
->mat
.u
.diffuse
.u1
.r
) * 255) << 16) |
540 ((int) ((This
->background
->mat
.u
.diffuse
.u2
.g
) * 255) << 8) |
541 ((int) ((This
->background
->mat
.u
.diffuse
.u3
.b
) * 255) << 0) |
542 ((int) ((This
->background
->mat
.u
.diffuse
.u4
.a
) * 255) << 24);
546 return IDirect3DDevice7_Clear(ICOM_INTERFACE(This
->active_device
, IDirect3DDevice7
),
549 dwFlags
& (D3DCLEAR_ZBUFFER
| D3DCLEAR_TARGET
),
555 /*****************************************************************************
556 * IDirect3DViewport3::AddLight
558 * Adds an light to the viewport
561 * lpDirect3DLight: Interface of the light to add
565 * DDERR_INVALIDPARAMS if Direct3DLight is NULL
566 * DDERR_INVALIDPARAMS if there are 8 lights or more
568 *****************************************************************************/
569 static HRESULT WINAPI
570 IDirect3DViewportImpl_AddLight(IDirect3DViewport3
*iface
,
571 IDirect3DLight
*lpDirect3DLight
)
573 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
574 IDirect3DLightImpl
*lpDirect3DLightImpl
= ICOM_OBJECT(IDirect3DLightImpl
, IDirect3DLight
, lpDirect3DLight
);
576 DWORD map
= This
->map_lights
;
578 TRACE("(%p)->(%p)\n", This
, lpDirect3DLight
);
580 if (This
->num_lights
>= 8)
581 return DDERR_INVALIDPARAMS
;
583 /* Find a light number and update both light and viewports objects accordingly */
588 lpDirect3DLightImpl
->dwLightIndex
= i
;
590 This
->map_lights
|= 1<<i
;
592 /* Add the light in the 'linked' chain */
593 lpDirect3DLightImpl
->next
= This
->lights
;
594 This
->lights
= lpDirect3DLightImpl
;
596 /* Attach the light to the viewport */
597 lpDirect3DLightImpl
->active_viewport
= This
;
599 /* If active, activate the light */
600 if (This
->active_device
!= NULL
) {
601 lpDirect3DLightImpl
->activate(lpDirect3DLightImpl
);
607 /*****************************************************************************
608 * IDirect3DViewport3::DeleteLight
610 * Deletes a light from the viewports' light list
613 * lpDirect3DLight: Light to delete
617 * DDERR_INVALIDPARAMS if the light wasn't found
619 *****************************************************************************/
620 static HRESULT WINAPI
621 IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3
*iface
,
622 IDirect3DLight
*lpDirect3DLight
)
624 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
625 IDirect3DLightImpl
*lpDirect3DLightImpl
= ICOM_OBJECT(IDirect3DLightImpl
, IDirect3DLight
, lpDirect3DLight
);
626 IDirect3DLightImpl
*cur_light
, *prev_light
= NULL
;
628 TRACE("(%p)->(%p)\n", This
, lpDirect3DLight
);
629 cur_light
= This
->lights
;
630 while (cur_light
!= NULL
) {
631 if (cur_light
== lpDirect3DLightImpl
) {
632 lpDirect3DLightImpl
->desactivate(lpDirect3DLightImpl
);
633 if (prev_light
== NULL
) This
->lights
= cur_light
->next
;
634 else prev_light
->next
= cur_light
->next
;
635 /* Detach the light to the viewport */
636 cur_light
->active_viewport
= NULL
;
638 This
->map_lights
&= ~(1<<lpDirect3DLightImpl
->dwLightIndex
);
641 prev_light
= cur_light
;
642 cur_light
= cur_light
->next
;
644 return DDERR_INVALIDPARAMS
;
647 /*****************************************************************************
648 * IDirect3DViewport::NextLight
650 * Enumerates the lights associated with the viewport
653 * lpDirect3DLight: Light to start with
654 * lplpDirect3DLight: Address to store the successor to
657 * D3D_OK, because it's a stub
659 *****************************************************************************/
660 static HRESULT WINAPI
661 IDirect3DViewportImpl_NextLight(IDirect3DViewport3
*iface
,
662 IDirect3DLight
*lpDirect3DLight
,
663 IDirect3DLight
**lplpDirect3DLight
,
666 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
667 FIXME("(%p)->(%p,%p,%08lx): stub!\n", This
, lpDirect3DLight
, lplpDirect3DLight
, dwFlags
);
671 /*****************************************************************************
672 * IDirect3DViewport2 Methods.
673 *****************************************************************************/
675 /*****************************************************************************
676 * IDirect3DViewport3::GetViewport2
678 * Returns the currently set viewport in a D3DVIEWPORT2 structure.
679 * Simmilar to IDirect3DViewport3::GetViewport
682 * lpData: Pointer to the structure to fill
686 * DDERR_INVALIDPARAMS if the viewport was set with
687 * IDirect3DViewport3::SetViewport
688 * DDERR_INVALIDPARAMS if Data is NULL
690 *****************************************************************************/
691 static HRESULT WINAPI
692 IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3
*iface
,
693 D3DVIEWPORT2
*lpData
)
695 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
697 TRACE("(%p)->(%p)\n", This
, lpData
);
698 if (This
->use_vp2
!= 1) {
699 ERR(" Requesting to get a D3DVIEWPORT2 struct where a D3DVIEWPORT was set !\n");
700 return DDERR_INVALIDPARAMS
;
702 dwSize
= lpData
->dwSize
;
703 memset(lpData
, 0, dwSize
);
704 memcpy(lpData
, &(This
->viewports
.vp2
), dwSize
);
706 if (TRACE_ON(d3d7
)) {
707 TRACE(" returning D3DVIEWPORT2 :\n");
708 _dump_D3DVIEWPORT2(lpData
);
714 /*****************************************************************************
715 * IDirect3DViewport3::SetViewport2
717 * Sets the viewport from a D3DVIEWPORT2 structure
720 * lpData: Viewport to set
725 *****************************************************************************/
726 static HRESULT WINAPI
727 IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3
*iface
,
728 D3DVIEWPORT2
*lpData
)
730 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
731 LPDIRECT3DVIEWPORT3 current_viewport
;
732 TRACE("(%p/%p)->(%p)\n", This
, iface
, lpData
);
734 if (TRACE_ON(d3d7
)) {
735 TRACE(" getting D3DVIEWPORT2 :\n");
736 _dump_D3DVIEWPORT2(lpData
);
740 memset(&(This
->viewports
.vp2
), 0, sizeof(This
->viewports
.vp2
));
741 memcpy(&(This
->viewports
.vp2
), lpData
, lpData
->dwSize
);
743 if (This
->active_device
) {
744 IDirect3DDevice3_GetCurrentViewport(ICOM_INTERFACE(This
->active_device
, IDirect3DDevice3
), ¤t_viewport
);
745 if (ICOM_OBJECT(IDirect3DViewportImpl
, IDirect3DViewport3
, current_viewport
) == This
)
746 This
->activate(This
);
747 IDirect3DViewport3_Release(current_viewport
);
753 /*****************************************************************************
754 * IDirect3DViewport3 Methods.
755 *****************************************************************************/
757 /*****************************************************************************
758 * IDirect3DViewport3::SetBackgroundDepth2
760 * Sets a IDirectDrawSurface4 surface as the background depth surface
763 * lpDDS: Surface to set
766 * D3D_OK, because it's stub
768 *****************************************************************************/
769 static HRESULT WINAPI
770 IDirect3DViewportImpl_SetBackgroundDepth2(IDirect3DViewport3
*iface
,
771 IDirectDrawSurface4
*lpDDS
)
773 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
774 FIXME("(%p)->(%p): stub!\n", This
, lpDDS
);
778 /*****************************************************************************
779 * IDirect3DViewport3::GetBackgroundDepth2
781 * Returns the IDirect3DSurface4 interface to the background depth surface
784 * lplpDDS: Address to store the interface pointer at
785 * lpValid: Set to true if a surface is assigned
788 * D3D_OK because it's a stub
790 *****************************************************************************/
791 static HRESULT WINAPI
792 IDirect3DViewportImpl_GetBackgroundDepth2(IDirect3DViewport3
*iface
,
793 IDirectDrawSurface4
**lplpDDS
,
796 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
797 FIXME("(%p/%p)->(%p,%p): stub!\n", This
, iface
, lplpDDS
, lpValid
);
801 /*****************************************************************************
802 * IDirect3DViewport3::Clear2
804 * Another clearing method
807 * Count: Number of rectangles to clear
808 * Rects: Rectangle array to clear
809 * Flags: Some flags :)
810 * Color: Color to fill the render target with
811 * Z: Value to fill the depth buffer with
812 * Stencil: Value to fill the stencil bits with
816 *****************************************************************************/
817 static HRESULT WINAPI
818 IDirect3DViewportImpl_Clear2(IDirect3DViewport3
*iface
,
826 ICOM_THIS_FROM(IDirect3DViewportImpl
, IDirect3DViewport3
, iface
);
827 TRACE("(%p)->(%08lx,%p,%08lx,%08lx,%f,%08lx)\n", This
, dwCount
, lpRects
, dwFlags
, dwColor
, dvZ
, dwStencil
);
828 if (This
->active_device
== NULL
) {
829 ERR(" Trying to clear a viewport not attached to a device !\n");
830 return D3DERR_VIEWPORTHASNODEVICE
;
832 return IDirect3DDevice7_Clear(ICOM_INTERFACE(This
->active_device
, IDirect3DDevice7
),
841 /*****************************************************************************
843 *****************************************************************************/
845 const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl
=
847 /*** IUnknown Methods ***/
848 IDirect3DViewportImpl_QueryInterface
,
849 IDirect3DViewportImpl_AddRef
,
850 IDirect3DViewportImpl_Release
,
851 /*** IDirect3DViewport Methods */
852 IDirect3DViewportImpl_Initialize
,
853 IDirect3DViewportImpl_GetViewport
,
854 IDirect3DViewportImpl_SetViewport
,
855 IDirect3DViewportImpl_TransformVertices
,
856 IDirect3DViewportImpl_LightElements
,
857 IDirect3DViewportImpl_SetBackground
,
858 IDirect3DViewportImpl_GetBackground
,
859 IDirect3DViewportImpl_SetBackgroundDepth
,
860 IDirect3DViewportImpl_GetBackgroundDepth
,
861 IDirect3DViewportImpl_Clear
,
862 IDirect3DViewportImpl_AddLight
,
863 IDirect3DViewportImpl_DeleteLight
,
864 IDirect3DViewportImpl_NextLight
,
865 /*** IDirect3DViewport2 Methods ***/
866 IDirect3DViewportImpl_GetViewport2
,
867 IDirect3DViewportImpl_SetViewport2
,
868 /*** IDirect3DViewport3 Methods ***/
869 IDirect3DViewportImpl_SetBackgroundDepth2
,
870 IDirect3DViewportImpl_GetBackgroundDepth2
,
871 IDirect3DViewportImpl_Clear2
,