2 * Copyright 2006 Stefan Dösinger
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
22 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
36 #include "wine/list.h"
37 #ifdef DDRAW_INIT_GUID
40 #include "wine/wined3d.h"
42 extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HIDDEN;
44 /*****************************************************************************
45 * IParent - a helper interface
46 *****************************************************************************/
47 DEFINE_GUID(IID_IParent, 0xc20e4c88, 0x74e7, 0x4940, 0xba, 0x9f, 0x2e, 0x32, 0x3f, 0x9d, 0xc9, 0x81);
48 typedef struct IParent *LPPARENT, *PPARENT;
50 #define INTERFACE IParent
51 DECLARE_INTERFACE_(IParent,IUnknown)
53 /*** IUnknown methods ***/
54 STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
55 STDMETHOD_(ULONG,AddRef)(THIS) PURE;
56 STDMETHOD_(ULONG,Release)(THIS) PURE;
60 #if !defined(__cplusplus) || defined(CINTERFACE)
61 /*** IUnknown methods ***/
62 #define IParent_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
63 #define IParent_AddRef(p) (p)->lpVtbl->AddRef(p)
64 #define IParent_Release(p) (p)->lpVtbl->Release(p)
68 /* Typdef the interfaces */
69 typedef struct IDirectDrawImpl IDirectDrawImpl;
70 typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
71 typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
72 typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
73 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
74 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
75 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
76 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
77 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
78 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
79 typedef struct IParentImpl IParentImpl;
81 /* Callbacks for implicit object destruction */
82 extern ULONG WINAPI D3D7CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) DECLSPEC_HIDDEN;
84 /* Global critical section */
85 extern CRITICAL_SECTION ddraw_cs DECLSPEC_HIDDEN;
87 extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
89 /*****************************************************************************
90 * IDirectDraw implementation structure
91 *****************************************************************************/
95 IWineD3DVertexDeclaration *decl;
98 struct IDirectDrawImpl
100 /* IUnknown fields */
101 const IDirectDraw7Vtbl *lpVtbl;
102 const IDirectDraw4Vtbl *IDirectDraw4_vtbl;
103 const IDirectDraw3Vtbl *IDirectDraw3_vtbl;
104 const IDirectDraw2Vtbl *IDirectDraw2_vtbl;
105 const IDirectDrawVtbl *IDirectDraw_vtbl;
106 const IDirect3D7Vtbl *IDirect3D7_vtbl;
107 const IDirect3D3Vtbl *IDirect3D3_vtbl;
108 const IDirect3D2Vtbl *IDirect3D2_vtbl;
109 const IDirect3DVtbl *IDirect3D_vtbl;
110 const IWineD3DDeviceParentVtbl *device_parent_vtbl;
112 /* See comment in IDirectDraw::AddRef */
113 LONG ref7, ref4, ref2, ref3, ref1, numIfaces;
115 /* WineD3D linkage */
117 IWineD3DDevice *wineD3DDevice;
118 BOOL d3d_initialized;
120 /* Misc ddraw fields */
126 /* DirectDraw things, which are not handled by WineD3D */
127 DWORD cooperative_level;
129 DWORD orig_width, orig_height;
133 IDirectDrawSurfaceImpl *d3d_target;
135 IDirect3DDeviceImpl *d3ddevice;
143 /* The surface type to request */
144 WINED3DSURFTYPE ImplType;
146 /* Helpers for surface creation */
147 IDirectDrawSurfaceImpl *tex_root;
150 /* For the dll unload cleanup code */
151 struct list ddraw_list_entry;
152 /* The surface list - can't relay this to WineD3D
155 struct list surface_list;
159 struct FvfToDecl *decls;
160 UINT numConvertedDecls, declArraySize;
163 #define DDRAW_WINDOW_CLASS_NAME "ddraw_wc"
165 /* Declare the VTables. They can be found ddraw.c */
166 extern const IDirectDraw7Vtbl IDirectDraw7_Vtbl DECLSPEC_HIDDEN;
167 extern const IDirectDraw4Vtbl IDirectDraw4_Vtbl DECLSPEC_HIDDEN;
168 extern const IDirectDraw3Vtbl IDirectDraw3_Vtbl DECLSPEC_HIDDEN;
169 extern const IDirectDraw2Vtbl IDirectDraw2_Vtbl DECLSPEC_HIDDEN;
170 extern const IDirectDrawVtbl IDirectDraw1_Vtbl DECLSPEC_HIDDEN;
171 extern const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl DECLSPEC_HIDDEN;
173 /* Helper structures */
174 typedef struct EnumDisplayModesCBS
177 LPDDENUMMODESCALLBACK2 callback;
178 } EnumDisplayModesCBS;
180 typedef struct EnumSurfacesCBS
183 LPDDENUMSURFACESCALLBACK7 callback;
184 LPDDSURFACEDESC2 pDDSD;
188 /* Utility functions */
189 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_HIDDEN;
190 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
191 HRESULT WINAPI ddraw_recreate_surfaces_cb(IDirectDrawSurface7 *surf,
192 DDSURFACEDESC2 *desc, void *Context) DECLSPEC_HIDDEN;
193 IWineD3DVertexDeclaration *ddraw_find_decl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
195 static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface)
197 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D_vtbl));
200 static inline IDirectDrawImpl *ddraw_from_d3d2(IDirect3D2 *iface)
202 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D2_vtbl));
205 static inline IDirectDrawImpl *ddraw_from_d3d3(IDirect3D3 *iface)
207 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D3_vtbl));
210 static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
212 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D7_vtbl));
215 /* The default surface type */
216 extern WINED3DSURFTYPE DefaultSurfaceType DECLSPEC_HIDDEN;
218 /*****************************************************************************
219 * IDirectDrawSurface implementation structure
220 *****************************************************************************/
222 struct IDirectDrawSurfaceImpl
224 /* IUnknown fields */
225 const IDirectDrawSurface7Vtbl *lpVtbl;
226 const IDirectDrawSurface3Vtbl *IDirectDrawSurface3_vtbl;
227 const IDirectDrawGammaControlVtbl *IDirectDrawGammaControl_vtbl;
228 const IDirect3DTexture2Vtbl *IDirect3DTexture2_vtbl;
229 const IDirect3DTextureVtbl *IDirect3DTexture_vtbl;
232 IUnknown *ifaceToRelease;
236 /* Connections to other Objects */
237 IDirectDrawImpl *ddraw;
238 IWineD3DSurface *WineD3DSurface;
239 IWineD3DBaseTexture *wineD3DTexture;
240 IWineD3DSwapChain *wineD3DSwapChain;
242 /* This implementation handles attaching surfaces to other surfaces */
243 IDirectDrawSurfaceImpl *next_attached;
244 IDirectDrawSurfaceImpl *first_attached;
246 /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
247 * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
248 * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
249 * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
251 #define MAX_COMPLEX_ATTACHED 6
252 IDirectDrawSurfaceImpl *complex_array[MAX_COMPLEX_ATTACHED];
253 /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
254 * but no pointer to prevent temptations to traverse it in the wrong direction.
256 BOOL is_complex_root;
258 /* Surface description, for GetAttachedSurface */
259 DDSURFACEDESC2 surface_desc;
262 DWORD uniqueness_value;
264 WINED3DSURFTYPE ImplType;
266 /* For D3DDevice creation */
269 /* Clipper objects */
270 IDirectDrawClipperImpl *clipper;
272 /* For the ddraw surface list */
273 struct list surface_list_entry;
278 /* VTable declaration. It's located in surface.c / surface_thunks.c */
279 extern const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl DECLSPEC_HIDDEN;
280 extern const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl DECLSPEC_HIDDEN;
281 extern const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl DECLSPEC_HIDDEN;
282 extern const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl DECLSPEC_HIDDEN;
283 extern const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl DECLSPEC_HIDDEN;
285 void ddraw_surface_destroy(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN;
287 static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface)
289 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture_vtbl));
292 static inline IDirectDrawSurfaceImpl *surface_from_texture2(IDirect3DTexture2 *iface)
294 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl));
297 static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3 *iface)
299 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirectDrawSurface3_vtbl));
302 /* Get the number of bytes per pixel for a given surface */
303 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
304 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
306 /*****************************************************************************
307 * IParent Implementation
308 *****************************************************************************/
311 /* IUnknown fields */
312 const IParentVtbl *lpVtbl;
315 /* IParentImpl fields */
320 extern const IParentVtbl IParent_Vtbl DECLSPEC_HIDDEN;
322 /*****************************************************************************
323 * IDirect3DDevice implementation
324 *****************************************************************************/
326 #define DDRAW_INVALID_HANDLE ~0U
328 enum ddraw_handle_type
331 DDRAW_HANDLE_MATERIAL,
333 DDRAW_HANDLE_STATEBLOCK,
334 DDRAW_HANDLE_SURFACE,
337 struct ddraw_handle_entry
340 enum ddraw_handle_type type;
343 struct ddraw_handle_table
345 struct ddraw_handle_entry *entries;
346 struct ddraw_handle_entry *free_entries;
351 BOOL ddraw_handle_table_init(struct ddraw_handle_table *t, UINT initial_size) DECLSPEC_HIDDEN;
352 void ddraw_handle_table_destroy(struct ddraw_handle_table *t) DECLSPEC_HIDDEN;
353 DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
354 void *ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
355 void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
357 struct IDirect3DDeviceImpl
360 const IDirect3DDevice7Vtbl *lpVtbl;
361 const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl;
362 const IDirect3DDevice2Vtbl *IDirect3DDevice2_vtbl;
363 const IDirect3DDeviceVtbl *IDirect3DDevice_vtbl;
366 /* Other object connections */
367 IWineD3DDevice *wineD3DDevice;
368 IDirectDrawImpl *ddraw;
369 IWineD3DBuffer *indexbuffer;
370 IDirectDrawSurfaceImpl *target;
371 BOOL OffScreenTarget;
373 /* Viewport management */
374 IDirect3DViewportImpl *viewport_list;
375 IDirect3DViewportImpl *current_viewport;
376 D3DVIEWPORT7 active_viewport;
378 /* Required to keep track which of two available texture blending modes in d3ddevice3 is used */
379 BOOL legacyTextureBlending;
384 /* Rendering functions to wrap D3D(1-3) to D3D7 */
385 D3DPRIMITIVETYPE primitive_type;
389 LPBYTE vertex_buffer;
393 /* Handle management */
394 struct ddraw_handle_table handle_table;
395 D3DMATRIXHANDLE world, proj, view;
398 /* Vtables in various versions */
399 extern const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUSetup_Vtbl DECLSPEC_HIDDEN;
400 extern const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUPreserve_Vtbl DECLSPEC_HIDDEN;
401 extern const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl DECLSPEC_HIDDEN;
402 extern const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl DECLSPEC_HIDDEN;
403 extern const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl DECLSPEC_HIDDEN;
406 extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
408 /* Helper functions */
409 HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
410 WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This) DECLSPEC_HIDDEN;
412 static inline IDirect3DDeviceImpl *device_from_device1(IDirect3DDevice *iface)
414 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice_vtbl));
417 static inline IDirect3DDeviceImpl *device_from_device2(IDirect3DDevice2 *iface)
419 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice2_vtbl));
422 static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
424 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice3_vtbl));
428 struct EnumTextureFormatsCBS
430 LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
431 LPD3DENUMPIXELFORMATSCALLBACK cbv7;
435 /*****************************************************************************
436 * IDirect3D implementation
437 *****************************************************************************/
439 /* No implementation structure as this is only another interface to DirectDraw */
442 extern const IDirect3DVtbl IDirect3D1_Vtbl DECLSPEC_HIDDEN;
443 extern const IDirect3D2Vtbl IDirect3D2_Vtbl DECLSPEC_HIDDEN;
444 extern const IDirect3D3Vtbl IDirect3D3_Vtbl DECLSPEC_HIDDEN;
445 extern const IDirect3D7Vtbl IDirect3D7_Vtbl DECLSPEC_HIDDEN;
447 /* Structure for EnumZBufferFormats */
448 struct EnumZBufferFormatsData
450 LPD3DENUMPIXELFORMATSCALLBACK Callback;
454 /*****************************************************************************
455 * IDirectDrawClipper implementation structure
456 *****************************************************************************/
457 struct IDirectDrawClipperImpl
459 /* IUnknown fields */
460 const IDirectDrawClipperVtbl *lpVtbl;
463 IWineD3DClipper *wineD3DClipper;
467 extern const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl DECLSPEC_HIDDEN;
469 typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;
471 /*****************************************************************************
472 * IDirectDrawPalette implementation structure
473 *****************************************************************************/
474 struct IDirectDrawPaletteImpl
476 /* IUnknown fields */
477 const IDirectDrawPaletteVtbl *lpVtbl;
481 IWineD3DPalette *wineD3DPalette;
483 /* IDirectDrawPalette fields */
484 IUnknown *ifaceToRelease;
486 extern const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl DECLSPEC_HIDDEN;
488 /******************************************************************************
489 * DirectDraw ClassFactory implementation - incomplete
490 ******************************************************************************/
493 const IClassFactoryVtbl *lpVtbl;
496 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
499 /* Helper structures */
500 struct object_creation_info
503 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
507 /******************************************************************************
508 * IDirect3DLight implementation structure - Wraps to D3D7
509 ******************************************************************************/
510 struct IDirect3DLightImpl
512 const IDirect3DLightVtbl *lpVtbl;
515 /* IDirect3DLight fields */
516 IDirectDrawImpl *ddraw;
518 /* If this light is active for one viewport, put the viewport here */
519 IDirect3DViewportImpl *active_viewport;
526 /* Chained list used for adding / removing from viewports */
527 IDirect3DLightImpl *next;
529 /* Activation function */
530 void (*activate)(IDirect3DLightImpl*);
531 void (*desactivate)(IDirect3DLightImpl*);
532 void (*update)(IDirect3DLightImpl*);
536 extern const IDirect3DLightVtbl IDirect3DLight_Vtbl DECLSPEC_HIDDEN;
538 /* Helper functions */
539 void light_update(IDirect3DLightImpl *This) DECLSPEC_HIDDEN;
540 void light_activate(IDirect3DLightImpl *This) DECLSPEC_HIDDEN;
541 void light_desactivate(IDirect3DLightImpl *This) DECLSPEC_HIDDEN;
543 /******************************************************************************
544 * IDirect3DMaterial implementation structure - Wraps to D3D7
545 ******************************************************************************/
546 struct IDirect3DMaterialImpl
548 const IDirect3DMaterial3Vtbl *lpVtbl;
549 const IDirect3DMaterial2Vtbl *IDirect3DMaterial2_vtbl;
550 const IDirect3DMaterialVtbl *IDirect3DMaterial_vtbl;
553 /* IDirect3DMaterial2 fields */
554 IDirectDrawImpl *ddraw;
555 IDirect3DDeviceImpl *active_device;
560 void (*activate)(IDirect3DMaterialImpl* this);
563 /* VTables in various versions */
564 extern const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl DECLSPEC_HIDDEN;
565 extern const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl DECLSPEC_HIDDEN;
566 extern const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl DECLSPEC_HIDDEN;
568 /* Helper functions */
569 void material_activate(IDirect3DMaterialImpl* This) DECLSPEC_HIDDEN;
571 /*****************************************************************************
572 * IDirect3DViewport - Wraps to D3D7
573 *****************************************************************************/
574 struct IDirect3DViewportImpl
576 const IDirect3DViewport3Vtbl *lpVtbl;
579 /* IDirect3DViewport fields */
580 IDirectDrawImpl *ddraw;
582 /* If this viewport is active for one device, put the device here */
583 IDirect3DDeviceImpl *active_device;
596 /* Activation function */
597 void (*activate)(IDirect3DViewportImpl*, BOOL);
599 /* Field used to chain viewports together */
600 IDirect3DViewportImpl *next;
603 IDirect3DLightImpl *lights;
605 /* Background material */
606 IDirect3DMaterialImpl *background;
610 extern const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl DECLSPEC_HIDDEN;
612 /* Helper functions */
613 void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) DECLSPEC_HIDDEN;
615 /*****************************************************************************
616 * IDirect3DExecuteBuffer - Wraps to D3D7
617 *****************************************************************************/
618 struct IDirect3DExecuteBufferImpl
621 const IDirect3DExecuteBufferVtbl *lpVtbl;
624 /* IDirect3DExecuteBuffer fields */
625 IDirectDrawImpl *ddraw;
626 IDirect3DDeviceImpl *d3ddev;
628 D3DEXECUTEBUFFERDESC desc;
631 /* This buffer will store the transformed vertices */
636 /* This flags is set to TRUE if we allocated ourselves the
643 extern const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl DECLSPEC_HIDDEN;
645 /* The execute function */
646 void IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
647 IDirect3DDeviceImpl *Device, IDirect3DViewportImpl *ViewportImpl) DECLSPEC_HIDDEN;
649 /*****************************************************************************
650 * IDirect3DVertexBuffer
651 *****************************************************************************/
652 struct IDirect3DVertexBufferImpl
654 /*** IUnknown Methods ***/
655 const IDirect3DVertexBuffer7Vtbl *lpVtbl;
656 const IDirect3DVertexBufferVtbl *IDirect3DVertexBuffer_vtbl;
659 /*** WineD3D and ddraw links ***/
660 IWineD3DBuffer *wineD3DVertexBuffer;
661 IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
662 IDirectDrawImpl *ddraw;
664 /*** Storage for D3D7 specific things ***/
670 extern const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl DECLSPEC_HIDDEN;
671 extern const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl DECLSPEC_HIDDEN;
673 static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
675 return (IDirect3DVertexBufferImpl *)((char*)iface
676 - FIELD_OFFSET(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_vtbl));
679 /*****************************************************************************
680 * Helper functions from utils.c
681 *****************************************************************************/
683 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
684 (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
686 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
687 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
689 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat) DECLSPEC_HIDDEN;
690 WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat) DECLSPEC_HIDDEN;
691 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN;
692 void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN;
693 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;
694 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
695 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in) DECLSPEC_HIDDEN;
696 void DDRAW_dump_cooperativelevel(DWORD cooplevel) DECLSPEC_HIDDEN;
698 /* This only needs to be here as long the processvertices functionality of
699 * IDirect3DExecuteBuffer isn't in WineD3D */
700 void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN;
702 void multiply_matrix_D3D_way(LPD3DMATRIX result, const D3DMATRIX *m1, const D3DMATRIX *m2) DECLSPEC_HIDDEN;
704 /* Helper function in main.c */
705 BOOL LoadWineD3D(void) DECLSPEC_HIDDEN;
707 /* Used for generic dumping */
714 #define FE(x) { x, #x }
720 void (*func)(const void *);
725 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
727 #define DD_STRUCT_COPY_BYSIZE(to,from) \
729 DWORD __size = (to)->dwSize; \
730 DWORD __copysize = __size; \
731 DWORD __resetsize = __size; \
732 assert(to != from); \
733 if (__resetsize > sizeof(*to)) \
734 __resetsize = sizeof(*to); \
735 memset(to,0,__resetsize); \
736 if ((from)->dwSize < __size) \
737 __copysize = (from)->dwSize; \
738 memcpy(to,from,__copysize); \
739 (to)->dwSize = __size;/*restore size*/ \
745 HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;