4 This files contains the implementation of Direct3DViewport2. */
9 #include "wine/obj_base.h"
13 #include "debugtools.h"
16 #include "d3d_private.h"
18 DEFAULT_DEBUG_CHANNEL(ddraw
)
22 static ICOM_VTABLE(IDirect3DViewport2
) viewport2_vtable
;
24 /*******************************************************************************
25 * Viewport1/2 static functions
27 static void activate(IDirect3DViewport2Impl
* This
) {
28 IDirect3DLightImpl
* l
;
30 /* Activate all the lights associated with this context */
39 /*******************************************************************************
40 * Viewport1/2 Creation functions
42 LPDIRECT3DVIEWPORT2
d3dviewport2_create(IDirect3D2Impl
* d3d2
)
44 IDirect3DViewport2Impl
* vp
;
46 vp
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirect3DViewport2Impl
));
48 ICOM_VTBL(vp
) = &viewport2_vtable
;
52 vp
->device
.active_device2
= NULL
;
53 vp
->activate
= activate
;
57 vp
->nextlight
= GL_LIGHT0
;
59 return (LPDIRECT3DVIEWPORT2
)vp
;
62 LPDIRECT3DVIEWPORT
d3dviewport_create(IDirect3DImpl
* d3d1
)
64 IDirect3DViewport2Impl
* vp
;
66 vp
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirect3DViewport2Impl
));
68 ICOM_VTBL(vp
) = &viewport2_vtable
;
72 vp
->device
.active_device1
= NULL
;
73 vp
->activate
= activate
;
77 vp
->nextlight
= GL_LIGHT0
;
79 return (LPDIRECT3DVIEWPORT
) vp
;
82 /*******************************************************************************
83 * IDirect3DViewport2 methods
86 static HRESULT WINAPI
IDirect3DViewport2Impl_QueryInterface(LPDIRECT3DVIEWPORT2 iface
,
90 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
92 FIXME("(%p)->(%s,%p): stub\n", This
, debugstr_guid(riid
),ppvObj
);
99 static ULONG WINAPI
IDirect3DViewport2Impl_AddRef(LPDIRECT3DVIEWPORT2 iface
)
101 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
102 TRACE("(%p)->()incrementing from %lu.\n", This
, This
->ref
);
104 return ++(This
->ref
);
109 static ULONG WINAPI
IDirect3DViewport2Impl_Release(LPDIRECT3DVIEWPORT2 iface
)
111 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
112 FIXME("(%p)->() decrementing from %lu.\n", This
, This
->ref
);
114 if (!--(This
->ref
)) {
115 HeapFree(GetProcessHeap(),0,This
);
122 /*** IDirect3DViewport methods ***/
123 static HRESULT WINAPI
IDirect3DViewport2Impl_Initialize(LPDIRECT3DVIEWPORT2 iface
,
126 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
127 FIXME("(%p)->(%p): stub\n", This
, d3d
);
132 static HRESULT WINAPI
IDirect3DViewport2Impl_GetViewport(LPDIRECT3DVIEWPORT2 iface
,
135 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
136 FIXME("(%p)->(%p): stub\n", This
, lpvp
);
138 if (This
->use_vp2
!= 0)
139 return DDERR_INVALIDPARAMS
;
141 *lpvp
= This
->viewport
.vp1
;
146 static HRESULT WINAPI
IDirect3DViewport2Impl_SetViewport(LPDIRECT3DVIEWPORT2 iface
,
149 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
150 FIXME("(%p)->(%p): stub\n", This
, lpvp
);
153 This
->viewport
.vp1
= *lpvp
;
155 TRACE("dwSize = %ld dwX = %ld dwY = %ld\n",
156 lpvp
->dwSize
, lpvp
->dwX
, lpvp
->dwY
);
157 TRACE("dwWidth = %ld dwHeight = %ld\n",
158 lpvp
->dwWidth
, lpvp
->dwHeight
);
159 TRACE("dvScaleX = %f dvScaleY = %f\n",
160 lpvp
->dvScaleX
, lpvp
->dvScaleY
);
161 TRACE("dvMaxX = %f dvMaxY = %f\n",
162 lpvp
->dvMaxX
, lpvp
->dvMaxY
);
163 TRACE("dvMinZ = %f dvMaxZ = %f\n",
164 lpvp
->dvMinZ
, lpvp
->dvMaxZ
);
170 static HRESULT WINAPI
IDirect3DViewport2Impl_TransformVertices(LPDIRECT3DVIEWPORT2 iface
,
172 LPD3DTRANSFORMDATA lpData
,
176 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
177 FIXME("(%p)->(%8ld,%p,%08lx,%p): stub\n",
178 This
, dwVertexCount
, lpData
, dwFlags
, lpOffScreen
);
183 static HRESULT WINAPI
IDirect3DViewport2Impl_LightElements(LPDIRECT3DVIEWPORT2 iface
,
184 DWORD dwElementCount
,
185 LPD3DLIGHTDATA lpData
)
187 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
188 FIXME("(%p)->(%8ld,%p): stub\n", This
, dwElementCount
, lpData
);
193 static HRESULT WINAPI
IDirect3DViewport2Impl_SetBackground(LPDIRECT3DVIEWPORT2 iface
,
194 D3DMATERIALHANDLE hMat
)
196 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
197 FIXME("(%p)->(%08lx): stub\n", This
, (DWORD
) hMat
);
202 static HRESULT WINAPI
IDirect3DViewport2Impl_GetBackground(LPDIRECT3DVIEWPORT2 iface
,
203 LPD3DMATERIALHANDLE lphMat
,
206 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
207 FIXME("(%p)->(%p,%p): stub\n", This
, lphMat
, lpValid
);
212 static HRESULT WINAPI
IDirect3DViewport2Impl_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface
,
213 LPDIRECTDRAWSURFACE lpDDSurface
)
215 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
216 FIXME("(%p)->(%p): stub\n", This
, lpDDSurface
);
221 static HRESULT WINAPI
IDirect3DViewport2Impl_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface
,
222 LPDIRECTDRAWSURFACE
* lplpDDSurface
,
225 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
226 FIXME("(%p)->(%p,%p): stub\n", This
, lplpDDSurface
, lpValid
);
231 static HRESULT WINAPI
IDirect3DViewport2Impl_Clear(LPDIRECT3DVIEWPORT2 iface
,
236 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
238 FIXME("(%p)->(%8ld,%p,%08lx): stub\n", This
, dwCount
, lpRects
, dwFlags
);
240 /* For the moment, ignore the rectangles */
241 if (This
->device
.active_device1
!= NULL
) {
242 /* Get the rendering context */
244 This
->device
.active_device2
->set_context(This
->device
.active_device2
);
246 This
->device
.active_device1
->set_context(This
->device
.active_device1
);
249 /* Clears the screen */
251 glGetBooleanv(GL_DEPTH_TEST
, &ztest
);
252 glDepthMask(GL_TRUE
); /* Enables Z writing to be sure to delete also the Z buffer */
253 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
260 static HRESULT WINAPI
IDirect3DViewport2Impl_AddLight(LPDIRECT3DVIEWPORT2 iface
,
261 LPDIRECT3DLIGHT lpLight
)
263 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
264 IDirect3DLightImpl
* ilpLight
=(IDirect3DLightImpl
*)lpLight
;
265 FIXME("(%p)->(%p): stub\n", This
, ilpLight
);
267 /* Add the light in the 'linked' chain */
268 ilpLight
->next
= This
->lights
;
269 This
->lights
= ilpLight
;
271 /* If active, activate the light */
272 if (This
->device
.active_device1
!= NULL
) {
273 /* Get the rendering context */
275 This
->device
.active_device2
->set_context(This
->device
.active_device2
);
277 This
->device
.active_device1
->set_context(This
->device
.active_device1
);
279 /* Activate the light */
280 ilpLight
->light_num
= This
->nextlight
++;
281 ilpLight
->activate(ilpLight
);
287 static HRESULT WINAPI
IDirect3DViewport2Impl_DeleteLight(LPDIRECT3DVIEWPORT2 iface
,
288 LPDIRECT3DLIGHT lpLight
)
290 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
291 FIXME("(%p)->(%p): stub\n", This
, lpLight
);
296 static HRESULT WINAPI
IDirect3DViewport2Impl_NextLight(LPDIRECT3DVIEWPORT2 iface
,
297 LPDIRECT3DLIGHT lpLight
,
298 LPDIRECT3DLIGHT
* lplpLight
,
301 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
302 FIXME("(%p)->(%p,%p,%08lx): stub\n", This
, lpLight
, lplpLight
, dwFlags
);
307 /*** IDirect3DViewport2 methods ***/
308 static HRESULT WINAPI
IDirect3DViewport2Impl_GetViewport2(LPDIRECT3DVIEWPORT2 iface
,
309 LPD3DVIEWPORT2 lpViewport2
)
311 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
312 TRACE("(%p)->(%p)\n", This
, lpViewport2
);
314 if (This
->use_vp2
!= 1)
315 return DDERR_INVALIDPARAMS
;
317 *lpViewport2
= This
->viewport
.vp2
;
322 static HRESULT WINAPI
IDirect3DViewport2Impl_SetViewport2(LPDIRECT3DVIEWPORT2 iface
,
323 LPD3DVIEWPORT2 lpViewport2
)
325 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
326 TRACE("(%p)->(%p)\n", This
, lpViewport2
);
328 TRACE("dwSize = %ld dwX = %ld dwY = %ld\n",
329 lpViewport2
->dwSize
, lpViewport2
->dwX
, lpViewport2
->dwY
);
330 TRACE("dwWidth = %ld dwHeight = %ld\n",
331 lpViewport2
->dwWidth
, lpViewport2
->dwHeight
);
332 TRACE("dvClipX = %f dvClipY = %f\n",
333 lpViewport2
->dvClipX
, lpViewport2
->dvClipY
);
334 TRACE("dvClipWidth = %f dvClipHeight = %f\n",
335 lpViewport2
->dvClipWidth
, lpViewport2
->dvClipHeight
);
336 TRACE("dvMinZ = %f dvMaxZ = %f\n",
337 lpViewport2
->dvMinZ
, lpViewport2
->dvMaxZ
);
339 This
->viewport
.vp2
= *lpViewport2
;
346 /*******************************************************************************
347 * IDirect3DViewport1/2 VTable
349 static ICOM_VTABLE(IDirect3DViewport2
) viewport2_vtable
=
351 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
352 /*** IUnknown methods ***/
353 IDirect3DViewport2Impl_QueryInterface
,
354 IDirect3DViewport2Impl_AddRef
,
355 IDirect3DViewport2Impl_Release
,
356 /*** IDirect3DViewport methods ***/
357 IDirect3DViewport2Impl_Initialize
,
358 IDirect3DViewport2Impl_GetViewport
,
359 IDirect3DViewport2Impl_SetViewport
,
360 IDirect3DViewport2Impl_TransformVertices
,
361 IDirect3DViewport2Impl_LightElements
,
362 IDirect3DViewport2Impl_SetBackground
,
363 IDirect3DViewport2Impl_GetBackground
,
364 IDirect3DViewport2Impl_SetBackgroundDepth
,
365 IDirect3DViewport2Impl_GetBackgroundDepth
,
366 IDirect3DViewport2Impl_Clear
,
367 IDirect3DViewport2Impl_AddLight
,
368 IDirect3DViewport2Impl_DeleteLight
,
369 IDirect3DViewport2Impl_NextLight
,
370 /*** IDirect3DViewport2 methods ***/
371 IDirect3DViewport2Impl_GetViewport2
,
372 IDirect3DViewport2Impl_SetViewport2
375 #else /* HAVE_MESAGL */
377 LPDIRECT3DVIEWPORT
d3dviewport_create(IDirect3DImpl
* d3d1
) {
378 ERR("Should not be called...\n");
382 LPDIRECT3DVIEWPORT2
d3dviewport2_create(IDirect3D2Impl
* d3d2
) {
383 ERR("Should not be called...\n");
387 #endif /* HAVE_MESAGL */