4 This files contains the implementation of Direct3DViewport2. */
9 #include "wine/obj_base.h"
13 #include "debugtools.h"
16 #include "d3d_private.h"
17 #include "mesa_private.h"
19 DEFAULT_DEBUG_CHANNEL(ddraw)
23 #define D3DVPRIVATE(x) mesa_d3dv_private*dvpriv=((mesa_d3dv_private*)x->private)
24 #define D3DLPRIVATE(x) mesa_d3dl_private*dlpriv=((mesa_d3dl_private*)x->private)
26 static ICOM_VTABLE(IDirect3DViewport2) viewport2_vtable;
28 /*******************************************************************************
29 * Viewport1/2 static functions
31 static void activate(IDirect3DViewport2Impl* This) {
32 IDirect3DLightImpl* l;
34 /* Activate all the lights associated with this context */
43 /*******************************************************************************
44 * Viewport1/2 Creation functions
46 LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2)
48 IDirect3DViewport2Impl* vp;
50 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2Impl));
51 vp->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dv_private));
53 ICOM_VTBL(vp) = &viewport2_vtable;
57 vp->device.active_device2 = NULL;
58 vp->activate = activate;
62 ((mesa_d3dv_private *) vp->private)->nextlight = GL_LIGHT0;
64 return (LPDIRECT3DVIEWPORT2)vp;
67 LPDIRECT3DVIEWPORT d3dviewport_create(IDirect3DImpl* d3d1)
69 IDirect3DViewport2Impl* vp;
71 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2Impl));
72 vp->private = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(mesa_d3dv_private));
74 ICOM_VTBL(vp) = &viewport2_vtable;
78 vp->device.active_device1 = NULL;
79 vp->activate = activate;
83 ((mesa_d3dv_private *) vp->private)->nextlight = GL_LIGHT0;
85 return (LPDIRECT3DVIEWPORT) vp;
88 /*******************************************************************************
89 * IDirect3DViewport2 methods
92 HRESULT WINAPI IDirect3DViewport2Impl_QueryInterface(LPDIRECT3DVIEWPORT2 iface,
96 ICOM_THIS(IDirect3DViewport2Impl,iface);
98 FIXME("(%p)->(%s,%p): stub\n", This, debugstr_guid(riid),ppvObj);
105 ULONG WINAPI IDirect3DViewport2Impl_AddRef(LPDIRECT3DVIEWPORT2 iface)
107 ICOM_THIS(IDirect3DViewport2Impl,iface);
108 TRACE("(%p)->()incrementing from %lu.\n", This, This->ref );
110 return ++(This->ref);
115 ULONG WINAPI IDirect3DViewport2Impl_Release(LPDIRECT3DVIEWPORT2 iface)
117 ICOM_THIS(IDirect3DViewport2Impl,iface);
118 FIXME("(%p)->() decrementing from %lu.\n", This, This->ref );
120 if (!--(This->ref)) {
121 HeapFree(GetProcessHeap(),0,This);
128 /*** IDirect3DViewport methods ***/
129 HRESULT WINAPI IDirect3DViewport2Impl_Initialize(LPDIRECT3DVIEWPORT2 iface,
132 ICOM_THIS(IDirect3DViewport2Impl,iface);
133 FIXME("(%p)->(%p): stub\n", This, d3d);
138 HRESULT WINAPI IDirect3DViewport2Impl_GetViewport(LPDIRECT3DVIEWPORT2 iface,
141 ICOM_THIS(IDirect3DViewport2Impl,iface);
142 FIXME("(%p)->(%p): stub\n", This, lpvp);
144 if (This->use_vp2 != 0)
145 return DDERR_INVALIDPARAMS;
147 *lpvp = This->viewport.vp1;
152 HRESULT WINAPI IDirect3DViewport2Impl_SetViewport(LPDIRECT3DVIEWPORT2 iface,
155 ICOM_THIS(IDirect3DViewport2Impl,iface);
156 FIXME("(%p)->(%p): stub\n", This, lpvp);
159 This->viewport.vp1 = *lpvp;
161 TRACE("dwSize = %ld dwX = %ld dwY = %ld\n",
162 lpvp->dwSize, lpvp->dwX, lpvp->dwY);
163 TRACE("dwWidth = %ld dwHeight = %ld\n",
164 lpvp->dwWidth, lpvp->dwHeight);
165 TRACE("dvScaleX = %f dvScaleY = %f\n",
166 lpvp->dvScaleX, lpvp->dvScaleY);
167 TRACE("dvMaxX = %f dvMaxY = %f\n",
168 lpvp->dvMaxX, lpvp->dvMaxY);
169 TRACE("dvMinZ = %f dvMaxZ = %f\n",
170 lpvp->dvMinZ, lpvp->dvMaxZ);
176 HRESULT WINAPI IDirect3DViewport2Impl_TransformVertices(LPDIRECT3DVIEWPORT2 iface,
178 LPD3DTRANSFORMDATA lpData,
182 ICOM_THIS(IDirect3DViewport2Impl,iface);
183 FIXME("(%p)->(%8ld,%p,%08lx,%p): stub\n",
184 This, dwVertexCount, lpData, dwFlags, lpOffScreen);
189 HRESULT WINAPI IDirect3DViewport2Impl_LightElements(LPDIRECT3DVIEWPORT2 iface,
190 DWORD dwElementCount,
191 LPD3DLIGHTDATA lpData)
193 ICOM_THIS(IDirect3DViewport2Impl,iface);
194 FIXME("(%p)->(%8ld,%p): stub\n", This, dwElementCount, lpData);
199 HRESULT WINAPI IDirect3DViewport2Impl_SetBackground(LPDIRECT3DVIEWPORT2 iface,
200 D3DMATERIALHANDLE hMat)
202 ICOM_THIS(IDirect3DViewport2Impl,iface);
203 FIXME("(%p)->(%08lx): stub\n", This, (DWORD) hMat);
208 HRESULT WINAPI IDirect3DViewport2Impl_GetBackground(LPDIRECT3DVIEWPORT2 iface,
209 LPD3DMATERIALHANDLE lphMat,
212 ICOM_THIS(IDirect3DViewport2Impl,iface);
213 FIXME("(%p)->(%p,%p): stub\n", This, lphMat, lpValid);
218 HRESULT WINAPI IDirect3DViewport2Impl_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface,
219 LPDIRECTDRAWSURFACE lpDDSurface)
221 ICOM_THIS(IDirect3DViewport2Impl,iface);
222 FIXME("(%p)->(%p): stub\n", This, lpDDSurface);
227 HRESULT WINAPI IDirect3DViewport2Impl_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 iface,
228 LPDIRECTDRAWSURFACE* lplpDDSurface,
231 ICOM_THIS(IDirect3DViewport2Impl,iface);
232 FIXME("(%p)->(%p,%p): stub\n", This, lplpDDSurface, lpValid);
237 HRESULT WINAPI IDirect3DViewport2Impl_Clear(LPDIRECT3DVIEWPORT2 iface,
242 ICOM_THIS(IDirect3DViewport2Impl,iface);
244 FIXME("(%p)->(%8ld,%p,%08lx): stub\n", This, dwCount, lpRects, dwFlags);
246 /* For the moment, ignore the rectangles */
247 if (This->device.active_device1 != NULL) {
248 /* Get the rendering context */
250 This->device.active_device2->set_context(This->device.active_device2);
252 This->device.active_device1->set_context(This->device.active_device1);
255 /* Clears the screen */
257 glGetBooleanv(GL_DEPTH_TEST, &ztest);
258 glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
259 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
266 HRESULT WINAPI IDirect3DViewport2Impl_AddLight(LPDIRECT3DVIEWPORT2 iface,
267 LPDIRECT3DLIGHT lpLight)
269 ICOM_THIS(IDirect3DViewport2Impl,iface);
270 IDirect3DLightImpl* ilpLight=(IDirect3DLightImpl*)lpLight;
271 FIXME("(%p)->(%p): stub\n", This, ilpLight);
273 /* Add the light in the 'linked' chain */
274 ilpLight->next = This->lights;
275 This->lights = ilpLight;
277 /* If active, activate the light */
278 if (This->device.active_device1 != NULL) {
280 D3DLPRIVATE(ilpLight);
282 /* Get the rendering context */
284 This->device.active_device2->set_context(This->device.active_device2);
286 This->device.active_device1->set_context(This->device.active_device1);
288 /* Activate the light */
289 dlpriv->light_num = dvpriv->nextlight++;
290 ilpLight->activate(ilpLight);
296 HRESULT WINAPI IDirect3DViewport2Impl_DeleteLight(LPDIRECT3DVIEWPORT2 iface,
297 LPDIRECT3DLIGHT lpLight)
299 ICOM_THIS(IDirect3DViewport2Impl,iface);
300 FIXME("(%p)->(%p): stub\n", This, lpLight);
305 HRESULT WINAPI IDirect3DViewport2Impl_NextLight(LPDIRECT3DVIEWPORT2 iface,
306 LPDIRECT3DLIGHT lpLight,
307 LPDIRECT3DLIGHT* lplpLight,
310 ICOM_THIS(IDirect3DViewport2Impl,iface);
311 FIXME("(%p)->(%p,%p,%08lx): stub\n", This, lpLight, lplpLight, dwFlags);
316 /*** IDirect3DViewport2 methods ***/
317 HRESULT WINAPI IDirect3DViewport2Impl_GetViewport2(LPDIRECT3DVIEWPORT2 iface,
318 LPD3DVIEWPORT2 lpViewport2)
320 ICOM_THIS(IDirect3DViewport2Impl,iface);
321 TRACE("(%p)->(%p)\n", This, lpViewport2);
323 if (This->use_vp2 != 1)
324 return DDERR_INVALIDPARAMS;
326 *lpViewport2 = This->viewport.vp2;
331 HRESULT WINAPI IDirect3DViewport2Impl_SetViewport2(LPDIRECT3DVIEWPORT2 iface,
332 LPD3DVIEWPORT2 lpViewport2)
334 ICOM_THIS(IDirect3DViewport2Impl,iface);
335 TRACE("(%p)->(%p)\n", This, lpViewport2);
337 TRACE("dwSize = %ld dwX = %ld dwY = %ld\n",
338 lpViewport2->dwSize, lpViewport2->dwX, lpViewport2->dwY);
339 TRACE("dwWidth = %ld dwHeight = %ld\n",
340 lpViewport2->dwWidth, lpViewport2->dwHeight);
341 TRACE("dvClipX = %f dvClipY = %f\n",
342 lpViewport2->dvClipX, lpViewport2->dvClipY);
343 TRACE("dvClipWidth = %f dvClipHeight = %f\n",
344 lpViewport2->dvClipWidth, lpViewport2->dvClipHeight);
345 TRACE("dvMinZ = %f dvMaxZ = %f\n",
346 lpViewport2->dvMinZ, lpViewport2->dvMaxZ);
348 This->viewport.vp2 = *lpViewport2;
355 /*******************************************************************************
356 * IDirect3DViewport1/2 VTable
358 static ICOM_VTABLE(IDirect3DViewport2) viewport2_vtable =
360 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
361 /*** IUnknown methods ***/
362 IDirect3DViewport2Impl_QueryInterface,
363 IDirect3DViewport2Impl_AddRef,
364 IDirect3DViewport2Impl_Release,
365 /*** IDirect3DViewport methods ***/
366 IDirect3DViewport2Impl_Initialize,
367 IDirect3DViewport2Impl_GetViewport,
368 IDirect3DViewport2Impl_SetViewport,
369 IDirect3DViewport2Impl_TransformVertices,
370 IDirect3DViewport2Impl_LightElements,
371 IDirect3DViewport2Impl_SetBackground,
372 IDirect3DViewport2Impl_GetBackground,
373 IDirect3DViewport2Impl_SetBackgroundDepth,
374 IDirect3DViewport2Impl_GetBackgroundDepth,
375 IDirect3DViewport2Impl_Clear,
376 IDirect3DViewport2Impl_AddLight,
377 IDirect3DViewport2Impl_DeleteLight,
378 IDirect3DViewport2Impl_NextLight,
379 /*** IDirect3DViewport2 methods ***/
380 IDirect3DViewport2Impl_GetViewport2,
381 IDirect3DViewport2Impl_SetViewport2
384 #else /* HAVE_OPENGL */
386 LPDIRECT3DVIEWPORT d3dviewport_create(IDirect3DImpl* d3d1) {
387 ERR("Should not be called...\n");
391 LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2) {
392 ERR("Should not be called...\n");
396 #endif /* HAVE_OPENGL */