4 This files contains the implementation of Direct3DViewport2. */
9 #include "wine/obj_base.h"
15 #include "d3d_private.h"
20 static IDirect3DViewport2_VTable viewport2_vtable
;
22 /*******************************************************************************
23 * Viewport1/2 static functions
25 static void activate(LPDIRECT3DVIEWPORT2
this) {
28 /* Activate all the lights associated with this context */
37 /*******************************************************************************
38 * Viewport1/2 Creation functions
40 LPDIRECT3DVIEWPORT2
d3dviewport2_create(LPDIRECT3D2 d3d
)
42 LPDIRECT3DVIEWPORT2 vp
;
44 vp
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirect3DViewport2
));
46 vp
->lpvtbl
= &viewport2_vtable
;
50 vp
->device
.active_device2
= NULL
;
51 vp
->activate
= activate
;
55 vp
->nextlight
= GL_LIGHT0
;
60 LPDIRECT3DVIEWPORT
d3dviewport_create(LPDIRECT3D d3d
)
62 LPDIRECT3DVIEWPORT2 vp
;
64 vp
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(IDirect3DViewport2
));
66 vp
->lpvtbl
= &viewport2_vtable
;
70 vp
->device
.active_device1
= NULL
;
71 vp
->activate
= activate
;
75 vp
->nextlight
= GL_LIGHT0
;
77 return (LPDIRECT3DVIEWPORT
) vp
;
80 /*******************************************************************************
81 * IDirect3DViewport2 methods
84 static HRESULT WINAPI
IDirect3DViewport2_QueryInterface(LPDIRECT3DVIEWPORT2
this,
90 WINE_StringFromCLSID((LPCLSID
)riid
,xrefiid
);
91 FIXME(ddraw
, "(%p)->(%s,%p): stub\n", this, xrefiid
,ppvObj
);
98 static ULONG WINAPI
IDirect3DViewport2_AddRef(LPDIRECT3DVIEWPORT2
this)
100 TRACE(ddraw
, "(%p)->()incrementing from %lu.\n", this, this->ref
);
102 return ++(this->ref
);
107 static ULONG WINAPI
IDirect3DViewport2_Release(LPDIRECT3DVIEWPORT2
this)
109 FIXME( ddraw
, "(%p)->() decrementing from %lu.\n", this, this->ref
);
111 if (!--(this->ref
)) {
112 HeapFree(GetProcessHeap(),0,this);
119 /*** IDirect3DViewport methods ***/
120 static HRESULT WINAPI
IDirect3DViewport2_Initialize(LPDIRECT3DVIEWPORT2
this,
123 FIXME(ddraw
, "(%p)->(%p): stub\n", this, d3d
);
128 static HRESULT WINAPI
IDirect3DViewport2_GetViewport(LPDIRECT3DVIEWPORT2
this,
131 FIXME(ddraw
, "(%p)->(%p): stub\n", this, lpvp
);
133 if (this->use_vp2
!= 0)
134 return DDERR_INVALIDPARAMS
;
136 *lpvp
= this->viewport
.vp1
;
141 static HRESULT WINAPI
IDirect3DViewport2_SetViewport(LPDIRECT3DVIEWPORT2
this,
144 FIXME(ddraw
, "(%p)->(%p): stub\n", this, lpvp
);
147 this->viewport
.vp1
= *lpvp
;
149 TRACE(ddraw
, "dwSize = %ld dwX = %ld dwY = %ld\n",
150 lpvp
->dwSize
, lpvp
->dwX
, lpvp
->dwY
);
151 TRACE(ddraw
, "dwWidth = %ld dwHeight = %ld\n",
152 lpvp
->dwWidth
, lpvp
->dwHeight
);
153 TRACE(ddraw
, "dvScaleX = %f dvScaleY = %f\n",
154 lpvp
->dvScaleX
, lpvp
->dvScaleY
);
155 TRACE(ddraw
, "dvMaxX = %f dvMaxY = %f\n",
156 lpvp
->dvMaxX
, lpvp
->dvMaxY
);
157 TRACE(ddraw
, "dvMinZ = %f dvMaxZ = %f\n",
158 lpvp
->dvMinZ
, lpvp
->dvMaxZ
);
164 static HRESULT WINAPI
IDirect3DViewport2_TransformVertices(LPDIRECT3DVIEWPORT2
this,
166 LPD3DTRANSFORMDATA lpData
,
170 FIXME(ddraw
, "(%p)->(%8ld,%p,%08lx,%p): stub\n",
171 this, dwVertexCount
, lpData
, dwFlags
, lpOffScreen
);
176 static HRESULT WINAPI
IDirect3DViewport2_LightElements(LPDIRECT3DVIEWPORT2
this,
177 DWORD dwElementCount
,
178 LPD3DLIGHTDATA lpData
)
180 FIXME(ddraw
, "(%p)->(%8ld,%p): stub\n", this, dwElementCount
, lpData
);
185 static HRESULT WINAPI
IDirect3DViewport2_SetBackground(LPDIRECT3DVIEWPORT2
this,
186 D3DMATERIALHANDLE hMat
)
188 FIXME(ddraw
, "(%p)->(%08lx): stub\n", this, (DWORD
) hMat
);
193 static HRESULT WINAPI
IDirect3DViewport2_GetBackground(LPDIRECT3DVIEWPORT2
this,
194 LPD3DMATERIALHANDLE lphMat
,
197 FIXME(ddraw
, "(%p)->(%p,%p): stub\n", this, lphMat
, lpValid
);
202 static HRESULT WINAPI
IDirect3DViewport2_SetBackgroundDepth(LPDIRECT3DVIEWPORT2
this,
203 LPDIRECTDRAWSURFACE lpDDSurface
)
205 FIXME(ddraw
, "(%p)->(%p): stub\n", this, lpDDSurface
);
210 static HRESULT WINAPI
IDirect3DViewport2_GetBackgroundDepth(LPDIRECT3DVIEWPORT2
this,
211 LPDIRECTDRAWSURFACE
* lplpDDSurface
,
214 FIXME(ddraw
, "(%p)->(%p,%p): stub\n", this, lplpDDSurface
, lpValid
);
219 static HRESULT WINAPI
IDirect3DViewport2_Clear(LPDIRECT3DVIEWPORT2
this,
225 FIXME(ddraw
, "(%p)->(%8ld,%p,%08lx): stub\n", this, dwCount
, lpRects
, dwFlags
);
227 /* For the moment, ignore the rectangles */
228 if (this->device
.active_device1
!= NULL
) {
229 /* Get the rendering context */
231 this->device
.active_device2
->set_context(this->device
.active_device2
);
233 this->device
.active_device1
->set_context(this->device
.active_device1
);
236 /* Clears the screen */
237 glGetBooleanv(GL_DEPTH_TEST
, &ztest
);
238 glDepthMask(GL_TRUE
); /* Enables Z writing to be sure to delete also the Z buffer */
239 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
245 static HRESULT WINAPI
IDirect3DViewport2_AddLight(LPDIRECT3DVIEWPORT2
this,
246 LPDIRECT3DLIGHT lpLight
)
248 FIXME(ddraw
, "(%p)->(%p): stub\n", this, lpLight
);
250 /* Add the light in the 'linked' chain */
251 lpLight
->next
= this->lights
;
252 this->lights
= lpLight
;
254 /* If active, activate the light */
255 if (this->device
.active_device1
!= NULL
) {
256 /* Get the rendering context */
258 this->device
.active_device2
->set_context(this->device
.active_device2
);
260 this->device
.active_device1
->set_context(this->device
.active_device1
);
262 /* Activate the light */
263 lpLight
->light_num
= this->nextlight
++;
264 lpLight
->activate(lpLight
);
270 static HRESULT WINAPI
IDirect3DViewport2_DeleteLight(LPDIRECT3DVIEWPORT2
this,
271 LPDIRECT3DLIGHT lpLight
)
273 FIXME(ddraw
, "(%p)->(%p): stub\n", this, lpLight
);
278 static HRESULT WINAPI
IDirect3DViewport2_NextLight(LPDIRECT3DVIEWPORT2
this,
279 LPDIRECT3DLIGHT lpLight
,
280 LPDIRECT3DLIGHT
* lplpLight
,
283 FIXME(ddraw
, "(%p)->(%p,%p,%08lx): stub\n", this, lpLight
, lplpLight
, dwFlags
);
288 /*** IDirect3DViewport2 methods ***/
289 static HRESULT WINAPI
IDirect3DViewport2_GetViewport2(LPDIRECT3DVIEWPORT2
this,
290 LPD3DVIEWPORT2 lpViewport2
)
292 TRACE(ddraw
, "(%p)->(%p)\n", this, lpViewport2
);
294 if (this->use_vp2
!= 1)
295 return DDERR_INVALIDPARAMS
;
297 *lpViewport2
= this->viewport
.vp2
;
302 static HRESULT WINAPI
IDirect3DViewport2_SetViewport2(LPDIRECT3DVIEWPORT2
this,
303 LPD3DVIEWPORT2 lpViewport2
)
305 TRACE(ddraw
, "(%p)->(%p)\n", this, lpViewport2
);
307 TRACE(ddraw
, "dwSize = %ld dwX = %ld dwY = %ld\n",
308 lpViewport2
->dwSize
, lpViewport2
->dwX
, lpViewport2
->dwY
);
309 TRACE(ddraw
, "dwWidth = %ld dwHeight = %ld\n",
310 lpViewport2
->dwWidth
, lpViewport2
->dwHeight
);
311 TRACE(ddraw
, "dvClipX = %f dvClipY = %f\n",
312 lpViewport2
->dvClipX
, lpViewport2
->dvClipY
);
313 TRACE(ddraw
, "dvClipWidth = %f dvClipHeight = %f\n",
314 lpViewport2
->dvClipWidth
, lpViewport2
->dvClipHeight
);
315 TRACE(ddraw
, "dvMinZ = %f dvMaxZ = %f\n",
316 lpViewport2
->dvMinZ
, lpViewport2
->dvMaxZ
);
318 this->viewport
.vp2
= *lpViewport2
;
325 /*******************************************************************************
326 * IDirect3DViewport1/2 VTable
328 static IDirect3DViewport2_VTable viewport2_vtable
= {
329 /*** IUnknown methods ***/
330 IDirect3DViewport2_QueryInterface
,
331 IDirect3DViewport2_AddRef
,
332 IDirect3DViewport2_Release
,
333 /*** IDirect3DViewport methods ***/
334 IDirect3DViewport2_Initialize
,
335 IDirect3DViewport2_GetViewport
,
336 IDirect3DViewport2_SetViewport
,
337 IDirect3DViewport2_TransformVertices
,
338 IDirect3DViewport2_LightElements
,
339 IDirect3DViewport2_SetBackground
,
340 IDirect3DViewport2_GetBackground
,
341 IDirect3DViewport2_SetBackgroundDepth
,
342 IDirect3DViewport2_GetBackgroundDepth
,
343 IDirect3DViewport2_Clear
,
344 IDirect3DViewport2_AddLight
,
345 IDirect3DViewport2_DeleteLight
,
346 IDirect3DViewport2_NextLight
,
347 /*** IDirect3DViewport2 methods ***/
348 IDirect3DViewport2_GetViewport2
,
349 IDirect3DViewport2_SetViewport2
352 #else /* HAVE_MESAGL */
354 LPDIRECT3DVIEWPORT
d3dviewport_create(LPDIRECT3D d3d
) {
355 ERR(ddraw
, "Should not be called...\n");
359 LPDIRECT3DVIEWPORT2
d3dviewport2_create(LPDIRECT3D2 d3d
) {
360 ERR(ddraw
, "Should not be called...\n");
364 #endif /* HAVE_MESAGL */