4 This files contains the implementation of Direct3DViewport2. */
9 #include "wine/obj_base.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 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 */
253 glGetBooleanv(GL_DEPTH_TEST, &ztest);
254 glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
255 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
262 static HRESULT WINAPI IDirect3DViewport2Impl_AddLight(LPDIRECT3DVIEWPORT2 iface,
263 LPDIRECT3DLIGHT lpLight)
265 ICOM_THIS(IDirect3DViewport2Impl,iface);
266 IDirect3DLightImpl* ilpLight=(IDirect3DLightImpl*)lpLight;
267 FIXME(ddraw, "(%p)->(%p): stub\n", This, ilpLight);
269 /* Add the light in the 'linked' chain */
270 ilpLight->next = This->lights;
271 This->lights = ilpLight;
273 /* If active, activate the light */
274 if (This->device.active_device1 != NULL) {
275 /* Get the rendering context */
277 This->device.active_device2->set_context(This->device.active_device2);
279 This->device.active_device1->set_context(This->device.active_device1);
281 /* Activate the light */
282 ilpLight->light_num = This->nextlight++;
283 ilpLight->activate(ilpLight);
289 static HRESULT WINAPI IDirect3DViewport2Impl_DeleteLight(LPDIRECT3DVIEWPORT2 iface,
290 LPDIRECT3DLIGHT lpLight)
292 ICOM_THIS(IDirect3DViewport2Impl,iface);
293 FIXME(ddraw, "(%p)->(%p): stub\n", This, lpLight);
298 static HRESULT WINAPI IDirect3DViewport2Impl_NextLight(LPDIRECT3DVIEWPORT2 iface,
299 LPDIRECT3DLIGHT lpLight,
300 LPDIRECT3DLIGHT* lplpLight,
303 ICOM_THIS(IDirect3DViewport2Impl,iface);
304 FIXME(ddraw, "(%p)->(%p,%p,%08lx): stub\n", This, lpLight, lplpLight, dwFlags);
309 /*** IDirect3DViewport2 methods ***/
310 static HRESULT WINAPI IDirect3DViewport2Impl_GetViewport2(LPDIRECT3DVIEWPORT2 iface,
311 LPD3DVIEWPORT2 lpViewport2)
313 ICOM_THIS(IDirect3DViewport2Impl,iface);
314 TRACE(ddraw, "(%p)->(%p)\n", This, lpViewport2);
316 if (This->use_vp2 != 1)
317 return DDERR_INVALIDPARAMS;
319 *lpViewport2 = This->viewport.vp2;
324 static HRESULT WINAPI IDirect3DViewport2Impl_SetViewport2(LPDIRECT3DVIEWPORT2 iface,
325 LPD3DVIEWPORT2 lpViewport2)
327 ICOM_THIS(IDirect3DViewport2Impl,iface);
328 TRACE(ddraw, "(%p)->(%p)\n", This, lpViewport2);
330 TRACE(ddraw, "dwSize = %ld dwX = %ld dwY = %ld\n",
331 lpViewport2->dwSize, lpViewport2->dwX, lpViewport2->dwY);
332 TRACE(ddraw, "dwWidth = %ld dwHeight = %ld\n",
333 lpViewport2->dwWidth, lpViewport2->dwHeight);
334 TRACE(ddraw, "dvClipX = %f dvClipY = %f\n",
335 lpViewport2->dvClipX, lpViewport2->dvClipY);
336 TRACE(ddraw, "dvClipWidth = %f dvClipHeight = %f\n",
337 lpViewport2->dvClipWidth, lpViewport2->dvClipHeight);
338 TRACE(ddraw, "dvMinZ = %f dvMaxZ = %f\n",
339 lpViewport2->dvMinZ, lpViewport2->dvMaxZ);
341 This->viewport.vp2 = *lpViewport2;
348 /*******************************************************************************
349 * IDirect3DViewport1/2 VTable
351 static ICOM_VTABLE(IDirect3DViewport2) viewport2_vtable = {
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(ddraw, "Should not be called...\n");
382 LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2) {
383 ERR(ddraw, "Should not be called...\n");
387 #endif /* HAVE_MESAGL */