4 This files contains the implementation of Direct3DViewport2. */
9 #include "wine/obj_base.h"
12 #include "debugtools.h"
14 #include "d3d_private.h"
15 #include "mesa_private.h"
17 DEFAULT_DEBUG_CHANNEL(ddraw);
21 #define D3DVPRIVATE(x) mesa_d3dv_private*dvpriv=((mesa_d3dv_private*)x->private)
22 #define D3DLPRIVATE(x) mesa_d3dl_private*dlpriv=((mesa_d3dl_private*)x->private)
24 static ICOM_VTABLE(IDirect3DViewport2) viewport2_vtable;
26 /*******************************************************************************
27 * Viewport1/2 static functions
29 static void activate(IDirect3DViewport2Impl* This) {
30 IDirect3DLightImpl* l;
32 /* Activate all the lights associated with this context */
41 /*******************************************************************************
42 * Viewport1/2 Creation functions
44 LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2)
46 IDirect3DViewport2Impl* vp;
48 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2Impl));
49 vp->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dv_private));
51 ICOM_VTBL(vp) = &viewport2_vtable;
55 vp->device.active_device2 = NULL;
56 vp->activate = activate;
60 ((mesa_d3dv_private *) vp->private)->nextlight = GL_LIGHT0;
62 return (LPDIRECT3DVIEWPORT2)vp;
65 LPDIRECT3DVIEWPORT d3dviewport_create(IDirect3DImpl* d3d1)
67 IDirect3DViewport2Impl* vp;
69 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2Impl));
70 vp->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dv_private));
72 ICOM_VTBL(vp) = &viewport2_vtable;
76 vp->device.active_device1 = NULL;
77 vp->activate = activate;
81 ((mesa_d3dv_private *) vp->private)->nextlight = GL_LIGHT0;
83 return (LPDIRECT3DVIEWPORT) vp;
86 /*******************************************************************************
87 * IDirect3DViewport2 methods
90 HRESULT WINAPI IDirect3DViewport2Impl_QueryInterface(LPDIRECT3DVIEWPORT2 iface,
94 ICOM_THIS(IDirect3DViewport2Impl,iface);
96 FIXME("(%p)->(%s,%p): stub\n", This, debugstr_guid(riid),ppvObj);
103 ULONG WINAPI IDirect3DViewport2Impl_AddRef(LPDIRECT3DVIEWPORT2 iface)
105 ICOM_THIS(IDirect3DViewport2Impl,iface);
106 TRACE("(%p)->()incrementing from %lu.\n", This, This->ref );
108 return ++(This->ref);
113 ULONG WINAPI IDirect3DViewport2Impl_Release(LPDIRECT3DVIEWPORT2 iface)
115 ICOM_THIS(IDirect3DViewport2Impl,iface);
116 FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
118 if (!--(This->ref)) {
119 HeapFree(GetProcessHeap(),0,This);
126 /*** IDirect3DViewport methods ***/
127 HRESULT WINAPI IDirect3DViewport2Impl_Initialize(LPDIRECT3DVIEWPORT2 iface,
130 ICOM_THIS(IDirect3DViewport2Impl,iface);
131 FIXME("(%p)->(%p): stub\n", This, d3d);
136 HRESULT WINAPI IDirect3DViewport2Impl_GetViewport(LPDIRECT3DVIEWPORT2 iface,
139 ICOM_THIS(IDirect3DViewport2Impl,iface);
140 FIXME("(%p)->(%p): stub\n", This, lpvp);
142 if (This->use_vp2 != 0)
143 return DDERR_INVALIDPARAMS;
145 *lpvp = This->viewport.vp1;
150 HRESULT WINAPI IDirect3DViewport2Impl_SetViewport(LPDIRECT3DVIEWPORT2 iface,
153 ICOM_THIS(IDirect3DViewport2Impl,iface);
154 FIXME("(%p)->(%p): stub\n", This, lpvp);
157 This->viewport.vp1 = *lpvp;
159 TRACE("dwSize = %ld dwX = %ld dwY = %ld\n",
160 lpvp->dwSize, lpvp->dwX, lpvp->dwY);
161 TRACE("dwWidth = %ld dwHeight = %ld\n",
162 lpvp->dwWidth, lpvp->dwHeight);
163 TRACE("dvScaleX = %f dvScaleY = %f\n",
164 lpvp->dvScaleX, lpvp->dvScaleY);
165 TRACE("dvMaxX = %f dvMaxY = %f\n",
166 lpvp->dvMaxX, lpvp->dvMaxY);
167 TRACE("dvMinZ = %f dvMaxZ = %f\n",
168 lpvp->dvMinZ, lpvp->dvMaxZ);
174 HRESULT WINAPI IDirect3DViewport2Impl_TransformVertices(LPDIRECT3DVIEWPORT2 iface,
176 LPD3DTRANSFORMDATA lpData,
180 ICOM_THIS(IDirect3DViewport2Impl,iface);
181 FIXME("(%p)->(%8ld,%p,%08lx,%p): stub\n",
182 This, dwVertexCount, lpData, dwFlags, lpOffScreen);
187 HRESULT WINAPI IDirect3DViewport2Impl_LightElements(LPDIRECT3DVIEWPORT2 iface,
188 DWORD dwElementCount,
189 LPD3DLIGHTDATA lpData)
191 ICOM_THIS(IDirect3DViewport2Impl,iface);
192 FIXME("(%p)->(%8ld,%p): stub\n", This, dwElementCount, lpData);
197 HRESULT WINAPI IDirect3DViewport2Impl_SetBackground(LPDIRECT3DVIEWPORT2 iface,
198 D3DMATERIALHANDLE hMat)
200 ICOM_THIS(IDirect3DViewport2Impl,iface);
201 FIXME("(%p)->(%08lx): stub\n", This, (DWORD) hMat);
206 HRESULT WINAPI IDirect3DViewport2Impl_GetBackground(LPDIRECT3DVIEWPORT2 iface,
207 LPD3DMATERIALHANDLE lphMat,
210 ICOM_THIS(IDirect3DViewport2Impl,iface);
211 FIXME("(%p)->(%p,%p): stub\n", This, lphMat, lpValid);
216 HRESULT WINAPI IDirect3DViewport2Impl_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface,
217 LPDIRECTDRAWSURFACE lpDDSurface)
219 ICOM_THIS(IDirect3DViewport2Impl,iface);
220 FIXME("(%p)->(%p): stub\n", This, lpDDSurface);
225 HRESULT WINAPI IDirect3DViewport2Impl_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface,
226 LPDIRECTDRAWSURFACE* lplpDDSurface,
229 ICOM_THIS(IDirect3DViewport2Impl,iface);
230 FIXME("(%p)->(%p,%p): stub\n", This, lplpDDSurface, lpValid);
235 HRESULT WINAPI IDirect3DViewport2Impl_Clear(LPDIRECT3DVIEWPORT2 iface,
240 ICOM_THIS(IDirect3DViewport2Impl,iface);
242 FIXME("(%p)->(%8ld,%p,%08lx): stub\n", This, dwCount, lpRects, dwFlags);
244 /* For the moment, ignore the rectangles */
245 if (This->device.active_device1 != NULL) {
246 /* Get the rendering context */
248 This->device.active_device2->set_context(This->device.active_device2);
250 This->device.active_device1->set_context(This->device.active_device1);
253 /* Clears the screen */
255 glGetBooleanv(GL_DEPTH_TEST, &ztest);
256 glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
257 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
264 HRESULT WINAPI IDirect3DViewport2Impl_AddLight(LPDIRECT3DVIEWPORT2 iface,
265 LPDIRECT3DLIGHT lpLight)
267 ICOM_THIS(IDirect3DViewport2Impl,iface);
268 IDirect3DLightImpl* ilpLight=(IDirect3DLightImpl*)lpLight;
269 FIXME("(%p)->(%p): stub\n", This, ilpLight);
271 /* Add the light in the 'linked' chain */
272 ilpLight->next = This->lights;
273 This->lights = ilpLight;
275 /* If active, activate the light */
276 if (This->device.active_device1 != NULL) {
278 D3DLPRIVATE(ilpLight);
280 /* Get the rendering context */
282 This->device.active_device2->set_context(This->device.active_device2);
284 This->device.active_device1->set_context(This->device.active_device1);
286 /* Activate the light */
287 dlpriv->light_num = dvpriv->nextlight++;
288 ilpLight->activate(ilpLight);
294 HRESULT WINAPI IDirect3DViewport2Impl_DeleteLight(LPDIRECT3DVIEWPORT2 iface,
295 LPDIRECT3DLIGHT lpLight)
297 ICOM_THIS(IDirect3DViewport2Impl,iface);
298 FIXME("(%p)->(%p): stub\n", This, lpLight);
303 HRESULT WINAPI IDirect3DViewport2Impl_NextLight(LPDIRECT3DVIEWPORT2 iface,
304 LPDIRECT3DLIGHT lpLight,
305 LPDIRECT3DLIGHT* lplpLight,
308 ICOM_THIS(IDirect3DViewport2Impl,iface);
309 FIXME("(%p)->(%p,%p,%08lx): stub\n", This, lpLight, lplpLight, dwFlags);
314 /*** IDirect3DViewport2 methods ***/
315 HRESULT WINAPI IDirect3DViewport2Impl_GetViewport2(LPDIRECT3DVIEWPORT2 iface,
316 LPD3DVIEWPORT2 lpViewport2)
318 ICOM_THIS(IDirect3DViewport2Impl,iface);
319 TRACE("(%p)->(%p)\n", This, lpViewport2);
321 if (This->use_vp2 != 1)
322 return DDERR_INVALIDPARAMS;
324 *lpViewport2 = This->viewport.vp2;
329 HRESULT WINAPI IDirect3DViewport2Impl_SetViewport2(LPDIRECT3DVIEWPORT2 iface,
330 LPD3DVIEWPORT2 lpViewport2)
332 ICOM_THIS(IDirect3DViewport2Impl,iface);
333 TRACE("(%p)->(%p)\n", This, lpViewport2);
335 TRACE("dwSize = %ld dwX = %ld dwY = %ld\n",
336 lpViewport2->dwSize, lpViewport2->dwX, lpViewport2->dwY);
337 TRACE("dwWidth = %ld dwHeight = %ld\n",
338 lpViewport2->dwWidth, lpViewport2->dwHeight);
339 TRACE("dvClipX = %f dvClipY = %f\n",
340 lpViewport2->dvClipX, lpViewport2->dvClipY);
341 TRACE("dvClipWidth = %f dvClipHeight = %f\n",
342 lpViewport2->dvClipWidth, lpViewport2->dvClipHeight);
343 TRACE("dvMinZ = %f dvMaxZ = %f\n",
344 lpViewport2->dvMinZ, lpViewport2->dvMaxZ);
346 This->viewport.vp2 = *lpViewport2;
353 /*******************************************************************************
354 * IDirect3DViewport1/2 VTable
356 static ICOM_VTABLE(IDirect3DViewport2) viewport2_vtable =
358 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
359 /*** IUnknown methods ***/
360 IDirect3DViewport2Impl_QueryInterface,
361 IDirect3DViewport2Impl_AddRef,
362 IDirect3DViewport2Impl_Release,
363 /*** IDirect3DViewport methods ***/
364 IDirect3DViewport2Impl_Initialize,
365 IDirect3DViewport2Impl_GetViewport,
366 IDirect3DViewport2Impl_SetViewport,
367 IDirect3DViewport2Impl_TransformVertices,
368 IDirect3DViewport2Impl_LightElements,
369 IDirect3DViewport2Impl_SetBackground,
370 IDirect3DViewport2Impl_GetBackground,
371 IDirect3DViewport2Impl_SetBackgroundDepth,
372 IDirect3DViewport2Impl_GetBackgroundDepth,
373 IDirect3DViewport2Impl_Clear,
374 IDirect3DViewport2Impl_AddLight,
375 IDirect3DViewport2Impl_DeleteLight,
376 IDirect3DViewport2Impl_NextLight,
377 /*** IDirect3DViewport2 methods ***/
378 IDirect3DViewport2Impl_GetViewport2,
379 IDirect3DViewport2Impl_SetViewport2
382 #else /* HAVE_OPENGL */
384 LPDIRECT3DVIEWPORT d3dviewport_create(IDirect3DImpl* d3d1) {
385 ERR("Should not be called...\n");
389 LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2) {
390 ERR("Should not be called...\n");
394 #endif /* HAVE_OPENGL */