13 #include "ddraw_private.h"
14 #include "mesa_private.h"
17 #include "debugtools.h"
19 DEFAULT_DEBUG_CHANNEL(ddraw
);
21 /*******************************************************************************
24 static HRESULT WINAPI
MESA_IDirect3DImpl_QueryInterface(
25 LPDIRECT3D iface
,REFIID refiid
,LPVOID
*obj
27 ICOM_THIS(IDirect3DImpl
,iface
);
28 /* FIXME: Not sure if this is correct */
30 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(refiid
),obj
);
31 if (( IsEqualGUID( &IID_IDirectDraw
, refiid
) ) ||
32 ( IsEqualGUID (&IID_IDirectDraw2
, refiid
) ) ||
33 ( IsEqualGUID( &IID_IDirectDraw4
, refiid
) )
36 IDirect3D_AddRef(iface
);
37 TRACE(" Creating IDirectDrawX interface (%p)\n", *obj
);
40 if (( IsEqualGUID( &IID_IDirect3D
, refiid
) ) ||
41 ( IsEqualGUID( &IID_IUnknown
, refiid
) ) ) {
43 IDirect3D_AddRef(iface
);
44 TRACE(" Creating IDirect3D interface (%p)\n", *obj
);
47 if ( IsEqualGUID( &IID_IDirect3D2
, refiid
) ) {
50 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
52 d3d
->ddraw
= This
->ddraw
;
53 IDirect3D_AddRef(iface
);
54 ICOM_VTBL(d3d
) = &mesa_d3d2vt
;
56 TRACE(" Creating IDirect3D2 interface (%p)\n", *obj
);
59 FIXME("(%p):interface for IID %s NOT found!\n",This
,debugstr_guid(refiid
));
60 return OLE_E_ENUM_NOMORE
;
63 static ULONG WINAPI
MESA_IDirect3DImpl_Release(LPDIRECT3D iface
)
65 ICOM_THIS(IDirect3DImpl
,iface
);
66 TRACE("(%p)->() decrementing from %lu.\n", This
, This
->ref
);
69 IDirectDraw2_Release((IDirectDraw2
*)This
->ddraw
);
70 HeapFree(GetProcessHeap(),0,This
);
76 static HRESULT WINAPI
MESA_IDirect3DImpl_EnumDevices(
77 LPDIRECT3D iface
, LPD3DENUMDEVICESCALLBACK cb
, LPVOID context
79 ICOM_THIS(IDirect3DImpl
,iface
);
80 FIXME("(%p)->(%p,%p),stub!\n",This
,cb
,context
);
82 /* Call functions defined in d3ddevices.c */
83 if (!d3d_OpenGL_dx3(cb
, context
))
89 static HRESULT WINAPI
MESA_IDirect3DImpl_CreateLight(
90 LPDIRECT3D iface
, LPDIRECT3DLIGHT
*lplight
, IUnknown
*lpunk
92 ICOM_THIS(IDirect3DImpl
,iface
);
93 TRACE("(%p)->(%p,%p): stub\n", This
, lplight
, lpunk
);
95 /* Call the creation function that is located in d3dlight.c */
96 *lplight
= d3dlight_create_dx3(This
);
101 static HRESULT WINAPI
MESA_IDirect3DImpl_CreateMaterial(
102 LPDIRECT3D iface
, LPDIRECT3DMATERIAL
*lpmaterial
, IUnknown
*lpunk
104 ICOM_THIS(IDirect3DImpl
,iface
);
105 TRACE("(%p)->(%p,%p): stub\n", This
, lpmaterial
, lpunk
);
106 /* Call the creation function that is located in d3dviewport.c */
107 *lpmaterial
= d3dmaterial_create(This
);
111 static HRESULT WINAPI
MESA_IDirect3DImpl_CreateViewport(
112 LPDIRECT3D iface
, LPDIRECT3DVIEWPORT
*lpviewport
, IUnknown
*lpunk
114 ICOM_THIS(IDirect3DImpl
,iface
);
115 TRACE("(%p)->(%p,%p): stub\n", This
, lpviewport
, lpunk
);
117 /* Call the creation function that is located in d3dviewport.c */
118 *lpviewport
= d3dviewport_create(This
);
123 static HRESULT WINAPI
MESA_IDirect3DImpl_FindDevice(
124 LPDIRECT3D iface
, LPD3DFINDDEVICESEARCH lpfinddevsrc
,
125 LPD3DFINDDEVICERESULT lpfinddevrst
)
127 ICOM_THIS(IDirect3DImpl
,iface
);
128 FIXME("(%p)->(%p,%p): stub\n", This
, lpfinddevsrc
, lpfinddevrst
);
133 ICOM_VTABLE(IDirect3D
) mesa_d3dvt
=
135 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
136 MESA_IDirect3DImpl_QueryInterface
,
137 IDirect3DImpl_AddRef
,
138 MESA_IDirect3DImpl_Release
,
139 IDirect3DImpl_Initialize
,
140 MESA_IDirect3DImpl_EnumDevices
,
141 MESA_IDirect3DImpl_CreateLight
,
142 MESA_IDirect3DImpl_CreateMaterial
,
143 MESA_IDirect3DImpl_CreateViewport
,
144 MESA_IDirect3DImpl_FindDevice
147 /*******************************************************************************
150 static HRESULT WINAPI
MESA_IDirect3D2Impl_QueryInterface(
151 LPDIRECT3D2 iface
,REFIID refiid
,LPVOID
*obj
) {
152 ICOM_THIS(IDirect3D2Impl
,iface
);
154 /* FIXME: Not sure if this is correct */
156 TRACE("(%p)->(%s,%p)\n",This
,debugstr_guid(refiid
),obj
);
157 if ( ( IsEqualGUID( &IID_IDirectDraw
, refiid
) ) ||
158 ( IsEqualGUID( &IID_IDirectDraw2
, refiid
) ) ||
159 ( IsEqualGUID( &IID_IDirectDraw4
, refiid
) ) ) {
161 IDirect3D2_AddRef(iface
);
163 TRACE(" Creating IDirectDrawX interface (%p)\n", *obj
);
167 if ( ( IsEqualGUID( &IID_IDirect3D2
, refiid
) ) ||
168 ( IsEqualGUID( &IID_IUnknown
, refiid
) ) ) {
170 IDirect3D2_AddRef(iface
);
172 TRACE(" Creating IDirect3D2 interface (%p)\n", *obj
);
176 if ( IsEqualGUID( &IID_IDirect3D
, refiid
) ) {
179 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
181 d3d
->ddraw
= This
->ddraw
;
182 IDirect3D2_AddRef(iface
);
183 ICOM_VTBL(d3d
) = &mesa_d3dvt
;
185 TRACE(" Creating IDirect3D interface (%p)\n", *obj
);
188 FIXME("(%p):interface for IID %s NOT found!\n",This
,debugstr_guid(refiid
));
189 return OLE_E_ENUM_NOMORE
;
192 static ULONG WINAPI
MESA_IDirect3D2Impl_Release(LPDIRECT3D2 iface
) {
193 ICOM_THIS(IDirect3D2Impl
,iface
);
194 TRACE("(%p)->() decrementing from %lu.\n", This
, This
->ref
);
196 if (!--(This
->ref
)) {
197 IDirectDraw2_Release((IDirectDraw2
*)This
->ddraw
);
198 HeapFree(GetProcessHeap(),0,This
);
204 static HRESULT WINAPI
MESA_IDirect3D2Impl_EnumDevices(
205 LPDIRECT3D2 iface
,LPD3DENUMDEVICESCALLBACK cb
, LPVOID context
207 ICOM_THIS(IDirect3D2Impl
,iface
);
208 FIXME("(%p)->(%p,%p),stub!\n",This
,cb
,context
);
210 /* Call functions defined in d3ddevices.c */
211 if (!d3d_OpenGL(cb
, context
))
216 static HRESULT WINAPI
MESA_IDirect3D2Impl_CreateLight(
217 LPDIRECT3D2 iface
, LPDIRECT3DLIGHT
*lplight
, IUnknown
*lpunk
219 ICOM_THIS(IDirect3D2Impl
,iface
);
220 TRACE("(%p)->(%p,%p): stub\n", This
, lplight
, lpunk
);
222 /* Call the creation function that is located in d3dlight.c */
223 *lplight
= d3dlight_create(This
);
228 static HRESULT WINAPI
MESA_IDirect3D2Impl_CreateMaterial(
229 LPDIRECT3D2 iface
, LPDIRECT3DMATERIAL2
*lpmaterial
, IUnknown
*lpunk
231 ICOM_THIS(IDirect3D2Impl
,iface
);
232 TRACE("(%p)->(%p,%p): stub\n", This
, lpmaterial
, lpunk
);
234 /* Call the creation function that is located in d3dviewport.c */
235 *lpmaterial
= d3dmaterial2_create(This
);
240 static HRESULT WINAPI
MESA_IDirect3D2Impl_CreateViewport(
241 LPDIRECT3D2 iface
, LPDIRECT3DVIEWPORT2
*lpviewport
, IUnknown
*lpunk
243 ICOM_THIS(IDirect3D2Impl
,iface
);
244 TRACE("(%p)->(%p,%p): stub\n", This
, lpviewport
, lpunk
);
246 /* Call the creation function that is located in d3dviewport.c */
247 *lpviewport
= d3dviewport2_create(This
);
252 static HRESULT WINAPI
MESA_IDirect3D2Impl_FindDevice(
253 LPDIRECT3D2 iface
, LPD3DFINDDEVICESEARCH lpfinddevsrc
,
254 LPD3DFINDDEVICERESULT lpfinddevrst
)
256 ICOM_THIS(IDirect3D2Impl
,iface
);
257 FIXME("(%p)->(%p,%p): stub\n", This
, lpfinddevsrc
, lpfinddevrst
);
261 static HRESULT WINAPI
MESA_IDirect3D2Impl_CreateDevice(
262 LPDIRECT3D2 iface
, REFCLSID rguid
, LPDIRECTDRAWSURFACE surface
,
263 LPDIRECT3DDEVICE2
*device
)
265 ICOM_THIS(IDirect3D2Impl
,iface
);
267 FIXME("(%p)->(%s,%p,%p): stub\n",This
,debugstr_guid(rguid
),surface
,device
);
269 if (is_OpenGL(rguid
, (IDirectDrawSurfaceImpl
*)surface
, (IDirect3DDevice2Impl
**)device
, This
)) {
270 IDirect3D2_AddRef(iface
);
274 return DDERR_INVALIDPARAMS
;
277 ICOM_VTABLE(IDirect3D2
) mesa_d3d2vt
=
279 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
280 MESA_IDirect3D2Impl_QueryInterface
,
281 IDirect3D2Impl_AddRef
,
282 MESA_IDirect3D2Impl_Release
,
283 MESA_IDirect3D2Impl_EnumDevices
,
284 MESA_IDirect3D2Impl_CreateLight
,
285 MESA_IDirect3D2Impl_CreateMaterial
,
286 MESA_IDirect3D2Impl_CreateViewport
,
287 MESA_IDirect3D2Impl_FindDevice
,
288 MESA_IDirect3D2Impl_CreateDevice
291 static HRESULT WINAPI
MESA_IDirect3D3Impl_CreateVertexBuffer(
293 LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc
,
294 LPDIRECT3DVERTEXBUFFER
* lplpD3DVertBuf
,
302 static HRESULT WINAPI
MESA_IDirect3D3Impl_EnumZBufferFormats(
305 LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback
,
309 return DDERR_NOZBUFFERHW
; /* Pretend we don't have valid HW */
312 static HRESULT WINAPI
MESA_IDirect3D3Impl_EvictManagedTextures(
320 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
321 # define XCAST(fun) (typeof(mesa_d3d3vt.fun))
323 # define XCAST(fun) (void*)
326 ICOM_VTABLE(IDirect3D3
) mesa_d3d3vt
=
328 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
329 XCAST(QueryInterface
)MESA_IDirect3D2Impl_QueryInterface
,
330 XCAST(AddRef
)IDirect3D2Impl_AddRef
,
331 XCAST(Release
)MESA_IDirect3D2Impl_Release
,
332 XCAST(EnumDevices
)MESA_IDirect3D2Impl_EnumDevices
,
333 XCAST(CreateLight
)MESA_IDirect3D2Impl_CreateLight
,
334 XCAST(CreateMaterial
)MESA_IDirect3D2Impl_CreateMaterial
,
335 XCAST(CreateViewport
)MESA_IDirect3D2Impl_CreateViewport
,
336 XCAST(FindDevice
)MESA_IDirect3D2Impl_FindDevice
,
337 XCAST(CreateDevice
)MESA_IDirect3D2Impl_CreateDevice
,
338 XCAST(CreateVertexBuffer
)MESA_IDirect3D3Impl_CreateVertexBuffer
,
339 XCAST(EnumZBufferFormats
)MESA_IDirect3D3Impl_EnumZBufferFormats
,
340 XCAST(EvictManagedTextures
)MESA_IDirect3D3Impl_EvictManagedTextures
343 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
347 HRESULT
create_direct3d(LPVOID
*obj
,IDirectDrawImpl
* ddraw
) {
350 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
352 d3d
->ddraw
= (IDirectDrawImpl
*) ddraw
;
353 d3d
->private = NULL
; /* unused for now */
354 IDirectDraw_AddRef((LPDIRECTDRAW
)ddraw
);
355 ICOM_VTBL(d3d
) = &mesa_d3dvt
;
356 *obj
= (LPUNKNOWN
)d3d
;
357 TRACE(" Created IDirect3D interface (%p)\n", *obj
);
362 HRESULT
create_direct3d2(LPVOID
*obj
,IDirectDrawImpl
* ddraw
) {
365 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
367 d3d
->ddraw
= (IDirectDrawImpl
*) ddraw
;
368 d3d
->private = NULL
; /* unused for now */
369 IDirectDraw_AddRef((LPDIRECTDRAW
)ddraw
);
370 ICOM_VTBL(d3d
) = &mesa_d3d2vt
;
371 *obj
= (LPUNKNOWN
)d3d
;
372 TRACE(" Creating IDirect3D2 interface (%p)\n", *obj
);
377 HRESULT
create_direct3d3(LPVOID
*obj
,IDirectDrawImpl
* ddraw
) {
380 d3d
= HeapAlloc(GetProcessHeap(),0,sizeof(*d3d
));
382 d3d
->ddraw
= (IDirectDrawImpl
*) ddraw
;
383 d3d
->private = NULL
; /* unused for now */
385 IDirectDraw_AddRef((LPDIRECTDRAW
)ddraw
);
386 ICOM_VTBL(d3d
) = &mesa_d3d3vt
;
387 *obj
= (LPUNKNOWN
)d3d
;
389 TRACE(" Creating IDirect3D3 interface (%p)\n", *obj
);