msdaps: Add support for remoting IRowset_GetNextRows.
[wine/multimedia.git] / dlls / ddraw / ddraw_private.h
blobd6f4a57d0a063d03d6f4b2cac25a8e87c4b47f99
1 /*
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! */
24 #include <stdarg.h>
25 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wtypes.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "ddraw.h"
33 #include "ddrawi.h"
34 #include "d3d.h"
36 #include "wine/list.h"
37 #ifdef DDRAW_INIT_GUID
38 #include "initguid.h"
39 #endif
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;
58 #undef INTERFACE
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)
65 #endif
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 *****************************************************************************/
92 struct FvfToDecl
94 DWORD fvf;
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 */
116 IWineD3D *wineD3D;
117 IWineD3DDevice *wineD3DDevice;
118 BOOL d3d_initialized;
120 /* Misc ddraw fields */
121 UINT total_vidmem;
122 DWORD cur_scanline;
123 BOOL fake_vblank;
124 BOOL initialized;
126 /* DirectDraw things, which are not handled by WineD3D */
127 DWORD cooperative_level;
129 DWORD orig_width, orig_height;
130 DWORD orig_bpp;
132 /* D3D things */
133 IDirectDrawSurfaceImpl *d3d_target;
134 HWND d3d_window;
135 IDirect3DDeviceImpl *d3ddevice;
136 int d3dversion;
138 /* Various HWNDs */
139 HWND focuswindow;
140 HWND devicewindow;
141 HWND dest_window;
143 /* The surface type to request */
144 WINED3DSURFTYPE ImplType;
147 /* Our private window class */
148 char classname[32];
149 WNDCLASSA wnd_class;
151 /* Helpers for surface creation */
152 IDirectDrawSurfaceImpl *tex_root;
153 BOOL depthstencil;
155 /* For the dll unload cleanup code */
156 struct list ddraw_list_entry;
157 /* The surface list - can't relay this to WineD3D
158 * because of IParent
160 struct list surface_list;
161 LONG surfaces;
163 /* FVF management */
164 struct FvfToDecl *decls;
165 UINT numConvertedDecls, declArraySize;
168 /* Declare the VTables. They can be found ddraw.c */
169 extern const IDirectDraw7Vtbl IDirectDraw7_Vtbl DECLSPEC_HIDDEN;
170 extern const IDirectDraw4Vtbl IDirectDraw4_Vtbl DECLSPEC_HIDDEN;
171 extern const IDirectDraw3Vtbl IDirectDraw3_Vtbl DECLSPEC_HIDDEN;
172 extern const IDirectDraw2Vtbl IDirectDraw2_Vtbl DECLSPEC_HIDDEN;
173 extern const IDirectDrawVtbl IDirectDraw1_Vtbl DECLSPEC_HIDDEN;
174 extern const IWineD3DDeviceParentVtbl ddraw_wined3d_device_parent_vtbl DECLSPEC_HIDDEN;
176 /* Helper structures */
177 typedef struct EnumDisplayModesCBS
179 void *context;
180 LPDDENUMMODESCALLBACK2 callback;
181 } EnumDisplayModesCBS;
183 typedef struct EnumSurfacesCBS
185 void *context;
186 LPDDENUMSURFACESCALLBACK7 callback;
187 LPDDSURFACEDESC2 pDDSD;
188 DWORD Flags;
189 } EnumSurfacesCBS;
191 /* Utility functions */
192 void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_HIDDEN;
193 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
194 void IDirectDrawImpl_Destroy(IDirectDrawImpl *This) DECLSPEC_HIDDEN;
195 HRESULT WINAPI IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
196 DDSURFACEDESC2 *desc, void *Context) DECLSPEC_HIDDEN;
197 IWineD3DVertexDeclaration *IDirectDrawImpl_FindDecl(IDirectDrawImpl *This, DWORD fvf) DECLSPEC_HIDDEN;
199 static inline IDirectDrawImpl *ddraw_from_d3d1(IDirect3D *iface)
201 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D_vtbl));
204 static inline IDirectDrawImpl *ddraw_from_d3d2(IDirect3D2 *iface)
206 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D2_vtbl));
209 static inline IDirectDrawImpl *ddraw_from_d3d3(IDirect3D3 *iface)
211 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D3_vtbl));
214 static inline IDirectDrawImpl *ddraw_from_d3d7(IDirect3D7 *iface)
216 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirect3D7_vtbl));
219 static inline IDirectDrawImpl *ddraw_from_ddraw1(IDirectDraw *iface)
221 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw_vtbl));
224 static inline IDirectDrawImpl *ddraw_from_ddraw2(IDirectDraw2 *iface)
226 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw2_vtbl));
229 static inline IDirectDrawImpl *ddraw_from_ddraw3(IDirectDraw3 *iface)
231 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw3_vtbl));
234 static inline IDirectDrawImpl *ddraw_from_ddraw4(IDirectDraw4 *iface)
236 return (IDirectDrawImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawImpl, IDirectDraw4_vtbl));
239 /* The default surface type */
240 extern WINED3DSURFTYPE DefaultSurfaceType DECLSPEC_HIDDEN;
242 /*****************************************************************************
243 * IDirectDrawSurface implementation structure
244 *****************************************************************************/
246 struct IDirectDrawSurfaceImpl
248 /* IUnknown fields */
249 const IDirectDrawSurface7Vtbl *lpVtbl;
250 const IDirectDrawSurface3Vtbl *IDirectDrawSurface3_vtbl;
251 const IDirectDrawGammaControlVtbl *IDirectDrawGammaControl_vtbl;
252 const IDirect3DTexture2Vtbl *IDirect3DTexture2_vtbl;
253 const IDirect3DTextureVtbl *IDirect3DTexture_vtbl;
255 LONG ref;
256 IUnknown *ifaceToRelease;
258 int version;
260 /* Connections to other Objects */
261 IDirectDrawImpl *ddraw;
262 IWineD3DSurface *WineD3DSurface;
263 IWineD3DBaseTexture *wineD3DTexture;
264 IWineD3DSwapChain *wineD3DSwapChain;
266 /* This implementation handles attaching surfaces to other surfaces */
267 IDirectDrawSurfaceImpl *next_attached;
268 IDirectDrawSurfaceImpl *first_attached;
270 /* Complex surfaces are organized in a tree, although the tree is degenerated to a list in most cases.
271 * In mipmap and primary surfaces each level has only one attachment, which is the next surface level.
272 * Only the cube texture root has 6 surfaces attached, which then have a normal mipmap chain attached
273 * to them. So hardcode the array to 6, a dynamic array or a list would be an overkill.
275 #define MAX_COMPLEX_ATTACHED 6
276 IDirectDrawSurfaceImpl *complex_array[MAX_COMPLEX_ATTACHED];
277 /* You can't traverse the tree upwards. Only a flag for Surface::Release because its needed there,
278 * but no pointer to prevent temptations to traverse it in the wrong direction.
280 BOOL is_complex_root;
282 /* Surface description, for GetAttachedSurface */
283 DDSURFACEDESC2 surface_desc;
285 /* Misc things */
286 DWORD uniqueness_value;
287 UINT mipmap_level;
288 WINED3DSURFTYPE ImplType;
290 /* For D3DDevice creation */
291 BOOL isRenderTarget;
293 /* Clipper objects */
294 IDirectDrawClipperImpl *clipper;
296 /* For the ddraw surface list */
297 struct list surface_list_entry;
299 DWORD Handle;
302 /* VTable declaration. It's located in surface.c / surface_thunks.c */
303 extern const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl DECLSPEC_HIDDEN;
304 extern const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl DECLSPEC_HIDDEN;
305 extern const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl DECLSPEC_HIDDEN;
306 extern const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl DECLSPEC_HIDDEN;
307 extern const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl DECLSPEC_HIDDEN;
309 HRESULT WINAPI IDirectDrawSurfaceImpl_AddAttachedSurface(IDirectDrawSurfaceImpl *This,
310 IDirectDrawSurfaceImpl *Surf) DECLSPEC_HIDDEN;
311 void IDirectDrawSurfaceImpl_Destroy(IDirectDrawSurfaceImpl *This) DECLSPEC_HIDDEN;
313 static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface)
315 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture_vtbl));
318 static inline IDirectDrawSurfaceImpl *surface_from_texture2(IDirect3DTexture2 *iface)
320 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirect3DTexture2_vtbl));
323 static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3 *iface)
325 return (IDirectDrawSurfaceImpl *)((char*)iface - FIELD_OFFSET(IDirectDrawSurfaceImpl, IDirectDrawSurface3_vtbl));
328 /* Get the number of bytes per pixel for a given surface */
329 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
330 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
332 /*****************************************************************************
333 * IParent Implementation
334 *****************************************************************************/
335 struct IParentImpl
337 /* IUnknown fields */
338 const IParentVtbl *lpVtbl;
339 LONG ref;
341 /* IParentImpl fields */
342 IUnknown *child;
346 extern const IParentVtbl IParent_Vtbl DECLSPEC_HIDDEN;
348 /*****************************************************************************
349 * IDirect3DDevice implementation
350 *****************************************************************************/
351 typedef enum
353 DDrawHandle_Unknown = 0,
354 DDrawHandle_Texture = 1,
355 DDrawHandle_Material = 2,
356 DDrawHandle_Matrix = 3,
357 DDrawHandle_StateBlock = 4
358 } DDrawHandleTypes;
360 struct HandleEntry
362 void *ptr;
363 DDrawHandleTypes type;
366 struct IDirect3DDeviceImpl
368 /* IUnknown */
369 const IDirect3DDevice7Vtbl *lpVtbl;
370 const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl;
371 const IDirect3DDevice2Vtbl *IDirect3DDevice2_vtbl;
372 const IDirect3DDeviceVtbl *IDirect3DDevice_vtbl;
373 LONG ref;
375 /* Other object connections */
376 IWineD3DDevice *wineD3DDevice;
377 IDirectDrawImpl *ddraw;
378 IWineD3DBuffer *indexbuffer;
379 IDirectDrawSurfaceImpl *target;
380 BOOL OffScreenTarget;
382 /* Viewport management */
383 IDirect3DViewportImpl *viewport_list;
384 IDirect3DViewportImpl *current_viewport;
385 D3DVIEWPORT7 active_viewport;
387 /* Required to keep track which of two available texture blending modes in d3ddevice3 is used */
388 BOOL legacyTextureBlending;
390 /* Light state */
391 DWORD material;
393 /* Rendering functions to wrap D3D(1-3) to D3D7 */
394 D3DPRIMITIVETYPE primitive_type;
395 DWORD vertex_type;
396 DWORD render_flags;
397 DWORD nb_vertices;
398 LPBYTE vertex_buffer;
399 DWORD vertex_size;
400 DWORD buffer_size;
402 /* Handle management */
403 struct HandleEntry *Handles;
404 DWORD numHandles;
405 D3DMATRIXHANDLE world, proj, view;
408 /* Vtables in various versions */
409 extern const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUSetup_Vtbl DECLSPEC_HIDDEN;
410 extern const IDirect3DDevice7Vtbl IDirect3DDevice7_FPUPreserve_Vtbl DECLSPEC_HIDDEN;
411 extern const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl DECLSPEC_HIDDEN;
412 extern const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl DECLSPEC_HIDDEN;
413 extern const IDirect3DDeviceVtbl IDirect3DDevice1_Vtbl DECLSPEC_HIDDEN;
415 /* The IID */
416 extern const GUID IID_D3DDEVICE_WineD3D DECLSPEC_HIDDEN;
418 /* Helper functions */
419 HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7) DECLSPEC_HIDDEN;
420 DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This) DECLSPEC_HIDDEN;
421 WINED3DZBUFFERTYPE IDirect3DDeviceImpl_UpdateDepthStencil(IDirect3DDeviceImpl *This) DECLSPEC_HIDDEN;
423 static inline IDirect3DDeviceImpl *device_from_device1(IDirect3DDevice *iface)
425 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice_vtbl));
428 static inline IDirect3DDeviceImpl *device_from_device2(IDirect3DDevice2 *iface)
430 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice2_vtbl));
433 static inline IDirect3DDeviceImpl *device_from_device3(IDirect3DDevice3 *iface)
435 return (IDirect3DDeviceImpl *)((char*)iface - FIELD_OFFSET(IDirect3DDeviceImpl, IDirect3DDevice3_vtbl));
438 /* Structures */
439 struct EnumTextureFormatsCBS
441 LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
442 LPD3DENUMPIXELFORMATSCALLBACK cbv7;
443 void *Context;
446 /*****************************************************************************
447 * IDirect3D implementation
448 *****************************************************************************/
450 /* No implementation structure as this is only another interface to DirectDraw */
452 /* the Vtables */
453 extern const IDirect3DVtbl IDirect3D1_Vtbl DECLSPEC_HIDDEN;
454 extern const IDirect3D2Vtbl IDirect3D2_Vtbl DECLSPEC_HIDDEN;
455 extern const IDirect3D3Vtbl IDirect3D3_Vtbl DECLSPEC_HIDDEN;
456 extern const IDirect3D7Vtbl IDirect3D7_Vtbl DECLSPEC_HIDDEN;
458 /* Structure for EnumZBufferFormats */
459 struct EnumZBufferFormatsData
461 LPD3DENUMPIXELFORMATSCALLBACK Callback;
462 void *Context;
465 /*****************************************************************************
466 * IDirectDrawClipper implementation structure
467 *****************************************************************************/
468 struct IDirectDrawClipperImpl
470 /* IUnknown fields */
471 const IDirectDrawClipperVtbl *lpVtbl;
472 LONG ref;
474 IWineD3DClipper *wineD3DClipper;
475 IDirectDrawImpl *ddraw_owner;
478 extern const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl DECLSPEC_HIDDEN;
480 typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;
482 /*****************************************************************************
483 * IDirectDrawPalette implementation structure
484 *****************************************************************************/
485 struct IDirectDrawPaletteImpl
487 /* IUnknown fields */
488 const IDirectDrawPaletteVtbl *lpVtbl;
489 LONG ref;
491 /* WineD3D uplink */
492 IWineD3DPalette *wineD3DPalette;
494 /* IDirectDrawPalette fields */
495 IDirectDrawImpl *ddraw_owner;
496 IUnknown *ifaceToRelease;
498 extern const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl DECLSPEC_HIDDEN;
500 /******************************************************************************
501 * DirectDraw ClassFactory implementation - incomplete
502 ******************************************************************************/
503 typedef struct
505 const IClassFactoryVtbl *lpVtbl;
507 LONG ref;
508 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
509 } IClassFactoryImpl;
511 /* Helper structures */
512 struct object_creation_info
514 const CLSID *clsid;
515 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
516 void **ppObj);
519 /******************************************************************************
520 * IDirect3DLight implementation structure - Wraps to D3D7
521 ******************************************************************************/
522 struct IDirect3DLightImpl
524 const IDirect3DLightVtbl *lpVtbl;
525 LONG ref;
527 /* IDirect3DLight fields */
528 IDirectDrawImpl *ddraw;
530 /* If this light is active for one viewport, put the viewport here */
531 IDirect3DViewportImpl *active_viewport;
533 D3DLIGHT2 light;
534 D3DLIGHT7 light7;
536 DWORD dwLightIndex;
538 /* Chained list used for adding / removing from viewports */
539 IDirect3DLightImpl *next;
541 /* Activation function */
542 void (*activate)(IDirect3DLightImpl*);
543 void (*desactivate)(IDirect3DLightImpl*);
544 void (*update)(IDirect3DLightImpl*);
547 /* Vtable */
548 extern const IDirect3DLightVtbl IDirect3DLight_Vtbl DECLSPEC_HIDDEN;
550 /* Helper functions */
551 void light_update(IDirect3DLightImpl *This) DECLSPEC_HIDDEN;
552 void light_activate(IDirect3DLightImpl *This) DECLSPEC_HIDDEN;
553 void light_desactivate(IDirect3DLightImpl *This) DECLSPEC_HIDDEN;
555 /******************************************************************************
556 * IDirect3DMaterial implementation structure - Wraps to D3D7
557 ******************************************************************************/
558 struct IDirect3DMaterialImpl
560 const IDirect3DMaterial3Vtbl *lpVtbl;
561 const IDirect3DMaterial2Vtbl *IDirect3DMaterial2_vtbl;
562 const IDirect3DMaterialVtbl *IDirect3DMaterial_vtbl;
563 LONG ref;
565 /* IDirect3DMaterial2 fields */
566 IDirectDrawImpl *ddraw;
567 IDirect3DDeviceImpl *active_device;
569 D3DMATERIAL mat;
570 DWORD Handle;
572 void (*activate)(IDirect3DMaterialImpl* this);
575 /* VTables in various versions */
576 extern const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl DECLSPEC_HIDDEN;
577 extern const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl DECLSPEC_HIDDEN;
578 extern const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl DECLSPEC_HIDDEN;
580 /* Helper functions */
581 void material_activate(IDirect3DMaterialImpl* This) DECLSPEC_HIDDEN;
583 /*****************************************************************************
584 * IDirect3DViewport - Wraps to D3D7
585 *****************************************************************************/
586 struct IDirect3DViewportImpl
588 const IDirect3DViewport3Vtbl *lpVtbl;
589 LONG ref;
591 /* IDirect3DViewport fields */
592 IDirectDrawImpl *ddraw;
594 /* If this viewport is active for one device, put the device here */
595 IDirect3DDeviceImpl *active_device;
597 DWORD num_lights;
598 DWORD map_lights;
600 int use_vp2;
602 union
604 D3DVIEWPORT vp1;
605 D3DVIEWPORT2 vp2;
606 } viewports;
608 /* Activation function */
609 void (*activate)(IDirect3DViewportImpl*, BOOL);
611 /* Field used to chain viewports together */
612 IDirect3DViewportImpl *next;
614 /* Lights list */
615 IDirect3DLightImpl *lights;
617 /* Background material */
618 IDirect3DMaterialImpl *background;
621 /* Vtable */
622 extern const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl DECLSPEC_HIDDEN;
624 /* Helper functions */
625 void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) DECLSPEC_HIDDEN;
627 /*****************************************************************************
628 * IDirect3DExecuteBuffer - Wraps to D3D7
629 *****************************************************************************/
630 struct IDirect3DExecuteBufferImpl
632 /* IUnknown */
633 const IDirect3DExecuteBufferVtbl *lpVtbl;
634 LONG ref;
636 /* IDirect3DExecuteBuffer fields */
637 IDirectDrawImpl *ddraw;
638 IDirect3DDeviceImpl *d3ddev;
640 D3DEXECUTEBUFFERDESC desc;
641 D3DEXECUTEDATA data;
643 /* This buffer will store the transformed vertices */
644 void *vertex_data;
645 WORD *indices;
646 int nb_indices;
648 /* This flags is set to TRUE if we allocated ourselves the
649 * data buffer
651 BOOL need_free;
654 /* The VTable */
655 extern const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl DECLSPEC_HIDDEN;
657 /* The execute function */
658 void IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
659 IDirect3DDeviceImpl *Device, IDirect3DViewportImpl *ViewportImpl) DECLSPEC_HIDDEN;
661 /*****************************************************************************
662 * IDirect3DVertexBuffer
663 *****************************************************************************/
664 struct IDirect3DVertexBufferImpl
666 /*** IUnknown Methods ***/
667 const IDirect3DVertexBuffer7Vtbl *lpVtbl;
668 const IDirect3DVertexBufferVtbl *IDirect3DVertexBuffer_vtbl;
669 LONG ref;
671 /*** WineD3D and ddraw links ***/
672 IWineD3DBuffer *wineD3DVertexBuffer;
673 IWineD3DVertexDeclaration *wineD3DVertexDeclaration;
674 IDirectDrawImpl *ddraw;
676 /*** Storage for D3D7 specific things ***/
677 DWORD Caps;
678 DWORD fvf;
681 /* The Vtables */
682 extern const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl DECLSPEC_HIDDEN;
683 extern const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl DECLSPEC_HIDDEN;
685 static inline IDirect3DVertexBufferImpl *vb_from_vb1(IDirect3DVertexBuffer *iface)
687 return (IDirect3DVertexBufferImpl *)((char*)iface
688 - FIELD_OFFSET(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer_vtbl));
691 /*****************************************************************************
692 * Helper functions from utils.c
693 *****************************************************************************/
695 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
696 (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
698 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
699 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
701 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat) DECLSPEC_HIDDEN;
702 WINED3DFORMAT PixelFormat_DD2WineD3D(const DDPIXELFORMAT *DDPixelFormat) DECLSPEC_HIDDEN;
703 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd) DECLSPEC_HIDDEN;
704 void dump_D3DMATRIX(const D3DMATRIX *mat) DECLSPEC_HIDDEN;
705 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps) DECLSPEC_HIDDEN;
706 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
707 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in) DECLSPEC_HIDDEN;
708 void DDRAW_dump_cooperativelevel(DWORD cooplevel) DECLSPEC_HIDDEN;
710 /* This only needs to be here as long the processvertices functionality of
711 * IDirect3DExecuteBuffer isn't in WineD3D */
712 void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2) DECLSPEC_HIDDEN;
714 void multiply_matrix_D3D_way(LPD3DMATRIX result, const D3DMATRIX *m1, const D3DMATRIX *m2) DECLSPEC_HIDDEN;
716 /* Helper function in main.c */
717 BOOL LoadWineD3D(void) DECLSPEC_HIDDEN;
719 /* Used for generic dumping */
720 typedef struct
722 DWORD val;
723 const char* name;
724 } flag_info;
726 #define FE(x) { x, #x }
728 typedef struct
730 DWORD val;
731 const char* name;
732 void (*func)(const void *);
733 ptrdiff_t offset;
734 } member_info;
736 /* Structure copy */
737 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
739 #define DD_STRUCT_COPY_BYSIZE(to,from) \
740 do { \
741 DWORD __size = (to)->dwSize; \
742 DWORD __copysize = __size; \
743 DWORD __resetsize = __size; \
744 assert(to != from); \
745 if (__resetsize > sizeof(*to)) \
746 __resetsize = sizeof(*to); \
747 memset(to,0,__resetsize); \
748 if ((from)->dwSize < __size) \
749 __copysize = (from)->dwSize; \
750 memcpy(to,from,__copysize); \
751 (to)->dwSize = __size;/*restore size*/ \
752 } while (0)
755 #endif
757 HRESULT hr_ddraw_from_wined3d(HRESULT hr) DECLSPEC_HIDDEN;