Add support for vertex shader constants to the stateblock.
[wine/gsoc_dplay.git] / dlls / ddraw / direct3d_main.c
blob1b3a3ec23700f87102b5ff7eb2d21eb5fccc1aac
1 /*
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
19 #include "config.h"
21 #include <assert.h>
22 #ifdef HAVE_UNISTD_H
23 # include <unistd.h>
24 #endif
25 #include <fcntl.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdio.h>
30 #include "winerror.h"
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "ddraw.h"
35 #include "d3d.h"
36 #include "wine/debug.h"
38 #include "d3d_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
43 HRESULT WINAPI
44 Main_IDirect3DImpl_1_Initialize(LPDIRECT3D iface,
45 REFIID riid)
47 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D, iface);
48 TRACE("(%p/%p)->(%s) no-op...\n", This, iface, debugstr_guid(riid));
49 return D3D_OK;
52 HRESULT WINAPI
53 Main_IDirect3DImpl_3_2T_1T_EnumDevices(LPDIRECT3D3 iface,
54 LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
55 LPVOID lpUserArg)
57 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
58 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg);
59 return D3D_OK;
62 HRESULT WINAPI
63 Main_IDirect3DImpl_3_2T_1T_CreateLight(LPDIRECT3D3 iface,
64 LPDIRECT3DLIGHT* lplpDirect3DLight,
65 IUnknown* pUnkOuter)
67 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
68 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DLight, pUnkOuter);
69 return D3D_OK;
72 HRESULT WINAPI
73 Main_IDirect3DImpl_3_2T_1T_CreateMaterial(LPDIRECT3D3 iface,
74 LPDIRECT3DMATERIAL3* lplpDirect3DMaterial3,
75 IUnknown* pUnkOuter)
77 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
78 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpDirect3DMaterial3, pUnkOuter);
79 return D3D_OK;
82 HRESULT WINAPI
83 Main_IDirect3DImpl_3_2T_1T_CreateViewport(LPDIRECT3D3 iface,
84 LPDIRECT3DVIEWPORT3* lplpD3DViewport3,
85 IUnknown* pUnkOuter)
87 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
88 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lplpD3DViewport3, pUnkOuter);
89 return D3D_OK;
92 HRESULT WINAPI
93 Main_IDirect3DImpl_3_2T_1T_FindDevice(LPDIRECT3D3 iface,
94 LPD3DFINDDEVICESEARCH lpD3DDFS,
95 LPD3DFINDDEVICERESULT lpD3DFDR)
97 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
98 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpD3DDFS, lpD3DFDR);
99 return D3D_OK;
102 HRESULT WINAPI
103 Main_IDirect3DImpl_2_CreateDevice(LPDIRECT3D2 iface,
104 REFCLSID rclsid,
105 LPDIRECTDRAWSURFACE lpDDS,
106 LPDIRECT3DDEVICE2* lplpD3DDevice2)
108 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D2, iface);
109 FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice2);
110 return D3D_OK;
113 HRESULT WINAPI
114 Main_IDirect3DImpl_3_CreateDevice(LPDIRECT3D3 iface,
115 REFCLSID rclsid,
116 LPDIRECTDRAWSURFACE4 lpDDS,
117 LPDIRECT3DDEVICE3* lplpD3DDevice3,
118 LPUNKNOWN lpUnk)
120 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D3, iface);
121 FIXME("(%p/%p)->(%s,%p,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice3, lpUnk);
122 return D3D_OK;
125 HRESULT WINAPI
126 Main_IDirect3DImpl_7_3T_EnumZBufferFormats(LPDIRECT3D7 iface,
127 REFCLSID riidDevice,
128 LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
129 LPVOID lpContext)
131 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
132 FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
133 return D3D_OK;
136 HRESULT WINAPI
137 Main_IDirect3DImpl_7_3T_EvictManagedTextures(LPDIRECT3D7 iface)
139 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
140 FIXME("(%p/%p)->(): stub!\n", This, iface);
141 return D3D_OK;
144 HRESULT WINAPI
145 Main_IDirect3DImpl_7_EnumDevices(LPDIRECT3D7 iface,
146 LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback,
147 LPVOID lpUserArg)
149 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
150 FIXME("(%p/%p)->(%p,%p): stub!\n", This, iface, lpEnumDevicesCallback, lpUserArg);
151 return D3D_OK;
154 HRESULT WINAPI
155 Main_IDirect3DImpl_7_CreateDevice(LPDIRECT3D7 iface,
156 REFCLSID rclsid,
157 LPDIRECTDRAWSURFACE7 lpDDS,
158 LPDIRECT3DDEVICE7* lplpD3DDevice)
160 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
161 FIXME("(%p/%p)->(%s,%p,%p): stub!\n", This, iface, debugstr_guid(rclsid), lpDDS, lplpD3DDevice);
162 return D3D_OK;
165 HRESULT WINAPI
166 Main_IDirect3DImpl_7_3T_CreateVertexBuffer(LPDIRECT3D7 iface,
167 LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
168 LPDIRECT3DVERTEXBUFFER7* lplpD3DVertBuf,
169 DWORD dwFlags)
171 ICOM_THIS_FROM(IDirectDrawImpl, IDirect3D7, iface);
172 FIXME("(%p/%p)->(%p,%p,%08lx): stub!\n", This, iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags);
173 return D3D_OK;
176 HRESULT WINAPI
177 Thunk_IDirect3DImpl_7_QueryInterface(LPDIRECT3D7 iface,
178 REFIID riid,
179 LPVOID* obp)
181 TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
182 return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface),
183 riid,
184 obp);
187 HRESULT WINAPI
188 Thunk_IDirect3DImpl_3_QueryInterface(LPDIRECT3D3 iface,
189 REFIID riid,
190 LPVOID* obp)
192 TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
193 return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface),
194 riid,
195 obp);
198 HRESULT WINAPI
199 Thunk_IDirect3DImpl_2_QueryInterface(LPDIRECT3D2 iface,
200 REFIID riid,
201 LPVOID* obp)
203 TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
204 return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface),
205 riid,
206 obp);
209 HRESULT WINAPI
210 Thunk_IDirect3DImpl_1_QueryInterface(LPDIRECT3D iface,
211 REFIID riid,
212 LPVOID* obp)
214 TRACE("(%p)->(%s,%p) thunking to IDirectDraw7 interface.\n", iface, debugstr_guid(riid), obp);
215 return IDirectDraw7_QueryInterface(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface),
216 riid,
217 obp);
220 ULONG WINAPI
221 Thunk_IDirect3DImpl_7_AddRef(LPDIRECT3D7 iface)
223 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
224 return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface));
227 ULONG WINAPI
228 Thunk_IDirect3DImpl_3_AddRef(LPDIRECT3D3 iface)
230 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
231 return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface));
234 ULONG WINAPI
235 Thunk_IDirect3DImpl_2_AddRef(LPDIRECT3D2 iface)
237 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
238 return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface));
241 ULONG WINAPI
242 Thunk_IDirect3DImpl_1_AddRef(LPDIRECT3D iface)
244 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
245 return IDirectDraw7_AddRef(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface));
248 ULONG WINAPI
249 Thunk_IDirect3DImpl_7_Release(LPDIRECT3D7 iface)
251 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
252 return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D7, IDirectDraw7, iface));
255 ULONG WINAPI
256 Thunk_IDirect3DImpl_3_Release(LPDIRECT3D3 iface)
258 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
259 return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirectDraw7, iface));
262 ULONG WINAPI
263 Thunk_IDirect3DImpl_2_Release(LPDIRECT3D2 iface)
265 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
266 return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirectDraw7, iface));
269 ULONG WINAPI
270 Thunk_IDirect3DImpl_1_Release(LPDIRECT3D iface)
272 TRACE("(%p)->() thunking to IDirectDraw7 interface.\n", iface);
273 return IDirectDraw7_Release(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirectDraw7, iface));
276 HRESULT WINAPI
277 Thunk_IDirect3DImpl_3_EnumZBufferFormats(LPDIRECT3D3 iface,
278 REFCLSID riidDevice,
279 LPD3DENUMPIXELFORMATSCALLBACK lpEnumCallback,
280 LPVOID lpContext)
282 TRACE("(%p)->(%s,%p,%p) thunking to IDirect3D7 interface.\n", iface, debugstr_guid(riidDevice), lpEnumCallback, lpContext);
283 return IDirect3D7_EnumZBufferFormats(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface),
284 riidDevice,
285 lpEnumCallback,
286 lpContext);
289 HRESULT WINAPI
290 Thunk_IDirect3DImpl_3_EvictManagedTextures(LPDIRECT3D3 iface)
292 TRACE("(%p)->() thunking to IDirect3D7 interface.\n", iface);
293 return IDirect3D7_EvictManagedTextures(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface));
296 HRESULT WINAPI
297 Thunk_IDirect3DImpl_2_EnumDevices(LPDIRECT3D2 iface,
298 LPD3DENUMDEVICESCALLBACK lpEnumDevicesCallback,
299 LPVOID lpUserArg)
301 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpEnumDevicesCallback, lpUserArg);
302 return IDirect3D3_EnumDevices(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
303 lpEnumDevicesCallback,
304 lpUserArg);
307 HRESULT WINAPI
308 Thunk_IDirect3DImpl_2_CreateLight(LPDIRECT3D2 iface,
309 LPDIRECT3DLIGHT* lplpDirect3DLight,
310 IUnknown* pUnkOuter)
312 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter);
313 return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
314 lplpDirect3DLight,
315 pUnkOuter);
318 HRESULT WINAPI
319 Thunk_IDirect3DImpl_1_CreateLight(LPDIRECT3D iface,
320 LPDIRECT3DLIGHT* lplpDirect3DLight,
321 IUnknown* pUnkOuter)
323 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DLight, pUnkOuter);
324 return IDirect3D3_CreateLight(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
325 lplpDirect3DLight,
326 pUnkOuter);
329 HRESULT WINAPI
330 Thunk_IDirect3DImpl_1_CreateMaterial(LPDIRECT3D iface,
331 LPDIRECT3DMATERIAL* lplpDirect3DMaterial,
332 IUnknown* pUnkOuter)
334 HRESULT ret;
335 LPDIRECT3DMATERIAL3 ret_val;
337 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial, pUnkOuter);
338 ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
339 &ret_val,
340 pUnkOuter);
342 *lplpDirect3DMaterial = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial, ret_val);
344 TRACE(" returning interface %p.\n", *lplpDirect3DMaterial);
346 return ret;
349 HRESULT WINAPI
350 Thunk_IDirect3DImpl_1_CreateViewport(LPDIRECT3D iface,
351 LPDIRECT3DVIEWPORT* lplpD3DViewport,
352 IUnknown* pUnkOuter)
354 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport, pUnkOuter);
355 return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
356 (LPDIRECT3DVIEWPORT3 *) lplpD3DViewport /* No need to cast here */,
357 pUnkOuter);
360 HRESULT WINAPI
361 Thunk_IDirect3DImpl_2_CreateMaterial(LPDIRECT3D2 iface,
362 LPDIRECT3DMATERIAL2* lplpDirect3DMaterial2,
363 IUnknown* pUnkOuter)
365 HRESULT ret;
366 LPDIRECT3DMATERIAL3 ret_val;
368 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpDirect3DMaterial2, pUnkOuter);
369 ret = IDirect3D3_CreateMaterial(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
370 &ret_val,
371 pUnkOuter);
373 *lplpDirect3DMaterial2 = COM_INTERFACE_CAST(IDirect3DMaterialImpl, IDirect3DMaterial3, IDirect3DMaterial2, ret_val);
375 TRACE(" returning interface %p.\n", *lplpDirect3DMaterial2);
377 return ret;
380 HRESULT WINAPI
381 Thunk_IDirect3DImpl_2_CreateViewport(LPDIRECT3D2 iface,
382 LPDIRECT3DVIEWPORT2* lplpD3DViewport2,
383 IUnknown* pUnkOuter)
385 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lplpD3DViewport2, pUnkOuter);
386 return IDirect3D3_CreateViewport(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
387 (LPDIRECT3DVIEWPORT3 *) lplpD3DViewport2 /* No need to cast here */,
388 pUnkOuter);
392 HRESULT WINAPI
393 Thunk_IDirect3DImpl_3_CreateVertexBuffer(LPDIRECT3D3 iface,
394 LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc,
395 LPDIRECT3DVERTEXBUFFER* lplpD3DVertBuf,
396 DWORD dwFlags,
397 LPUNKNOWN lpUnk)
399 HRESULT ret;
400 LPDIRECT3DVERTEXBUFFER7 ret_val;
402 TRACE("(%p)->(%p,%p,%08lx,%p) thunking to IDirect3D7 interface.\n", iface, lpD3DVertBufDesc, lplpD3DVertBuf, dwFlags, lpUnk);
404 /* dwFlags is not used in the D3D7 interface, use the vertex buffer description instead */
405 if (dwFlags & D3DDP_DONOTCLIP) lpD3DVertBufDesc->dwCaps |= D3DVBCAPS_DONOTCLIP;
407 ret = IDirect3D7_CreateVertexBuffer(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D3, IDirect3D7, iface),
408 lpD3DVertBufDesc,
409 &ret_val,
410 dwFlags);
412 *lplpD3DVertBuf = COM_INTERFACE_CAST(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, IDirect3DVertexBuffer, ret_val);
414 TRACE(" returning interface %p.\n", *lplpD3DVertBuf);
416 return ret;
419 HRESULT WINAPI
420 Thunk_IDirect3DImpl_1_FindDevice(LPDIRECT3D iface,
421 LPD3DFINDDEVICESEARCH lpD3DDFS,
422 LPD3DFINDDEVICERESULT lplpD3DDevice)
424 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lplpD3DDevice);
425 return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D, IDirect3D3, iface),
426 lpD3DDFS,
427 lplpD3DDevice);
430 HRESULT WINAPI
431 Thunk_IDirect3DImpl_2_FindDevice(LPDIRECT3D2 iface,
432 LPD3DFINDDEVICESEARCH lpD3DDFS,
433 LPD3DFINDDEVICERESULT lpD3DFDR)
435 TRACE("(%p)->(%p,%p) thunking to IDirect3D3 interface.\n", iface, lpD3DDFS, lpD3DFDR);
436 return IDirect3D3_FindDevice(COM_INTERFACE_CAST(IDirectDrawImpl, IDirect3D2, IDirect3D3, iface),
437 lpD3DDFS,
438 lpD3DFDR);