Added prototypes for OleQueryLinkFromClip, OleQueryCreateFromClip,
[wine] / include / d3d.h
1 #ifndef _WINE_D3D_H
2 #define _WINE_D3D_H
3
4 #include "ddraw.h"
5
6 /* This is needed for GL_LIGHT */
7 #include "wine_gl.h"
8
9 DEFINE_GUID(IID_IDirect3D,              0x3BBA0080,0x2421,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 );
10 DEFINE_GUID(IID_IDirect3D2,             0x6aae1ec1,0x662a,0x11d0,0x88,0x9d,0x00,0xaa,0x00,0xbb,0xb7,0x6a);
11
12 DEFINE_GUID(IID_IDirect3DRampDevice,    0xF2086B20,0x259F,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 );
13 DEFINE_GUID(IID_IDirect3DRGBDevice,     0xA4665C60,0x2673,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56 );
14 DEFINE_GUID(IID_IDirect3DHALDevice,     0x84E63dE0,0x46AA,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E );
15 DEFINE_GUID(IID_IDirect3DMMXDevice,     0x881949a1,0xd6f3,0x11d0,0x89,0xab,0x00,0xa0,0xc9,0x05,0x41,0x29 );
16
17 DEFINE_GUID(IID_IDirect3DDevice,        0x64108800,0x957d,0x11D0,0x89,0xAB,0x00,0xA0,0xC9,0x05,0x41,0x29 );
18 DEFINE_GUID(IID_IDirect3DDevice2,       0x93281501,0x8CF8,0x11D0,0x89,0xAB,0x00,0xA0,0xC9,0x05,0x41,0x29);
19 DEFINE_GUID(IID_IDirect3DTexture,       0x2CDCD9E0,0x25A0,0x11CF,0xA3,0x1A,0x00,0xAA,0x00,0xB9,0x33,0x56);
20 DEFINE_GUID(IID_IDirect3DTexture2,      0x93281502,0x8CF8,0x11D0,0x89,0xAB,0x00,0xA0,0xC9,0x05,0x41,0x29);
21 DEFINE_GUID(IID_IDirect3DLight,         0x4417C142,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E);
22 DEFINE_GUID(IID_IDirect3DMaterial,      0x4417C144,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E);
23 DEFINE_GUID(IID_IDirect3DMaterial2,     0x93281503,0x8CF8,0x11D0,0x89,0xAB,0x00,0xA0,0xC9,0x05,0x41,0x29);
24 DEFINE_GUID(IID_IDirect3DExecuteBuffer, 0x4417C145,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E);
25 DEFINE_GUID(IID_IDirect3DViewport,      0x4417C146,0x33AD,0x11CF,0x81,0x6F,0x00,0x00,0xC0,0x20,0x15,0x6E);
26 DEFINE_GUID(IID_IDirect3DViewport2,     0x93281500,0x8CF8,0x11D0,0x89,0xAB,0x00,0xA0,0xC9,0x05,0x41,0x29);
27
28 typedef struct IDirect3D        IDirect3D ,*LPDIRECT3D ;
29 typedef struct IDirect3D2       IDirect3D2,*LPDIRECT3D2;
30 typedef struct IDirect3DLight   IDirect3DLight,*LPDIRECT3DLIGHT;
31 typedef struct IDirect3DDevice        IDirect3DDevice, *LPDIRECT3DDEVICE;
32 typedef struct IDirect3DDevice2       IDirect3DDevice2, *LPDIRECT3DDEVICE2;
33 typedef struct IDirect3DViewport2     IDirect3DViewport, IDirect3DViewport2, *LPDIRECT3DVIEWPORT2, *LPDIRECT3DVIEWPORT;
34 typedef struct IDirect3DMaterial2     IDirect3DMaterial, *LPDIRECT3DMATERIAL, IDirect3DMaterial2, *LPDIRECT3DMATERIAL2;
35 typedef struct IDirect3DTexture2      IDirect3DTexture, *LPDIRECT3DTEXTURE, IDirect3DTexture2,  *LPDIRECT3DTEXTURE2;
36 typedef struct IDirect3DExecuteBuffer IDirect3DExecuteBuffer, *LPDIRECT3DEXECUTEBUFFER;
37
38 /* ********************************************************************
39    Error Codes
40    ******************************************************************** */
41 #define D3D_OK                          DD_OK
42 #define D3DERR_BADMAJORVERSION          MAKE_DDHRESULT(700)
43 #define D3DERR_BADMINORVERSION          MAKE_DDHRESULT(701)
44 #define D3DERR_INVALID_DEVICE           MAKE_DDHRESULT(705)
45 #define D3DERR_INITFAILED               MAKE_DDHRESULT(706)
46 #define D3DERR_DEVICEAGGREGATED         MAKE_DDHRESULT(707)
47 #define D3DERR_EXECUTE_CREATE_FAILED    MAKE_DDHRESULT(710)
48 #define D3DERR_EXECUTE_DESTROY_FAILED   MAKE_DDHRESULT(711)
49 #define D3DERR_EXECUTE_LOCK_FAILED      MAKE_DDHRESULT(712)
50 #define D3DERR_EXECUTE_UNLOCK_FAILED    MAKE_DDHRESULT(713)
51 #define D3DERR_EXECUTE_LOCKED           MAKE_DDHRESULT(714)
52 #define D3DERR_EXECUTE_NOT_LOCKED       MAKE_DDHRESULT(715)
53 #define D3DERR_EXECUTE_FAILED           MAKE_DDHRESULT(716)
54 #define D3DERR_EXECUTE_CLIPPED_FAILED   MAKE_DDHRESULT(717)
55 #define D3DERR_TEXTURE_NO_SUPPORT       MAKE_DDHRESULT(720)
56 #define D3DERR_TEXTURE_CREATE_FAILED    MAKE_DDHRESULT(721)
57 #define D3DERR_TEXTURE_DESTROY_FAILED   MAKE_DDHRESULT(722)
58 #define D3DERR_TEXTURE_LOCK_FAILED      MAKE_DDHRESULT(723)
59 #define D3DERR_TEXTURE_UNLOCK_FAILED    MAKE_DDHRESULT(724)
60 #define D3DERR_TEXTURE_LOAD_FAILED      MAKE_DDHRESULT(725)
61 #define D3DERR_TEXTURE_SWAP_FAILED      MAKE_DDHRESULT(726)
62 #define D3DERR_TEXTURE_LOCKED           MAKE_DDHRESULT(727)
63 #define D3DERR_TEXTURE_NOT_LOCKED       MAKE_DDHRESULT(728)
64 #define D3DERR_TEXTURE_GETSURF_FAILED   MAKE_DDHRESULT(729)
65 #define D3DERR_MATRIX_CREATE_FAILED     MAKE_DDHRESULT(730)
66 #define D3DERR_MATRIX_DESTROY_FAILED    MAKE_DDHRESULT(731)
67 #define D3DERR_MATRIX_SETDATA_FAILED    MAKE_DDHRESULT(732)
68 #define D3DERR_MATRIX_GETDATA_FAILED    MAKE_DDHRESULT(733)
69 #define D3DERR_SETVIEWPORTDATA_FAILED   MAKE_DDHRESULT(734)
70 #define D3DERR_INVALIDCURRENTVIEWPORT   MAKE_DDHRESULT(735)
71 #define D3DERR_INVALIDPRIMITIVETYPE     MAKE_DDHRESULT(736)
72 #define D3DERR_INVALIDVERTEXTYPE        MAKE_DDHRESULT(737)
73 #define D3DERR_TEXTURE_BADSIZE          MAKE_DDHRESULT(738)
74 #define D3DERR_INVALIDRAMPTEXTURE       MAKE_DDHRESULT(739)
75 #define D3DERR_MATERIAL_CREATE_FAILED   MAKE_DDHRESULT(740)
76 #define D3DERR_MATERIAL_DESTROY_FAILED  MAKE_DDHRESULT(741)
77 #define D3DERR_MATERIAL_SETDATA_FAILED  MAKE_DDHRESULT(742)
78 #define D3DERR_MATERIAL_GETDATA_FAILED  MAKE_DDHRESULT(743)
79 #define D3DERR_INVALIDPALETTE           MAKE_DDHRESULT(744)
80 #define D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY MAKE_DDHRESULT(745)
81 #define D3DERR_ZBUFF_NEEDS_VIDEOMEMORY  MAKE_DDHRESULT(746)
82 #define D3DERR_SURFACENOTINVIDMEM       MAKE_DDHRESULT(747)
83 #define D3DERR_LIGHT_SET_FAILED         MAKE_DDHRESULT(750)
84 #define D3DERR_LIGHTHASVIEWPORT         MAKE_DDHRESULT(751)
85 #define D3DERR_LIGHTNOTINTHISVIEWPORT   MAKE_DDHRESULT(752)
86 #define D3DERR_SCENE_IN_SCENE           MAKE_DDHRESULT(760)
87 #define D3DERR_SCENE_NOT_IN_SCENE       MAKE_DDHRESULT(761)
88 #define D3DERR_SCENE_BEGIN_FAILED       MAKE_DDHRESULT(762)
89 #define D3DERR_SCENE_END_FAILED         MAKE_DDHRESULT(763)
90 #define D3DERR_INBEGIN                  MAKE_DDHRESULT(770)
91 #define D3DERR_NOTINBEGIN               MAKE_DDHRESULT(771)
92 #define D3DERR_NOVIEWPORTS              MAKE_DDHRESULT(772)
93 #define D3DERR_VIEWPORTDATANOTSET       MAKE_DDHRESULT(773)
94 #define D3DERR_VIEWPORTHASNODEVICE      MAKE_DDHRESULT(774)
95 #define D3DERR_NOCURRENTVIEWPORT        MAKE_DDHRESULT(775)
96
97 /* ********************************************************************
98    Enums
99    ******************************************************************** */
100 #define D3DNEXT_NEXT 0x01l
101 #define D3DNEXT_HEAD 0x02l
102 #define D3DNEXT_TAIL 0x04l
103
104 typedef enum {
105   D3DLIGHT_POINT          = 1,
106   D3DLIGHT_SPOT           = 2,
107   D3DLIGHT_DIRECTIONAL    = 3,
108   D3DLIGHT_PARALLELPOINT  = 4,
109   D3DLIGHT_FORCE_DWORD    = 0x7fffffff
110 } D3DLIGHTTYPE;
111
112 typedef enum {
113   D3DPT_POINTLIST     = 1,
114   D3DPT_LINELIST      = 2,
115   D3DPT_LINESTRIP     = 3,
116   D3DPT_TRIANGLELIST  = 4,
117   D3DPT_TRIANGLESTRIP = 5,
118   D3DPT_TRIANGLEFAN   = 6,
119   D3DPT_FORCE_DWORD   = 0x7fffffff
120 } D3DPRIMITIVETYPE;
121
122 typedef enum { 
123   D3DFILL_POINT         = 1, 
124   D3DFILL_WIREFRAME     = 2, 
125   D3DFILL_SOLID         = 3,
126   D3DFILL_FORCE_DWORD   = 0x7fffffff
127 } D3DFILLMODE; 
128
129 typedef enum { 
130   D3DSHADE_FLAT         = 1, 
131   D3DSHADE_GOURAUD      = 2, 
132   D3DSHADE_PHONG        = 3, 
133   D3DSHADE_FORCE_DWORD  = 0x7fffffff
134 } D3DSHADEMODE;
135
136 typedef enum { 
137   D3DCULL_NONE        = 1, 
138   D3DCULL_CW          = 2, 
139   D3DCULL_CCW         = 3, 
140   D3DCULL_FORCE_DWORD = 0x7fffffff 
141 } D3DCULL; 
142
143 typedef enum { 
144   D3DBLEND_ZERO            = 1, 
145   D3DBLEND_ONE             = 2, 
146   D3DBLEND_SRCCOLOR        = 3, 
147   D3DBLEND_INVSRCCOLOR     = 4, 
148   D3DBLEND_SRCALPHA        = 5, 
149   D3DBLEND_INVSRCALPHA     = 6, 
150   D3DBLEND_DESTALPHA       = 7, 
151   D3DBLEND_INVDESTALPHA    = 8, 
152   D3DBLEND_DESTCOLOR       = 9, 
153   D3DBLEND_INVDESTCOLOR    = 10, 
154   D3DBLEND_SRCALPHASAT     = 11, 
155   D3DBLEND_BOTHSRCALPHA    = 12, 
156   D3DBLEND_BOTHINVSRCALPHA = 13, 
157   D3DBLEND_FORCE_DWORD     = 0x7fffffff
158 } D3DBLEND; 
159
160 typedef enum { 
161   D3DTBLEND_DECAL         = 1, 
162   D3DTBLEND_MODULATE      = 2, 
163   D3DTBLEND_DECALALPHA    = 3, 
164   D3DTBLEND_MODULATEALPHA = 4, 
165   D3DTBLEND_DECALMASK     = 5, 
166   D3DTBLEND_MODULATEMASK  = 6, 
167   D3DTBLEND_COPY          = 7, 
168   D3DTBLEND_ADD           = 8, 
169   D3DTBLEND_FORCE_DWORD   = 0x7fffffff
170 } D3DTEXTUREBLEND;
171
172 typedef enum { 
173   D3DFILTER_NEAREST          = 1, 
174   D3DFILTER_LINEAR           = 2, 
175   D3DFILTER_MIPNEAREST       = 3, 
176   D3DFILTER_MIPLINEAR        = 4, 
177   D3DFILTER_LINEARMIPNEAREST = 5, 
178   D3DFILTER_LINEARMIPLINEAR  = 6, 
179   D3DFILTER_FORCE_DWORD      = 0x7fffffff
180 } D3DTEXTUREFILTER;
181
182 typedef enum {
183   D3DRENDERSTATE_TEXTUREHANDLE      = 1,    /* Texture handle */
184   D3DRENDERSTATE_ANTIALIAS          = 2,    /* D3DANTIALIASMODE */
185   D3DRENDERSTATE_TEXTUREADDRESS     = 3,    /* D3DTEXTUREADDRESS      */
186   D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,    /* TRUE for perspective correction */
187   D3DRENDERSTATE_WRAPU              = 5,    /* TRUE for wrapping in u */
188   D3DRENDERSTATE_WRAPV              = 6,    /* TRUE for wrapping in v */
189   D3DRENDERSTATE_ZENABLE            = 7,    /* TRUE to enable z test */
190   D3DRENDERSTATE_FILLMODE           = 8,    /* D3DFILL_MODE            */
191   D3DRENDERSTATE_SHADEMODE          = 9,    /* D3DSHADEMODE */
192   D3DRENDERSTATE_LINEPATTERN        = 10,   /* D3DLINEPATTERN */
193   D3DRENDERSTATE_MONOENABLE         = 11,   /* TRUE to enable mono rasterization */
194   D3DRENDERSTATE_ROP2               = 12,   /* ROP2 */
195   D3DRENDERSTATE_PLANEMASK          = 13,   /* DWORD physical plane mask */
196   D3DRENDERSTATE_ZWRITEENABLE       = 14,   /* TRUE to enable z writes */
197   D3DRENDERSTATE_ALPHATESTENABLE    = 15,   /* TRUE to enable alpha tests */
198   D3DRENDERSTATE_LASTPIXEL          = 16,   /* TRUE for last-pixel on lines */
199   D3DRENDERSTATE_TEXTUREMAG         = 17,   /* D3DTEXTUREFILTER */
200   D3DRENDERSTATE_TEXTUREMIN         = 18,   /* D3DTEXTUREFILTER */
201   D3DRENDERSTATE_SRCBLEND           = 19,   /* D3DBLEND */
202   D3DRENDERSTATE_DESTBLEND          = 20,   /* D3DBLEND */
203   D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,   /* D3DTEXTUREBLEND */
204   D3DRENDERSTATE_CULLMODE           = 22,   /* D3DCULL */
205   D3DRENDERSTATE_ZFUNC              = 23,   /* D3DCMPFUNC */
206   D3DRENDERSTATE_ALPHAREF           = 24,   /* D3DFIXED */
207   D3DRENDERSTATE_ALPHAFUNC          = 25,   /* D3DCMPFUNC */
208   D3DRENDERSTATE_DITHERENABLE       = 26,   /* TRUE to enable dithering */
209   D3DRENDERSTATE_ALPHABLENDENABLE   = 27,   /* TRUE to enable alpha blending */
210   D3DRENDERSTATE_FOGENABLE          = 28,   /* TRUE to enable fog */
211   D3DRENDERSTATE_SPECULARENABLE     = 29,   /* TRUE to enable specular */
212   D3DRENDERSTATE_ZVISIBLE           = 30,   /* TRUE to enable z checking */
213   D3DRENDERSTATE_SUBPIXEL           = 31,   /* TRUE to enable subpixel correction */
214   D3DRENDERSTATE_SUBPIXELX          = 32,   /* TRUE to enable correction in X only */
215   D3DRENDERSTATE_STIPPLEDALPHA      = 33,   /* TRUE to enable stippled alpha */
216   D3DRENDERSTATE_FOGCOLOR           = 34,   /* D3DCOLOR */
217   D3DRENDERSTATE_FOGTABLEMODE       = 35,   /* D3DFOGMODE */
218   D3DRENDERSTATE_FOGTABLESTART      = 36,   /* Fog table start        */
219   D3DRENDERSTATE_FOGTABLEEND        = 37,   /* Fog table end          */
220   D3DRENDERSTATE_FOGTABLEDENSITY    = 38,   /* Fog table density      */
221   D3DRENDERSTATE_STIPPLEENABLE      = 39,   /* TRUE to enable stippling */
222   D3DRENDERSTATE_EDGEANTIALIAS      = 40,   /* TRUE to enable edge antialiasing */
223   D3DRENDERSTATE_COLORKEYENABLE     = 41,   /* TRUE to enable source colorkeyed textures */
224   D3DRENDERSTATE_BORDERCOLOR        = 43,   /* Border color for texturing w/border */
225   D3DRENDERSTATE_TEXTUREADDRESSU    = 44,   /* Texture addressing mode for U coordinate */
226   D3DRENDERSTATE_TEXTUREADDRESSV    = 45,   /* Texture addressing mode for V coordinate */
227   D3DRENDERSTATE_MIPMAPLODBIAS      = 46,   /* D3DVALUE Mipmap LOD bias */
228   D3DRENDERSTATE_ZBIAS              = 47,   /* LONG Z bias */
229   D3DRENDERSTATE_RANGEFOGENABLE     = 48,   /* Enables range-based fog */
230   D3DRENDERSTATE_ANISOTROPY         = 49,   /* Max. anisotropy. 1 = no anisotropy */
231   D3DRENDERSTATE_FLUSHBATCH         = 50,   /* Explicit flush for DP batching (DX5 Only) */
232   D3DRENDERSTATE_STIPPLEPATTERN00   = 64,   /* Stipple pattern 01...  */
233   D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
234   D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
235   D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
236   D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
237   D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
238   D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
239   D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
240   D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
241   D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
242   D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
243   D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
244   D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
245   D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
246   D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
247   D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
248   D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
249   D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
250   D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
251   D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
252   D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
253   D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
254   D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
255   D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
256   D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
257   D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
258   D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
259   D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
260   D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
261   D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
262   D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
263   D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
264   D3DRENDERSTATE_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
265 } D3DRENDERSTATETYPE;
266
267 typedef enum { 
268   D3DCMP_NEVER        = 1, 
269   D3DCMP_LESS         = 2, 
270   D3DCMP_EQUAL        = 3, 
271   D3DCMP_LESSEQUAL    = 4, 
272   D3DCMP_GREATER      = 5, 
273   D3DCMP_NOTEQUAL     = 6, 
274   D3DCMP_GREATEREQUAL = 7, 
275   D3DCMP_ALWAYS       = 8, 
276   D3DCMP_FORCE_DWORD  = 0x7fffffff
277 } D3DCMPFUNC; 
278
279 typedef enum {
280   D3DLIGHTSTATE_MATERIAL      = 1,
281   D3DLIGHTSTATE_AMBIENT       = 2,
282   D3DLIGHTSTATE_COLORMODEL    = 3,
283   D3DLIGHTSTATE_FOGMODE       = 4,
284   D3DLIGHTSTATE_FOGSTART      = 5,
285   D3DLIGHTSTATE_FOGEND        = 6,
286   D3DLIGHTSTATE_FOGDENSITY    = 7,
287   D3DLIGHTSTATE_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
288 } D3DLIGHTSTATETYPE;
289
290 typedef enum {
291   D3DVT_VERTEX        = 1,
292   D3DVT_LVERTEX       = 2,
293   D3DVT_TLVERTEX      = 3,
294   D3DVT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
295 } D3DVERTEXTYPE;
296
297 typedef enum {
298   D3DTRANSFORMSTATE_WORLD           = 1,
299   D3DTRANSFORMSTATE_VIEW            = 2,
300   D3DTRANSFORMSTATE_PROJECTION      = 3,
301   D3DTRANSFORMSTATE_FORCE_DWORD     = 0x7fffffff, /* force 32-bit size enum */
302 } D3DTRANSFORMSTATETYPE;
303
304 /* ********************************************************************
305    Types and structures
306    ******************************************************************** */
307 typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
308 typedef DWORD D3DTEXTUREHANDLE,  *LPD3DTEXTUREHANDLE;
309 typedef DWORD D3DVIEWPORTHANDLE, *LPD3DVIEWPORTHANDLE;
310 typedef DWORD D3DMATRIXHANDLE,   *LPD3DMATRIXHANDLE;
311
312 typedef DWORD D3DCOLOR, *LPD3DCOLOR;
313
314 typedef struct {
315         DWORD   dwSize;
316         DWORD   dwCaps;
317 } D3DTRANSFORMCAPS,*LPD3DTRANSFORMCAPS;
318
319 #define D3DTRANSFORMCAPS_CLIP   0x00000001
320
321 typedef struct {
322         DWORD   dwSize;
323         DWORD   dwCaps;
324         DWORD   dwLightingModel;
325         DWORD   dwNumLights;
326 } D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS;
327
328 #define D3DLIGHTINGMODEL_RGB            0x00000001
329 #define D3DLIGHTINGMODEL_MONO           0x00000002
330
331 #define D3DLIGHTCAPS_POINT              0x00000001
332 #define D3DLIGHTCAPS_SPOT               0x00000002
333 #define D3DLIGHTCAPS_DIRECTIONAL        0x00000004
334 #define D3DLIGHTCAPS_PARALLELPOINT      0x00000008
335
336
337 #define D3DCOLOR_MONO   1
338 #define D3DCOLOR_RGB    2
339
340 typedef DWORD D3DCOLORMODEL;
341
342 typedef struct {
343     DWORD dwSize;
344     DWORD dwMiscCaps;                 /* Capability flags */
345     DWORD dwRasterCaps;
346     DWORD dwZCmpCaps;
347     DWORD dwSrcBlendCaps;
348     DWORD dwDestBlendCaps;
349     DWORD dwAlphaCmpCaps;
350     DWORD dwShadeCaps;
351     DWORD dwTextureCaps;
352     DWORD dwTextureFilterCaps;
353     DWORD dwTextureBlendCaps;
354     DWORD dwTextureAddressCaps;
355     DWORD dwStippleWidth;             /* maximum width and height of */
356     DWORD dwStippleHeight;            /* of supported stipple (up to 32x32) */
357 } D3DPRIMCAPS, *LPD3DPRIMCAPS;
358
359 /* D3DPRIMCAPS.dwMiscCaps */
360 #define D3DPMISCCAPS_MASKPLANES         0x00000001
361 #define D3DPMISCCAPS_MASKZ              0x00000002
362 #define D3DPMISCCAPS_LINEPATTERNREP     0x00000004
363 #define D3DPMISCCAPS_CONFORMANT         0x00000008
364 #define D3DPMISCCAPS_CULLNONE           0x00000010
365 #define D3DPMISCCAPS_CULLCW             0x00000020
366 #define D3DPMISCCAPS_CULLCCW            0x00000040
367
368 /* D3DPRIMCAPS.dwRasterCaps */
369 #define D3DPRASTERCAPS_DITHER                   0x00000001
370 #define D3DPRASTERCAPS_ROP2                     0x00000002
371 #define D3DPRASTERCAPS_XOR                      0x00000004
372 #define D3DPRASTERCAPS_PAT                      0x00000008
373 #define D3DPRASTERCAPS_ZTEST                    0x00000010
374 #define D3DPRASTERCAPS_SUBPIXEL                 0x00000020
375 #define D3DPRASTERCAPS_SUBPIXELX                0x00000040
376 #define D3DPRASTERCAPS_FOGVERTEX                0x00000080
377 #define D3DPRASTERCAPS_FOGTABLE                 0x00000100
378 #define D3DPRASTERCAPS_STIPPLE                  0x00000200
379 #define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT   0x00000400
380 #define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800
381 #define D3DPRASTERCAPS_ANTIALIASEDGES           0x00001000
382 #define D3DPRASTERCAPS_MIPMAPLODBIAS            0x00002000
383 #define D3DPRASTERCAPS_ZBIAS                    0x00004000
384 #define D3DPRASTERCAPS_ZBUFFERLESSHSR           0x00008000
385 #define D3DPRASTERCAPS_FOGRANGE                 0x00010000
386 #define D3DPRASTERCAPS_ANISOTROPY               0x00020000
387
388 /* D3DPRIMCAPS.dwZCmpCaps and dwAlphaCmpCaps */
389 #define D3DPCMPCAPS_NEVER               0x00000001
390 #define D3DPCMPCAPS_LESS                0x00000002
391 #define D3DPCMPCAPS_EQUAL               0x00000004
392 #define D3DPCMPCAPS_LESSEQUAL           0x00000008
393 #define D3DPCMPCAPS_GREATER             0x00000010
394 #define D3DPCMPCAPS_NOTEQUAL            0x00000020
395 #define D3DPCMPCAPS_GREATEREQUAL        0x00000040
396 #define D3DPCMPCAPS_ALWAYS              0x00000080
397
398 /* D3DPRIMCAPS.dwSourceBlendCaps, dwDestBlendCaps */
399 #define D3DPBLENDCAPS_ZERO              0x00000001
400 #define D3DPBLENDCAPS_ONE               0x00000002
401 #define D3DPBLENDCAPS_SRCCOLOR          0x00000004
402 #define D3DPBLENDCAPS_INVSRCCOLOR       0x00000008
403 #define D3DPBLENDCAPS_SRCALPHA          0x00000010
404 #define D3DPBLENDCAPS_INVSRCALPHA       0x00000020
405 #define D3DPBLENDCAPS_DESTALPHA         0x00000040
406 #define D3DPBLENDCAPS_INVDESTALPHA      0x00000080
407 #define D3DPBLENDCAPS_DESTCOLOR         0x00000100
408 #define D3DPBLENDCAPS_INVDESTCOLOR      0x00000200
409 #define D3DPBLENDCAPS_SRCALPHASAT       0x00000400
410 #define D3DPBLENDCAPS_BOTHSRCALPHA      0x00000800
411 #define D3DPBLENDCAPS_BOTHINVSRCALPHA   0x00001000
412
413 /* D3DPRIMCAPS.dwShadeCaps */
414 #define D3DPSHADECAPS_COLORFLATMONO     0x00000001
415 #define D3DPSHADECAPS_COLORFLATRGB      0x00000002
416 #define D3DPSHADECAPS_COLORGOURAUDMONO  0x00000004
417 #define D3DPSHADECAPS_COLORGOURAUDRGB   0x00000008
418 #define D3DPSHADECAPS_COLORPHONGMONO    0x00000010
419 #define D3DPSHADECAPS_COLORPHONGRGB     0x00000020
420
421 #define D3DPSHADECAPS_SPECULARFLATMONO  0x00000040
422 #define D3DPSHADECAPS_SPECULARFLATRGB   0x00000080
423 #define D3DPSHADECAPS_SPECULARGOURAUDMONO       0x00000100
424 #define D3DPSHADECAPS_SPECULARGOURAUDRGB        0x00000200
425 #define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400
426 #define D3DPSHADECAPS_SPECULARPHONGRGB  0x00000800
427
428 #define D3DPSHADECAPS_ALPHAFLATBLEND    0x00001000
429 #define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000
430 #define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000
431 #define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED      0x00008000
432 #define D3DPSHADECAPS_ALPHAPHONGBLEND   0x00010000
433 #define D3DPSHADECAPS_ALPHAPHONGSTIPPLED        0x00020000
434
435 #define D3DPSHADECAPS_FOGFLAT           0x00040000
436 #define D3DPSHADECAPS_FOGGOURAUD        0x00080000
437 #define D3DPSHADECAPS_FOGPHONG          0x00100000
438
439 /* D3DPRIMCAPS.dwTextureCaps */
440 #define D3DPTEXTURECAPS_PERSPECTIVE     0x00000001
441 #define D3DPTEXTURECAPS_POW2            0x00000002
442 #define D3DPTEXTURECAPS_ALPHA           0x00000004
443 #define D3DPTEXTURECAPS_TRANSPARENCY    0x00000008
444 #define D3DPTEXTURECAPS_BORDER          0x00000010
445 #define D3DPTEXTURECAPS_SQUAREONLY      0x00000020
446
447 /* D3DPRIMCAPS.dwTextureFilterCaps */
448 #define D3DPTFILTERCAPS_NEAREST         0x00000001
449 #define D3DPTFILTERCAPS_LINEAR          0x00000002
450 #define D3DPTFILTERCAPS_MIPNEAREST      0x00000004
451 #define D3DPTFILTERCAPS_MIPLINEAR       0x00000008
452 #define D3DPTFILTERCAPS_LINEARMIPNEAREST        0x00000010
453 #define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020
454
455 /* D3DPRIMCAPS.dwTextureBlendCaps */
456 #define D3DPTBLENDCAPS_DECAL            0x00000001
457 #define D3DPTBLENDCAPS_MODULATE         0x00000002
458 #define D3DPTBLENDCAPS_DECALALPHA       0x00000004
459 #define D3DPTBLENDCAPS_MODULATEALPHA    0x00000008
460 #define D3DPTBLENDCAPS_DECALMASK        0x00000010
461 #define D3DPTBLENDCAPS_MODULATEMASK     0x00000020
462 #define D3DPTBLENDCAPS_COPY             0x00000040
463 #define D3DPTBLENDCAPS_ADD              0x00000080
464
465 /* D3DPRIMCAPS.dwTextureAddressCaps */
466 #define D3DPTADDRESSCAPS_WRAP           0x00000001
467 #define D3DPTADDRESSCAPS_MIRROR         0x00000002
468 #define D3DPTADDRESSCAPS_CLAMP          0x00000004
469 #define D3DPTADDRESSCAPS_BORDER         0x00000008
470 #define D3DPTADDRESSCAPS_INDEPENDENTUV  0x00000010
471
472
473 /* D3DDEVICEDESC.dwFlags */
474 #define D3DDD_COLORMODEL                0x00000001
475 #define D3DDD_DEVCAPS                   0x00000002
476 #define D3DDD_TRANSFORMCAPS             0x00000004
477 #define D3DDD_LIGHTINGCAPS              0x00000008
478 #define D3DDD_BCLIPPING                 0x00000010
479 #define D3DDD_LINECAPS                  0x00000020
480 #define D3DDD_TRICAPS                   0x00000040
481 #define D3DDD_DEVICERENDERBITDEPTH      0x00000080
482 #define D3DDD_DEVICEZBUFFERBITDEPTH     0x00000100
483 #define D3DDD_MAXBUFFERSIZE             0x00000200
484 #define D3DDD_MAXVERTEXCOUNT            0x00000400
485
486 /* D3DDEVICEDESC.dwDevCaps */
487 #define D3DDEVCAPS_FLOATTLVERTEX        0x00000001
488 #define D3DDEVCAPS_SORTINCREASINGZ      0x00000002
489 #define D3DDEVCAPS_SORTDECREASINGZ      0X00000004
490 #define D3DDEVCAPS_SORTEXACT            0x00000008
491 #define D3DDEVCAPS_EXECUTESYSTEMMEMORY  0x00000010
492 #define D3DDEVCAPS_EXECUTEVIDEOMEMORY   0x00000020
493 #define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040
494 #define D3DDEVCAPS_TLVERTEXVIDEOMEMORY  0x00000080
495 #define D3DDEVCAPS_TEXTURESYSTEMMEMORY  0x00000100
496 #define D3DDEVCAPS_TEXTUREVIDEOMEMORY   0x00000200
497 #define D3DDEVCAPS_DRAWPRIMTLVERTEX     0x00000400
498 #define D3DDEVCAPS_CANRENDERAFTERFLIP   0x00000800
499 #define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000
500
501 typedef struct _D3DDeviceDesc {
502         DWORD           dwSize;
503         DWORD           dwFlags;
504         D3DCOLORMODEL   dcmColorModel;
505         DWORD           dwDevCaps;
506         D3DTRANSFORMCAPS dtcTransformCaps;
507         BOOL            bClipping;
508         D3DLIGHTINGCAPS dlcLightingCaps;
509         D3DPRIMCAPS     dpcLineCaps;
510         D3DPRIMCAPS     dpcTriCaps;
511         DWORD           dwDeviceRenderBitDepth;
512         DWORD           dwDeviceZBufferBitDepth;
513         DWORD           dwMaxBufferSize;
514         DWORD           dwMaxVertexCount;
515         /* *** New fields for DX5 *** */
516         DWORD           dwMinTextureWidth,dwMinTextureHeight;
517         DWORD           dwMaxTextureWidth,dwMaxTextureHeight;
518         DWORD           dwMinStippleWidth,dwMaxStippleWidth;
519         DWORD           dwMinStippleHeight,dwMaxStippleHeight;
520 } D3DDEVICEDESC,*LPD3DDEVICEDESC;
521  
522 typedef HRESULT (CALLBACK * LPD3DENUMDEVICESCALLBACK)(LPGUID lpGuid,LPSTR lpDeviceDescription,LPSTR lpDeviceName,LPD3DDEVICEDESC,LPD3DDEVICEDESC,LPVOID);
523 typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
524
525
526 /* dwflags for FindDevice */
527 #define D3DFDS_COLORMODEL               0x00000001
528 #define D3DFDS_GUID                     0x00000002
529 #define D3DFDS_HARDWARE                 0x00000004
530 #define D3DFDS_TRIANGLES                0x00000008
531 #define D3DFDS_LINES                    0x00000010
532 #define D3DFDS_MISCCAPS                 0x00000020
533 #define D3DFDS_RASTERCAPS               0x00000040
534 #define D3DFDS_ZCMPCAPS                 0x00000080
535 #define D3DFDS_ALPHACMPCAPS             0x00000100
536 #define D3DFDS_DSTBLENDCAPS             0x00000400
537 #define D3DFDS_SHADECAPS                0x00000800
538 #define D3DFDS_TEXTURECAPS              0x00001000
539 #define D3DFDS_TEXTUREFILTERCAPS        0x00002000
540 #define D3DFDS_TEXTUREBLENDCAPS         0x00004000
541 #define D3DFDS_TEXTUREADDRESSCAPS       0x00008000
542
543 typedef struct {
544     DWORD               dwSize;
545     DWORD               dwFlags;
546     BOOL                bHardware;
547     D3DCOLORMODEL       dcmColorModel;
548     GUID                guid;
549     DWORD               dwCaps;
550     D3DPRIMCAPS         dpcPrimCaps;
551 } D3DFINDDEVICESEARCH,*LPD3DFINDDEVICESEARCH;
552
553 typedef struct {
554     DWORD               dwSize;
555     GUID                guid;
556     D3DDEVICEDESC       ddHwDesc;
557     D3DDEVICEDESC       ddSwDesc;
558 } D3DFINDDEVICERESULT,*LPD3DFINDDEVICERESULT;
559
560 #define D3DVALP(val, prec)      ((float)(val))
561 #define D3DVAL(val)             ((float)(val))
562 typedef float D3DVALUE,*LPD3DVALUE;
563 #define D3DDivide(a, b)         (float)((double) (a) / (double) (b))
564 #define D3DMultiply(a, b)       ((a) * (b))
565
566 typedef struct {
567   DWORD         dwFlags;        /* Homogeneous clipping flags */
568         union {
569     D3DVALUE    hx;
570     D3DVALUE    dvHX;
571   } x;
572   union {
573     D3DVALUE    hy;
574     D3DVALUE    dvHY;
575   } y;
576   union {
577     D3DVALUE    hz;
578     D3DVALUE    dvHZ;
579   } z;
580 } D3DHVERTEX, *LPD3DHVERTEX;
581 /*
582  * Transformed/lit vertices
583  */
584 typedef struct {
585   union {
586     D3DVALUE    sx;             /* Screen coordinates */
587     D3DVALUE    dvSX;
588   } x;
589   union {
590     D3DVALUE    sy;
591     D3DVALUE    dvSY;
592   } y;
593   union {
594     D3DVALUE    sz;
595     D3DVALUE    dvSZ;
596   } z;
597   union {
598     D3DVALUE    rhw;            /* Reciprocal of homogeneous w */
599     D3DVALUE    dvRHW;
600   } r;
601   union {
602     D3DCOLOR    color;          /* Vertex color */
603     D3DCOLOR    dcColor;
604   } c;
605   union {
606     D3DCOLOR    specular;       /* Specular component of vertex */
607     D3DCOLOR    dcSpecular;
608   } s;
609   union {
610     D3DVALUE    tu;             /* Texture coordinates */
611     D3DVALUE    dvTU;
612   } u;
613   union {
614     D3DVALUE    tv;
615     D3DVALUE    dvTV;
616   } v;
617 } D3DTLVERTEX, *LPD3DTLVERTEX;
618 typedef struct {
619   union {
620     D3DVALUE     x;             /* Homogeneous coordinates */
621                 D3DVALUE dvX;
622         } x;
623         union {
624                 D3DVALUE y;
625                 D3DVALUE dvY;
626         } y;
627         union {
628                 D3DVALUE z;
629                 D3DVALUE dvZ;
630         } z;
631   DWORD            dwReserved;
632   union {
633     D3DCOLOR     color;         /* Vertex color */
634     D3DCOLOR     dcColor;
635   } c;
636   union {
637     D3DCOLOR     specular;      /* Specular component of vertex */
638     D3DCOLOR     dcSpecular;
639   } s;
640   union {
641     D3DVALUE     tu;            /* Texture coordinates */
642     D3DVALUE     dvTU;
643   } u;
644   union {
645     D3DVALUE     tv;
646     D3DVALUE     dvTV;
647   } v;
648 } D3DLVERTEX, *LPD3DLVERTEX;
649 typedef struct {
650   union {
651     D3DVALUE     x;             /* Homogeneous coordinates */
652     D3DVALUE     dvX;
653   } x;
654   union {
655     D3DVALUE     y;
656     D3DVALUE     dvY;
657   } y;
658   union {
659     D3DVALUE     z;
660     D3DVALUE     dvZ;
661   } z;
662   union {
663     D3DVALUE     nx;            /* Normal */
664     D3DVALUE     dvNX;
665   } nx;
666   union {
667     D3DVALUE     ny;
668     D3DVALUE     dvNY;
669   } ny;
670   union {
671     D3DVALUE     nz;
672     D3DVALUE     dvNZ;
673   } nz;
674   union {
675     D3DVALUE     tu;            /* Texture coordinates */
676     D3DVALUE     dvTU;
677   } u;
678   union {
679     D3DVALUE     tv;
680     D3DVALUE     dvTV;
681   } v;
682 } D3DVERTEX, *LPD3DVERTEX;
683
684 typedef struct {
685   union {
686     LONG x1;
687     LONG lX1;
688   } x1;
689   union {
690     LONG y1;
691     LONG lY1;
692   } y1;
693   union {
694     LONG x2;
695     LONG lX2;
696   } x2;
697   union {
698     LONG y2;
699     LONG lY2;
700   } y2;
701 } D3DRECT, *LPD3DRECT;
702
703 typedef struct {
704   union {
705         D3DVALUE        x;
706     D3DVALUE dvX;
707   } x;
708   union {
709         D3DVALUE        y;
710     D3DVALUE dvY;
711   } y;
712   union {
713         D3DVALUE        z;
714     D3DVALUE dvZ;
715   } z;
716   /* the c++ variant has operator overloads etc. too */
717 } D3DVECTOR,*LPD3DVECTOR;
718
719 typedef struct {
720   D3DVALUE        _11, _12, _13, _14;
721   D3DVALUE        _21, _22, _23, _24;
722   D3DVALUE        _31, _32, _33, _34;
723   D3DVALUE        _41, _42, _43, _44;
724 } D3DMATRIX, *LPD3DMATRIX;
725
726 typedef struct _D3DCOLORVALUE {
727         union {
728                 D3DVALUE r;
729                 D3DVALUE dvR;
730         } r;
731         union {
732                 D3DVALUE g;
733                 D3DVALUE dvG;
734         } g;
735         union {
736                 D3DVALUE b;
737                 D3DVALUE dvB;
738         } b;
739         union {
740                 D3DVALUE a;
741                 D3DVALUE dvA;
742         } a;
743 } D3DCOLORVALUE,*LPD3DCOLORVALUE;
744
745 typedef struct {
746     DWORD           dwSize;
747     D3DLIGHTTYPE    dltType;
748     D3DCOLORVALUE   dcvColor;
749     D3DVECTOR       dvPosition;         /* Position in world space */
750     D3DVECTOR       dvDirection;        /* Direction in world space */
751     D3DVALUE        dvRange;            /* Cutoff range */
752     D3DVALUE        dvFalloff;          /* Falloff */
753     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
754     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
755     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
756     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
757     D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
758 } D3DLIGHT,*LPD3DLIGHT;
759
760 /* flags bits */
761 #define D3DLIGHT_ACTIVE         0x00000001
762 #define D3DLIGHT_NO_SPECULAR    0x00000002
763
764 /* Textures */
765 typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
766
767
768 /* Statistics structure */
769 typedef struct {
770   DWORD        dwSize;
771   DWORD        dwTrianglesDrawn;
772   DWORD        dwLinesDrawn;
773   DWORD        dwPointsDrawn;
774   DWORD        dwSpansDrawn;
775   DWORD        dwVerticesProcessed;
776 } D3DSTATS, *LPD3DSTATS;
777
778 /* Clipping */
779 typedef struct _D3DCLIPSTATUS {
780   DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
781   DWORD dwStatus; /* Clip status */
782   float minx, maxx; /* X extents */
783   float miny, maxy; /* Y extents */
784   float minz, maxz; /* Z extents */
785 } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
786
787 typedef struct {
788   DWORD               dwSize;
789   union {
790     D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
791     D3DCOLORVALUE   dcvDiffuse;
792   } a;
793   union {
794     D3DCOLORVALUE   ambient;        /* Ambient color RGB */
795     D3DCOLORVALUE   dcvAmbient;
796   } b;
797   union {
798     D3DCOLORVALUE   specular;       /* Specular 'shininess' */
799     D3DCOLORVALUE   dcvSpecular;
800   } c;
801   union {
802     D3DCOLORVALUE   emissive;       /* Emissive color RGB */
803     D3DCOLORVALUE   dcvEmissive;
804   } d;
805   union {
806     D3DVALUE        power;          /* Sharpness if specular highlight */
807     D3DVALUE        dvPower;
808   } e;
809   D3DTEXTUREHANDLE    hTexture;       /* Handle to texture map */
810   DWORD               dwRampSize;
811 } D3DMATERIAL, *LPD3DMATERIAL;
812
813 typedef struct {
814   D3DVECTOR dvPosition;  /* Lightable point in model space */
815   D3DVECTOR dvNormal;    /* Normalised unit vector */
816 } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
817
818 typedef struct {
819   DWORD       dwSize;
820   DWORD       dwX;
821   DWORD       dwY;            /* Top left */
822   DWORD       dwWidth;
823   DWORD       dwHeight;       /* Dimensions */
824   D3DVALUE    dvScaleX;       /* Scale homogeneous to screen */
825   D3DVALUE    dvScaleY;       /* Scale homogeneous to screen */
826   D3DVALUE    dvMaxX;         /* Min/max homogeneous x coord */
827   D3DVALUE    dvMaxY;         /* Min/max homogeneous y coord */
828   D3DVALUE    dvMinZ;
829   D3DVALUE    dvMaxZ;         /* Min/max homogeneous z coord */
830 } D3DVIEWPORT, *LPD3DVIEWPORT;
831
832 typedef struct {
833   DWORD       dwSize;
834   DWORD       dwX;
835   DWORD       dwY;            /* Viewport Top left */
836   DWORD       dwWidth;
837   DWORD       dwHeight;       /* Viewport Dimensions */
838   D3DVALUE    dvClipX;        /* Top left of clip volume */
839   D3DVALUE    dvClipY;
840   D3DVALUE    dvClipWidth;    /* Clip Volume Dimensions */
841   D3DVALUE    dvClipHeight;
842   D3DVALUE    dvMinZ;         /* Min/max of clip Volume */
843   D3DVALUE    dvMaxZ;
844 } D3DVIEWPORT2, *LPD3DVIEWPORT2;
845
846 #define D3DTRANSFORM_CLIPPED       0x00000001l
847 #define D3DTRANSFORM_UNCLIPPED     0x00000002l
848
849 typedef struct {
850   DWORD           dwSize;
851   LPVOID          lpIn;           /* Input vertices */
852   DWORD           dwInSize;       /* Stride of input vertices */
853   LPVOID          lpOut;          /* Output vertices */
854   DWORD           dwOutSize;      /* Stride of output vertices */
855   LPD3DHVERTEX    lpHOut;         /* Output homogeneous vertices */
856   DWORD           dwClip;         /* Clipping hint */
857   DWORD           dwClipIntersection;
858   DWORD           dwClipUnion;    /* Union of all clip flags */
859   D3DRECT         drExtent;       /* Extent of transformed vertices */
860 } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
861
862 /* flags bits */
863 #define D3DLIGHT_ACTIVE         0x00000001
864 #define D3DLIGHT_NO_SPECULAR    0x00000002
865
866 /* maximum valid light range */
867 #define D3DLIGHT_RANGE_MAX              ((float)sqrt(FLT_MAX))
868
869 typedef struct _D3DLIGHT2 {
870   DWORD           dwSize;
871   D3DLIGHTTYPE    dltType;            /* Type of light source */
872   D3DCOLORVALUE   dcvColor;           /* Color of light */
873   D3DVECTOR       dvPosition;         /* Position in world space */
874   D3DVECTOR       dvDirection;        /* Direction in world space */
875   D3DVALUE        dvRange;            /* Cutoff range */
876   D3DVALUE        dvFalloff;          /* Falloff */
877   D3DVALUE        dvAttenuation0;     /* Constant attenuation */
878   D3DVALUE        dvAttenuation1;     /* Linear attenuation */
879   D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
880   D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
881   D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
882   DWORD           dwFlags;
883 } D3DLIGHT2, *LPD3DLIGHT2;
884
885 typedef struct _D3DLIGHTDATA {
886   DWORD                dwSize;
887   LPD3DLIGHTINGELEMENT lpIn;          /* Input positions and normals */
888   DWORD                dwInSize;      /* Stride of input elements */
889   LPD3DTLVERTEX        lpOut;         /* Output colors */
890   DWORD                dwOutSize;     /* Stride of output colors */
891 } D3DLIGHTDATA, *LPD3DLIGHTDATA;
892
893 typedef struct _D3DPICKRECORD {
894   BYTE     bOpcode;
895   BYTE     bPad;
896   DWORD    dwOffset;
897   D3DVALUE dvZ;
898 } D3DPICKRECORD, *LPD3DPICKRECORD;
899
900
901 typedef struct _D3DExecuteBufferDesc { 
902   DWORD  dwSize; 
903   DWORD  dwFlags; 
904   DWORD  dwCaps; 
905   DWORD  dwBufferSize; 
906   LPVOID lpData; 
907 } D3DEXECUTEBUFFERDESC; 
908 typedef D3DEXECUTEBUFFERDESC *LPD3DEXECUTEBUFFERDESC; 
909
910 #define D3DDEB_BUFSIZE          0x00000001l     /* buffer size valid */
911 #define D3DDEB_CAPS             0x00000002l     /* caps valid */
912 #define D3DDEB_LPDATA           0x00000004l     /* lpData valid */
913
914 #define D3DDEBCAPS_SYSTEMMEMORY 0x00000001l     /* buffer in system memory */
915 #define D3DDEBCAPS_VIDEOMEMORY  0x00000002l     /* buffer in device memory */
916 #define D3DDEBCAPS_MEM (D3DDEBCAPS_SYSTEMMEMORY|D3DDEBCAPS_VIDEOMEMORY)
917
918 /*
919  * Values for d3d status.
920  */
921 #define D3DSTATUS_CLIPUNIONLEFT                 D3DCLIP_LEFT
922 #define D3DSTATUS_CLIPUNIONRIGHT                D3DCLIP_RIGHT
923 #define D3DSTATUS_CLIPUNIONTOP                  D3DCLIP_TOP
924 #define D3DSTATUS_CLIPUNIONBOTTOM               D3DCLIP_BOTTOM
925 #define D3DSTATUS_CLIPUNIONFRONT                D3DCLIP_FRONT
926 #define D3DSTATUS_CLIPUNIONBACK                 D3DCLIP_BACK
927 #define D3DSTATUS_CLIPUNIONGEN0                 D3DCLIP_GEN0
928 #define D3DSTATUS_CLIPUNIONGEN1                 D3DCLIP_GEN1
929 #define D3DSTATUS_CLIPUNIONGEN2                 D3DCLIP_GEN2
930 #define D3DSTATUS_CLIPUNIONGEN3                 D3DCLIP_GEN3
931 #define D3DSTATUS_CLIPUNIONGEN4                 D3DCLIP_GEN4
932 #define D3DSTATUS_CLIPUNIONGEN5                 D3DCLIP_GEN5
933
934 #define D3DSTATUS_CLIPINTERSECTIONLEFT          0x00001000L
935 #define D3DSTATUS_CLIPINTERSECTIONRIGHT         0x00002000L
936 #define D3DSTATUS_CLIPINTERSECTIONTOP           0x00004000L
937 #define D3DSTATUS_CLIPINTERSECTIONBOTTOM        0x00008000L
938 #define D3DSTATUS_CLIPINTERSECTIONFRONT         0x00010000L
939 #define D3DSTATUS_CLIPINTERSECTIONBACK          0x00020000L
940 #define D3DSTATUS_CLIPINTERSECTIONGEN0          0x00040000L
941 #define D3DSTATUS_CLIPINTERSECTIONGEN1          0x00080000L
942 #define D3DSTATUS_CLIPINTERSECTIONGEN2          0x00100000L
943 #define D3DSTATUS_CLIPINTERSECTIONGEN3          0x00200000L
944 #define D3DSTATUS_CLIPINTERSECTIONGEN4          0x00400000L
945 #define D3DSTATUS_CLIPINTERSECTIONGEN5          0x00800000L
946 #define D3DSTATUS_ZNOTVISIBLE                   0x01000000L
947
948 #define D3DSTATUS_CLIPUNIONALL  (               \
949             D3DSTATUS_CLIPUNIONLEFT     |       \
950             D3DSTATUS_CLIPUNIONRIGHT    |       \
951             D3DSTATUS_CLIPUNIONTOP      |       \
952             D3DSTATUS_CLIPUNIONBOTTOM   |       \
953             D3DSTATUS_CLIPUNIONFRONT    |       \
954             D3DSTATUS_CLIPUNIONBACK     |       \
955             D3DSTATUS_CLIPUNIONGEN0     |       \
956             D3DSTATUS_CLIPUNIONGEN1     |       \
957             D3DSTATUS_CLIPUNIONGEN2     |       \
958             D3DSTATUS_CLIPUNIONGEN3     |       \
959             D3DSTATUS_CLIPUNIONGEN4     |       \
960             D3DSTATUS_CLIPUNIONGEN5             \
961             )
962
963 #define D3DSTATUS_CLIPINTERSECTIONALL   (               \
964             D3DSTATUS_CLIPINTERSECTIONLEFT      |       \
965             D3DSTATUS_CLIPINTERSECTIONRIGHT     |       \
966             D3DSTATUS_CLIPINTERSECTIONTOP       |       \
967             D3DSTATUS_CLIPINTERSECTIONBOTTOM    |       \
968             D3DSTATUS_CLIPINTERSECTIONFRONT     |       \
969             D3DSTATUS_CLIPINTERSECTIONBACK      |       \
970             D3DSTATUS_CLIPINTERSECTIONGEN0      |       \
971             D3DSTATUS_CLIPINTERSECTIONGEN1      |       \
972             D3DSTATUS_CLIPINTERSECTIONGEN2      |       \
973             D3DSTATUS_CLIPINTERSECTIONGEN3      |       \
974             D3DSTATUS_CLIPINTERSECTIONGEN4      |       \
975             D3DSTATUS_CLIPINTERSECTIONGEN5              \
976             )
977
978 #define D3DSTATUS_DEFAULT       (                       \
979             D3DSTATUS_CLIPINTERSECTIONALL       |       \
980             D3DSTATUS_ZNOTVISIBLE)
981
982
983 typedef struct _D3DSTATUS { 
984   DWORD   dwFlags; 
985   DWORD   dwStatus; 
986   D3DRECT drExtent; 
987 } D3DSTATUS, *LPD3DSTATUS; 
988  
989
990 typedef struct _D3DEXECUTEDATA { 
991   DWORD     dwSize; 
992   DWORD     dwVertexOffset; 
993   DWORD     dwVertexCount; 
994   DWORD     dwInstructionOffset; 
995   DWORD     dwInstructionLength; 
996   DWORD     dwHVertexOffset; 
997   D3DSTATUS dsStatus; 
998 } D3DEXECUTEDATA, *LPD3DEXECUTEDATA; 
999
1000 typedef enum _D3DOPCODE { 
1001   D3DOP_POINT           = 1, 
1002   D3DOP_LINE            = 2, 
1003   D3DOP_TRIANGLE        = 3, 
1004   D3DOP_MATRIXLOAD      = 4, 
1005   D3DOP_MATRIXMULTIPLY  = 5, 
1006   D3DOP_STATETRANSFORM  = 6, 
1007   D3DOP_STATELIGHT      = 7, 
1008   D3DOP_STATERENDER     = 8, 
1009   D3DOP_PROCESSVERTICES = 9, 
1010   D3DOP_TEXTURELOAD     = 10, 
1011   D3DOP_EXIT            = 11, 
1012   D3DOP_BRANCHFORWARD   = 12, 
1013   D3DOP_SPAN            = 13, 
1014   D3DOP_SETSTATUS       = 14, 
1015   
1016   D3DOP_FORCE_DWORD     = 0x7fffffff, 
1017 } D3DOPCODE; 
1018
1019 typedef struct _D3DPOINT { 
1020   WORD wCount; 
1021   WORD wFirst; 
1022 } D3DPOINT, *LPD3DPOINT; 
1023
1024 typedef struct _D3DLINE { 
1025   union { 
1026     WORD v1; 
1027     WORD wV1; 
1028   } v1; 
1029   union { 
1030     WORD v2; 
1031     WORD wV2; 
1032   } v2; 
1033 } D3DLINE, *LPD3DLINE; 
1034
1035 #define D3DTRIFLAG_START                        0x00000000L
1036 #define D3DTRIFLAG_STARTFLAT(len) (len)         /* 0 < len < 30 */
1037 #define D3DTRIFLAG_ODD                          0x0000001eL
1038 #define D3DTRIFLAG_EVEN                         0x0000001fL
1039
1040 #define D3DTRIFLAG_EDGEENABLE1                  0x00000100L /* v0-v1 edge */
1041 #define D3DTRIFLAG_EDGEENABLE2                  0x00000200L /* v1-v2 edge */
1042 #define D3DTRIFLAG_EDGEENABLE3                  0x00000400L /* v2-v0 edge */
1043 #define D3DTRIFLAG_EDGEENABLETRIANGLE \
1044         (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
1045
1046 typedef struct _D3DTRIANGLE { 
1047   union { 
1048     WORD v1; 
1049     WORD wV1; 
1050   } v1; 
1051   union { 
1052     WORD v2; 
1053     WORD wV2; 
1054   } v2; 
1055   union { 
1056     WORD v3; 
1057     WORD wV3; 
1058   } v3; 
1059   WORD     wFlags; 
1060 } D3DTRIANGLE, *LPD3DTRIANGLE; 
1061
1062 typedef struct _D3DMATRIXLOAD { 
1063   D3DMATRIXHANDLE hDestMatrix; 
1064   D3DMATRIXHANDLE hSrcMatrix; 
1065 } D3DMATRIXLOAD, *LPD3DMATRIXLOAD; 
1066
1067 typedef struct _D3DMATRIXMULTIPLY { 
1068   D3DMATRIXHANDLE hDestMatrix; 
1069   D3DMATRIXHANDLE hSrcMatrix1; 
1070   D3DMATRIXHANDLE hSrcMatrix2; 
1071 } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY; 
1072
1073 typedef struct _D3DSTATE { 
1074   union { 
1075     D3DTRANSFORMSTATETYPE dtstTransformStateType; 
1076     D3DLIGHTSTATETYPE     dlstLightStateType; 
1077     D3DRENDERSTATETYPE    drstRenderStateType; 
1078   } t; 
1079   union { 
1080     DWORD                 dwArg[1]; 
1081     D3DVALUE              dvArg[1]; 
1082   } v; 
1083 } D3DSTATE, *LPD3DSTATE; 
1084
1085 #define D3DPROCESSVERTICES_TRANSFORMLIGHT       0x00000000L
1086 #define D3DPROCESSVERTICES_TRANSFORM            0x00000001L
1087 #define D3DPROCESSVERTICES_COPY                 0x00000002L
1088 #define D3DPROCESSVERTICES_OPMASK               0x00000007L
1089
1090 #define D3DPROCESSVERTICES_UPDATEEXTENTS        0x00000008L
1091 #define D3DPROCESSVERTICES_NOCOLOR              0x00000010L
1092
1093 typedef struct _D3DPROCESSVERTICES { 
1094   DWORD dwFlags; 
1095   WORD  wStart; 
1096   WORD  wDest; 
1097   DWORD dwCount; 
1098   DWORD dwReserved; 
1099 } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES; 
1100
1101 typedef struct _D3DTEXTURELOAD { 
1102   D3DTEXTUREHANDLE hDestTexture; 
1103   D3DTEXTUREHANDLE hSrcTexture; 
1104 } D3DTEXTURELOAD, *LPD3DTEXTURELOAD; 
1105
1106 typedef struct _D3DBRANCH { 
1107   DWORD dwMask; 
1108   DWORD dwValue; 
1109   BOOL  bNegate; 
1110   DWORD dwOffset; 
1111 } D3DBRANCH, *LPD3DBRANCH; 
1112
1113 typedef struct _D3DSPAN { 
1114   WORD wCount; 
1115   WORD wFirst; 
1116 } D3DSPAN, *LPD3DSPAN; 
1117
1118 typedef struct _D3DINSTRUCTION { 
1119   BYTE bOpcode; 
1120   BYTE bSize; 
1121   WORD wCount; 
1122 } D3DINSTRUCTION, *LPD3DINSTRUCTION; 
1123
1124
1125 /* ********************************************************************
1126    Direct3D
1127    ******************************************************************** */
1128 #define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
1129 #define STDMETHOD_(ret,xfn) ret (CALLBACK *fn##xfn)
1130 #define PURE
1131 #define FAR
1132 #define THIS_ THIS ,
1133
1134 #define THIS LPDIRECT3D this
1135 typedef struct IDirect3D_VTable {
1136         /*** IUnknown methods ***/
1137         STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1138         STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1139         STDMETHOD_(ULONG, Release) (THIS) PURE;
1140         /*** IDirect3D methods ***/
1141         STDMETHOD(Initialize) (THIS_ REFIID) PURE;
1142         STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK, LPVOID) PURE;
1143         STDMETHOD(CreateLight) (THIS_ LPDIRECT3DLIGHT*, IUnknown*) PURE;
1144         STDMETHOD(CreateMaterial) (THIS_ LPDIRECT3DMATERIAL*, IUnknown*) PURE;
1145         STDMETHOD(CreateViewport) (THIS_ LPDIRECT3DVIEWPORT*, IUnknown*) PURE;
1146         STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT) PURE;
1147 } *LPDIRECT3D_VTABLE,IDirect3D_VTable;
1148
1149 struct IDirect3D {
1150         LPDIRECT3D_VTABLE       lpvtbl;
1151         DWORD                   ref;
1152         LPDIRECTDRAW            ddraw;
1153 };
1154 #undef THIS
1155
1156 /* ********************************************************************
1157    Direct3D2
1158    ******************************************************************** */
1159 #define THIS LPDIRECT3D2 this
1160 typedef struct IDirect3D2_VTable {
1161         /*** IUnknown methods ***/
1162         STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1163         STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1164         STDMETHOD_(ULONG, Release) (THIS) PURE;
1165         /*** IDirect3D2 methods ***/
1166         STDMETHOD(EnumDevices)(THIS_ LPD3DENUMDEVICESCALLBACK, LPVOID) PURE;
1167         STDMETHOD(CreateLight) (THIS_ LPDIRECT3DLIGHT*, IUnknown*) PURE;
1168         STDMETHOD(CreateMaterial) (THIS_ LPDIRECT3DMATERIAL2*, IUnknown*) PURE;
1169         STDMETHOD(CreateViewport) (THIS_ LPDIRECT3DVIEWPORT2*, IUnknown*) PURE;
1170         STDMETHOD(FindDevice)(THIS_ LPD3DFINDDEVICESEARCH, LPD3DFINDDEVICERESULT) PURE;
1171         STDMETHOD(CreateDevice)(THIS_ REFCLSID, LPDIRECTDRAWSURFACE, LPDIRECT3DDEVICE2 *) PURE;
1172 } *LPDIRECT3D2_VTABLE,IDirect3D2_VTable;
1173
1174 struct IDirect3D2 {
1175         LPDIRECT3D2_VTABLE      lpvtbl;
1176         DWORD                   ref;
1177         LPDIRECTDRAW            ddraw;
1178 };
1179 #undef THIS
1180
1181 /* ********************************************************************
1182    Direct3DLight
1183    ******************************************************************** */
1184 #define THIS LPDIRECT3DLIGHT this
1185 typedef struct IDirect3DLight_VTable {
1186         /*** IUnknown methods ***/
1187         STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1188         STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1189         STDMETHOD_(ULONG, Release) (THIS) PURE;
1190         /*** IDirect3DLight methods ***/
1191         STDMETHOD(Initialize) (THIS_ LPDIRECT3D) PURE;
1192         STDMETHOD(SetLight) (THIS_ LPD3DLIGHT) PURE;
1193         STDMETHOD(GetLight) (THIS_ LPD3DLIGHT) PURE;
1194 } IDirect3DLight_VTable,*LPDIRECT3DLIGHT_VTABLE;
1195
1196 struct IDirect3DLight {
1197         LPDIRECT3DLIGHT_VTABLE  lpvtbl;
1198         DWORD                   ref;
1199
1200   union {
1201     LPDIRECT3D            d3d;
1202     LPDIRECT3D2           d3d2;
1203   } d3d;
1204   int type;
1205   
1206   D3DLIGHT2               light;
1207
1208   /* Chained list used for adding / removing from viewports */
1209   LPDIRECT3DLIGHT next, prev;
1210
1211   /* Activation function */
1212   void (*activate)(THIS);
1213   int is_active;
1214   
1215   /* Awful OpenGL code !!! */
1216 #ifdef HAVE_MESAGL
1217   GLenum light_num;
1218 #endif
1219 };
1220
1221 #undef THIS
1222
1223 /* ********************************************************************
1224    Direct3DMaterial
1225    ******************************************************************** */
1226 #define THIS LPDIRECT3DMATERIAL this
1227 typedef struct IDirect3DMaterial_VTable {
1228   /*** IUnknown methods ***/
1229   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1230   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1231   STDMETHOD_(ULONG, Release) (THIS) PURE;
1232   /*** IDirect3DMaterial2 methods ***/
1233   STDMETHOD(Initialize) (THIS_ LPDIRECT3D) PURE;
1234   STDMETHOD(SetMaterial) (THIS_ LPD3DMATERIAL) PURE;
1235   STDMETHOD(GetMaterial) (THIS_ LPD3DMATERIAL) PURE;
1236   STDMETHOD(GetHandle) (THIS_ LPDIRECT3DDEVICE2, LPD3DMATERIALHANDLE) PURE;
1237   STDMETHOD_(HRESULT, Reserve) (THIS) PURE;
1238   STDMETHOD_(HRESULT, Unreserve) (THIS) PURE;
1239 } IDirect3DMaterial_VTable,*LPDIRECT3DMATERIAL_VTABLE;
1240
1241 #undef THIS
1242
1243
1244 /* ********************************************************************
1245    Direct3DMaterial2
1246    ******************************************************************** */
1247 #define THIS LPDIRECT3DMATERIAL2 this
1248 typedef struct IDirect3DMaterial2_VTable {
1249   /*** IUnknown methods ***/
1250   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1251   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1252   STDMETHOD_(ULONG, Release) (THIS) PURE;
1253   /*** IDirect3DMaterial2 methods ***/
1254   STDMETHOD(SetMaterial) (THIS_ LPD3DMATERIAL) PURE;
1255   STDMETHOD(GetMaterial) (THIS_ LPD3DMATERIAL) PURE;
1256   STDMETHOD(GetHandle) (THIS_ LPDIRECT3DDEVICE2, LPD3DMATERIALHANDLE) PURE;
1257 } IDirect3DMaterial2_VTable,*LPDIRECT3DMATERIAL2_VTABLE;
1258
1259 struct IDirect3DMaterial2 {
1260   LPDIRECT3DMATERIAL2_VTABLE  lpvtbl;
1261   DWORD                       ref;
1262
1263   union {
1264     LPDIRECT3D                d3d1;
1265     LPDIRECT3D2               d3d2;
1266   } d3d;
1267   union {
1268     LPDIRECT3DDEVICE  active_device1;
1269     LPDIRECT3DDEVICE2 active_device2;
1270   } device;
1271   int use_d3d2;
1272   
1273   D3DMATERIAL                 mat;
1274   
1275   void (*activate)(LPDIRECT3DMATERIAL2 this);
1276 };
1277
1278 #undef THIS
1279
1280 /* ********************************************************************
1281    Direct3DTexture
1282    ******************************************************************** */
1283 #define THIS LPDIRECT3DTEXTURE this
1284 typedef struct IDirect3DTexture_VTable {
1285   /*** IUnknown methods ***/
1286   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1287   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1288   STDMETHOD_(ULONG, Release) (THIS) PURE;
1289   /*** IDirect3DTexture methods ***/
1290   STDMETHOD(Initialize) (THIS_ LPDIRECT3DDEVICE, LPDIRECTDRAWSURFACE) PURE;
1291   STDMETHOD(GetHandle) (THIS_ LPDIRECT3DDEVICE, LPD3DTEXTUREHANDLE) PURE;
1292   STDMETHOD(PaletteChanged) (THIS_ DWORD, DWORD) PURE;
1293   STDMETHOD(Load) (THIS_ LPDIRECT3DTEXTURE) PURE;
1294   STDMETHOD_(HRESULT, Unload) (THIS) PURE;
1295 } IDirect3DTexture_VTable,*LPDIRECT3DTEXTURE_VTABLE;
1296
1297 /* The structure is the same as for Direct3DTexture2 */
1298
1299 #undef THIS
1300
1301 /* ********************************************************************
1302    Direct3DTexture2
1303    ******************************************************************** */
1304 #define THIS LPDIRECT3DTEXTURE2 this
1305 typedef struct IDirect3DTexture2_VTable {
1306   /*** IUnknown methods ***/
1307   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1308   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1309   STDMETHOD_(ULONG, Release) (THIS) PURE;
1310   /*** IDirect3DTexture2 methods ***/
1311   STDMETHOD(GetHandle) (THIS_ LPDIRECT3DDEVICE2, LPD3DTEXTUREHANDLE) PURE;
1312   STDMETHOD(PaletteChanged) (THIS_ DWORD, DWORD) PURE;
1313   STDMETHOD(Load) (THIS_ LPDIRECT3DTEXTURE2) PURE;  
1314 } IDirect3DTexture2_VTable,*LPDIRECT3DTEXTURE2_VTABLE;
1315
1316 struct IDirect3DTexture2 {
1317   LPDIRECT3DTEXTURE2_VTABLE  lpvtbl;
1318   DWORD                      ref;
1319
1320   void *D3Ddevice; /* I put (void *) to use the same pointer for both
1321                       Direct3D and Direct3D2 */
1322 #ifdef HAVE_MESAGL
1323   GLuint tex_name;
1324 #endif  
1325   LPDIRECTDRAWSURFACE4       surface;
1326 };
1327
1328 #undef THIS
1329
1330
1331 /* ********************************************************************
1332    Direct3DViewport
1333    ******************************************************************** */
1334 #define THIS LPDIRECT3DVIEWPORT this
1335 typedef struct IDirect3Viewport_VTable {
1336   /*** IUnknown methods ***/
1337   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1338   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1339   STDMETHOD_(ULONG, Release) (THIS) PURE;
1340   /*** IDirect3DViewport methods ***/
1341   STDMETHOD(Initialize) (THIS_ LPDIRECT3D) PURE;
1342   STDMETHOD(GetViewport) (THIS_ LPD3DVIEWPORT) PURE;
1343   STDMETHOD(SetViewport) (THIS_ LPD3DVIEWPORT) PURE;
1344   STDMETHOD(TransformVertices) (THIS_ DWORD, LPD3DTRANSFORMDATA, DWORD, LPDWORD) PURE;
1345   STDMETHOD(LightElements) (THIS_ DWORD, LPD3DLIGHTDATA) PURE;
1346   STDMETHOD(SetBackground) (THIS_ D3DMATERIALHANDLE) PURE;
1347   STDMETHOD(GetBackground) (THIS_ LPD3DMATERIALHANDLE, LPBOOL) PURE;
1348   STDMETHOD(SetBackgroundDepth) (THIS_ LPDIRECTDRAWSURFACE) PURE;
1349   STDMETHOD(GetBackgroundDepth) (THIS_ LPDIRECTDRAWSURFACE*, LPBOOL) PURE;
1350   STDMETHOD(Clear) (THIS_ DWORD, LPD3DRECT, DWORD) PURE;
1351   STDMETHOD(AddLight) (THIS_ LPDIRECT3DLIGHT) PURE;
1352   STDMETHOD(DeleteLight) (THIS_ LPDIRECT3DLIGHT) PURE;
1353   STDMETHOD(NextLight) (THIS_ LPDIRECT3DLIGHT, LPDIRECT3DLIGHT*, DWORD) PURE;
1354 } IDirect3DViewport_VTable,*LPDIRECT3DVIEWPORT_VTABLE;
1355
1356 #undef THIS
1357
1358
1359 /* ********************************************************************
1360    Direct3DViewport2
1361    ******************************************************************** */
1362 #define THIS LPDIRECT3DVIEWPORT2 this
1363 typedef struct IDirect3Viewport2_VTable {
1364   /*** IUnknown methods ***/
1365   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1366   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1367   STDMETHOD_(ULONG, Release) (THIS) PURE;
1368   /*** IDirect3DViewport methods ***/
1369   STDMETHOD(Initialize) (THIS_ LPDIRECT3D) PURE;
1370   STDMETHOD(GetViewport) (THIS_ LPD3DVIEWPORT) PURE;
1371   STDMETHOD(SetViewport) (THIS_ LPD3DVIEWPORT) PURE;
1372   STDMETHOD(TransformVertices) (THIS_ DWORD, LPD3DTRANSFORMDATA, DWORD, LPDWORD) PURE;
1373   STDMETHOD(LightElements) (THIS_ DWORD, LPD3DLIGHTDATA) PURE;
1374   STDMETHOD(SetBackground) (THIS_ D3DMATERIALHANDLE) PURE;
1375   STDMETHOD(GetBackground) (THIS_ LPD3DMATERIALHANDLE, LPBOOL) PURE;
1376   STDMETHOD(SetBackgroundDepth) (THIS_ LPDIRECTDRAWSURFACE) PURE;
1377   STDMETHOD(GetBackgroundDepth) (THIS_ LPDIRECTDRAWSURFACE*, LPBOOL) PURE;
1378   STDMETHOD(Clear) (THIS_ DWORD, LPD3DRECT, DWORD) PURE;
1379   STDMETHOD(AddLight) (THIS_ LPDIRECT3DLIGHT) PURE;
1380   STDMETHOD(DeleteLight) (THIS_ LPDIRECT3DLIGHT) PURE;
1381   STDMETHOD(NextLight) (THIS_ LPDIRECT3DLIGHT, LPDIRECT3DLIGHT*, DWORD) PURE;
1382   /*** IDirect3DViewport2 methods ***/
1383   STDMETHOD(GetViewport2) (THIS_ LPD3DVIEWPORT2) PURE;
1384   STDMETHOD(SetViewport2) (THIS_ LPD3DVIEWPORT2) PURE;
1385 } IDirect3DViewport2_VTable,*LPDIRECT3DVIEWPORT2_VTABLE;
1386
1387 struct IDirect3DViewport2 {
1388   LPDIRECT3DVIEWPORT2_VTABLE  lpvtbl;
1389   DWORD                       ref;
1390
1391   union {
1392     LPDIRECT3D                d3d1;
1393     LPDIRECT3D2               d3d2;
1394   } d3d;
1395   /* If this viewport is active for one device, put the device here */
1396   union {
1397     LPDIRECT3DDEVICE  active_device1;
1398     LPDIRECT3DDEVICE2 active_device2;
1399   } device;
1400   int use_d3d2;
1401
1402   union {
1403     D3DVIEWPORT              vp1;
1404     D3DVIEWPORT2             vp2;
1405   } viewport;
1406   int use_vp2;
1407
1408   /* Activation function */
1409   void (*activate)(THIS);
1410   
1411   /* Field used to chain viewports together */
1412   LPDIRECT3DVIEWPORT2 next;
1413
1414   /* Lights list */
1415   LPDIRECT3DLIGHT lights;
1416
1417   /* OpenGL code */
1418 #ifdef HAVE_MESAGL
1419   GLenum nextlight;
1420 #endif
1421 };
1422
1423 #undef THIS
1424
1425 /* ********************************************************************
1426    Direct3DExecuteBuffer
1427    ******************************************************************** */
1428 #define THIS LPDIRECT3DEXECUTEBUFFER this
1429 typedef struct IDirect3DExecuteBuffer_VTable {
1430   /*** IUnknown methods ***/
1431   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1432   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1433   STDMETHOD_(ULONG, Release) (THIS) PURE;
1434   /*** IDirect3DExecuteBuffer methods ***/
1435   STDMETHOD(Initialize) (THIS_ LPDIRECT3DDEVICE, LPD3DEXECUTEBUFFERDESC) PURE;
1436   STDMETHOD(Lock) (THIS_ LPD3DEXECUTEBUFFERDESC) PURE;
1437   STDMETHOD_(HRESULT, Unlock) (THIS) PURE;
1438   STDMETHOD(SetExecuteData) (THIS_ LPD3DEXECUTEDATA) PURE;
1439   STDMETHOD(GetExecuteData) (THIS_ LPD3DEXECUTEDATA) PURE;
1440   STDMETHOD(Validate) (THIS_ LPDWORD, LPD3DVALIDATECALLBACK, LPVOID, DWORD) PURE;
1441   STDMETHOD(Optimize) (THIS_ DWORD) PURE;
1442 } *LPDIRECT3DEXECUTEBUFFER_VTABLE,IDirect3DExecuteBuffer_VTable;
1443
1444 struct IDirect3DExecuteBuffer {
1445   LPDIRECT3DEXECUTEBUFFER_VTABLE lpvtbl;
1446   DWORD ref;
1447   
1448   LPDIRECT3DDEVICE d3ddev;
1449
1450   D3DEXECUTEBUFFERDESC desc;
1451   D3DEXECUTEDATA data;
1452
1453   /* This buffer will store the transformed vertices */
1454   void *vertex_data;
1455   D3DVERTEXTYPE vertex_type;
1456
1457   /* This flags is set to TRUE if we allocated ourselves the
1458      data buffer */
1459   BOOL need_free;
1460
1461   void (*execute)(LPDIRECT3DEXECUTEBUFFER this,
1462                   LPDIRECT3DDEVICE dev,
1463                   LPDIRECT3DVIEWPORT vp);
1464 };
1465
1466 #undef THIS
1467
1468 /* ********************************************************************
1469    Direct3DDevice
1470    ******************************************************************** */
1471 #define THIS LPDIRECT3DDEVICE this
1472 typedef struct IDirect3DDevice_VTable {
1473   /*** IUnknown methods ***/
1474   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1475   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1476   STDMETHOD_(ULONG, Release) (THIS) PURE;
1477   /*** IDirect3DDevice methods ***/
1478   STDMETHOD(Initialize) (THIS_ LPDIRECT3D, LPGUID, LPD3DDEVICEDESC) PURE;
1479   STDMETHOD(GetCaps) (THIS_ LPD3DDEVICEDESC, LPD3DDEVICEDESC) PURE;
1480   STDMETHOD(SwapTextureHandles) (THIS_ LPDIRECT3DTEXTURE, LPDIRECT3DTEXTURE) PURE;
1481   STDMETHOD(CreateExecuteBuffer) (THIS_ LPD3DEXECUTEBUFFERDESC, LPDIRECT3DEXECUTEBUFFER*, IUnknown*) PURE;
1482   STDMETHOD(GetStats) (THIS_ LPD3DSTATS) PURE;
1483   STDMETHOD(Execute) (THIS_ LPDIRECT3DEXECUTEBUFFER, LPDIRECT3DVIEWPORT, DWORD) PURE;
1484   STDMETHOD(AddViewport) (THIS_ LPDIRECT3DVIEWPORT) PURE;
1485   STDMETHOD(DeleteViewport) (THIS_ LPDIRECT3DVIEWPORT) PURE;
1486   STDMETHOD(NextViewport) (THIS_ LPDIRECT3DVIEWPORT, LPDIRECT3DVIEWPORT*, DWORD) PURE;
1487   STDMETHOD(Pick) (THIS_ LPDIRECT3DEXECUTEBUFFER, LPDIRECT3DVIEWPORT, DWORD, LPD3DRECT) PURE;
1488   STDMETHOD(GetPickRecords)(THIS_ LPDWORD, LPD3DPICKRECORD) PURE;
1489   STDMETHOD(EnumTextureFormats) (THIS_ LPD3DENUMTEXTUREFORMATSCALLBACK, LPVOID) PURE;
1490   STDMETHOD(CreateMatrix) (THIS_ LPD3DMATRIXHANDLE) PURE;
1491   STDMETHOD(SetMatrix) (THIS_ D3DMATRIXHANDLE, const LPD3DMATRIX) PURE;
1492   STDMETHOD(GetMatrix) (THIS_ D3DMATRIXHANDLE, LPD3DMATRIX) PURE;
1493   STDMETHOD(DeleteMatrix) (THIS_ D3DMATRIXHANDLE) PURE;
1494   STDMETHOD_(HRESULT, BeginScene) (THIS) PURE;
1495   STDMETHOD_(HRESULT, EndScene) (THIS) PURE;
1496   STDMETHOD(GetDirect3D) (THIS_ LPDIRECT3D*) PURE;
1497 } *LPDIRECT3DDEVICE_VTABLE,IDirect3DDevice_VTable;
1498
1499 struct IDirect3DDevice {
1500   /* This are the fields common to all Direct3DDevice implementations */
1501   LPDIRECT3DDEVICE_VTABLE lpvtbl;
1502   DWORD ref;
1503   
1504   LPDIRECT3D d3d;
1505   LPDIRECTDRAWSURFACE surface;
1506
1507   LPDIRECT3DVIEWPORT viewport_list;
1508   LPDIRECT3DVIEWPORT current_viewport;
1509
1510   void (*set_context)(THIS) ;
1511 };
1512
1513 #undef THIS
1514
1515 /* ********************************************************************
1516    Direct3DDevice2
1517    ******************************************************************** */
1518 #define THIS LPDIRECT3DDEVICE2 this
1519 typedef struct IDirect3DDevice2_VTable {
1520   /*** IUnknown methods ***/
1521   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID* ppvObj) PURE;
1522   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
1523   STDMETHOD_(ULONG, Release) (THIS) PURE;
1524   /*** IDirect3DDevice2 methods ***/
1525   STDMETHOD(GetCaps) (THIS_ LPD3DDEVICEDESC, LPD3DDEVICEDESC) PURE;
1526   STDMETHOD(SwapTextureHandles) (THIS_ LPDIRECT3DTEXTURE2, LPDIRECT3DTEXTURE2) PURE;
1527   STDMETHOD(GetStats) (THIS_ LPD3DSTATS) PURE;
1528   STDMETHOD(AddViewport) (THIS_ LPDIRECT3DVIEWPORT2) PURE;
1529   STDMETHOD(DeleteViewport) (THIS_ LPDIRECT3DVIEWPORT2) PURE;
1530   STDMETHOD(NextViewport) (THIS_ LPDIRECT3DVIEWPORT2, LPDIRECT3DVIEWPORT2*, DWORD) PURE;
1531   STDMETHOD(EnumTextureFormats) (THIS_ LPD3DENUMTEXTUREFORMATSCALLBACK, LPVOID) PURE;
1532   STDMETHOD_(HRESULT, BeginScene) (THIS) PURE;
1533   STDMETHOD_(HRESULT, EndScene) (THIS) PURE;
1534   STDMETHOD(GetDirect3D) (THIS_ LPDIRECT3D2*) PURE;
1535   
1536   /*** DrawPrimitive API ***/
1537   STDMETHOD(SetCurrentViewport) (THIS_ LPDIRECT3DVIEWPORT2) PURE;
1538   STDMETHOD(GetCurrentViewport) (THIS_ LPDIRECT3DVIEWPORT2 *) PURE;
1539   
1540   STDMETHOD(SetRenderTarget) (THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE;
1541   STDMETHOD(GetRenderTarget) (THIS_ LPDIRECTDRAWSURFACE *) PURE;
1542   
1543   STDMETHOD(Begin) (THIS_ D3DPRIMITIVETYPE, D3DVERTEXTYPE, DWORD) PURE;
1544   STDMETHOD(BeginIndexed) (THIS_ D3DPRIMITIVETYPE, D3DVERTEXTYPE, LPVOID, DWORD, DWORD) PURE;
1545   STDMETHOD(Vertex) (THIS_ LPVOID) PURE;
1546   STDMETHOD(Index) (THIS_ WORD) PURE;
1547   STDMETHOD(End) (THIS_ DWORD) PURE;
1548   
1549   STDMETHOD(GetRenderState) (THIS_ D3DRENDERSTATETYPE, LPDWORD) PURE;
1550   STDMETHOD(SetRenderState) (THIS_ D3DRENDERSTATETYPE, DWORD) PURE;
1551   STDMETHOD(GetLightState) (THIS_ D3DLIGHTSTATETYPE, LPDWORD) PURE;
1552   STDMETHOD(SetLightState) (THIS_ D3DLIGHTSTATETYPE, DWORD) PURE;
1553   STDMETHOD(SetTransform) (THIS_ D3DTRANSFORMSTATETYPE, LPD3DMATRIX) PURE;
1554   STDMETHOD(GetTransform) (THIS_ D3DTRANSFORMSTATETYPE, LPD3DMATRIX) PURE;
1555   STDMETHOD(MultiplyTransform) (THIS_ D3DTRANSFORMSTATETYPE, LPD3DMATRIX) PURE;
1556   
1557   STDMETHOD(DrawPrimitive) (THIS_ D3DPRIMITIVETYPE, D3DVERTEXTYPE, LPVOID, DWORD, DWORD) PURE;
1558   STDMETHOD(DrawIndexedPrimitive) (THIS_ D3DPRIMITIVETYPE, D3DVERTEXTYPE, LPVOID, DWORD, LPWORD, DWORD, DWORD) PURE;
1559   
1560   STDMETHOD(SetClipStatus) (THIS_ LPD3DCLIPSTATUS) PURE;
1561   STDMETHOD(GetClipStatus) (THIS_ LPD3DCLIPSTATUS) PURE;
1562 } *LPDIRECT3DDEVICE2_VTABLE,IDirect3DDevice2_VTable;
1563
1564 struct IDirect3DDevice2 {
1565   /* This are the fields common to all Direct3DDevice2 implementations */
1566   LPDIRECT3DDEVICE2_VTABLE lpvtbl;
1567   DWORD ref;
1568   
1569   LPDIRECT3D2 d3d;
1570   LPDIRECTDRAWSURFACE surface;
1571
1572   LPDIRECT3DVIEWPORT2 viewport_list;
1573   LPDIRECT3DVIEWPORT2 current_viewport;
1574
1575   void (*set_context)(THIS) ;
1576 };
1577 #undef THIS
1578
1579
1580 #undef THIS_
1581 #undef STDMETHOD
1582 #undef STDMETHOD_
1583 #undef PURE
1584 #undef FAR
1585 #endif