4 This files contains the implementation of Direct3DViewport2. */
10 #include "wine/obj_base.h"
17 #include "d3d_private.h"
22 static IDirect3DViewport2_VTable viewport2_vtable;
24 /*******************************************************************************
25 * Viewport1/2 static functions
27 static void activate(LPDIRECT3DVIEWPORT2 this) {
30 /* Activate all the lights associated with this context */
39 /*******************************************************************************
40 * Viewport1/2 Creation functions
42 LPDIRECT3DVIEWPORT2 d3dviewport2_create(LPDIRECT3D2 d3d)
44 LPDIRECT3DVIEWPORT2 vp;
46 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2));
48 vp->lpvtbl = &viewport2_vtable;
52 vp->device.active_device2 = NULL;
53 vp->activate = activate;
57 vp->nextlight = GL_LIGHT0;
62 LPDIRECT3DVIEWPORT d3dviewport_create(LPDIRECT3D d3d)
64 LPDIRECT3DVIEWPORT2 vp;
66 vp = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirect3DViewport2));
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 IDirect3DViewport2_QueryInterface(LPDIRECT3DVIEWPORT2 this,
92 WINE_StringFromCLSID((LPCLSID)riid,xrefiid);
93 FIXME(ddraw, "(%p)->(%s,%p): stub\n", this, xrefiid,ppvObj);
100 static ULONG WINAPI IDirect3DViewport2_AddRef(LPDIRECT3DVIEWPORT2 this)
102 TRACE(ddraw, "(%p)->()incrementing from %lu.\n", this, this->ref );
104 return ++(this->ref);
109 static ULONG WINAPI IDirect3DViewport2_Release(LPDIRECT3DVIEWPORT2 this)
111 FIXME( ddraw, "(%p)->() decrementing from %lu.\n", this, this->ref );
113 if (!--(this->ref)) {
114 HeapFree(GetProcessHeap(),0,this);
121 /*** IDirect3DViewport methods ***/
122 static HRESULT WINAPI IDirect3DViewport2_Initialize(LPDIRECT3DVIEWPORT2 this,
125 FIXME(ddraw, "(%p)->(%p): stub\n", this, d3d);
130 static HRESULT WINAPI IDirect3DViewport2_GetViewport(LPDIRECT3DVIEWPORT2 this,
133 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpvp);
135 if (this->use_vp2 != 0)
136 return DDERR_INVALIDPARAMS;
138 *lpvp = this->viewport.vp1;
143 static HRESULT WINAPI IDirect3DViewport2_SetViewport(LPDIRECT3DVIEWPORT2 this,
146 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpvp);
149 this->viewport.vp1 = *lpvp;
151 TRACE(ddraw, "dwSize = %ld dwX = %ld dwY = %ld\n",
152 lpvp->dwSize, lpvp->dwX, lpvp->dwY);
153 TRACE(ddraw, "dwWidth = %ld dwHeight = %ld\n",
154 lpvp->dwWidth, lpvp->dwHeight);
155 TRACE(ddraw, "dvScaleX = %f dvScaleY = %f\n",
156 lpvp->dvScaleX, lpvp->dvScaleY);
157 TRACE(ddraw, "dvMaxX = %f dvMaxY = %f\n",
158 lpvp->dvMaxX, lpvp->dvMaxY);
159 TRACE(ddraw, "dvMinZ = %f dvMaxZ = %f\n",
160 lpvp->dvMinZ, lpvp->dvMaxZ);
166 static HRESULT WINAPI IDirect3DViewport2_TransformVertices(LPDIRECT3DVIEWPORT2 this,
168 LPD3DTRANSFORMDATA lpData,
172 FIXME(ddraw, "(%p)->(%8ld,%p,%08lx,%p): stub\n",
173 this, dwVertexCount, lpData, dwFlags, lpOffScreen);
178 static HRESULT WINAPI IDirect3DViewport2_LightElements(LPDIRECT3DVIEWPORT2 this,
179 DWORD dwElementCount,
180 LPD3DLIGHTDATA lpData)
182 FIXME(ddraw, "(%p)->(%8ld,%p): stub\n", this, dwElementCount, lpData);
187 static HRESULT WINAPI IDirect3DViewport2_SetBackground(LPDIRECT3DVIEWPORT2 this,
188 D3DMATERIALHANDLE hMat)
190 FIXME(ddraw, "(%p)->(%08lx): stub\n", this, (DWORD) hMat);
195 static HRESULT WINAPI IDirect3DViewport2_GetBackground(LPDIRECT3DVIEWPORT2 this,
196 LPD3DMATERIALHANDLE lphMat,
199 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lphMat, lpValid);
204 static HRESULT WINAPI IDirect3DViewport2_SetBackgroundDepth(LPDIRECT3DVIEWPORT2 this,
205 LPDIRECTDRAWSURFACE lpDDSurface)
207 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpDDSurface);
212 static HRESULT WINAPI IDirect3DViewport2_GetBackgroundDepth(LPDIRECT3DVIEWPORT2 this,
213 LPDIRECTDRAWSURFACE* lplpDDSurface,
216 FIXME(ddraw, "(%p)->(%p,%p): stub\n", this, lplpDDSurface, lpValid);
221 static HRESULT WINAPI IDirect3DViewport2_Clear(LPDIRECT3DVIEWPORT2 this,
227 FIXME(ddraw, "(%p)->(%8ld,%p,%08lx): stub\n", this, dwCount, lpRects, dwFlags);
229 /* For the moment, ignore the rectangles */
230 if (this->device.active_device1 != NULL) {
231 /* Get the rendering context */
233 this->device.active_device2->set_context(this->device.active_device2);
235 this->device.active_device1->set_context(this->device.active_device1);
238 /* Clears the screen */
239 glGetBooleanv(GL_DEPTH_TEST, &ztest);
240 glDepthMask(GL_TRUE); /* Enables Z writing to be sure to delete also the Z buffer */
241 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
247 static HRESULT WINAPI IDirect3DViewport2_AddLight(LPDIRECT3DVIEWPORT2 this,
248 LPDIRECT3DLIGHT lpLight)
250 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpLight);
252 /* Add the light in the 'linked' chain */
253 lpLight->next = this->lights;
254 this->lights = lpLight;
256 /* If active, activate the light */
257 if (this->device.active_device1 != NULL) {
258 /* Get the rendering context */
260 this->device.active_device2->set_context(this->device.active_device2);
262 this->device.active_device1->set_context(this->device.active_device1);
264 /* Activate the light */
265 lpLight->light_num = this->nextlight++;
266 lpLight->activate(lpLight);
272 static HRESULT WINAPI IDirect3DViewport2_DeleteLight(LPDIRECT3DVIEWPORT2 this,
273 LPDIRECT3DLIGHT lpLight)
275 FIXME(ddraw, "(%p)->(%p): stub\n", this, lpLight);
280 static HRESULT WINAPI IDirect3DViewport2_NextLight(LPDIRECT3DVIEWPORT2 this,
281 LPDIRECT3DLIGHT lpLight,
282 LPDIRECT3DLIGHT* lplpLight,
285 FIXME(ddraw, "(%p)->(%p,%p,%08lx): stub\n", this, lpLight, lplpLight, dwFlags);
290 /*** IDirect3DViewport2 methods ***/
291 static HRESULT WINAPI IDirect3DViewport2_GetViewport2(LPDIRECT3DVIEWPORT2 this,
292 LPD3DVIEWPORT2 lpViewport2)
294 TRACE(ddraw, "(%p)->(%p)\n", this, lpViewport2);
296 if (this->use_vp2 != 1)
297 return DDERR_INVALIDPARAMS;
299 *lpViewport2 = this->viewport.vp2;
304 static HRESULT WINAPI IDirect3DViewport2_SetViewport2(LPDIRECT3DVIEWPORT2 this,
305 LPD3DVIEWPORT2 lpViewport2)
307 TRACE(ddraw, "(%p)->(%p)\n", this, lpViewport2);
309 TRACE(ddraw, "dwSize = %ld dwX = %ld dwY = %ld\n",
310 lpViewport2->dwSize, lpViewport2->dwX, lpViewport2->dwY);
311 TRACE(ddraw, "dwWidth = %ld dwHeight = %ld\n",
312 lpViewport2->dwWidth, lpViewport2->dwHeight);
313 TRACE(ddraw, "dvClipX = %f dvClipY = %f\n",
314 lpViewport2->dvClipX, lpViewport2->dvClipY);
315 TRACE(ddraw, "dvClipWidth = %f dvClipHeight = %f\n",
316 lpViewport2->dvClipWidth, lpViewport2->dvClipHeight);
317 TRACE(ddraw, "dvMinZ = %f dvMaxZ = %f\n",
318 lpViewport2->dvMinZ, lpViewport2->dvMaxZ);
320 this->viewport.vp2 = *lpViewport2;
327 /*******************************************************************************
328 * IDirect3DViewport1/2 VTable
330 static IDirect3DViewport2_VTable viewport2_vtable = {
331 /*** IUnknown methods ***/
332 IDirect3DViewport2_QueryInterface,
333 IDirect3DViewport2_AddRef,
334 IDirect3DViewport2_Release,
335 /*** IDirect3DViewport methods ***/
336 IDirect3DViewport2_Initialize,
337 IDirect3DViewport2_GetViewport,
338 IDirect3DViewport2_SetViewport,
339 IDirect3DViewport2_TransformVertices,
340 IDirect3DViewport2_LightElements,
341 IDirect3DViewport2_SetBackground,
342 IDirect3DViewport2_GetBackground,
343 IDirect3DViewport2_SetBackgroundDepth,
344 IDirect3DViewport2_GetBackgroundDepth,
345 IDirect3DViewport2_Clear,
346 IDirect3DViewport2_AddLight,
347 IDirect3DViewport2_DeleteLight,
348 IDirect3DViewport2_NextLight,
349 /*** IDirect3DViewport2 methods ***/
350 IDirect3DViewport2_GetViewport2,
351 IDirect3DViewport2_SetViewport2
354 #else /* HAVE_MESAGL */
356 LPDIRECT3DVIEWPORT d3dviewport_create(LPDIRECT3D d3d) {
357 ERR(ddraw, "Should not be called...\n");
361 LPDIRECT3DVIEWPORT2 d3dviewport2_create(LPDIRECT3D2 d3d) {
362 ERR(ddraw, "Should not be called...\n");
366 #endif /* HAVE_MESAGL */