]> icculus.org git repositories - taylor/freespace2.git/blob - include/vd3dtypes.h
Initial revision
[taylor/freespace2.git] / include / vd3dtypes.h
1 /*==========================================================================;
2  *
3  *  Copyright (C) 1995-1997 Microsoft Corporation.  All Rights Reserved.
4  *
5  *  File:       d3dtypes.h
6  *  Content:    Direct3D types include file
7  *
8  ***************************************************************************/
9
10 #ifndef _D3DTYPES_H_
11 #define _D3DTYPES_H_
12
13 #if (! defined WIN32) && (! defined WIN95)
14 #include "subwtype.h"
15 #else
16 #include <windows.h>
17 #endif
18
19 #include <float.h>
20 #include "vddraw.h"
21
22 #pragma pack(4)
23
24 /* D3DVALUE is the fundamental Direct3D fractional data type */
25
26 #define D3DVALP(val, prec) ((float)(val))
27 #define D3DVAL(val) ((float)(val))
28 typedef float D3DVALUE, *LPD3DVALUE;
29 #define D3DDivide(a, b)    (float)((double) (a) / (double) (b))
30 #define D3DMultiply(a, b)    ((a) * (b))
31
32 typedef LONG D3DFIXED;
33
34 #ifndef RGB_MAKE
35 /*
36  * Format of CI colors is
37  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38  *  |    alpha      |         color index           |   fraction    |
39  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40  */
41 #define CI_GETALPHA(ci)    ((ci) >> 24)
42 #define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
43 #define CI_GETFRACTION(ci) ((ci) & 0xff)
44 #define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
45 #define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
46 #define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
47
48 /*
49  * Format of RGBA colors is
50  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51  *  |    alpha      |      red      |     green     |     blue      |
52  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53  */
54 #define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
55 #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
56 #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
57 #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
58 #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
59
60 /* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
61  * The float values must be in the range 0..1
62  */
63 #define D3DRGB(r, g, b) \
64     (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
65 #define D3DRGBA(r, g, b, a) \
66     (   (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
67     |   (((long)((g) * 255)) << 8) | (long)((b) * 255) \
68     )
69
70 /*
71  * Format of RGB colors is
72  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73  *  |    ignored    |      red      |     green     |     blue      |
74  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75  */
76 #define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
77 #define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
78 #define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
79 #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
80 #define RGB_MAKE(r, g, b)       ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
81 #define RGBA_TORGB(rgba)       ((D3DCOLOR) ((rgba) & 0xffffff))
82 #define RGB_TORGBA(rgb)        ((D3DCOLOR) ((rgb) | 0xff000000))
83
84 #endif
85
86 /*
87  * Flags for Enumerate functions
88  */
89
90 /*
91  * Stop the enumeration
92  */
93 #define D3DENUMRET_CANCEL                        DDENUMRET_CANCEL
94
95 /*
96  * Continue the enumeration
97  */
98 #define D3DENUMRET_OK                            DDENUMRET_OK
99
100 typedef HRESULT (WINAPI* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
101 typedef HRESULT (WINAPI* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
102
103 typedef DWORD D3DCOLOR, *LPD3DCOLOR;
104
105 typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
106 typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
107 typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
108
109 typedef struct _D3DCOLORVALUE {
110     union {
111         D3DVALUE r;
112         D3DVALUE dvR;
113     };
114     union {
115         D3DVALUE g;
116         D3DVALUE dvG;
117     };
118     union {
119         D3DVALUE b;
120         D3DVALUE dvB;
121     };
122     union {
123         D3DVALUE a;
124         D3DVALUE dvA;
125     };
126 } D3DCOLORVALUE, *LPD3DCOLORVALUE;
127
128 typedef struct _D3DRECT {
129     union {
130         LONG x1;
131         LONG lX1;
132     };
133     union {
134         LONG y1;
135         LONG lY1;
136     };
137     union {
138         LONG x2;
139         LONG lX2;
140     };
141     union {
142         LONG y2;
143         LONG lY2;
144     };
145 } D3DRECT, *LPD3DRECT;
146
147 typedef struct _D3DVECTOR {
148     union {
149         D3DVALUE x;
150         D3DVALUE dvX;
151     };
152     union {
153         D3DVALUE y;
154         D3DVALUE dvY;
155     };
156     union {
157         D3DVALUE z;
158         D3DVALUE dvZ;
159     };
160 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
161
162 public:
163
164     // =====================================
165     // Constructors
166     // =====================================
167
168     _D3DVECTOR() { }
169     _D3DVECTOR(D3DVALUE f);
170     _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
171     _D3DVECTOR(const D3DVALUE f[3]);
172
173     // =====================================
174     // Access grants
175     // =====================================
176
177     const D3DVALUE&operator[](int i) const;
178     D3DVALUE&operator[](int i);
179
180     // =====================================
181     // Assignment operators
182     // =====================================
183
184     _D3DVECTOR& operator += (const _D3DVECTOR& v);
185     _D3DVECTOR& operator -= (const _D3DVECTOR& v);
186     _D3DVECTOR& operator *= (const _D3DVECTOR& v);
187     _D3DVECTOR& operator /= (const _D3DVECTOR& v);
188     _D3DVECTOR& operator *= (D3DVALUE s);
189     _D3DVECTOR& operator /= (D3DVALUE s);
190
191     // =====================================
192     // Unary operators
193     // =====================================
194
195     friend _D3DVECTOR operator + (const _D3DVECTOR& v);
196     friend _D3DVECTOR operator - (const _D3DVECTOR& v);
197
198
199     // =====================================
200     // Binary operators
201     // =====================================
202
203     // Addition and subtraction
204         friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
205         friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
206     // Scalar multiplication and division
207         friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
208         friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
209         friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
210     // Memberwise multiplication and division
211         friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
212         friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
213
214     // Vector dominance
215         friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
216         friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
217
218     // Bitwise equality
219         friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
220
221     // Length-related functions
222         friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
223         friend D3DVALUE Magnitude (const _D3DVECTOR& v);
224
225     // Returns vector with same direction and unit length
226         friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
227
228     // Return min/max component of the input vector
229         friend D3DVALUE Min (const _D3DVECTOR& v);
230         friend D3DVALUE Max (const _D3DVECTOR& v);
231
232     // Return memberwise min/max of input vectors
233         friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
234         friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
235
236     // Dot and cross product
237         friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
238         friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
239
240 #endif
241
242 } D3DVECTOR, *LPD3DVECTOR;
243
244 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
245 #include "vd3dvec.inl"
246 #endif
247
248 /*
249  * Vertex data types supported in an ExecuteBuffer.
250  */
251
252 /*
253  * Homogeneous vertices
254  */
255
256 typedef struct _D3DHVERTEX {
257     DWORD           dwFlags;        /* Homogeneous clipping flags */
258     union {
259         D3DVALUE    hx;
260         D3DVALUE    dvHX;
261     };
262     union {
263         D3DVALUE    hy;
264         D3DVALUE    dvHY;
265     };
266     union {
267         D3DVALUE    hz;
268         D3DVALUE    dvHZ;
269     };
270 } D3DHVERTEX, *LPD3DHVERTEX;
271
272 /*
273  * Transformed/lit vertices
274  */
275 typedef struct _D3DTLVERTEX {
276     union {
277         D3DVALUE    sx;             /* Screen coordinates */
278         D3DVALUE    dvSX;
279     };
280     union {
281         D3DVALUE    sy;
282         D3DVALUE    dvSY;
283     };
284     union {
285         D3DVALUE    sz;
286         D3DVALUE    dvSZ;
287     };
288     union {
289         D3DVALUE    rhw;            /* Reciprocal of homogeneous w */
290         D3DVALUE    dvRHW;
291     };
292     union {
293         D3DCOLOR    color;          /* Vertex color */
294         D3DCOLOR    dcColor;
295     };
296     union {
297         D3DCOLOR    specular;       /* Specular component of vertex */
298         D3DCOLOR    dcSpecular;
299     };
300     union {
301         D3DVALUE    tu;             /* Texture coordinates */
302         D3DVALUE    dvTU;
303     };
304     union {
305         D3DVALUE    tv;
306         D3DVALUE    dvTV;
307     };
308 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
309     _D3DTLVERTEX() { }
310     _D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
311                  D3DCOLOR _color, D3DCOLOR _specular,
312                  float _tu, float _tv)
313         { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
314           color = _color; specular = _specular;
315           tu = _tu; tv = _tv;
316         }
317 #endif
318 } D3DTLVERTEX, *LPD3DTLVERTEX;
319
320 /*
321  * Untransformed/lit vertices
322  */
323 typedef struct _D3DLVERTEX {
324     union {
325         D3DVALUE     x;             /* Homogeneous coordinates */
326         D3DVALUE     dvX;
327     };
328     union {
329         D3DVALUE     y;
330         D3DVALUE     dvY;
331     };
332     union {
333         D3DVALUE     z;
334         D3DVALUE     dvZ;
335     };
336     DWORD            dwReserved;
337     union {
338         D3DCOLOR     color;         /* Vertex color */
339         D3DCOLOR     dcColor;
340     };
341     union {
342         D3DCOLOR     specular;      /* Specular component of vertex */
343         D3DCOLOR     dcSpecular;
344     };
345     union {
346         D3DVALUE     tu;            /* Texture coordinates */
347         D3DVALUE     dvTU;
348     };
349     union {
350         D3DVALUE     tv;
351         D3DVALUE     dvTV;
352     };
353 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
354     _D3DLVERTEX() { }
355     _D3DLVERTEX(const D3DVECTOR& v,
356                 D3DCOLOR _color, D3DCOLOR _specular,
357                 float _tu, float _tv)
358         { x = v.x; y = v.y; z = v.z; dwReserved = 0;
359           color = _color; specular = _specular;
360           tu = _tu; tv = _tv;
361         }
362 #endif
363 } D3DLVERTEX, *LPD3DLVERTEX;
364
365 /*
366  * Untransformed/unlit vertices
367  */
368
369 typedef struct _D3DVERTEX {
370     union {
371         D3DVALUE     x;             /* Homogeneous coordinates */
372         D3DVALUE     dvX;
373     };
374     union {
375         D3DVALUE     y;
376         D3DVALUE     dvY;
377     };
378     union {
379         D3DVALUE     z;
380         D3DVALUE     dvZ;
381     };
382     union {
383         D3DVALUE     nx;            /* Normal */
384         D3DVALUE     dvNX;
385     };
386     union {
387         D3DVALUE     ny;
388         D3DVALUE     dvNY;
389     };
390     union {
391         D3DVALUE     nz;
392         D3DVALUE     dvNZ;
393     };
394     union {
395         D3DVALUE     tu;            /* Texture coordinates */
396         D3DVALUE     dvTU;
397     };
398     union {
399         D3DVALUE     tv;
400         D3DVALUE     dvTV;
401     };
402 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
403     _D3DVERTEX() { }
404     _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv)
405         { x = v.x; y = v.y; z = v.z;
406           nx = n.x; ny = n.y; nz = n.z;
407           tu = _tu; tv = _tv;
408         }
409 #endif
410 } D3DVERTEX, *LPD3DVERTEX;
411
412 /*
413  * Matrix, viewport, and tranformation structures and definitions.
414  */
415
416 typedef struct _D3DMATRIX {
417 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
418     union {
419         struct {
420 #endif
421
422             D3DVALUE        _11, _12, _13, _14;
423             D3DVALUE        _21, _22, _23, _24;
424             D3DVALUE        _31, _32, _33, _34;
425             D3DVALUE        _41, _42, _43, _44;
426
427 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
428         };
429         D3DVALUE m[4][4];
430     };
431     _D3DMATRIX() { }
432     _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03,
433                 D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13,
434                 D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23,
435                 D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _m33
436         ) 
437         {
438                 m[0][0] = _m00; m[0][1] = _m01; m[0][2] = _m02; m[0][3] = _m03;
439                 m[1][0] = _m10; m[1][1] = _m11; m[1][2] = _m12; m[1][3] = _m13;
440                 m[2][0] = _m20; m[2][1] = _m21; m[2][2] = _m22; m[2][3] = _m23;
441                 m[3][0] = _m30; m[3][1] = _m31; m[3][2] = _m32; m[3][3] = _m33;
442         }
443
444     D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; }
445     const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; }
446 #endif
447 } D3DMATRIX, *LPD3DMATRIX;
448
449 typedef struct _D3DVIEWPORT {
450     DWORD       dwSize;
451     DWORD       dwX;
452     DWORD       dwY;            /* Top left */
453     DWORD       dwWidth;
454     DWORD       dwHeight;       /* Dimensions */
455     D3DVALUE    dvScaleX;       /* Scale homogeneous to screen */
456     D3DVALUE    dvScaleY;       /* Scale homogeneous to screen */
457     D3DVALUE    dvMaxX;         /* Min/max homogeneous x coord */
458     D3DVALUE    dvMaxY;         /* Min/max homogeneous y coord */
459     D3DVALUE    dvMinZ;
460     D3DVALUE    dvMaxZ;         /* Min/max homogeneous z coord */
461 } D3DVIEWPORT, *LPD3DVIEWPORT;
462
463 typedef struct _D3DVIEWPORT2 {
464     DWORD       dwSize;
465     DWORD       dwX;
466     DWORD       dwY;            /* Viewport Top left */
467     DWORD       dwWidth;
468     DWORD       dwHeight;       /* Viewport Dimensions */
469     D3DVALUE    dvClipX;                /* Top left of clip volume */
470     D3DVALUE    dvClipY;        
471     D3DVALUE    dvClipWidth;    /* Clip Volume Dimensions */
472     D3DVALUE    dvClipHeight;
473     D3DVALUE    dvMinZ;                 /* Min/max of clip Volume */
474     D3DVALUE    dvMaxZ;         
475 } D3DVIEWPORT2, *LPD3DVIEWPORT2;
476
477 /*
478  * Values for clip fields.
479  */
480 #define D3DCLIP_LEFT                            0x00000001L
481 #define D3DCLIP_RIGHT                           0x00000002L
482 #define D3DCLIP_TOP                             0x00000004L
483 #define D3DCLIP_BOTTOM                          0x00000008L
484 #define D3DCLIP_FRONT                           0x00000010L
485 #define D3DCLIP_BACK                            0x00000020L
486 #define D3DCLIP_GEN0                            0x00000040L
487 #define D3DCLIP_GEN1                            0x00000080L
488 #define D3DCLIP_GEN2                            0x00000100L
489 #define D3DCLIP_GEN3                            0x00000200L
490 #define D3DCLIP_GEN4                            0x00000400L
491 #define D3DCLIP_GEN5                            0x00000800L
492
493 /*
494  * Values for d3d status.
495  */
496 #define D3DSTATUS_CLIPUNIONLEFT                 D3DCLIP_LEFT
497 #define D3DSTATUS_CLIPUNIONRIGHT                D3DCLIP_RIGHT
498 #define D3DSTATUS_CLIPUNIONTOP                  D3DCLIP_TOP
499 #define D3DSTATUS_CLIPUNIONBOTTOM               D3DCLIP_BOTTOM
500 #define D3DSTATUS_CLIPUNIONFRONT                D3DCLIP_FRONT
501 #define D3DSTATUS_CLIPUNIONBACK                 D3DCLIP_BACK
502 #define D3DSTATUS_CLIPUNIONGEN0                 D3DCLIP_GEN0
503 #define D3DSTATUS_CLIPUNIONGEN1                 D3DCLIP_GEN1
504 #define D3DSTATUS_CLIPUNIONGEN2                 D3DCLIP_GEN2
505 #define D3DSTATUS_CLIPUNIONGEN3                 D3DCLIP_GEN3
506 #define D3DSTATUS_CLIPUNIONGEN4                 D3DCLIP_GEN4
507 #define D3DSTATUS_CLIPUNIONGEN5                 D3DCLIP_GEN5
508
509 #define D3DSTATUS_CLIPINTERSECTIONLEFT          0x00001000L
510 #define D3DSTATUS_CLIPINTERSECTIONRIGHT         0x00002000L
511 #define D3DSTATUS_CLIPINTERSECTIONTOP           0x00004000L
512 #define D3DSTATUS_CLIPINTERSECTIONBOTTOM        0x00008000L
513 #define D3DSTATUS_CLIPINTERSECTIONFRONT         0x00010000L
514 #define D3DSTATUS_CLIPINTERSECTIONBACK          0x00020000L
515 #define D3DSTATUS_CLIPINTERSECTIONGEN0          0x00040000L
516 #define D3DSTATUS_CLIPINTERSECTIONGEN1          0x00080000L
517 #define D3DSTATUS_CLIPINTERSECTIONGEN2          0x00100000L
518 #define D3DSTATUS_CLIPINTERSECTIONGEN3          0x00200000L
519 #define D3DSTATUS_CLIPINTERSECTIONGEN4          0x00400000L
520 #define D3DSTATUS_CLIPINTERSECTIONGEN5          0x00800000L
521 #define D3DSTATUS_ZNOTVISIBLE                           0x01000000L
522 /* Do not use 0x80000000 for any status flags in future as it is reserved */
523
524 #define D3DSTATUS_CLIPUNIONALL  (               \
525             D3DSTATUS_CLIPUNIONLEFT     |       \
526             D3DSTATUS_CLIPUNIONRIGHT    |       \
527             D3DSTATUS_CLIPUNIONTOP      |       \
528             D3DSTATUS_CLIPUNIONBOTTOM   |       \
529             D3DSTATUS_CLIPUNIONFRONT    |       \
530             D3DSTATUS_CLIPUNIONBACK     |       \
531             D3DSTATUS_CLIPUNIONGEN0     |       \
532             D3DSTATUS_CLIPUNIONGEN1     |       \
533             D3DSTATUS_CLIPUNIONGEN2     |       \
534             D3DSTATUS_CLIPUNIONGEN3     |       \
535             D3DSTATUS_CLIPUNIONGEN4     |       \
536             D3DSTATUS_CLIPUNIONGEN5             \
537             )
538
539 #define D3DSTATUS_CLIPINTERSECTIONALL   (               \
540             D3DSTATUS_CLIPINTERSECTIONLEFT      |       \
541             D3DSTATUS_CLIPINTERSECTIONRIGHT     |       \
542             D3DSTATUS_CLIPINTERSECTIONTOP       |       \
543             D3DSTATUS_CLIPINTERSECTIONBOTTOM    |       \
544             D3DSTATUS_CLIPINTERSECTIONFRONT     |       \
545             D3DSTATUS_CLIPINTERSECTIONBACK      |       \
546             D3DSTATUS_CLIPINTERSECTIONGEN0      |       \
547             D3DSTATUS_CLIPINTERSECTIONGEN1      |       \
548             D3DSTATUS_CLIPINTERSECTIONGEN2      |       \
549             D3DSTATUS_CLIPINTERSECTIONGEN3      |       \
550             D3DSTATUS_CLIPINTERSECTIONGEN4      |       \
551             D3DSTATUS_CLIPINTERSECTIONGEN5              \
552             )
553
554 #define D3DSTATUS_DEFAULT       (                       \
555             D3DSTATUS_CLIPINTERSECTIONALL       |       \
556             D3DSTATUS_ZNOTVISIBLE)
557
558
559 /*
560  * Options for direct transform calls
561  */
562 #define D3DTRANSFORM_CLIPPED       0x00000001l
563 #define D3DTRANSFORM_UNCLIPPED     0x00000002l
564
565 typedef struct _D3DTRANSFORMDATA {
566     DWORD           dwSize;
567     LPVOID          lpIn;           /* Input vertices */
568     DWORD           dwInSize;       /* Stride of input vertices */
569     LPVOID          lpOut;          /* Output vertices */
570     DWORD           dwOutSize;      /* Stride of output vertices */
571     LPD3DHVERTEX    lpHOut;         /* Output homogeneous vertices */
572     DWORD           dwClip;         /* Clipping hint */
573     DWORD           dwClipIntersection;
574     DWORD           dwClipUnion;    /* Union of all clip flags */
575     D3DRECT         drExtent;       /* Extent of transformed vertices */
576 } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
577
578 /*
579  * Structure defining position and direction properties for lighting.
580  */
581 typedef struct _D3DLIGHTINGELEMENT {
582     D3DVECTOR dvPosition;           /* Lightable point in model space */
583     D3DVECTOR dvNormal;             /* Normalised unit vector */
584 } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
585
586 /*
587  * Structure defining material properties for lighting.
588  */
589 typedef struct _D3DMATERIAL {
590     DWORD               dwSize;
591     union {
592         D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
593         D3DCOLORVALUE   dcvDiffuse;
594     };
595     union {
596         D3DCOLORVALUE   ambient;        /* Ambient color RGB */
597         D3DCOLORVALUE   dcvAmbient;
598     };
599     union {
600         D3DCOLORVALUE   specular;       /* Specular 'shininess' */
601         D3DCOLORVALUE   dcvSpecular;
602     };
603     union {
604         D3DCOLORVALUE   emissive;       /* Emissive color RGB */
605         D3DCOLORVALUE   dcvEmissive;
606     };
607     union {
608         D3DVALUE        power;          /* Sharpness if specular highlight */
609         D3DVALUE        dvPower;
610     };
611     D3DTEXTUREHANDLE    hTexture;       /* Handle to texture map */
612     DWORD               dwRampSize;
613 } D3DMATERIAL, *LPD3DMATERIAL;
614
615 typedef enum _D3DLIGHTTYPE {
616     D3DLIGHT_POINT          = 1,
617     D3DLIGHT_SPOT           = 2,
618     D3DLIGHT_DIRECTIONAL    = 3,
619     D3DLIGHT_PARALLELPOINT  = 4,
620     D3DLIGHT_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
621 } D3DLIGHTTYPE;
622
623 /*
624  * Structure defining a light source and its properties.
625  */
626 typedef struct _D3DLIGHT {
627     DWORD           dwSize;
628     D3DLIGHTTYPE    dltType;            /* Type of light source */
629     D3DCOLORVALUE   dcvColor;           /* Color of light */
630     D3DVECTOR       dvPosition;         /* Position in world space */
631     D3DVECTOR       dvDirection;        /* Direction in world space */
632     D3DVALUE        dvRange;            /* Cutoff range */
633     D3DVALUE        dvFalloff;          /* Falloff */
634     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
635     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
636     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
637     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
638     D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
639 } D3DLIGHT, *LPD3DLIGHT;
640
641 /*
642  * Structure defining a light source and its properties.
643  */
644
645 /* flags bits */
646 #define D3DLIGHT_ACTIVE                 0x00000001
647 #define D3DLIGHT_NO_SPECULAR    0x00000002
648
649 /* maximum valid light range */
650 #define D3DLIGHT_RANGE_MAX              ((float)sqrt(FLT_MAX))
651
652 typedef struct _D3DLIGHT2 {
653     DWORD           dwSize;
654     D3DLIGHTTYPE    dltType;            /* Type of light source */
655     D3DCOLORVALUE   dcvColor;           /* Color of light */
656     D3DVECTOR       dvPosition;         /* Position in world space */
657     D3DVECTOR       dvDirection;        /* Direction in world space */
658     D3DVALUE        dvRange;            /* Cutoff range */
659     D3DVALUE        dvFalloff;          /* Falloff */
660     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
661     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
662     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
663     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
664     D3DVALUE        dvPhi;                      /* Outer angle of spotlight cone */
665         DWORD                   dwFlags;
666 } D3DLIGHT2, *LPD3DLIGHT2;
667
668 typedef struct _D3DLIGHTDATA {
669     DWORD                dwSize;
670     LPD3DLIGHTINGELEMENT lpIn;          /* Input positions and normals */
671     DWORD                dwInSize;      /* Stride of input elements */
672     LPD3DTLVERTEX        lpOut;         /* Output colors */
673     DWORD                dwOutSize;     /* Stride of output colors */
674 } D3DLIGHTDATA, *LPD3DLIGHTDATA;
675
676 /*
677  * Before DX5, these values were in an enum called
678  * D3DCOLORMODEL. This was not correct, since they are
679  * bit flags. A driver can surface either or both flags
680  * in the dcmColorModel member of D3DDEVICEDESC.
681  */
682 #define D3DCOLOR_MONO   1
683 #define D3DCOLOR_RGB    2
684
685 typedef DWORD D3DCOLORMODEL;
686
687 /*
688  * Options for clearing
689  */
690 #define D3DCLEAR_TARGET            0x00000001l /* Clear target surface */
691 #define D3DCLEAR_ZBUFFER           0x00000002l /* Clear target z buffer */
692
693 /*
694  * Execute buffers are allocated via Direct3D.  These buffers may then
695  * be filled by the application with instructions to execute along with
696  * vertex data.
697  */
698
699 /*
700  * Supported op codes for execute instructions.
701  */
702 typedef enum _D3DOPCODE {
703     D3DOP_POINT                 = 1,
704     D3DOP_LINE                  = 2,
705     D3DOP_TRIANGLE              = 3,
706     D3DOP_MATRIXLOAD            = 4,
707     D3DOP_MATRIXMULTIPLY        = 5,
708     D3DOP_STATETRANSFORM        = 6,
709     D3DOP_STATELIGHT            = 7,
710     D3DOP_STATERENDER           = 8,
711     D3DOP_PROCESSVERTICES       = 9,
712     D3DOP_TEXTURELOAD           = 10,
713     D3DOP_EXIT                  = 11,
714     D3DOP_BRANCHFORWARD         = 12,
715     D3DOP_SPAN                  = 13,
716     D3DOP_SETSTATUS             = 14,
717     D3DOP_FORCE_DWORD           = 0x7fffffff, /* force 32-bit size enum */
718 } D3DOPCODE;
719
720 typedef struct _D3DINSTRUCTION {
721     BYTE bOpcode;   /* Instruction opcode */
722     BYTE bSize;     /* Size of each instruction data unit */
723     WORD wCount;    /* Count of instruction data units to follow */
724 } D3DINSTRUCTION, *LPD3DINSTRUCTION;
725
726 /*
727  * Structure for texture loads
728  */
729 typedef struct _D3DTEXTURELOAD {
730     D3DTEXTUREHANDLE hDestTexture;
731     D3DTEXTUREHANDLE hSrcTexture;
732 } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
733
734 /*
735  * Structure for picking
736  */
737 typedef struct _D3DPICKRECORD {
738     BYTE     bOpcode;
739     BYTE     bPad;
740     DWORD    dwOffset;
741     D3DVALUE dvZ;
742 } D3DPICKRECORD, *LPD3DPICKRECORD;
743
744 /*
745  * The following defines the rendering states which can be set in the
746  * execute buffer.
747  */
748
749 typedef enum _D3DSHADEMODE {
750     D3DSHADE_FLAT              = 1,
751     D3DSHADE_GOURAUD           = 2,
752     D3DSHADE_PHONG             = 3,
753     D3DSHADE_FORCE_DWORD       = 0x7fffffff, /* force 32-bit size enum */
754 } D3DSHADEMODE;
755
756 typedef enum _D3DFILLMODE {
757     D3DFILL_POINT              = 1,
758     D3DFILL_WIREFRAME          = 2,
759     D3DFILL_SOLID              = 3,
760     D3DFILL_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
761 } D3DFILLMODE;
762
763 typedef struct _D3DLINEPATTERN {
764     WORD        wRepeatFactor;
765     WORD        wLinePattern;
766 } D3DLINEPATTERN;
767
768 typedef enum _D3DTEXTUREFILTER {
769     D3DFILTER_NEAREST          = 1,
770     D3DFILTER_LINEAR           = 2,
771     D3DFILTER_MIPNEAREST       = 3,
772     D3DFILTER_MIPLINEAR        = 4,
773     D3DFILTER_LINEARMIPNEAREST = 5,
774     D3DFILTER_LINEARMIPLINEAR  = 6,
775     D3DFILTER_FORCE_DWORD      = 0x7fffffff, /* force 32-bit size enum */
776 } D3DTEXTUREFILTER;
777
778 typedef enum _D3DBLEND {
779     D3DBLEND_ZERO              = 1,
780     D3DBLEND_ONE               = 2,
781     D3DBLEND_SRCCOLOR          = 3,
782     D3DBLEND_INVSRCCOLOR       = 4,
783     D3DBLEND_SRCALPHA          = 5,
784     D3DBLEND_INVSRCALPHA       = 6,
785     D3DBLEND_DESTALPHA         = 7,
786     D3DBLEND_INVDESTALPHA      = 8,
787     D3DBLEND_DESTCOLOR         = 9,
788     D3DBLEND_INVDESTCOLOR      = 10,
789     D3DBLEND_SRCALPHASAT       = 11,
790     D3DBLEND_BOTHSRCALPHA      = 12,
791     D3DBLEND_BOTHINVSRCALPHA   = 13,
792     D3DBLEND_FORCE_DWORD       = 0x7fffffff, /* force 32-bit size enum */
793 } D3DBLEND;
794
795 typedef enum _D3DTEXTUREBLEND {
796     D3DTBLEND_DECAL            = 1,
797     D3DTBLEND_MODULATE         = 2,
798     D3DTBLEND_DECALALPHA       = 3,
799     D3DTBLEND_MODULATEALPHA    = 4,
800     D3DTBLEND_DECALMASK        = 5,
801     D3DTBLEND_MODULATEMASK     = 6,
802     D3DTBLEND_COPY             = 7,
803     D3DTBLEND_ADD              = 8,
804     D3DTBLEND_FORCE_DWORD      = 0x7fffffff, /* force 32-bit size enum */
805 } D3DTEXTUREBLEND;
806
807 typedef enum _D3DTEXTUREADDRESS {
808     D3DTADDRESS_WRAP           = 1,
809     D3DTADDRESS_MIRROR         = 2,
810     D3DTADDRESS_CLAMP          = 3,
811     D3DTADDRESS_BORDER         = 4,
812     D3DTADDRESS_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
813 } D3DTEXTUREADDRESS;
814
815 typedef enum _D3DCULL {
816     D3DCULL_NONE               = 1,
817     D3DCULL_CW                 = 2,
818     D3DCULL_CCW                = 3,
819     D3DCULL_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
820 } D3DCULL;
821
822 typedef enum _D3DCMPFUNC {
823     D3DCMP_NEVER               = 1,
824     D3DCMP_LESS                = 2,
825     D3DCMP_EQUAL               = 3,
826     D3DCMP_LESSEQUAL           = 4,
827     D3DCMP_GREATER             = 5,
828     D3DCMP_NOTEQUAL            = 6,
829     D3DCMP_GREATEREQUAL        = 7,
830     D3DCMP_ALWAYS              = 8,
831     D3DCMP_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
832 } D3DCMPFUNC;
833
834 typedef enum _D3DFOGMODE {
835     D3DFOG_NONE                = 0,
836     D3DFOG_EXP                 = 1,
837     D3DFOG_EXP2                = 2,
838     D3DFOG_LINEAR              = 3,
839     D3DFOG_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
840 } D3DFOGMODE;
841
842 typedef enum _D3DANTIALIASMODE {
843     D3DANTIALIAS_NONE          = 0,
844     D3DANTIALIAS_SORTDEPENDENT = 1,
845     D3DANTIALIAS_SORTINDEPENDENT = 2,
846     D3DANTIALIAS_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
847 } D3DANTIALIASMODE;
848
849 // Vertex types supported by Direct3D
850 typedef enum _D3DVERTEXTYPE {
851     D3DVT_VERTEX        = 1,
852     D3DVT_LVERTEX       = 2,
853     D3DVT_TLVERTEX      = 3,
854     D3DVT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
855 } D3DVERTEXTYPE;
856
857 // Primitives supported by draw-primitive API
858 typedef enum _D3DPRIMITIVETYPE {
859     D3DPT_POINTLIST     = 1,
860     D3DPT_LINELIST      = 2,
861     D3DPT_LINESTRIP     = 3,
862     D3DPT_TRIANGLELIST  = 4,
863     D3DPT_TRIANGLESTRIP = 5,
864     D3DPT_TRIANGLEFAN   = 6,
865     D3DPT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
866 } D3DPRIMITIVETYPE;
867
868 /*
869  * Amount to add to a state to generate the override for that state.
870  */
871 #define D3DSTATE_OVERRIDE_BIAS          256
872
873 /*
874  * A state which sets the override flag for the specified state type.
875  */
876 #define D3DSTATE_OVERRIDE(type) ((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)
877
878 typedef enum _D3DTRANSFORMSTATETYPE {
879     D3DTRANSFORMSTATE_WORLD           = 1,
880     D3DTRANSFORMSTATE_VIEW            = 2,
881     D3DTRANSFORMSTATE_PROJECTION      = 3,
882     D3DTRANSFORMSTATE_FORCE_DWORD     = 0x7fffffff, /* force 32-bit size enum */
883 } D3DTRANSFORMSTATETYPE;
884
885 typedef enum _D3DLIGHTSTATETYPE {
886     D3DLIGHTSTATE_MATERIAL            = 1,
887     D3DLIGHTSTATE_AMBIENT             = 2,
888     D3DLIGHTSTATE_COLORMODEL          = 3,
889     D3DLIGHTSTATE_FOGMODE             = 4,
890     D3DLIGHTSTATE_FOGSTART            = 5,
891     D3DLIGHTSTATE_FOGEND              = 6,
892     D3DLIGHTSTATE_FOGDENSITY          = 7,
893     D3DLIGHTSTATE_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
894 } D3DLIGHTSTATETYPE;
895
896 typedef enum _D3DRENDERSTATETYPE {
897     D3DRENDERSTATE_TEXTUREHANDLE      = 1,    /* Texture handle */
898     D3DRENDERSTATE_ANTIALIAS          = 2,    /* D3DANTIALIASMODE */
899     D3DRENDERSTATE_TEXTUREADDRESS     = 3,    /* D3DTEXTUREADDRESS      */
900     D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,    /* TRUE for perspective correction */
901     D3DRENDERSTATE_WRAPU              = 5,    /* TRUE for wrapping in u */
902     D3DRENDERSTATE_WRAPV              = 6,    /* TRUE for wrapping in v */
903     D3DRENDERSTATE_ZENABLE            = 7,    /* TRUE to enable z test */
904     D3DRENDERSTATE_FILLMODE           = 8,    /* D3DFILL_MODE            */
905     D3DRENDERSTATE_SHADEMODE          = 9,    /* D3DSHADEMODE */
906     D3DRENDERSTATE_LINEPATTERN        = 10,   /* D3DLINEPATTERN */
907     D3DRENDERSTATE_MONOENABLE         = 11,   /* TRUE to enable mono rasterization */
908     D3DRENDERSTATE_ROP2               = 12,   /* ROP2 */
909     D3DRENDERSTATE_PLANEMASK          = 13,   /* DWORD physical plane mask */
910     D3DRENDERSTATE_ZWRITEENABLE       = 14,   /* TRUE to enable z writes */
911     D3DRENDERSTATE_ALPHATESTENABLE    = 15,   /* TRUE to enable alpha tests */
912     D3DRENDERSTATE_LASTPIXEL          = 16,   /* TRUE for last-pixel on lines */
913     D3DRENDERSTATE_TEXTUREMAG         = 17,   /* D3DTEXTUREFILTER */
914     D3DRENDERSTATE_TEXTUREMIN         = 18,   /* D3DTEXTUREFILTER */
915     D3DRENDERSTATE_SRCBLEND           = 19,   /* D3DBLEND */
916     D3DRENDERSTATE_DESTBLEND          = 20,   /* D3DBLEND */
917     D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,   /* D3DTEXTUREBLEND */
918     D3DRENDERSTATE_CULLMODE           = 22,   /* D3DCULL */
919     D3DRENDERSTATE_ZFUNC              = 23,   /* D3DCMPFUNC */
920     D3DRENDERSTATE_ALPHAREF           = 24,   /* D3DFIXED */
921     D3DRENDERSTATE_ALPHAFUNC          = 25,   /* D3DCMPFUNC */
922     D3DRENDERSTATE_DITHERENABLE       = 26,   /* TRUE to enable dithering */
923     D3DRENDERSTATE_ALPHABLENDENABLE   = 27,   /* TRUE to enable alpha blending */
924     D3DRENDERSTATE_FOGENABLE          = 28,   /* TRUE to enable fog */
925     D3DRENDERSTATE_SPECULARENABLE     = 29,   /* TRUE to enable specular */
926     D3DRENDERSTATE_ZVISIBLE           = 30,   /* TRUE to enable z checking */
927     D3DRENDERSTATE_SUBPIXEL           = 31,   /* TRUE to enable subpixel correction */
928     D3DRENDERSTATE_SUBPIXELX          = 32,   /* TRUE to enable correction in X only */
929     D3DRENDERSTATE_STIPPLEDALPHA      = 33,   /* TRUE to enable stippled alpha */
930     D3DRENDERSTATE_FOGCOLOR           = 34,   /* D3DCOLOR */
931     D3DRENDERSTATE_FOGTABLEMODE       = 35,   /* D3DFOGMODE */
932     D3DRENDERSTATE_FOGTABLESTART      = 36,   /* Fog table start        */
933     D3DRENDERSTATE_FOGTABLEEND        = 37,   /* Fog table end          */
934     D3DRENDERSTATE_FOGTABLEDENSITY    = 38,   /* Fog table density      */
935     D3DRENDERSTATE_STIPPLEENABLE      = 39,   /* TRUE to enable stippling */
936     D3DRENDERSTATE_EDGEANTIALIAS      = 40,   /* TRUE to enable edge antialiasing */
937     D3DRENDERSTATE_COLORKEYENABLE     = 41,   /* TRUE to enable source colorkeyed textures */
938     D3DRENDERSTATE_BORDERCOLOR        = 43,   /* Border color for texturing w/border */
939     D3DRENDERSTATE_TEXTUREADDRESSU    = 44,   /* Texture addressing mode for U coordinate */
940     D3DRENDERSTATE_TEXTUREADDRESSV    = 45,   /* Texture addressing mode for V coordinate */
941     D3DRENDERSTATE_MIPMAPLODBIAS      = 46,   /* D3DVALUE Mipmap LOD bias */
942     D3DRENDERSTATE_ZBIAS              = 47,   /* LONG Z bias */
943     D3DRENDERSTATE_RANGEFOGENABLE     = 48,   /* Enables range-based fog */
944     D3DRENDERSTATE_ANISOTROPY         = 49,   /* Max. anisotropy. 1 = no anisotropy */
945         D3DRENDERSTATE_FLUSHBATCH                 = 50,   /* Explicit flush for DP batching (DX5 Only) */
946     D3DRENDERSTATE_STIPPLEPATTERN00   = 64,   /* Stipple pattern 01...  */
947     D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
948     D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
949     D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
950     D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
951     D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
952     D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
953     D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
954     D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
955     D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
956     D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
957     D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
958     D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
959     D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
960     D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
961     D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
962     D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
963     D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
964     D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
965     D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
966     D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
967     D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
968     D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
969     D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
970     D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
971     D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
972     D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
973     D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
974     D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
975     D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
976     D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
977     D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
978     D3DRENDERSTATE_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
979 } D3DRENDERSTATETYPE;
980
981 // For back-compatibility with legacy compilations
982 #define D3DRENDERSTATE_BLENDENABLE      D3DRENDERSTATE_ALPHABLENDENABLE
983
984 #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
985
986 typedef struct _D3DSTATE {
987     union {
988         D3DTRANSFORMSTATETYPE   dtstTransformStateType;
989         D3DLIGHTSTATETYPE       dlstLightStateType;
990         D3DRENDERSTATETYPE      drstRenderStateType;
991     };
992     union {
993         DWORD                   dwArg[1];
994         D3DVALUE                dvArg[1];
995     };
996 } D3DSTATE, *LPD3DSTATE;
997
998 /*
999  * Operation used to load matrices
1000  * hDstMat = hSrcMat
1001  */
1002 typedef struct _D3DMATRIXLOAD {
1003     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
1004     D3DMATRIXHANDLE hSrcMatrix;   /* Source matrix */
1005 } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
1006
1007 /*
1008  * Operation used to multiply matrices
1009  * hDstMat = hSrcMat1 * hSrcMat2
1010  */
1011 typedef struct _D3DMATRIXMULTIPLY {
1012     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
1013     D3DMATRIXHANDLE hSrcMatrix1;  /* First source matrix */
1014     D3DMATRIXHANDLE hSrcMatrix2;  /* Second source matrix */
1015 } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
1016
1017 /*
1018  * Operation used to transform and light vertices.
1019  */
1020 typedef struct _D3DPROCESSVERTICES {
1021     DWORD        dwFlags;    /* Do we transform or light or just copy? */
1022     WORD         wStart;     /* Index to first vertex in source */
1023     WORD         wDest;      /* Index to first vertex in local buffer */
1024     DWORD        dwCount;    /* Number of vertices to be processed */
1025     DWORD        dwReserved; /* Must be zero */
1026 } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
1027
1028 #define D3DPROCESSVERTICES_TRANSFORMLIGHT       0x00000000L
1029 #define D3DPROCESSVERTICES_TRANSFORM            0x00000001L
1030 #define D3DPROCESSVERTICES_COPY                 0x00000002L
1031 #define D3DPROCESSVERTICES_OPMASK               0x00000007L
1032
1033 #define D3DPROCESSVERTICES_UPDATEEXTENTS        0x00000008L
1034 #define D3DPROCESSVERTICES_NOCOLOR              0x00000010L
1035
1036
1037 /*
1038  * Triangle flags
1039  */
1040  
1041 /*
1042  * Tri strip and fan flags.
1043  * START loads all three vertices
1044  * EVEN and ODD load just v3 with even or odd culling
1045  * START_FLAT contains a count from 0 to 29 that allows the
1046  * whole strip or fan to be culled in one hit.
1047  * e.g. for a quad len = 1
1048  */
1049 #define D3DTRIFLAG_START                        0x00000000L
1050 #define D3DTRIFLAG_STARTFLAT(len) (len)         /* 0 < len < 30 */
1051 #define D3DTRIFLAG_ODD                          0x0000001eL
1052 #define D3DTRIFLAG_EVEN                         0x0000001fL
1053
1054 /*
1055  * Triangle edge flags
1056  * enable edges for wireframe or antialiasing
1057  */
1058 #define D3DTRIFLAG_EDGEENABLE1                  0x00000100L /* v0-v1 edge */
1059 #define D3DTRIFLAG_EDGEENABLE2                  0x00000200L /* v1-v2 edge */
1060 #define D3DTRIFLAG_EDGEENABLE3                  0x00000400L /* v2-v0 edge */
1061 #define D3DTRIFLAG_EDGEENABLETRIANGLE \
1062         (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
1063         
1064 /*
1065  * Primitive structures and related defines.  Vertex offsets are to types
1066  * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
1067  */
1068
1069 /*
1070  * Triangle list primitive structure
1071  */
1072 typedef struct _D3DTRIANGLE {
1073     union {
1074         WORD    v1;            /* Vertex indices */
1075         WORD    wV1;
1076     };
1077     union {
1078         WORD    v2;
1079         WORD    wV2;
1080     };
1081     union {
1082         WORD    v3;
1083         WORD    wV3;
1084     };
1085     WORD        wFlags;       /* Edge (and other) flags */
1086 } D3DTRIANGLE, *LPD3DTRIANGLE;
1087
1088 /*
1089  * Line list structure.
1090  * The instruction count defines the number of line segments.
1091  */
1092 typedef struct _D3DLINE {
1093     union {
1094         WORD    v1;            /* Vertex indices */
1095         WORD    wV1;
1096     };
1097     union {
1098         WORD    v2;
1099         WORD    wV2;
1100     };
1101 } D3DLINE, *LPD3DLINE;
1102
1103 /*
1104  * Span structure
1105  * Spans join a list of points with the same y value.
1106  * If the y value changes, a new span is started.
1107  */
1108 typedef struct _D3DSPAN {
1109     WORD        wCount; /* Number of spans */
1110     WORD        wFirst; /* Index to first vertex */
1111 } D3DSPAN, *LPD3DSPAN;
1112
1113 /*
1114  * Point structure
1115  */
1116 typedef struct _D3DPOINT {
1117     WORD        wCount;         /* number of points         */
1118     WORD        wFirst;         /* index to first vertex    */
1119 } D3DPOINT, *LPD3DPOINT;
1120
1121
1122 /*
1123  * Forward branch structure.
1124  * Mask is logically anded with the driver status mask
1125  * if the result equals 'value', the branch is taken.
1126  */
1127 typedef struct _D3DBRANCH {
1128     DWORD       dwMask;         /* Bitmask against D3D status */
1129     DWORD       dwValue;
1130     BOOL        bNegate;        /* TRUE to negate comparison */
1131     DWORD       dwOffset;       /* How far to branch forward (0 for exit)*/
1132 } D3DBRANCH, *LPD3DBRANCH;
1133
1134 /*
1135  * Status used for set status instruction.
1136  * The D3D status is initialised on device creation
1137  * and is modified by all execute calls.
1138  */
1139 typedef struct _D3DSTATUS {
1140     DWORD       dwFlags;        /* Do we set extents or status */
1141     DWORD       dwStatus;       /* D3D status */
1142     D3DRECT     drExtent;
1143 } D3DSTATUS, *LPD3DSTATUS;
1144
1145 #define D3DSETSTATUS_STATUS             0x00000001L
1146 #define D3DSETSTATUS_EXTENTS            0x00000002L
1147 #define D3DSETSTATUS_ALL        (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
1148
1149 typedef struct _D3DCLIPSTATUS {
1150         DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
1151         DWORD dwStatus; /* Clip status */
1152         float minx, maxx; /* X extents */
1153         float miny, maxy; /* Y extents */
1154         float minz, maxz; /* Z extents */
1155 } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
1156
1157 #define D3DCLIPSTATUS_STATUS        0x00000001L
1158 #define D3DCLIPSTATUS_EXTENTS2      0x00000002L
1159 #define D3DCLIPSTATUS_EXTENTS3      0x00000004L
1160
1161 /*
1162  * Statistics structure
1163  */
1164 typedef struct _D3DSTATS {
1165     DWORD        dwSize;
1166     DWORD        dwTrianglesDrawn;
1167     DWORD        dwLinesDrawn;
1168     DWORD        dwPointsDrawn;
1169     DWORD        dwSpansDrawn;
1170     DWORD        dwVerticesProcessed;
1171 } D3DSTATS, *LPD3DSTATS;
1172
1173 /*
1174  * Execute options.
1175  * When calling using D3DEXECUTE_UNCLIPPED all the primitives 
1176  * inside the buffer must be contained within the viewport.
1177  */
1178 #define D3DEXECUTE_CLIPPED       0x00000001l
1179 #define D3DEXECUTE_UNCLIPPED     0x00000002l
1180
1181 typedef struct _D3DEXECUTEDATA {
1182     DWORD       dwSize;
1183     DWORD       dwVertexOffset;
1184     DWORD       dwVertexCount;
1185     DWORD       dwInstructionOffset;
1186     DWORD       dwInstructionLength;
1187     DWORD       dwHVertexOffset;
1188     D3DSTATUS   dsStatus;       /* Status after execute */
1189 } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
1190
1191 /*
1192  * Palette flags.
1193  * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
1194  */
1195 #define D3DPAL_FREE     0x00    /* Renderer may use this entry freely */
1196 #define D3DPAL_READONLY 0x40    /* Renderer may not set this entry */
1197 #define D3DPAL_RESERVED 0x80    /* Renderer may not use this entry */
1198
1199 #pragma pack()
1200
1201 #endif /* _D3DTYPES_H_ */
1202