2 * Copyright 2000 Marcus Meissner
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
34 #include "d3d_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
39 Main_IDirect3DImpl_7_3T_2T_1T_QueryInterface(LPDIRECT3D7 iface,
43 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
45 TRACE("(%p/%p)->(%s,%p)\n", This, iface, debugstr_guid(riid), obp);
47 /* By default, set the object pointer to NULL */
50 if (( IsEqualGUID( &IID_IDirectDraw, riid ) ) ||
51 ( IsEqualGUID (&IID_IDirectDraw2, riid ) ) ||
52 ( IsEqualGUID (&IID_IDirectDraw4, riid ) ) ||
53 ( IsEqualGUID( &IID_IDirectDraw7, riid ) )
56 TRACE(" Creating IDirectDrawX interface by calling DirectDraw function.\n");
57 ret = IDirectDraw_QueryInterface(ICOM_INTERFACE(This->ddraw,IDirectDraw), riid, obp);
59 IDirectDraw_Release(ICOM_INTERFACE(This->ddraw,IDirectDraw));
60 IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D));
64 if ( IsEqualGUID( &IID_IUnknown, riid ) ) {
65 IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D));
67 TRACE(" Creating IUnknown interface at %p.\n", *obp);
70 if ( IsEqualGUID( &IID_IDirect3D, riid ) ) {
71 IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D));
72 *obp = ICOM_INTERFACE(This, IDirect3D);
73 TRACE(" Creating IDirect3D interface %p\n", *obp);
76 if ( IsEqualGUID( &IID_IDirect3D2, riid ) ) {
77 IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D));
78 *obp = ICOM_INTERFACE(This, IDirect3D2);
79 TRACE(" Creating IDirect3D2 interface %p\n", *obp);
82 if ( IsEqualGUID( &IID_IDirect3D3, riid ) ) {
83 IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D));
84 *obp = ICOM_INTERFACE(This, IDirect3D3);
85 TRACE(" Creating IDirect3D3 interface %p\n", *obp);
88 if ( IsEqualGUID( &IID_IDirect3D7, riid ) ) {
89 /* This is not 100 % true as we should not be able to QueryInterface a '7' version from another one.
90 But well, to factorize the code, why check for application bugs :-) ?
92 IDirect3D_AddRef(ICOM_INTERFACE(This,IDirect3D));
93 *obp = ICOM_INTERFACE(This, IDirect3D7);
94 TRACE(" Creating IDirect3D7 interface %p\n", *obp);
97 FIXME("(%p): interface for IID %s NOT found!\n", This, debugstr_guid(riid));
98 return OLE_E_ENUM_NOMORE;
102 Main_IDirect3DImpl_7_3T_2T_1T_AddRef(LPDIRECT3D7 iface)
104 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
105 TRACE("(%p/%p)->() incrementing from %lu.\n", This, iface, This->ref);
107 return ++(This->ref);
111 Main_IDirect3DImpl_7_3T_2T_1T_Release(LPDIRECT3D7 iface)
113 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
114 TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, This->ref);
115 if (--(This->ref) == 0) {
116 IDirectDraw_Release(ICOM_INTERFACE(This->ddraw, IDirectDraw));
117 HeapFree(GetProcessHeap(), 0, This);
124 Main_IDirect3DImpl_1_Initialize(LPDIRECT3D iface,
127 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface);
128 TRACE("(%p/%p)->(%s) no-op...\n", This, iface, debugstr_guid(riid));
133 Main_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface,
134 LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
137 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
138 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg);
143 Main_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface,
144 LPDIRECT3DLIGHT* lplpDirect3DLight,
147 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
148 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DLight, pUnkOuter);
153 Main_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface,
154 LPDIRECT3DMATERIAL3* lplpDirect3DMaterial3,
157 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
158 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DMaterial3, pUnkOuter);
163 Main_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface,
164 LPDIRECT3DVIEWPORT3* lplpD3DViewport3,
167 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
168 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpD3DViewport3, pUnkOuter);
173 Main_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
174 LPD3DFINDDEVICESEARCH lpD3DDFS,
175 LPD3DFINDDEVICERESULT lplpD3DDevice)
177 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D, iface);
178 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lplpD3DDevice);
183 Main_IDirect3DImpl_3_2T_FindDevice(LPDIRECT3D3 iface,
184 LPD3DFINDDEVICESEARCH lpD3DDFS,
185 LPD3DFINDDEVICERESULT lpD3DFDR)
187 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
188 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR);
193 Main_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface,
195 LPDIRECTDRAWSURFACE lpDDS,
196 LPDIRECT3DDEVICE2* lplpD3DDevice2)
198 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D2, iface);
199 FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice2);
204 Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface,
206 LPDIRECTDRAWSURFACE4 lpDDS,
207 LPDIRECT3DDEVICE3* lplpD3DDevice3,
210 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D3, iface);
211 FIXME("(%p/%p)->(%s,%p,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice3, lpUnk);
216 Main_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface,
218 LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
221 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
222 FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
227 Main_IDirect3DImpl_7_3T_EvictManagedTextures(LPDIRECT3D7 iface)
229 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
230 FIXME("(%p/%p)->(): stub!\n", This, iface);
235 Main_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface,
236 LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback,
239 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
240 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg);
245 Main_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface,
247 LPDIRECTDRAWSURFACE7 lpDDS,
248 LPDIRECT3DDEVICE7* lplpD3DDevice)
250 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
251 FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice);
256 Main_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface,
257 LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
258 LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf,
261 ICOM_THIS_FROM(IDirect3DImpl, IDirect3D7, iface);
262 FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags);
267 Thunk_IDirect3DImpl_3_QueryInterface(LPDIRECT3D3 iface,
271 TRACE("(%p)->(%s,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riid), obp);
272 return IDirect3D7_QueryInterface(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface),
278 Thunk_IDirect3DImpl_2_QueryInterface(LPDIRECT3D2 iface,
282 TRACE("(%p)->(%s,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riid), obp);
283 return IDirect3D7_QueryInterface(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D7, iface),
289 Thunk_IDirect3DImpl_1_QueryInterface(LPDIRECT3D iface,
293 TRACE("(%p)->(%s,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riid), obp);
294 return IDirect3D7_QueryInterface(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D7, iface),
300 Thunk_IDirect3DImpl_3_AddRef(LPDIRECT3D3 iface)
302 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
303 return IDirect3D7_AddRef(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface));
307 Thunk_IDirect3DImpl_2_AddRef(LPDIRECT3D2 iface)
309 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
310 return IDirect3D7_AddRef(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D7, iface));
314 Thunk_IDirect3DImpl_1_AddRef(LPDIRECT3D iface)
316 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
317 return IDirect3D7_AddRef(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D7, iface));
321 Thunk_IDirect3DImpl_3_Release(LPDIRECT3D3 iface)
323 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
324 return IDirect3D7_Release(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface));
328 Thunk_IDirect3DImpl_2_Release(LPDIRECT3D2 iface)
330 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
331 return IDirect3D7_Release(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D7, iface));
335 Thunk_IDirect3DImpl_1_Release(LPDIRECT3D iface)
337 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
338 return IDirect3D7_Release(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D7, iface));
342 Thunk_IDirect3DImpl_3_EnumZBufferFormats(LPDIRECT3D3 iface,
344 LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
347 TRACE("(%p)->(%s,%p,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
348 return IDirect3D7_EnumZBufferFormats(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface),
355 Thunk_IDirect3DImpl_3_EvictManagedTextures(LPDIRECT3D3 iface)
357 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
358 return IDirect3D7_EvictManagedTextures(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface));
362 Thunk_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface,
363 LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
366 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpEnumDevicesCallback, lpUserArg);
367 return IDirect3D3_EnumDevices(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface),
368 lpEnumDevicesCallback,
373 Thunk_IDirect3DImpl_1_EnumDevices(LPDIRECT3D iface,
374 LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
377 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpEnumDevicesCallback, lpUserArg);
378 return IDirect3D3_EnumDevices(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
379 lpEnumDevicesCallback,
384 Thunk_IDirect3DImpl_2_CreateLight(LPDIRECT3D2 iface,
385 LPDIRECT3DLIGHT* lplpDirect3DLight,
388 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter);
389 return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface),
395 Thunk_IDirect3DImpl_1_CreateLight(LPDIRECT3D iface,
396 LPDIRECT3DLIGHT* lplpDirect3DLight,
399 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter);
400 return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
406 Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
407 LPD3DFINDDEVICESEARCH lpD3DDFS,
408 LPD3DFINDDEVICERESULT lpD3DFDR)
410 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lpD3DFDR);
411 return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface),
417 Thunk_IDirect3DImpl_1_CreateMaterial(LPDIRECT3D iface,
418 LPDIRECT3DMATERIAL* lplpDirect3DMaterial,
422 LPDIRECT3DMATERIAL3 ret_val;
424 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial, pUnkOuter);
425 ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
429 *lplpDirect3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, &ret_val);
431 TRACE(" returning interface %p.\n", *lplpDirect3DMaterial);
437 Thunk_IDirect3DImpl_1_CreateViewport(LPDIRECT3D iface,
438 LPDIRECT3DVIEWPORT* lplpD3DViewport,
441 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport, pUnkOuter);
442 return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D, IDirect3D3, iface),
443 (LPDIRECT3DVIEWPORT3 *) lplpD3DViewport /* No need to cast here */,
448 Thunk_IDirect3DImpl_2_CreateMaterial(LPDIRECT3D2 iface,
449 LPDIRECT3DMATERIAL2* lplpDirect3DMaterial2,
453 LPDIRECT3DMATERIAL3 ret_val;
455 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial2, pUnkOuter);
456 ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface),
460 *lplpDirect3DMaterial2 = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, &ret_val);
462 TRACE(" returning interface %p.\n", *lplpDirect3DMaterial2);
468 Thunk_IDirect3DImpl_2_CreateViewport(LPDIRECT3D2 iface,
469 LPDIRECT3DVIEWPORT* lplpD3DViewport2,
472 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport2, pUnkOuter);
473 return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D2, IDirect3D3, iface),
474 (LPDIRECT3DVIEWPORT3 *) lplpD3DViewport2 /* No need to cast here */,
480 Thunk_IDirect3DImpl_3_CreateVertexBuffer(LPDIRECT3D3 iface,
481 LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
482 LPDIRECT3DVERTEXBUFFER* lplpD3DVertBuf,
487 LPDIRECT3DVERTEXBUFFER7 ret_val;
489 TRACE("(%p)->(%p,%p,%08lx,%p) thunking to IDirect3D7 interface.\n", iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags, lpUnk);
490 ret = IDirect3D7_CreateVertexBuffer(COM_INTERFACE_CAST(IDirect3DImpl, IDirect3D3, IDirect3D7, iface),
495 *lplpD3DVertBuf = COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, IDirect3DVertexBuffer, ret_val);
497 TRACE(" returning interface %p.\n", *lplpD3DVertBuf);