4 This files contains the implementation of Direct3DViewport2. */
10 #include "wine/obj_base.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;
150 TRACE(ddraw, "dwSize = %ld dwX = %ld dwY = %ld\n",
151 lpvp->dwSize, lpvp->dwX, lpvp->dwY);
152 TRACE(ddraw, "dwWidth = %ld dwHeight = %ld\n",
153 lpvp->dwWidth, lpvp->dwHeight);
154 TRACE(ddraw, "dvScaleX = %f dvScaleY = %f\n",
155 lpvp->dvScaleX, lpvp->dvScaleY);
156 TRACE(ddraw, "dvMaxX = %f dvMaxY = %f\n",
157 lpvp->dvMaxX, lpvp->dvMaxY);
158 TRACE(ddraw, "dvMinZ = %f dvMaxZ = %f\n",
159 lpvp->dvMinZ, lpvp->dvMaxZ);
165 static HRESULT WINAPI IDirect3DViewport2_TransformVertices(LPDIRECT3DVIEWPORT2 this,
167 LPD3DTRANSFORMDATA lpData,
171 FIXME(ddraw, "(%p)->(%8ld,%p,%08lx,%p): stub\n",
172 this, dwVertexCount, lpData, dwFlags, lpOffScreen);
177 static HRESULT WINAPI IDirect3DViewport2_LightElements(LPDIRECT3DVIEWPORT2 this,
178 DWORD dwElementCount,
179 LPD3DLIGHTDATA lpData)
181 FIXME(ddraw, "(%p)->(%8ld,%p): stub\n", this, dwElementCount, lpData);
186 static HRESULT WINAPI IDirect3DViewport2_SetBackground(LPDIRECT3DVIEWPORT2 this,
187 D3DMATERIALHANDLE hMat)
189 FIXME(ddraw, "(%p)->(%08lx): stub\n", this, (DWORD) hMat);
194 static HRESULT WINAPI IDirect3DViewport2_GetBackground(LPDIRECT3DVIEWPORT2 this,
195 LPD3DMATERIALHANDLE lphMat,
198 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lphMat, lpValid);
203 static HRESULT WINAPI IDirect3DViewport2_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 this,
204 LPDIRECTDRAWSURFACE lpDDSurface)
206 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpDDSurface);
211 static HRESULT WINAPI IDirect3DViewport2_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 this,
212 LPDIRECTDRAWSURFACE* lplpDDSurface,
215 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lplpDDSurface, lpValid);
220 static HRESULT WINAPI IDirect3DViewport2_Clear(LPDIRECT3DVIEWPORT2 this,
226 FIXME(ddraw, "(%p)->(%8ld,%p,%08lx): stub\n", this, dwCount, lpRects, dwFlags);
228 /* For the moment, ignore the rectangles */
229 if (this->device.active_device1 != NULL) {
230 /* Get the rendering context */
232 this->device.active_device2->set_context(this->device.active_device2);
234 this->device.active_device1->set_context(this->device.active_device1);
237 /* Clears the screen */
238 glGetBooleanv(GL_DEPTH_TEST, &ztest);
239 glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
240 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
246 static HRESULT WINAPI IDirect3DViewport2_AddLight(LPDIRECT3DVIEWPORT2 this,
247 LPDIRECT3DLIGHT lpLight)
249 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpLight);
251 /* Add the light in the 'linked' chain */
252 lpLight->next = this->lights;
253 this->lights = lpLight;
255 /* If active, activate the light */
256 if (this->device.active_device1 != NULL) {
257 /* Get the rendering context */
259 this->device.active_device2->set_context(this->device.active_device2);
261 this->device.active_device1->set_context(this->device.active_device1);
263 /* Activate the light */
264 lpLight->light_num = this->nextlight++;
265 lpLight->activate(lpLight);
271 static HRESULT WINAPI IDirect3DViewport2_DeleteLight(LPDIRECT3DVIEWPORT2 this,
272 LPDIRECT3DLIGHT lpLight)
274 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpLight);
279 static HRESULT WINAPI IDirect3DViewport2_NextLight(LPDIRECT3DVIEWPORT2 this,
280 LPDIRECT3DLIGHT lpLight,
281 LPDIRECT3DLIGHT* lplpLight,
284 FIXME(ddraw, "(%p)->(%p,%p,%08lx): stub\n", this, lpLight, lplpLight, dwFlags);
289 /*** IDirect3DViewport2 methods ***/
290 static HRESULT WINAPI IDirect3DViewport2_GetViewport2(LPDIRECT3DVIEWPORT2 this,
291 LPD3DVIEWPORT2 lpViewport2)
293 TRACE(ddraw, "(%p)->(%p)\n", this, lpViewport2);
295 if (this->use_vp2 != 1)
296 return DDERR_INVALIDPARAMS;
298 *lpViewport2 = this->viewport.vp2;
303 static HRESULT WINAPI IDirect3DViewport2_SetViewport2(LPDIRECT3DVIEWPORT2 this,
304 LPD3DVIEWPORT2 lpViewport2)
306 TRACE(ddraw, "(%p)->(%p)\n", this, lpViewport2);
308 TRACE(ddraw, "dwSize = %ld dwX = %ld dwY = %ld\n",
309 lpViewport2->dwSize, lpViewport2->dwX, lpViewport2->dwY);
310 TRACE(ddraw, "dwWidth = %ld dwHeight = %ld\n",
311 lpViewport2->dwWidth, lpViewport2->dwHeight);
312 TRACE(ddraw, "dvClipX = %f dvClipY = %f\n",
313 lpViewport2->dvClipX, lpViewport2->dvClipY);
314 TRACE(ddraw, "dvClipWidth = %f dvClipHeight = %f\n",
315 lpViewport2->dvClipWidth, lpViewport2->dvClipHeight);
316 TRACE(ddraw, "dvMinZ = %f dvMaxZ = %f\n",
317 lpViewport2->dvMinZ, lpViewport2->dvMaxZ);
319 this->viewport.vp2 = *lpViewport2;
326 /*******************************************************************************
327 * IDirect3DViewport1/2 VTable
329 static IDirect3DViewport2_VTable viewport2_vtable = {
330 /*** IUnknown methods ***/
331 IDirect3DViewport2_QueryInterface,
332 IDirect3DViewport2_AddRef,
333 IDirect3DViewport2_Release,
334 /*** IDirect3DViewport methods ***/
335 IDirect3DViewport2_Initialize,
336 IDirect3DViewport2_GetViewport,
337 IDirect3DViewport2_SetViewport,
338 IDirect3DViewport2_TransformVertices,
339 IDirect3DViewport2_LightElements,
340 IDirect3DViewport2_SetBackground,
341 IDirect3DViewport2_GetBackground,
342 IDirect3DViewport2_SetBackgroundDepth,
343 IDirect3DViewport2_GetBackgroundDepth,
344 IDirect3DViewport2_Clear,
345 IDirect3DViewport2_AddLight,
346 IDirect3DViewport2_DeleteLight,
347 IDirect3DViewport2_NextLight,
348 /*** IDirect3DViewport2 methods ***/
349 IDirect3DViewport2_GetViewport2,
350 IDirect3DViewport2_SetViewport2
353 #else /* HAVE_MESAGL */
355 LPDIRECT3DVIEWPORT d3dviewport_create(LPDIRECT3D d3d) {
356 ERR(ddraw, "Should not be called...\n");
360 LPDIRECT3DVIEWPORT2 d3dviewport2_create(LPDIRECT3D2 d3d) {
361 ERR(ddraw, "Should not be called...\n");
365 #endif /* HAVE_MESAGL */