4 This files contains the implementation of Direct3DViewport2. */
9 #include "wine/obj_base.h"
15 #include "d3d_private.h"
17 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 vp
->lpvtbl
= &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 vp
->lpvtbl
= &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
);
93 WINE_StringFromCLSID((LPCLSID
)riid
,xrefiid
);
94 FIXME(ddraw
, "(%p)->(%s,%p): stub\n", This
, xrefiid
,ppvObj
);
101 static ULONG WINAPI
IDirect3DViewport2Impl_AddRef(LPDIRECT3DVIEWPORT2 iface
)
103 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
104 TRACE(ddraw
, "(%p)->()incrementing from %lu.\n", This
, This
->ref
);
106 return ++(This
->ref
);
111 static ULONG WINAPI
IDirect3DViewport2Impl_Release(LPDIRECT3DVIEWPORT2 iface
)
113 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
114 FIXME( ddraw
, "(%p)->() decrementing from %lu.\n", This
, This
->ref
);
116 if (!--(This
->ref
)) {
117 HeapFree(GetProcessHeap(),0,This
);
124 /*** IDirect3DViewport methods ***/
125 static HRESULT WINAPI
IDirect3DViewport2Impl_Initialize(LPDIRECT3DVIEWPORT2 iface
,
128 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
129 FIXME(ddraw
, "(%p)->(%p): stub\n", This
, d3d
);
134 static HRESULT WINAPI
IDirect3DViewport2Impl_GetViewport(LPDIRECT3DVIEWPORT2 iface
,
137 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
138 FIXME(ddraw
, "(%p)->(%p): stub\n", This
, lpvp
);
140 if (This
->use_vp2
!= 0)
141 return DDERR_INVALIDPARAMS
;
143 *lpvp
= This
->viewport
.vp1
;
148 static HRESULT WINAPI
IDirect3DViewport2Impl_SetViewport(LPDIRECT3DVIEWPORT2 iface
,
151 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
152 FIXME(ddraw
, "(%p)->(%p): stub\n", This
, lpvp
);
155 This
->viewport
.vp1
= *lpvp
;
157 TRACE(ddraw
, "dwSize = %ld dwX = %ld dwY = %ld\n",
158 lpvp
->dwSize
, lpvp
->dwX
, lpvp
->dwY
);
159 TRACE(ddraw
, "dwWidth = %ld dwHeight = %ld\n",
160 lpvp
->dwWidth
, lpvp
->dwHeight
);
161 TRACE(ddraw
, "dvScaleX = %f dvScaleY = %f\n",
162 lpvp
->dvScaleX
, lpvp
->dvScaleY
);
163 TRACE(ddraw
, "dvMaxX = %f dvMaxY = %f\n",
164 lpvp
->dvMaxX
, lpvp
->dvMaxY
);
165 TRACE(ddraw
, "dvMinZ = %f dvMaxZ = %f\n",
166 lpvp
->dvMinZ
, lpvp
->dvMaxZ
);
172 static HRESULT WINAPI
IDirect3DViewport2Impl_TransformVertices(LPDIRECT3DVIEWPORT2 iface
,
174 LPD3DTRANSFORMDATA lpData
,
178 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
179 FIXME(ddraw
, "(%p)->(%8ld,%p,%08lx,%p): stub\n",
180 This
, dwVertexCount
, lpData
, dwFlags
, lpOffScreen
);
185 static HRESULT WINAPI
IDirect3DViewport2Impl_LightElements(LPDIRECT3DVIEWPORT2 iface
,
186 DWORD dwElementCount
,
187 LPD3DLIGHTDATA lpData
)
189 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
190 FIXME(ddraw
, "(%p)->(%8ld,%p): stub\n", This
, dwElementCount
, lpData
);
195 static HRESULT WINAPI
IDirect3DViewport2Impl_SetBackground(LPDIRECT3DVIEWPORT2 iface
,
196 D3DMATERIALHANDLE hMat
)
198 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
199 FIXME(ddraw
, "(%p)->(%08lx): stub\n", This
, (DWORD
) hMat
);
204 static HRESULT WINAPI
IDirect3DViewport2Impl_GetBackground(LPDIRECT3DVIEWPORT2 iface
,
205 LPD3DMATERIALHANDLE lphMat
,
208 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
209 FIXME(ddraw
, "(%p)->(%p,%p): stub\n", This
, lphMat
, lpValid
);
214 static HRESULT WINAPI
IDirect3DViewport2Impl_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface
,
215 LPDIRECTDRAWSURFACE lpDDSurface
)
217 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
218 FIXME(ddraw
, "(%p)->(%p): stub\n", This
, lpDDSurface
);
223 static HRESULT WINAPI
IDirect3DViewport2Impl_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface
,
224 LPDIRECTDRAWSURFACE
* lplpDDSurface
,
227 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
228 FIXME(ddraw
, "(%p)->(%p,%p): stub\n", This
, lplpDDSurface
, lpValid
);
233 static HRESULT WINAPI
IDirect3DViewport2Impl_Clear(LPDIRECT3DVIEWPORT2 iface
,
238 ICOM_THIS(IDirect3DViewport2Impl
,iface
);
240 FIXME(ddraw
, "(%p)->(%8ld,%p,%08lx): stub\n", This
, dwCount
, lpRects
, dwFlags
);
242 /* For the moment, ignore the rectangles */
243 if (This
->device
.active_device1
!= NULL
) {
244 /* Get the rendering context */
246 This
->device
.active_device2
->set_context(This
->device
.active_device2
);
248 This
->device
.active_device1
->set_context(This
->device
.active_device1
);
251 /* Clears the screen */
252 glGetBooleanv(GL_DEPTH_TEST
, &ztest
);
253 glDepthMask(GL_TRUE
); /* Enables Z writing to be sure to delete also the Z buffer */
254 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(ddraw
, "(%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(ddraw
, "(%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(ddraw
, "(%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(ddraw
, "(%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(ddraw
, "(%p)->(%p)\n", This
, lpViewport2
);
328 TRACE(ddraw
, "dwSize = %ld dwX = %ld dwY = %ld\n",
329 lpViewport2
->dwSize
, lpViewport2
->dwX
, lpViewport2
->dwY
);
330 TRACE(ddraw
, "dwWidth = %ld dwHeight = %ld\n",
331 lpViewport2
->dwWidth
, lpViewport2
->dwHeight
);
332 TRACE(ddraw
, "dvClipX = %f dvClipY = %f\n",
333 lpViewport2
->dvClipX
, lpViewport2
->dvClipY
);
334 TRACE(ddraw
, "dvClipWidth = %f dvClipHeight = %f\n",
335 lpViewport2
->dvClipWidth
, lpViewport2
->dvClipHeight
);
336 TRACE(ddraw
, "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
= {
350 /*** IUnknown methods ***/
351 IDirect3DViewport2Impl_QueryInterface
,
352 IDirect3DViewport2Impl_AddRef
,
353 IDirect3DViewport2Impl_Release
,
354 /*** IDirect3DViewport methods ***/
355 IDirect3DViewport2Impl_Initialize
,
356 IDirect3DViewport2Impl_GetViewport
,
357 IDirect3DViewport2Impl_SetViewport
,
358 IDirect3DViewport2Impl_TransformVertices
,
359 IDirect3DViewport2Impl_LightElements
,
360 IDirect3DViewport2Impl_SetBackground
,
361 IDirect3DViewport2Impl_GetBackground
,
362 IDirect3DViewport2Impl_SetBackgroundDepth
,
363 IDirect3DViewport2Impl_GetBackgroundDepth
,
364 IDirect3DViewport2Impl_Clear
,
365 IDirect3DViewport2Impl_AddLight
,
366 IDirect3DViewport2Impl_DeleteLight
,
367 IDirect3DViewport2Impl_NextLight
,
368 /*** IDirect3DViewport2 methods ***/
369 IDirect3DViewport2Impl_GetViewport2
,
370 IDirect3DViewport2Impl_SetViewport2
373 #else /* HAVE_MESAGL */
375 LPDIRECT3DVIEWPORT
d3dviewport_create(IDirect3DImpl
* d3d1
) {
376 ERR(ddraw
, "Should not be called...\n");
380 LPDIRECT3DVIEWPORT2
d3dviewport2_create(IDirect3D2Impl
* d3d2
) {
381 ERR(ddraw
, "Should not be called...\n");
385 #endif /* HAVE_MESAGL */