wined3d: Use D3DCUBEMAP_FACES consistently in the WINED3D namespace.
[wine] / dlls / ddraw / ddraw_private.h
1 /*
2  * Copyright 2006 Stefan Dösinger
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
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #ifndef __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
20 #define __WINE_DLLS_DDRAW_DDRAW_PRIVATE_H
21
22 /* MAY NOT CONTAIN X11 or DGA specific includes/defines/structs! */
23
24 #include <stdarg.h>
25 #include <stdio.h>
26
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"
35
36 #include "ddcomimpl.h"
37
38 #include "wine/wined3d_interface.h"
39 #include "wine/list.h"
40
41 /*****************************************************************************
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;
46
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;
77
78 /*****************************************************************************
79  * IDirectDraw implementation structure
80  *****************************************************************************/
81
82 struct IDirectDrawImpl
83 {
84     /* IUnknown fields */
85     ICOM_VFIELD_MULTI(IDirectDraw7);
86     ICOM_VFIELD_MULTI(IDirectDraw4);
87     ICOM_VFIELD_MULTI(IDirectDraw2);
88     ICOM_VFIELD_MULTI(IDirectDraw);
89     ICOM_VFIELD_MULTI(IDirect3D7);
90     ICOM_VFIELD_MULTI(IDirect3D3);
91     ICOM_VFIELD_MULTI(IDirect3D2);
92     ICOM_VFIELD_MULTI(IDirect3D);
93
94     /* See comment in IDirectDraw::AddRef */
95     LONG                    ref7, ref4, ref2, ref1, numIfaces;
96
97     /* WineD3D linkage */
98     IWineD3D                *wineD3D;
99     IWineD3DDevice          *wineD3DDevice;
100     IDirectDrawSurfaceImpl  *DepthStencilBuffer;
101     BOOL                    d3d_initialized;
102
103     /* Misc ddraw fields */
104     UINT                    total_vidmem;
105     DWORD                   cur_scanline;
106     BOOL                    fake_vblank;
107     BOOL                    initialized;
108
109     /* DirectDraw things, which are not handled by WineD3D */
110     DWORD                   cooperative_level;
111
112     DWORD                   orig_width, orig_height;
113     DWORD                   orig_bpp;
114
115     DDCAPS                  caps;
116
117     LONG                    style;
118     LONG                    exStyle;
119
120     /* D3D things */
121     IDirectDrawSurfaceImpl  *d3d_target;
122     HWND                    d3d_window;
123     IDirect3DDeviceImpl     *d3ddevice;
124     int                     d3dversion;
125
126     /* Various HWNDs */
127     HWND                    focuswindow;
128     HWND                    devicewindow;
129
130     /* The surface type to request */
131     WINED3DSURFTYPE         ImplType;
132
133
134     /* Our private window class */
135     char classname[32];
136     WNDCLASSA wnd_class;
137
138     /* Helpers for surface creation */
139     IDirectDrawSurfaceImpl *tex_root;
140     BOOL                    depthstencil;
141
142     /* For the dll unload cleanup code */
143     struct list ddraw_list_entry;
144     /* The surface list - can't relay this to WineD3D
145      * because of IParent
146      */
147     struct list surface_list;
148     LONG surfaces;
149 };
150
151 /* Declare the VTables. They can be found ddraw.c */
152 const IDirectDraw7Vtbl IDirectDraw7_Vtbl;
153 const IDirectDraw4Vtbl IDirectDraw4_Vtbl;
154 const IDirectDraw2Vtbl IDirectDraw2_Vtbl;
155 const IDirectDrawVtbl  IDirectDraw1_Vtbl;
156
157 /* Helper structures */
158 typedef struct EnumDisplayModesCBS
159 {
160     void *context;
161     LPDDENUMMODESCALLBACK2 callback;
162 } EnumDisplayModesCBS;
163
164 typedef struct EnumSurfacesCBS
165 {
166     void *context;
167     LPDDENUMSURFACESCALLBACK7 callback;
168     LPDDSURFACEDESC2 pDDSD;
169     DWORD Flags;
170 } EnumSurfacesCBS;
171
172 /* Utility functions */
173 void
174 DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS* pIn,
175                              DDSCAPS2* pOut);
176 void
177 DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2* pIn,
178                                         DDDEVICEIDENTIFIER* pOut);
179 void
180 IDirectDrawImpl_Destroy(IDirectDrawImpl *This);
181
182 HRESULT WINAPI
183 IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
184                                          DDSURFACEDESC2 *desc,
185                                          void *Context);
186 void
187 remove_ddraw_object(IDirectDrawImpl *ddraw);
188
189 /* The default surface type */
190 extern WINED3DSURFTYPE DefaultSurfaceType;
191
192 /*****************************************************************************
193  * IDirectDrawSurface implementation structure
194  *****************************************************************************/
195
196 struct IDirectDrawSurfaceImpl
197 {
198     /* IUnknown fields */
199     ICOM_VFIELD_MULTI(IDirectDrawSurface7);
200     ICOM_VFIELD_MULTI(IDirectDrawSurface3);
201     ICOM_VFIELD_MULTI(IDirectDrawGammaControl);
202     ICOM_VFIELD_MULTI(IDirect3DTexture2);
203     ICOM_VFIELD_MULTI(IDirect3DTexture);
204
205     LONG                     ref;
206     IUnknown                *ifaceToRelease;
207
208     int                     version;
209
210     /* Connections to other Objects */
211     IDirectDrawImpl         *ddraw;
212     IWineD3DSurface         *WineD3DSurface;
213     IWineD3DTexture         *wineD3DTexture;
214
215     /* This implementation handles attaching surfaces to other surfaces */
216     IDirectDrawSurfaceImpl  *next_attached;
217     IDirectDrawSurfaceImpl  *first_attached;
218     IDirectDrawSurfaceImpl  *next_complex;
219     IDirectDrawSurfaceImpl  *first_complex;
220
221     /* Surface description, for GetAttachedSurface */
222     DDSURFACEDESC2          surface_desc;
223
224     /* Misc things */
225     DWORD                   uniqueness_value;
226     UINT                    mipmap_level;
227     WINED3DSURFTYPE         ImplType;
228
229     /* For D3DDevice creation */
230     BOOL                    isRenderTarget;
231
232     /* Clipper objects */
233     IDirectDrawClipperImpl  *clipper;
234
235     /* For the ddraw surface list */
236     struct list             surface_list_entry;
237
238     DWORD                   Handle;
239 };
240
241 /* VTable declaration. It's located in surface.c / surface_thunks.c */
242 const IDirectDrawSurface7Vtbl IDirectDrawSurface7_Vtbl;
243 const IDirectDrawSurface3Vtbl IDirectDrawSurface3_Vtbl;
244 const IDirectDrawGammaControlVtbl IDirectDrawGammaControl_Vtbl;
245 const IDirect3DTexture2Vtbl IDirect3DTexture2_Vtbl;
246 const IDirect3DTextureVtbl IDirect3DTexture1_Vtbl;
247
248 /* Get the number of bytes per pixel for a given surface */
249 #define PFGET_BPP(pf) (pf.dwFlags&DDPF_PALETTEINDEXED8?1:((pf.dwRGBBitCount+7)/8))
250 #define GET_BPP(desc) PFGET_BPP(desc.ddpfPixelFormat)
251
252 /*****************************************************************************
253  * IParent Implementation
254  *****************************************************************************/
255 struct IParentImpl
256 {
257     /* IUnknown fields */
258     ICOM_VFIELD_MULTI(IParent);
259     LONG                    ref;
260
261     /* IParentImpl fields */
262     IUnknown      *child;
263
264 };
265
266 const IParentVtbl IParent_Vtbl;
267
268 /*****************************************************************************
269  * IDirect3DDevice implementation
270  *****************************************************************************/
271 typedef enum
272 {
273     DDrawHandle_Unknown       = 0,
274     DDrawHandle_Texture       = 1,
275     DDrawHandle_Material      = 2,
276     DDrawHandle_Matrix        = 3,
277     DDrawHandle_StateBlock    = 4
278 } DDrawHandleTypes;
279
280 struct HandleEntry
281 {
282     void    *ptr;
283     DDrawHandleTypes      type;
284 };
285
286 struct IDirect3DDeviceImpl
287 {
288     /* IUnknown */
289     ICOM_VFIELD_MULTI(IDirect3DDevice7);
290     ICOM_VFIELD_MULTI(IDirect3DDevice3);
291     ICOM_VFIELD_MULTI(IDirect3DDevice2);
292     ICOM_VFIELD_MULTI(IDirect3DDevice);
293     LONG                    ref;
294
295     /* Other object connections */
296     IWineD3DDevice          *wineD3DDevice;
297     IDirectDrawImpl         *ddraw;
298     IWineD3DIndexBuffer     *indexbuffer;
299     IDirectDrawSurfaceImpl  *target;
300     BOOL                    OffScreenTarget;
301
302     /* Viewport management */
303     IDirect3DViewportImpl *viewport_list;
304     IDirect3DViewportImpl *current_viewport;
305     D3DVIEWPORT7 active_viewport;
306
307     /* Light state */
308     DWORD material;
309
310     /* Rendering functions to wrap D3D(1-3) to D3D7 */
311     D3DPRIMITIVETYPE primitive_type;
312     DWORD vertex_type;
313     DWORD render_flags;
314     DWORD nb_vertices;
315     LPBYTE vertex_buffer;
316     DWORD vertex_size;
317     DWORD buffer_size;
318
319     /* Handle management */
320     struct HandleEntry      *Handles;
321     DWORD                    numHandles;
322 };
323
324 /* Vtables in various versions */
325 const IDirect3DDevice7Vtbl IDirect3DDevice7_Vtbl;
326 const IDirect3DDevice3Vtbl IDirect3DDevice3_Vtbl;
327 const IDirect3DDevice2Vtbl IDirect3DDevice2_Vtbl;
328 const IDirect3DDeviceVtbl  IDirect3DDevice1_Vtbl;
329
330 /* The IID */
331 const GUID IID_D3DDEVICE_WineD3D;
332
333 /* Helper functions */
334 HRESULT IDirect3DImpl_GetCaps(IWineD3D *WineD3D, D3DDEVICEDESC *Desc123, D3DDEVICEDESC7 *Desc7);
335 DWORD IDirect3DDeviceImpl_CreateHandle(IDirect3DDeviceImpl *This);
336
337 /* Structures */
338 struct EnumTextureFormatsCBS
339 {
340     LPD3DENUMTEXTUREFORMATSCALLBACK cbv2;
341     LPD3DENUMPIXELFORMATSCALLBACK cbv7;
342     void *Context;
343 };
344
345 /*****************************************************************************
346  * IDirect3D implementation
347  *****************************************************************************/
348
349 /* No implementation structure as this is only another interface to DirectDraw */
350
351 /* the Vtables */
352 const IDirect3DVtbl  IDirect3D1_Vtbl;
353 const IDirect3D2Vtbl IDirect3D2_Vtbl;
354 const IDirect3D3Vtbl IDirect3D3_Vtbl;
355 const IDirect3D7Vtbl IDirect3D7_Vtbl;
356
357 /* Structure for EnumZBufferFormats */
358 struct EnumZBufferFormatsData
359 {
360     LPD3DENUMPIXELFORMATSCALLBACK Callback;
361     void *Context;
362 };
363
364 /*****************************************************************************
365  * IDirectDrawClipper implementation structure
366  *****************************************************************************/
367 struct IDirectDrawClipperImpl
368 {
369     /* IUnknown fields */
370     ICOM_VFIELD_MULTI(IDirectDrawClipper);
371     LONG ref;
372
373     /* IDirectDrawClipper fields */
374     HWND hWnd;
375
376     IDirectDrawImpl* ddraw_owner;
377     struct IDirectDrawClipperImpl* prev_ddraw;
378     struct IDirectDrawClipperImpl* next_ddraw;
379 };
380
381 const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl;
382
383 /*****************************************************************************
384  * IDirectDrawPalette implementation structure
385  *****************************************************************************/
386 struct IDirectDrawPaletteImpl
387 {
388     /* IUnknown fields */
389     ICOM_VFIELD_MULTI(IDirectDrawPalette);
390     LONG ref;
391
392     /* WineD3D uplink */
393     IWineD3DPalette           *wineD3DPalette;
394
395     /* IDirectDrawPalette fields */
396     IDirectDrawImpl           *ddraw_owner;
397     IUnknown                  *ifaceToRelease;
398 };
399 const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl;
400
401 /******************************************************************************
402  * DirectDraw ClassFactory implementation - incomplete
403  ******************************************************************************/
404 typedef struct
405 {
406     ICOM_VFIELD_MULTI(IClassFactory);
407
408     LONG ref;
409     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID iid, LPVOID *ppObj);
410 } IClassFactoryImpl;
411
412 /* Helper structures */
413 struct object_creation_info
414 {
415     const CLSID *clsid;
416     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, REFIID riid,
417                                  void **ppObj);
418 };
419
420 /******************************************************************************
421  * IDirect3DLight implementation structure - Wraps to D3D7
422  ******************************************************************************/
423 struct IDirect3DLightImpl
424 {
425     ICOM_VFIELD_MULTI(IDirect3DLight);
426     LONG ref;
427
428     /* IDirect3DLight fields */
429     IDirectDrawImpl           *ddraw;
430
431     /* If this light is active for one viewport, put the viewport here */
432     IDirect3DViewportImpl     *active_viewport;
433
434     D3DLIGHT2 light;
435     D3DLIGHT7 light7;
436
437     DWORD dwLightIndex;
438
439     /* Chained list used for adding / removing from viewports */
440     IDirect3DLightImpl        *next;
441
442     /* Activation function */
443     void                      (*activate)(IDirect3DLightImpl*);
444     void                      (*desactivate)(IDirect3DLightImpl*);
445     void                      (*update)(IDirect3DLightImpl*);
446 };
447
448 /* Vtable */
449 const IDirect3DLightVtbl IDirect3DLight_Vtbl;
450
451 /* Helper functions */
452 void light_update(IDirect3DLightImpl* This);
453 void light_activate(IDirect3DLightImpl* This);
454 void light_desactivate(IDirect3DLightImpl* This);
455
456 /******************************************************************************
457  * IDirect3DMaterial implementation structure - Wraps to D3D7
458  ******************************************************************************/
459 struct IDirect3DMaterialImpl
460 {
461     ICOM_VFIELD_MULTI(IDirect3DMaterial3);
462     ICOM_VFIELD_MULTI(IDirect3DMaterial2);
463     ICOM_VFIELD_MULTI(IDirect3DMaterial);
464     LONG  ref;
465
466     /* IDirect3DMaterial2 fields */
467     IDirectDrawImpl               *ddraw;
468     IDirect3DDeviceImpl           *active_device;
469
470     D3DMATERIAL mat;
471     DWORD Handle;
472
473     void (*activate)(IDirect3DMaterialImpl* this);
474 };
475
476 /* VTables in various versions */
477 const IDirect3DMaterialVtbl IDirect3DMaterial_Vtbl;
478 const IDirect3DMaterial2Vtbl IDirect3DMaterial2_Vtbl;
479 const IDirect3DMaterial3Vtbl IDirect3DMaterial3_Vtbl;
480
481 /* Helper functions */
482 void material_activate(IDirect3DMaterialImpl* This);
483
484 /*****************************************************************************
485  * IDirect3DViewport - Wraps to D3D7
486  *****************************************************************************/
487 struct IDirect3DViewportImpl
488 {
489     ICOM_VFIELD_MULTI(IDirect3DViewport3);
490     LONG ref;
491
492     /* IDirect3DViewport fields */
493     IDirectDrawImpl           *ddraw;
494
495     /* If this viewport is active for one device, put the device here */
496     IDirect3DDeviceImpl       *active_device;
497
498     DWORD                     num_lights;
499     DWORD                     map_lights;
500
501     int                       use_vp2;
502
503     union
504     {
505         D3DVIEWPORT vp1;
506         D3DVIEWPORT2 vp2;
507     } viewports;
508
509     /* Activation function */
510     void                      (*activate)(IDirect3DViewportImpl*);
511
512     /* Field used to chain viewports together */
513     IDirect3DViewportImpl     *next;
514
515     /* Lights list */
516     IDirect3DLightImpl        *lights;
517
518     /* Background material */
519     IDirect3DMaterialImpl     *background;
520 };
521
522 /* Vtable */
523 const IDirect3DViewport3Vtbl IDirect3DViewport3_Vtbl;
524
525 /* Helper functions */
526 void viewport_activate(IDirect3DViewportImpl* This);
527
528 /*****************************************************************************
529  * IDirect3DExecuteBuffer - Wraps to D3D7
530  *****************************************************************************/
531 struct IDirect3DExecuteBufferImpl
532 {
533     /* IUnknown */
534     ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
535     LONG                 ref;
536
537     /* IDirect3DExecuteBuffer fields */
538     IDirectDrawImpl      *ddraw;
539     IDirect3DDeviceImpl  *d3ddev;
540
541     D3DEXECUTEBUFFERDESC desc;
542     D3DEXECUTEDATA       data;
543
544     /* This buffer will store the transformed vertices */
545     void                 *vertex_data;
546     WORD                 *indices;
547     int                  nb_indices;
548
549     /* This flags is set to TRUE if we allocated ourselves the
550      * data buffer
551      */
552     BOOL                 need_free;
553 };
554
555 /* The VTable */
556 const IDirect3DExecuteBufferVtbl IDirect3DExecuteBuffer_Vtbl;
557
558 /* The execute function */
559 void
560 IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
561                                    IDirect3DDeviceImpl *Device,
562                                    IDirect3DViewportImpl *ViewportImpl);
563
564 /*****************************************************************************
565  * IDirect3DVertexBuffer
566  *****************************************************************************/
567 struct IDirect3DVertexBufferImpl
568 {
569     /*** IUnknown Methods ***/
570     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
571     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
572     LONG                 ref;
573
574     /*** WineD3D link ***/
575     IWineD3DVertexBuffer *wineD3DVertexBuffer;
576
577     /*** Storage for D3D7 specific things ***/
578     DWORD                Caps;
579 };
580
581 /* The Vtables */
582 const IDirect3DVertexBuffer7Vtbl IDirect3DVertexBuffer7_Vtbl;
583 const IDirect3DVertexBufferVtbl IDirect3DVertexBuffer1_Vtbl;
584
585 /*****************************************************************************
586  * Helper functions from utils.c
587  *****************************************************************************/
588
589 #define GET_TEXCOUNT_FROM_FVF(d3dvtVertexType) \
590     (((d3dvtVertexType) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
591
592 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
593     (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
594
595 void PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat, WINED3DFORMAT WineD3DFormat);
596 WINED3DFORMAT PixelFormat_DD2WineD3D(DDPIXELFORMAT *DDPixelFormat);
597 void DDRAW_dump_surface_desc(const DDSURFACEDESC2 *lpddsd);
598 void DDRAW_dump_pixelformat(const DDPIXELFORMAT *PixelFormat);
599 void dump_D3DMATRIX(D3DMATRIX *mat);
600 void DDRAW_dump_DDCAPS(const DDCAPS *lpcaps);
601 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
602 void DDRAW_dump_DDSCAPS2(const DDSCAPS2 *in);
603 void DDRAW_dump_cooperativelevel(DWORD cooplevel);
604
605 /* This only needs to be here as long the processvertices functionality of
606  * IDirect3DExecuteBuffer isn't in WineD3D */
607 void multiply_matrix(LPD3DMATRIX dest, LPD3DMATRIX src1, LPD3DMATRIX src2);
608
609 /* Used for generic dumping */
610 typedef struct
611 {
612     DWORD val;
613     const char* name;
614 } flag_info;
615
616 #define FE(x) { x, #x }
617
618 typedef struct
619 {
620     DWORD val;
621     const char* name;
622     void (*func)(const void *);
623     ptrdiff_t offset;
624 } member_info;
625
626 /* Structure copy */
627 #define DDRAW_dump_flags(flags,names,num_names) DDRAW_dump_flags_(flags, names, num_names, 1)
628 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
629
630 #define DD_STRUCT_COPY_BYSIZE(to,from)                  \
631         do {                                            \
632                 DWORD __size = (to)->dwSize;            \
633                 DWORD __copysize = __size;              \
634                 DWORD __resetsize = __size;             \
635                 assert(to != from);                     \
636                 if (__resetsize > sizeof(*to))          \
637                     __resetsize = sizeof(*to);          \
638                 memset(to,0,__resetsize);               \
639                 if ((from)->dwSize < __size)            \
640                     __copysize = (from)->dwSize;        \
641                 memcpy(to,from,__copysize);             \
642                 (to)->dwSize = __size;/*restore size*/  \
643         } while (0)
644
645
646 #endif
647
648 HRESULT hr_ddraw_from_wined3d(HRESULT hr);