4 This files contains the implementation of Direct3DViewport2. */
10 #include "interfaces.h"
16 #include "d3d_private.h"
21 static IDirect3DViewport2_VTable viewport2_vtable;
23 /*******************************************************************************
24 * Viewport1/2 static functions
26 static void activate(LPDIRECT3DVIEWPORT2 this) {
29 /* Activate all the lights associated with this context */
38 /*******************************************************************************
39 * Viewport1/2 Creation functions
41 LPDIRECT3DVIEWPORT2 d3dviewport2_create(LPDIRECT3D2 d3d)
43 LPDIRECT3DVIEWPORT2 vp;
45 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2));
47 vp->lpvtbl = &viewport2_vtable;
51 vp->device.active_device2 = NULL;
52 vp->activate = activate;
56 vp->nextlight = GL_LIGHT0;
61 LPDIRECT3DVIEWPORT d3dviewport_create(LPDIRECT3D d3d)
63 LPDIRECT3DVIEWPORT2 vp;
65 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2));
67 vp->lpvtbl = &viewport2_vtable;
71 vp->device.active_device1 = NULL;
72 vp->activate = activate;
76 vp->nextlight = GL_LIGHT0;
78 return (LPDIRECT3DVIEWPORT) vp;
81 /*******************************************************************************
82 * IDirect3DViewport2 methods
85 static HRESULT WINAPI IDirect3DViewport2_QueryInterface(LPDIRECT3DVIEWPORT2 this,
91 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
92 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
99 static ULONG WINAPI IDirect3DViewport2_AddRef(LPDIRECT3DVIEWPORT2 this)
101 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref );
103 return ++(this->ref);
108 static ULONG WINAPI IDirect3DViewport2_Release(LPDIRECT3DVIEWPORT2 this)
110 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref );
112 if (!--(this->ref)) {
113 HeapFree(GetProcessHeap(),0,this);
120 /*** IDirect3DViewport methods ***/
121 static HRESULT WINAPI IDirect3DViewport2_Initialize(LPDIRECT3DVIEWPORT2 this,
124 FIXME(ddraw, "(%p)->(%p): stub\n", this, d3d);
129 static HRESULT WINAPI IDirect3DViewport2_GetViewport(LPDIRECT3DVIEWPORT2 this,
132 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpvp);
134 if (this->use_vp2 != 0)
135 return DDERR_INVALIDPARAMS;
137 *lpvp = this->viewport.vp1;
142 static HRESULT WINAPI IDirect3DViewport2_SetViewport(LPDIRECT3DVIEWPORT2 this,
145 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpvp);
148 this->viewport.vp1 = *lpvp;
153 static HRESULT WINAPI IDirect3DViewport2_TransformVertices(LPDIRECT3DVIEWPORT2 this,
155 LPD3DTRANSFORMDATA lpData,
159 FIXME(ddraw, "(%p)->(%8ld,%p,%08lx,%p): stub\n",
160 this, dwVertexCount, lpData, dwFlags, lpOffScreen);
165 static HRESULT WINAPI IDirect3DViewport2_LightElements(LPDIRECT3DVIEWPORT2 this,
166 DWORD dwElementCount,
167 LPD3DLIGHTDATA lpData)
169 FIXME(ddraw, "(%p)->(%8ld,%p): stub\n", this, dwElementCount, lpData);
174 static HRESULT WINAPI IDirect3DViewport2_SetBackground(LPDIRECT3DVIEWPORT2 this,
175 D3DMATERIALHANDLE hMat)
177 FIXME(ddraw, "(%p)->(%08x): stub\n", this, hMat);
182 static HRESULT WINAPI IDirect3DViewport2_GetBackground(LPDIRECT3DVIEWPORT2 this,
183 LPD3DMATERIALHANDLE lphMat,
186 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lphMat, lpValid);
191 static HRESULT WINAPI IDirect3DViewport2_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 this,
192 LPDIRECTDRAWSURFACE lpDDSurface)
194 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpDDSurface);
199 static HRESULT WINAPI IDirect3DViewport2_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 this,
200 LPDIRECTDRAWSURFACE* lplpDDSurface,
203 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lplpDDSurface, lpValid);
208 static HRESULT WINAPI IDirect3DViewport2_Clear(LPDIRECT3DVIEWPORT2 this,
214 FIXME(ddraw, "(%p)->(%8ld,%p,%08lx): stub\n", this, dwCount, lpRects, dwFlags);
216 /* For the moment, ignore the rectangles */
217 if (this->device.active_device1 != NULL) {
218 /* Get the rendering context */
220 this->device.active_device2->set_context(this->device.active_device2);
222 this->device.active_device1->set_context(this->device.active_device1);
224 /* Clears the screen */
225 glGetBooleanv(GL_DEPTH_TEST, &ztest);
226 glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
227 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
234 static HRESULT WINAPI IDirect3DViewport2_AddLight(LPDIRECT3DVIEWPORT2 this,
235 LPDIRECT3DLIGHT lpLight)
237 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpLight);
239 /* Add the light in the 'linked' chain */
240 lpLight->next = this->lights;
241 this->lights = lpLight;
243 /* If active, activate the light */
244 if (this->device.active_device1 != NULL) {
245 /* Get the rendering context */
247 this->device.active_device2->set_context(this->device.active_device2);
249 this->device.active_device1->set_context(this->device.active_device1);
251 /* Activate the light */
252 lpLight->light_num = this->nextlight++;
253 lpLight->activate(lpLight);
259 static HRESULT WINAPI IDirect3DViewport2_DeleteLight(LPDIRECT3DVIEWPORT2 this,
260 LPDIRECT3DLIGHT lpLight)
262 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpLight);
267 static HRESULT WINAPI IDirect3DViewport2_NextLight(LPDIRECT3DVIEWPORT2 this,
268 LPDIRECT3DLIGHT lpLight,
269 LPDIRECT3DLIGHT* lplpLight,
272 FIXME(ddraw, "(%p)->(%p,%p,%08lx): stub\n", this, lpLight, lplpLight, dwFlags);
277 /*** IDirect3DViewport2 methods ***/
278 static HRESULT WINAPI IDirect3DViewport2_GetViewport2(LPDIRECT3DVIEWPORT2 this,
279 LPD3DVIEWPORT2 lpViewport2)
281 TRACE(ddraw, "(%p)->(%p)\n", this, lpViewport2);
283 if (this->use_vp2 != 1)
284 return DDERR_INVALIDPARAMS;
286 *lpViewport2 = this->viewport.vp2;
291 static HRESULT WINAPI IDirect3DViewport2_SetViewport2(LPDIRECT3DVIEWPORT2 this,
292 LPD3DVIEWPORT2 lpViewport2)
294 TRACE(ddraw, "(%p)->(%p)\n", this, lpViewport2);
296 TRACE(ddraw, "dwSize = %ld dwX = %ld dwY = %ld\n",
297 lpViewport2->dwSize, lpViewport2->dwX, lpViewport2->dwY);
298 TRACE(ddraw, "dwWidth = %ld dwHeight = %ld\n",
299 lpViewport2->dwWidth, lpViewport2->dwHeight);
300 TRACE(ddraw, "dvClipX = %f dvClipY = %f\n",
301 lpViewport2->dvClipX, lpViewport2->dvClipY);
302 TRACE(ddraw, "dvClipWidth = %f dvClipHeight = %f\n",
303 lpViewport2->dvClipWidth, lpViewport2->dvClipHeight);
304 TRACE(ddraw, "dvMinZ = %f dvMaxZ = %f\n",
305 lpViewport2->dvMinZ, lpViewport2->dvMaxZ);
307 this->viewport.vp2 = *lpViewport2;
314 /*******************************************************************************
315 * IDirect3DViewport1/2 VTable
317 static IDirect3DViewport2_VTable viewport2_vtable = {
318 /*** IUnknown methods ***/
319 IDirect3DViewport2_QueryInterface,
320 IDirect3DViewport2_AddRef,
321 IDirect3DViewport2_Release,
322 /*** IDirect3DViewport methods ***/
323 IDirect3DViewport2_Initialize,
324 IDirect3DViewport2_GetViewport,
325 IDirect3DViewport2_SetViewport,
326 IDirect3DViewport2_TransformVertices,
327 IDirect3DViewport2_LightElements,
328 IDirect3DViewport2_SetBackground,
329 IDirect3DViewport2_GetBackground,
330 IDirect3DViewport2_SetBackgroundDepth,
331 IDirect3DViewport2_GetBackgroundDepth,
332 IDirect3DViewport2_Clear,
333 IDirect3DViewport2_AddLight,
334 IDirect3DViewport2_DeleteLight,
335 IDirect3DViewport2_NextLight,
336 /*** IDirect3DViewport2 methods ***/
337 IDirect3DViewport2_GetViewport2,
338 IDirect3DViewport2_SetViewport2
341 #else /* HAVE_MESAGL */
343 LPDIRECT3DVIEWPORT d3dviewport_create(LPDIRECT3D d3d) {
344 ERR(ddraw, "Should not be called...\n");
348 LPDIRECT3DVIEWPORT2 d3dviewport2_create(LPDIRECT3D2 d3d) {
349 ERR(ddraw, "Should not be called...\n");
353 #endif /* HAVE_MESAGL */