Commit | Line | Data |
---|---|---|
0799c1a7 | 1 | /* |
e1ced22d | 2 | * Copyright 2006 Stefan Dösinger |
0799c1a7 AJ |
3 | * |
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. | |
8 | * | |
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. | |
13 | * | |
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 | |
360a3f91 | 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
0799c1a7 | 17 | */ |
d6c0f9f7 | 18 | |
10ad97c8 MM |
19 | #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H |
20 | #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H | |
9e2f4af9 | 21 | |
10ad97c8 | 22 | /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */ |
ba02d1d7 | 23 | |
e37c6e18 | 24 | #include <stdarg.h> |
96a24ec8 LU |
25 | #include <stdio.h> |
26 | ||
e37c6e18 | 27 | #include "windef.h" |
10ad97c8 | 28 | #include "winbase.h" |
f5cea729 | 29 | #include "wtypes.h" |
10ad97c8 | 30 | #include "wingdi.h" |
896889f3 | 31 | #include "winuser.h" |
10ad97c8 | 32 | #include "ddraw.h" |
c8901d6f | 33 | #include "ddrawi.h" |
91c6f817 | 34 | #include "d3d.h" |
c8901d6f | 35 | |
d6c0f9f7 | 36 | #include "ddcomimpl.h" |
9e2f4af9 | 37 | |
a6917b14 | 38 | #include "wine/wined3d.h" |
09e794af | 39 | #include "wine/list.h" |
eac96b56 | 40 | |
9e2f4af9 | 41 | /***************************************************************************** |
c8901d6f SD |
42 | * IParent - a helper interface |
43 | *****************************************************************************/ | |
44 | DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81); | |
45 | typedef struct IParent *LPPARENT, *PPARENT; | |
9e2f4af9 | 46 | |
c8901d6f SD |
47 | #define INTERFACE IParent |
48 | DECLARE_INTERFACE_(IParent,IUnknown) | |
49 | { | |
50 | /*** IUnknown methods ***/ | |
51 | STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; | |
52 | STDMETHOD_(ULONG,AddRef)(THIS) PURE; | |
53 | STDMETHOD_(ULONG,Release)(THIS) PURE; | |
54 | }; | |
55 | #undef INTERFACE | |
56 | ||
57 | #if !defined(__cplusplus) || defined(CINTERFACE) | |
58 | /*** IUnknown methods ***/ | |
59 | #define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) | |
60 | #define IParent_AddRef(p) (p)->lpVtbl->AddRef(p) | |
61 | #define IParent_Release(p) (p)->lpVtbl->Release(p) | |
62 | #endif | |
63 | ||
64 | ||
65 | /* Typdef the interfaces */ | |
66 | typedef struct IDirectDrawImpl IDirectDrawImpl; | |
67 | typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl; | |
68 | typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl; | |
69 | typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl; | |
70 | typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl; | |
71 | typedef struct IDirect3DLightImpl IDirect3DLightImpl; | |
72 | typedef struct IDirect3DViewportImpl IDirect3DViewportImpl; | |
73 | typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl; | |
74 | typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl; | |
75 | typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl; | |
76 | typedef struct IParentImpl IParentImpl; | |
9e2f4af9 | 77 | |
3fd04308 | 78 | /* Callbacks for implicit object destruction */ |
5e0fc621 MA |
79 | extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain); |
80 | ||
3fd04308 MA |
81 | extern ULONG WINAPI D3D7CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface); |
82 | ||
5307dd20 SD |
83 | /* Global critical section */ |
84 | extern CRITICAL_SECTION ddraw_cs; | |
85 | ||
248ae8f1 DG |
86 | extern DWORD force_refresh_rate; |
87 | ||
c8901d6f SD |
88 | /***************************************************************************** |
89 | * IDirectDraw implementation structure | |
90 | *****************************************************************************/ | |
0386eed9 SD |
91 | struct FvfToDecl |
92 | { | |
93 | DWORD fvf; | |
94 | IWineD3DVertexDeclaration *decl; | |
95 | }; | |
9e2f4af9 | 96 | |
9e2f4af9 FG |
97 | struct IDirectDrawImpl |
98 | { | |
c8901d6f | 99 | /* IUnknown fields */ |
d6c0f9f7 AJ |
100 | ICOM_VFIELD_MULTI(IDirectDraw7); |
101 | ICOM_VFIELD_MULTI(IDirectDraw4); | |
39888679 | 102 | ICOM_VFIELD_MULTI(IDirectDraw3); |
d6c0f9f7 AJ |
103 | ICOM_VFIELD_MULTI(IDirectDraw2); |
104 | ICOM_VFIELD_MULTI(IDirectDraw); | |
4aba282b LU |
105 | ICOM_VFIELD_MULTI(IDirect3D7); |
106 | ICOM_VFIELD_MULTI(IDirect3D3); | |
107 | ICOM_VFIELD_MULTI(IDirect3D2); | |
108 | ICOM_VFIELD_MULTI(IDirect3D); | |
d6c0f9f7 | 109 | |
0a812957 | 110 | /* See comment in IDirectDraw::AddRef */ |
325f666f | 111 | LONG ref7, ref4, ref2, ref3, ref1, numIfaces; |
d6c0f9f7 | 112 | |
c8901d6f SD |
113 | /* WineD3D linkage */ |
114 | IWineD3D *wineD3D; | |
115 | IWineD3DDevice *wineD3DDevice; | |
116 | IDirectDrawSurfaceImpl *DepthStencilBuffer; | |
117 | BOOL d3d_initialized; | |
bfae5c83 | 118 | |
9bfbfcbe | 119 | /* Misc ddraw fields */ |
c8901d6f SD |
120 | UINT total_vidmem; |
121 | DWORD cur_scanline; | |
122 | BOOL fake_vblank; | |
123 | BOOL initialized; | |
10ad97c8 | 124 | |
c8901d6f SD |
125 | /* DirectDraw things, which are not handled by WineD3D */ |
126 | DWORD cooperative_level; | |
01b94360 | 127 | |
c8901d6f SD |
128 | DWORD orig_width, orig_height; |
129 | DWORD orig_bpp; | |
d6c0f9f7 | 130 | |
c8901d6f SD |
131 | /* D3D things */ |
132 | IDirectDrawSurfaceImpl *d3d_target; | |
133 | HWND d3d_window; | |
134 | IDirect3DDeviceImpl *d3ddevice; | |
546a60ff | 135 | int d3dversion; |
10ad97c8 | 136 | |
9bfbfcbe | 137 | /* Various HWNDs */ |
c8901d6f SD |
138 | HWND focuswindow; |
139 | HWND devicewindow; | |
34b37fe2 | 140 | HWND dest_window; |
10ad97c8 | 141 | |
c8901d6f | 142 | /* The surface type to request */ |
546a60ff | 143 | WINED3DSURFTYPE ImplType; |
d6c0f9f7 | 144 | |
c8901d6f SD |
145 | |
146 | /* Our private window class */ | |
147 | char classname[32]; | |
148 | WNDCLASSA wnd_class; | |
149 | ||
150 | /* Helpers for surface creation */ | |
151 | IDirectDrawSurfaceImpl *tex_root; | |
152 | BOOL depthstencil; | |
153 | ||
154 | /* For the dll unload cleanup code */ | |
09e794af | 155 | struct list ddraw_list_entry; |
2e5628df SD |
156 | /* The surface list - can't relay this to WineD3D |
157 | * because of IParent | |
158 | */ | |
159 | struct list surface_list; | |
c8901d6f | 160 | LONG surfaces; |
0386eed9 SD |
161 | |
162 | /* FVF management */ | |
163 | struct FvfToDecl *decls; | |
164 | UINT numConvertedDecls, declArraySize; | |
9e2f4af9 FG |
165 | }; |
166 | ||
c8901d6f SD |
167 | /* Declare the VTables. They can be found ddraw.c */ |
168 | const IDirectDraw7Vtbl IDirectDraw7_Vtbl; | |
169 | const IDirectDraw4Vtbl IDirectDraw4_Vtbl; | |
39888679 | 170 | const IDirectDraw3Vtbl IDirectDraw3_Vtbl; |
c8901d6f SD |
171 | const IDirectDraw2Vtbl IDirectDraw2_Vtbl; |
172 | const IDirectDrawVtbl IDirectDraw1_Vtbl; | |
173 | ||
174 | /* Helper structures */ | |
175 | typedef struct EnumDisplayModesCBS | |
176 | { | |
177 | void *context; | |
178 | LPDDENUMMODESCALLBACK2 callback; | |
179 | } EnumDisplayModesCBS; | |
180 | ||
181 | typedef struct EnumSurfacesCBS | |
182 | { | |
183 | void *context; | |
184 | LPDDENUMSURFACESCALLBACK7 callback; | |
185 | LPDDSURFACEDESC2 pDDSD; | |
186 | DWORD Flags; | |
187 | } EnumSurfacesCBS; | |
188 | ||
189 | /* Utility functions */ | |
190 | void | |
191 | DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn, | |
192 | DDSCAPS2* pOut); | |
193 | void | |
194 | DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn, | |
195 | DDDEVICEIDENTIFIER* pOut); | |
196 | void | |
197 | IDirectDrawImpl_Destroy(IDirectDrawImpl *This); | |
198 | ||
199 | HRESULT WINAPI | |
200 | IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf, | |
201 | DDSURFACEDESC2 *desc, | |
202 | void *Context); | |
0386eed9 SD |
203 | IWineD3DVertexDeclaration * |
204 | IDirectDrawImpl_FindDecl(IDirectDrawImpl *This, | |
205 | DWORD fvf); | |
206 | ||
c8901d6f SD |
207 | /* The default surface type */ |
208 | extern WINED3DSURFTYPE DefaultSurfaceType; | |
209 | ||
9e2f4af9 FG |
210 | /***************************************************************************** |
211 | * IDirectDrawSurface implementation structure | |
c8901d6f | 212 | *****************************************************************************/ |
d6c0f9f7 AJ |
213 | |
214 | struct IDirectDrawSurfaceImpl | |
9e2f4af9 | 215 | { |
d6c0f9f7 AJ |
216 | /* IUnknown fields */ |
217 | ICOM_VFIELD_MULTI(IDirectDrawSurface7); | |
218 | ICOM_VFIELD_MULTI(IDirectDrawSurface3); | |
01b94360 | 219 | ICOM_VFIELD_MULTI(IDirectDrawGammaControl); |
91c6f817 LU |
220 | ICOM_VFIELD_MULTI(IDirect3DTexture2); |
221 | ICOM_VFIELD_MULTI(IDirect3DTexture); | |
f48db828 | 222 | |
c8901d6f | 223 | LONG ref; |
0a812957 | 224 | IUnknown *ifaceToRelease; |
9e2f4af9 | 225 | |
c8901d6f | 226 | int version; |
81c75441 | 227 | |
c8901d6f SD |
228 | /* Connections to other Objects */ |
229 | IDirectDrawImpl *ddraw; | |
230 | IWineD3DSurface *WineD3DSurface; | |
7ca369d9 | 231 | IWineD3DBaseTexture *wineD3DTexture; |
e178ddd9 | 232 | IWineD3DSwapChain *wineD3DSwapChain; |
9e2f4af9 | 233 | |
c8901d6f SD |
234 | /* This implementation handles attaching surfaces to other surfaces */ |
235 | IDirectDrawSurfaceImpl *next_attached; | |
236 | IDirectDrawSurfaceImpl *first_attached; | |
9e3e799c SD |
237 | |
238 | /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases. | |
239 | * In mipmap and primary surfaces each level has only one attachment, which is the next surface level. | |
240 | * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached | |
241 | * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill. | |
242 | */ | |
243 | #define MAX_COMPLEX_ATTACHED 6 | |
244 | IDirectDrawSurfaceImpl *complex_array[MAX_COMPLEX_ATTACHED]; | |
245 | /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there, | |
246 | * but no pointer to prevent temptations to traverse it in the wrong direction. | |
247 | */ | |
248 | BOOL is_complex_root; | |
6db05029 | 249 | |
c8901d6f SD |
250 | /* Surface description, for GetAttachedSurface */ |
251 | DDSURFACEDESC2 surface_desc; | |
9e2f4af9 | 252 | |
c8901d6f SD |
253 | /* Misc things */ |
254 | DWORD uniqueness_value; | |
255 | UINT mipmap_level; | |
256 | WINED3DSURFTYPE ImplType; | |
d6c0f9f7 | 257 | |
c8901d6f SD |
258 | /* For D3DDevice creation */ |
259 | BOOL isRenderTarget; | |
d6c0f9f7 | 260 | |
c8901d6f SD |
261 | /* Clipper objects */ |
262 | IDirectDrawClipperImpl *clipper; | |
d6c0f9f7 | 263 | |
c8901d6f | 264 | /* For the ddraw surface list */ |
2e5628df | 265 | struct list surface_list_entry; |
1e2413f4 SD |
266 | |
267 | DWORD Handle; | |
c8901d6f | 268 | }; |
10ad97c8 | 269 | |
c8901d6f SD |
270 | /* VTable declaration. It's located in surface.c / surface_thunks.c */ |
271 | const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl; | |
272 | const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl; | |
273 | const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl; | |
274 | const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl; | |
275 | const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl; | |
d6c0f9f7 | 276 | |
bed50115 | 277 | HRESULT WINAPI IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *Surf); |
c5055fb3 | 278 | void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This); |
bed50115 | 279 | |
c8901d6f SD |
280 | /* Get the number of bytes per pixel for a given surface */ |
281 | #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8)) | |
282 | #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat) | |
10ad97c8 | 283 | |
c8901d6f SD |
284 | /***************************************************************************** |
285 | * IParent Implementation | |
286 | *****************************************************************************/ | |
287 | struct IParentImpl | |
288 | { | |
289 | /* IUnknown fields */ | |
290 | ICOM_VFIELD_MULTI(IParent); | |
291 | LONG ref; | |
10ad97c8 | 292 | |
c8901d6f SD |
293 | /* IParentImpl fields */ |
294 | IUnknown *child; | |
f48db828 | 295 | |
c8901d6f | 296 | }; |
9e2f4af9 | 297 | |
c8901d6f | 298 | const IParentVtbl IParent_Vtbl; |
9e2f4af9 | 299 | |
c8901d6f SD |
300 | /***************************************************************************** |
301 | * IDirect3DDevice implementation | |
302 | *****************************************************************************/ | |
1e2413f4 SD |
303 | typedef enum |
304 | { | |
305 | DDrawHandle_Unknown = 0, | |
306 | DDrawHandle_Texture = 1, | |
d50ff220 | 307 | DDrawHandle_Material = 2, |
1c86290b SD |
308 | DDrawHandle_Matrix = 3, |
309 | DDrawHandle_StateBlock = 4 | |
1e2413f4 SD |
310 | } DDrawHandleTypes; |
311 | ||
312 | struct HandleEntry | |
313 | { | |
314 | void *ptr; | |
315 | DDrawHandleTypes type; | |
316 | }; | |
317 | ||
c8901d6f SD |
318 | struct IDirect3DDeviceImpl |
319 | { | |
320 | /* IUnknown */ | |
321 | ICOM_VFIELD_MULTI(IDirect3DDevice7); | |
322 | ICOM_VFIELD_MULTI(IDirect3DDevice3); | |
323 | ICOM_VFIELD_MULTI(IDirect3DDevice2); | |
324 | ICOM_VFIELD_MULTI(IDirect3DDevice); | |
325 | LONG ref; | |
326 | ||
327 | /* Other object connections */ | |
328 | IWineD3DDevice *wineD3DDevice; | |
329 | IDirectDrawImpl *ddraw; | |
330 | IWineD3DIndexBuffer *indexbuffer; | |
331 | IDirectDrawSurfaceImpl *target; | |
332 | BOOL OffScreenTarget; | |
333 | ||
334 | /* Viewport management */ | |
335 | IDirect3DViewportImpl *viewport_list; | |
336 | IDirect3DViewportImpl *current_viewport; | |
337 | D3DVIEWPORT7 active_viewport; | |
338 | ||
8f72961e AD |
339 | /* Required to keep track which of two available texture blending modes in d3ddevice3 is used */ |
340 | BOOL legacyTextureBlending; | |
341 | ||
c8901d6f SD |
342 | /* Light state */ |
343 | DWORD material; | |
344 | ||
345 | /* Rendering functions to wrap D3D(1-3) to D3D7 */ | |
346 | D3DPRIMITIVETYPE primitive_type; | |
347 | DWORD vertex_type; | |
348 | DWORD render_flags; | |
349 | DWORD nb_vertices; | |
350 | LPBYTE vertex_buffer; | |
351 | DWORD vertex_size; | |
352 | DWORD buffer_size; | |
1e2413f4 SD |
353 | |
354 | /* Handle management */ | |
355 | struct HandleEntry *Handles; | |
356 | DWORD numHandles; | |
f7597dee | 357 | D3DMATRIXHANDLE world, proj, view; |
c8901d6f | 358 | }; |
9713f651 | 359 | |
c8901d6f | 360 | /* Vtables in various versions */ |
cb5e06c9 AD |
361 | const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUSetup_Vtbl; |
362 | const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUPreserve_Vtbl; | |
c8901d6f SD |
363 | const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl; |
364 | const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl; | |
365 | const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl; | |
9713f651 | 366 | |
c8901d6f SD |
367 | /* The IID */ |
368 | const GUID IID_D3DDEVICE_WineD3D; | |
10ad97c8 | 369 | |
c8901d6f SD |
370 | /* Helper functions */ |
371 | HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7); | |
1e2413f4 | 372 | DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This); |
ffae39c3 | 373 | WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This); |
5f49e78e | 374 | |
c8901d6f SD |
375 | /* Structures */ |
376 | struct EnumTextureFormatsCBS | |
5f49e78e | 377 | { |
c8901d6f SD |
378 | LPD3DENUMTEXTUREFORMATSCALLBACK cbv2; |
379 | LPD3DENUMPIXELFORMATSCALLBACK cbv7; | |
380 | void *Context; | |
381 | }; | |
5f49e78e | 382 | |
c8901d6f SD |
383 | /***************************************************************************** |
384 | * IDirect3D implementation | |
385 | *****************************************************************************/ | |
5f49e78e | 386 | |
c8901d6f SD |
387 | /* No implementation structure as this is only another interface to DirectDraw */ |
388 | ||
389 | /* the Vtables */ | |
390 | const IDirect3DVtbl IDirect3D1_Vtbl; | |
391 | const IDirect3D2Vtbl IDirect3D2_Vtbl; | |
392 | const IDirect3D3Vtbl IDirect3D3_Vtbl; | |
393 | const IDirect3D7Vtbl IDirect3D7_Vtbl; | |
394 | ||
395 | /* Structure for EnumZBufferFormats */ | |
396 | struct EnumZBufferFormatsData | |
5f49e78e | 397 | { |
c8901d6f SD |
398 | LPD3DENUMPIXELFORMATSCALLBACK Callback; |
399 | void *Context; | |
400 | }; | |
5f49e78e | 401 | |
c8901d6f SD |
402 | /***************************************************************************** |
403 | * IDirectDrawClipper implementation structure | |
404 | *****************************************************************************/ | |
405 | struct IDirectDrawClipperImpl | |
406 | { | |
407 | /* IUnknown fields */ | |
408 | ICOM_VFIELD_MULTI(IDirectDrawClipper); | |
409 | LONG ref; | |
5f49e78e | 410 | |
d93e161b SD |
411 | IWineD3DClipper *wineD3DClipper; |
412 | IDirectDrawImpl *ddraw_owner; | |
c8901d6f | 413 | }; |
719187f1 | 414 | |
c8901d6f | 415 | const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl; |
719187f1 | 416 | |
99a50b53 | 417 | typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper; |
d93e161b | 418 | |
719187f1 | 419 | /***************************************************************************** |
c8901d6f SD |
420 | * IDirectDrawPalette implementation structure |
421 | *****************************************************************************/ | |
422 | struct IDirectDrawPaletteImpl | |
423 | { | |
424 | /* IUnknown fields */ | |
425 | ICOM_VFIELD_MULTI(IDirectDrawPalette); | |
426 | LONG ref; | |
719187f1 | 427 | |
c8901d6f SD |
428 | /* WineD3D uplink */ |
429 | IWineD3DPalette *wineD3DPalette; | |
719187f1 | 430 | |
c8901d6f SD |
431 | /* IDirectDrawPalette fields */ |
432 | IDirectDrawImpl *ddraw_owner; | |
915174d8 | 433 | IUnknown *ifaceToRelease; |
c8901d6f SD |
434 | }; |
435 | const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl; | |
719187f1 | 436 | |
c8901d6f | 437 | /****************************************************************************** |
9bfbfcbe | 438 | * DirectDraw ClassFactory implementation - incomplete |
c8901d6f SD |
439 | ******************************************************************************/ |
440 | typedef struct | |
441 | { | |
442 | ICOM_VFIELD_MULTI(IClassFactory); | |
719187f1 | 443 | |
c8901d6f SD |
444 | LONG ref; |
445 | HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj); | |
446 | } IClassFactoryImpl; | |
719187f1 | 447 | |
c8901d6f SD |
448 | /* Helper structures */ |
449 | struct object_creation_info | |
450 | { | |
451 | const CLSID *clsid; | |
452 | HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid, | |
453 | void **ppObj); | |
454 | }; | |
719187f1 | 455 | |
c8901d6f SD |
456 | /****************************************************************************** |
457 | * IDirect3DLight implementation structure - Wraps to D3D7 | |
458 | ******************************************************************************/ | |
459 | struct IDirect3DLightImpl | |
460 | { | |
461 | ICOM_VFIELD_MULTI(IDirect3DLight); | |
462 | LONG ref; | |
719187f1 | 463 | |
c8901d6f SD |
464 | /* IDirect3DLight fields */ |
465 | IDirectDrawImpl *ddraw; | |
719187f1 | 466 | |
c8901d6f SD |
467 | /* If this light is active for one viewport, put the viewport here */ |
468 | IDirect3DViewportImpl *active_viewport; | |
719187f1 | 469 | |
c8901d6f SD |
470 | D3DLIGHT2 light; |
471 | D3DLIGHT7 light7; | |
719187f1 | 472 | |
c8901d6f | 473 | DWORD dwLightIndex; |
719187f1 | 474 | |
c8901d6f SD |
475 | /* Chained list used for adding / removing from viewports */ |
476 | IDirect3DLightImpl *next; | |
719187f1 | 477 | |
c8901d6f SD |
478 | /* Activation function */ |
479 | void (*activate)(IDirect3DLightImpl*); | |
480 | void (*desactivate)(IDirect3DLightImpl*); | |
481 | void (*update)(IDirect3DLightImpl*); | |
482 | }; | |
719187f1 | 483 | |
c8901d6f SD |
484 | /* Vtable */ |
485 | const IDirect3DLightVtbl IDirect3DLight_Vtbl; | |
719187f1 | 486 | |
c8901d6f SD |
487 | /* Helper functions */ |
488 | void light_update(IDirect3DLightImpl* This); | |
489 | void light_activate(IDirect3DLightImpl* This); | |
490 | void light_desactivate(IDirect3DLightImpl* This); | |
719187f1 | 491 | |
c8901d6f SD |
492 | /****************************************************************************** |
493 | * IDirect3DMaterial implementation structure - Wraps to D3D7 | |
494 | ******************************************************************************/ | |
495 | struct IDirect3DMaterialImpl | |
719187f1 | 496 | { |
c8901d6f SD |
497 | ICOM_VFIELD_MULTI(IDirect3DMaterial3); |
498 | ICOM_VFIELD_MULTI(IDirect3DMaterial2); | |
499 | ICOM_VFIELD_MULTI(IDirect3DMaterial); | |
500 | LONG ref; | |
719187f1 | 501 | |
c8901d6f SD |
502 | /* IDirect3DMaterial2 fields */ |
503 | IDirectDrawImpl *ddraw; | |
504 | IDirect3DDeviceImpl *active_device; | |
719187f1 | 505 | |
c8901d6f | 506 | D3DMATERIAL mat; |
1e2413f4 | 507 | DWORD Handle; |
c8901d6f SD |
508 | |
509 | void (*activate)(IDirect3DMaterialImpl* this); | |
510 | }; | |
511 | ||
9bfbfcbe | 512 | /* VTables in various versions */ |
c8901d6f SD |
513 | const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl; |
514 | const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl; | |
515 | const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl; | |
516 | ||
517 | /* Helper functions */ | |
518 | void material_activate(IDirect3DMaterialImpl* This); | |
719187f1 CC |
519 | |
520 | /***************************************************************************** | |
c8901d6f SD |
521 | * IDirect3DViewport - Wraps to D3D7 |
522 | *****************************************************************************/ | |
523 | struct IDirect3DViewportImpl | |
719187f1 | 524 | { |
c8901d6f SD |
525 | ICOM_VFIELD_MULTI(IDirect3DViewport3); |
526 | LONG ref; | |
527 | ||
528 | /* IDirect3DViewport fields */ | |
529 | IDirectDrawImpl *ddraw; | |
530 | ||
531 | /* If this viewport is active for one device, put the device here */ | |
532 | IDirect3DDeviceImpl *active_device; | |
719187f1 | 533 | |
c8901d6f SD |
534 | DWORD num_lights; |
535 | DWORD map_lights; | |
536 | ||
537 | int use_vp2; | |
719187f1 CC |
538 | |
539 | union | |
540 | { | |
c8901d6f SD |
541 | D3DVIEWPORT vp1; |
542 | D3DVIEWPORT2 vp2; | |
543 | } viewports; | |
719187f1 | 544 | |
c8901d6f | 545 | /* Activation function */ |
6a48e405 | 546 | void (*activate)(IDirect3DViewportImpl*, BOOL); |
719187f1 | 547 | |
c8901d6f SD |
548 | /* Field used to chain viewports together */ |
549 | IDirect3DViewportImpl *next; | |
719187f1 | 550 | |
c8901d6f SD |
551 | /* Lights list */ |
552 | IDirect3DLightImpl *lights; | |
553 | ||
554 | /* Background material */ | |
555 | IDirect3DMaterialImpl *background; | |
719187f1 CC |
556 | }; |
557 | ||
c8901d6f SD |
558 | /* Vtable */ |
559 | const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl; | |
719187f1 | 560 | |
c8901d6f | 561 | /* Helper functions */ |
6a48e405 | 562 | void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights); |
719187f1 CC |
563 | |
564 | /***************************************************************************** | |
c8901d6f SD |
565 | * IDirect3DExecuteBuffer - Wraps to D3D7 |
566 | *****************************************************************************/ | |
567 | struct IDirect3DExecuteBufferImpl | |
719187f1 | 568 | { |
c8901d6f SD |
569 | /* IUnknown */ |
570 | ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer); | |
571 | LONG ref; | |
572 | ||
573 | /* IDirect3DExecuteBuffer fields */ | |
574 | IDirectDrawImpl *ddraw; | |
575 | IDirect3DDeviceImpl *d3ddev; | |
576 | ||
577 | D3DEXECUTEBUFFERDESC desc; | |
578 | D3DEXECUTEDATA data; | |
579 | ||
580 | /* This buffer will store the transformed vertices */ | |
581 | void *vertex_data; | |
582 | WORD *indices; | |
583 | int nb_indices; | |
584 | ||
585 | /* This flags is set to TRUE if we allocated ourselves the | |
586 | * data buffer | |
587 | */ | |
588 | BOOL need_free; | |
719187f1 CC |
589 | }; |
590 | ||
c8901d6f SD |
591 | /* The VTable */ |
592 | const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl; | |
593 | ||
594 | /* The execute function */ | |
595 | void | |
596 | IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This, | |
597 | IDirect3DDeviceImpl *Device, | |
598 | IDirect3DViewportImpl *ViewportImpl); | |
719187f1 CC |
599 | |
600 | /***************************************************************************** | |
c8901d6f SD |
601 | * IDirect3DVertexBuffer |
602 | *****************************************************************************/ | |
603 | struct IDirect3DVertexBufferImpl | |
604 | { | |
605 | /*** IUnknown Methods ***/ | |
606 | ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7); | |
607 | ICOM_VFIELD_MULTI(IDirect3DVertexBuffer); | |
608 | LONG ref; | |
719187f1 | 609 | |
3581d8e8 | 610 | /*** WineD3D and ddraw links ***/ |
c8901d6f | 611 | IWineD3DVertexBuffer *wineD3DVertexBuffer; |
0386eed9 | 612 | IWineD3DVertexDeclaration *wineD3DVertexDeclaration; |
3581d8e8 | 613 | IDirectDrawImpl *ddraw; |
719187f1 | 614 | |
c8901d6f SD |
615 | /*** Storage for D3D7 specific things ***/ |
616 | DWORD Caps; | |
719187f1 CC |
617 | }; |
618 | ||
c8901d6f SD |
619 | /* The Vtables */ |
620 | const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl; | |
621 | const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl; | |
719187f1 CC |
622 | |
623 | /***************************************************************************** | |
c8901d6f SD |
624 | * Helper functions from utils.c |
625 | *****************************************************************************/ | |
626 | ||
627 | #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \ | |
628 | (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT) | |
629 | ||
630 | #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \ | |
631 | (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1) | |
632 | ||
633 | void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat); | |
e4253fd8 | 634 | WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat); |
c8901d6f | 635 | void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd); |
e4253fd8 | 636 | void dump_D3DMATRIX(const D3DMATRIX *mat); |
c8901d6f SD |
637 | void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps); |
638 | DWORD get_flexible_vertex_size(DWORD d3dvtVertexType); | |
639 | void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in); | |
640 | void DDRAW_dump_cooperativelevel(DWORD cooplevel); | |
641 | ||
642 | /* This only needs to be here as long the processvertices functionality of | |
643 | * IDirect3DExecuteBuffer isn't in WineD3D */ | |
e4253fd8 | 644 | void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2); |
c8901d6f | 645 | |
606186d4 MK |
646 | /* Helper function in main.c */ |
647 | BOOL LoadWineD3D(void); | |
648 | ||
c8901d6f | 649 | /* Used for generic dumping */ |
719187f1 CC |
650 | typedef struct |
651 | { | |
c8901d6f SD |
652 | DWORD val; |
653 | const char* name; | |
654 | } flag_info; | |
719187f1 | 655 | |
c8901d6f | 656 | #define FE(x) { x, #x } |
719187f1 | 657 | |
c8901d6f SD |
658 | typedef struct |
659 | { | |
660 | DWORD val; | |
661 | const char* name; | |
662 | void (*func)(const void *); | |
663 | ptrdiff_t offset; | |
664 | } member_info; | |
719187f1 | 665 | |
c8901d6f | 666 | /* Structure copy */ |
c8901d6f | 667 | #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) } |
719187f1 | 668 | |
c8901d6f SD |
669 | #define DD_STRUCT_COPY_BYSIZE(to,from) \ |
670 | do { \ | |
671 | DWORD __size = (to)->dwSize; \ | |
672 | DWORD __copysize = __size; \ | |
673 | DWORD __resetsize = __size; \ | |
674 | assert(to != from); \ | |
675 | if (__resetsize > sizeof(*to)) \ | |
676 | __resetsize = sizeof(*to); \ | |
677 | memset(to,0,__resetsize); \ | |
678 | if ((from)->dwSize < __size) \ | |
679 | __copysize = (from)->dwSize; \ | |
680 | memcpy(to,from,__copysize); \ | |
681 | (to)->dwSize = __size;/*restore size*/ \ | |
682 | } while (0) | |
683 | ||
684 | ||
685 | #endif | |
686 | ||
687 | HRESULT hr_ddraw_from_wined3d(HRESULT hr); |