1/*==========================================================================;
2 *
3 *  Copyright (C) 1995-1996 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#ifndef WIN32
14#include "subwtype.h"
15#else
16#include <windows.h>
17#endif
18
19#include <ddraw.h>
20
21#pragma pack(4)
22
23#if defined(__cplusplus)
24extern "C"
25{
26#endif
27
28/* D3DVALUE is the fundamental Direct3D fractional data type */
29
30#define D3DVALP(val, prec) ((float)(val))
31#define D3DVAL(val) ((float)(val))
32typedef float D3DVALUE, *LPD3DVALUE;
33#define D3DDivide(a, b)    (float)((double) (a) / (double) (b))
34#define D3DMultiply(a, b)    ((a) * (b))
35
36typedef LONG D3DFIXED;
37
38#ifndef RGB_MAKE
39/*
40 * Format of CI colors is
41 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 *  |    alpha      |         color index           |   fraction    |
43 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 */
45#define CI_GETALPHA(ci)    ((ci) >> 24)
46#define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
47#define CI_GETFRACTION(ci) ((ci) & 0xff)
48#define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
49#define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
50#define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
51
52/*
53 * Format of RGBA colors is
54 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 *  |    alpha      |      red      |     green     |     blue      |
56 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 */
58#define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
59#define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
60#define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
61#define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
62#define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
63
64/* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
65 * The float values must be in the range 0..1
66 */
67#define D3DRGB(r, g, b) \
68    (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
69#define D3DRGBA(r, g, b, a) \
70    (   (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
71    |   (((long)((g) * 255)) << 8) | (long)((b) * 255) \
72    )
73
74/*
75 * Format of RGB colors is
76 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 *  |    ignored    |      red      |     green     |     blue      |
78 *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 */
80#define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
81#define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
82#define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
83#define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
84#define RGB_MAKE(r, g, b)       ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
85#define RGBA_TORGB(rgba)       ((D3DCOLOR) ((rgba) & 0xffffff))
86#define RGB_TORGBA(rgb)        ((D3DCOLOR) ((rgb) | 0xff000000))
87
88#endif
89
90/*
91 * Flags for Enumerate functions
92 */
93
94/*
95 * Stop the enumeration
96 */
97#define D3DENUMRET_CANCEL                        DDENUMRET_CANCEL
98
99/*
100 * Continue the enumeration
101 */
102#define D3DENUMRET_OK                            DDENUMRET_OK
103
104typedef HRESULT (WINAPI* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
105typedef HRESULT (WINAPI* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
106
107typedef DWORD D3DCOLOR, D3DCOLOR, *LPD3DCOLOR;
108
109typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
110typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
111typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
112
113typedef struct _D3DCOLORVALUE {
114    union {
115        D3DVALUE r;
116        D3DVALUE dvR;
117    };
118    union {
119        D3DVALUE g;
120        D3DVALUE dvG;
121    };
122    union {
123        D3DVALUE b;
124        D3DVALUE dvB;
125    };
126    union {
127        D3DVALUE a;
128        D3DVALUE dvA;
129    };
130} D3DCOLORVALUE;
131
132typedef struct _D3DRECT {
133    union {
134        LONG x1;
135        LONG lX1;
136    };
137    union {
138        LONG y1;
139        LONG lY1;
140    };
141    union {
142        LONG x2;
143        LONG lX2;
144    };
145    union {
146        LONG y2;
147        LONG lY2;
148    };
149} D3DRECT, *LPD3DRECT;
150
151typedef struct _D3DVECTOR {
152    union {
153        D3DVALUE x;
154        D3DVALUE dvX;
155    };
156    union {
157        D3DVALUE y;
158        D3DVALUE dvY;
159    };
160    union {
161        D3DVALUE z;
162        D3DVALUE dvZ;
163    };
164} D3DVECTOR, *LPD3DVECTOR;
165
166
167/*
168 * Vertex data types supported in an ExecuteBuffer.
169 */
170
171/*
172 * Homogeneous vertices
173 */
174
175typedef struct _D3DHVERTEX {
176    DWORD           dwFlags;        /* Homogeneous clipping flags */
177    union {
178        D3DVALUE    hx;
179        D3DVALUE    dvHX;
180    };
181    union {
182        D3DVALUE    hy;
183        D3DVALUE    dvHY;
184    };
185    union {
186        D3DVALUE    hz;
187        D3DVALUE    dvHZ;
188    };
189} D3DHVERTEX, *LPD3DHVERTEX;
190
191/*
192 * Transformed/lit vertices
193 */
194typedef struct _D3DTLVERTEX {
195    union {
196        D3DVALUE    sx;             /* Screen coordinates */
197        D3DVALUE    dvSX;
198    };
199    union {
200        D3DVALUE    sy;
201        D3DVALUE    dvSY;
202    };
203    union {
204        D3DVALUE    sz;
205        D3DVALUE    dvSZ;
206    };
207    union {
208        D3DVALUE    rhw;            /* Reciprocal of homogeneous w */
209        D3DVALUE    dvRHW;
210    };
211    union {
212        D3DCOLOR    color;          /* Vertex color */
213        D3DCOLOR    dcColor;
214    };
215    union {
216        D3DCOLOR    specular;       /* Specular component of vertex */
217        D3DCOLOR    dcSpecular;
218    };
219    union {
220        D3DVALUE    tu;             /* Texture coordinates */
221        D3DVALUE    dvTU;
222    };
223    union {
224        D3DVALUE    tv;
225        D3DVALUE    dvTV;
226    };
227} D3DTLVERTEX, *LPD3DTLVERTEX;
228
229/*
230 * Untransformed/lit vertices
231 */
232typedef struct _D3DLVERTEX {
233    union {
234        D3DVALUE     x;             /* Homogeneous coordinates */
235        D3DVALUE     dvX;
236    };
237    union {
238        D3DVALUE     y;
239        D3DVALUE     dvY;
240    };
241    union {
242        D3DVALUE     z;
243        D3DVALUE     dvZ;
244    };
245    DWORD            dwReserved;
246    union {
247        D3DCOLOR     color;         /* Vertex color */
248        D3DCOLOR     dcColor;
249    };
250    union {
251        D3DCOLOR     specular;      /* Specular component of vertex */
252        D3DCOLOR     dcSpecular;
253    };
254    union {
255        D3DVALUE     tu;            /* Texture coordinates */
256        D3DVALUE     dvTU;
257    };
258    union {
259        D3DVALUE     tv;
260        D3DVALUE     dvTV;
261    };
262} D3DLVERTEX, *LPD3DLVERTEX;
263
264/*
265 * Untransformed/unlit vertices
266 */
267
268typedef struct _D3DVERTEX {
269    union {
270        D3DVALUE     x;             /* Homogeneous coordinates */
271        D3DVALUE     dvX;
272    };
273    union {
274        D3DVALUE     y;
275        D3DVALUE     dvY;
276    };
277    union {
278        D3DVALUE     z;
279        D3DVALUE     dvZ;
280    };
281    union {
282        D3DVALUE     nx;            /* Normal */
283        D3DVALUE     dvNX;
284    };
285    union {
286        D3DVALUE     ny;
287        D3DVALUE     dvNY;
288    };
289    union {
290        D3DVALUE     nz;
291        D3DVALUE     dvNZ;
292    };
293    union {
294        D3DVALUE     tu;            /* Texture coordinates */
295        D3DVALUE     dvTU;
296    };
297    union {
298        D3DVALUE     tv;
299        D3DVALUE     dvTV;
300    };
301} D3DVERTEX, *LPD3DVERTEX;
302
303/*
304 * Matrix, viewport, and tranformation structures and definitions.
305 */
306
307typedef struct _D3DMATRIX {
308    D3DVALUE        _11, _12, _13, _14;
309    D3DVALUE        _21, _22, _23, _24;
310    D3DVALUE        _31, _32, _33, _34;
311    D3DVALUE        _41, _42, _43, _44;
312} D3DMATRIX, *LPD3DMATRIX;
313
314typedef struct _D3DVIEWPORT {
315    DWORD       dwSize;
316    DWORD       dwX;
317    DWORD       dwY;            /* Top left */
318    DWORD       dwWidth;
319    DWORD       dwHeight;       /* Dimensions */
320    D3DVALUE    dvScaleX;       /* Scale homogeneous to screen */
321    D3DVALUE    dvScaleY;       /* Scale homogeneous to screen */
322    D3DVALUE    dvMaxX;         /* Min/max homogeneous x coord */
323    D3DVALUE    dvMaxY;         /* Min/max homogeneous y coord */
324    D3DVALUE    dvMinZ;
325    D3DVALUE    dvMaxZ;         /* Min/max homogeneous z coord */
326} D3DVIEWPORT, *LPD3DVIEWPORT;
327
328/*
329 * Values for clip fields.
330 */
331#define D3DCLIP_LEFT                            0x00000001L
332#define D3DCLIP_RIGHT                           0x00000002L
333#define D3DCLIP_TOP                             0x00000004L
334#define D3DCLIP_BOTTOM                          0x00000008L
335#define D3DCLIP_FRONT                           0x00000010L
336#define D3DCLIP_BACK                            0x00000020L
337#define D3DCLIP_GEN0                            0x00000040L
338#define D3DCLIP_GEN1                            0x00000080L
339#define D3DCLIP_GEN2                            0x00000100L
340#define D3DCLIP_GEN3                            0x00000200L
341#define D3DCLIP_GEN4                            0x00000400L
342#define D3DCLIP_GEN5                            0x00000800L
343
344/*
345 * Values for d3d status.
346 */
347#define D3DSTATUS_CLIPUNIONLEFT                 D3DCLIP_LEFT
348#define D3DSTATUS_CLIPUNIONRIGHT                D3DCLIP_RIGHT
349#define D3DSTATUS_CLIPUNIONTOP                  D3DCLIP_TOP
350#define D3DSTATUS_CLIPUNIONBOTTOM               D3DCLIP_BOTTOM
351#define D3DSTATUS_CLIPUNIONFRONT                D3DCLIP_FRONT
352#define D3DSTATUS_CLIPUNIONBACK                 D3DCLIP_BACK
353#define D3DSTATUS_CLIPUNIONGEN0                 D3DCLIP_GEN0
354#define D3DSTATUS_CLIPUNIONGEN1                 D3DCLIP_GEN1
355#define D3DSTATUS_CLIPUNIONGEN2                 D3DCLIP_GEN2
356#define D3DSTATUS_CLIPUNIONGEN3                 D3DCLIP_GEN3
357#define D3DSTATUS_CLIPUNIONGEN4                 D3DCLIP_GEN4
358#define D3DSTATUS_CLIPUNIONGEN5                 D3DCLIP_GEN5
359
360#define D3DSTATUS_CLIPINTERSECTIONLEFT          0x00001000L
361#define D3DSTATUS_CLIPINTERSECTIONRIGHT         0x00002000L
362#define D3DSTATUS_CLIPINTERSECTIONTOP           0x00004000L
363#define D3DSTATUS_CLIPINTERSECTIONBOTTOM        0x00008000L
364#define D3DSTATUS_CLIPINTERSECTIONFRONT         0x00010000L
365#define D3DSTATUS_CLIPINTERSECTIONBACK          0x00020000L
366#define D3DSTATUS_CLIPINTERSECTIONGEN0          0x00040000L
367#define D3DSTATUS_CLIPINTERSECTIONGEN1          0x00080000L
368#define D3DSTATUS_CLIPINTERSECTIONGEN2          0x00100000L
369#define D3DSTATUS_CLIPINTERSECTIONGEN3          0x00200000L
370#define D3DSTATUS_CLIPINTERSECTIONGEN4          0x00400000L
371#define D3DSTATUS_CLIPINTERSECTIONGEN5          0x00800000L
372#define D3DSTATUS_ZNOTVISIBLE                   0x01000000L
373
374#define D3DSTATUS_CLIPUNIONALL  (               \
375            D3DSTATUS_CLIPUNIONLEFT     |       \
376            D3DSTATUS_CLIPUNIONRIGHT    |       \
377            D3DSTATUS_CLIPUNIONTOP      |       \
378            D3DSTATUS_CLIPUNIONBOTTOM   |       \
379            D3DSTATUS_CLIPUNIONFRONT    |       \
380            D3DSTATUS_CLIPUNIONBACK     |       \
381            D3DSTATUS_CLIPUNIONGEN0     |       \
382            D3DSTATUS_CLIPUNIONGEN1     |       \
383            D3DSTATUS_CLIPUNIONGEN2     |       \
384            D3DSTATUS_CLIPUNIONGEN3     |       \
385            D3DSTATUS_CLIPUNIONGEN4     |       \
386            D3DSTATUS_CLIPUNIONGEN5             \
387            )
388
389#define D3DSTATUS_CLIPINTERSECTIONALL   (               \
390            D3DSTATUS_CLIPINTERSECTIONLEFT      |       \
391            D3DSTATUS_CLIPINTERSECTIONRIGHT     |       \
392            D3DSTATUS_CLIPINTERSECTIONTOP       |       \
393            D3DSTATUS_CLIPINTERSECTIONBOTTOM    |       \
394            D3DSTATUS_CLIPINTERSECTIONFRONT     |       \
395            D3DSTATUS_CLIPINTERSECTIONBACK      |       \
396            D3DSTATUS_CLIPINTERSECTIONGEN0      |       \
397            D3DSTATUS_CLIPINTERSECTIONGEN1      |       \
398            D3DSTATUS_CLIPINTERSECTIONGEN2      |       \
399            D3DSTATUS_CLIPINTERSECTIONGEN3      |       \
400            D3DSTATUS_CLIPINTERSECTIONGEN4      |       \
401            D3DSTATUS_CLIPINTERSECTIONGEN5              \
402            )
403
404#define D3DSTATUS_DEFAULT       (                       \
405            D3DSTATUS_CLIPINTERSECTIONALL       |       \
406            D3DSTATUS_ZNOTVISIBLE)
407
408
409/*
410 * Options for direct transform calls
411 */
412#define D3DTRANSFORM_CLIPPED       0x00000001l
413#define D3DTRANSFORM_UNCLIPPED     0x00000002l
414
415typedef struct _D3DTRANSFORMDATA {
416    DWORD           dwSize;
417    LPVOID          lpIn;           /* Input vertices */
418    DWORD           dwInSize;       /* Stride of input vertices */
419    LPVOID          lpOut;          /* Output vertices */
420    DWORD           dwOutSize;      /* Stride of output vertices */
421    LPD3DHVERTEX    lpHOut;         /* Output homogeneous vertices */
422    DWORD           dwClip;         /* Clipping hint */
423    DWORD           dwClipIntersection;
424    DWORD           dwClipUnion;    /* Union of all clip flags */
425    D3DRECT         drExtent;       /* Extent of transformed vertices */
426} D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
427
428/*
429 * Structure defining position and direction properties for lighting.
430 */
431typedef struct _D3DLIGHTINGELEMENT {
432    D3DVECTOR dvPosition;           /* Lightable point in model space */
433    D3DVECTOR dvNormal;             /* Normalised unit vector */
434} D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
435
436/*
437 * Structure defining material properties for lighting.
438 */
439typedef struct _D3DMATERIAL {
440    DWORD               dwSize;
441    union {
442        D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
443        D3DCOLORVALUE   dcvDiffuse;
444    };
445    union {
446        D3DCOLORVALUE   ambient;        /* Ambient color RGB */
447        D3DCOLORVALUE   dcvAmbient;
448    };
449    union {
450        D3DCOLORVALUE   specular;       /* Specular 'shininess' */
451        D3DCOLORVALUE   dcvSpecular;
452    };
453    union {
454        D3DCOLORVALUE   emissive;       /* Emissive color RGB */
455        D3DCOLORVALUE   dcvEmissive;
456    };
457    union {
458        D3DVALUE        power;          /* Sharpness if specular highlight */
459        D3DVALUE        dvPower;
460    };
461    D3DTEXTUREHANDLE    hTexture;       /* Handle to texture map */
462    DWORD               dwRampSize;
463} D3DMATERIAL, *LPD3DMATERIAL;
464
465typedef enum _D3DLIGHTTYPE {
466    D3DLIGHT_POINT          = 1,
467    D3DLIGHT_SPOT           = 2,
468    D3DLIGHT_DIRECTIONAL    = 3,
469    D3DLIGHT_PARALLELPOINT  = 4,
470    D3DLIGHT_GLSPOT         = 5,
471} D3DLIGHTTYPE;
472
473/*
474 * Structure defining a light source and its properties.
475 */
476typedef struct _D3DLIGHT {
477    DWORD           dwSize;
478    D3DLIGHTTYPE    dltType;            /* Type of light source */
479    D3DCOLORVALUE   dcvColor;           /* Color of light */
480    D3DVECTOR       dvPosition;         /* Position in world space */
481    D3DVECTOR       dvDirection;        /* Direction in world space */
482    D3DVALUE        dvRange;            /* Cutoff range */
483    D3DVALUE        dvFalloff;          /* Falloff */
484    D3DVALUE        dvAttenuation0;     /* Constant attenuation */
485    D3DVALUE        dvAttenuation1;     /* Linear attenuation */
486    D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
487    D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
488    D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
489} D3DLIGHT, *LPD3DLIGHT;
490
491typedef struct _D3DLIGHTDATA {
492    DWORD                dwSize;
493    LPD3DLIGHTINGELEMENT lpIn;          /* Input positions and normals */
494    DWORD                dwInSize;      /* Stride of input elements */
495    LPD3DTLVERTEX        lpOut;         /* Output colors */
496    DWORD                dwOutSize;     /* Stride of output colors */
497} D3DLIGHTDATA, *LPD3DLIGHTDATA;
498
499typedef enum _D3DCOLORMODEL {
500    D3DCOLOR_MONO           = 1,
501    D3DCOLOR_RGB            = 2,
502} D3DCOLORMODEL;
503
504/*
505 * Options for clearing
506 */
507#define D3DCLEAR_TARGET            0x00000001l /* Clear target surface */
508#define D3DCLEAR_ZBUFFER           0x00000002l /* Clear target z buffer */
509
510/*
511 * Execute buffers are allocated via Direct3D.  These buffers may then
512 * be filled by the application with instructions to execute along with
513 * vertex data.
514 */
515
516/*
517 * Supported op codes for execute instructions.
518 */
519typedef enum _D3DOPCODE {
520    D3DOP_POINT                 = 1,
521    D3DOP_LINE                  = 2,
522    D3DOP_TRIANGLE              = 3,
523    D3DOP_MATRIXLOAD            = 4,
524    D3DOP_MATRIXMULTIPLY        = 5,
525    D3DOP_STATETRANSFORM        = 6,
526    D3DOP_STATELIGHT            = 7,
527    D3DOP_STATERENDER           = 8,
528    D3DOP_PROCESSVERTICES       = 9,
529    D3DOP_TEXTURELOAD           = 10,
530    D3DOP_EXIT                  = 11,
531    D3DOP_BRANCHFORWARD         = 12,
532    D3DOP_SPAN                  = 13,
533    D3DOP_SETSTATUS             = 14,
534} D3DOPCODE;
535
536typedef struct _D3DINSTRUCTION {
537    BYTE bOpcode;   /* Instruction opcode */
538    BYTE bSize;     /* Size of each instruction data unit */
539    WORD wCount;    /* Count of instruction data units to follow */
540} D3DINSTRUCTION, *LPD3DINSTRUCTION;
541
542/*
543 * Structure for texture loads
544 */
545typedef struct _D3DTEXTURELOAD {
546    D3DTEXTUREHANDLE hDestTexture;
547    D3DTEXTUREHANDLE hSrcTexture;
548} D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
549
550/*
551 * Structure for picking
552 */
553typedef struct _D3DPICKRECORD {
554    BYTE     bOpcode;
555    BYTE     bPad;
556    DWORD    dwOffset;
557    D3DVALUE dvZ;
558} D3DPICKRECORD, *LPD3DPICKRECORD;
559
560/*
561 * The following defines the rendering states which can be set in the
562 * execute buffer.
563 */
564
565typedef enum _D3DSHADEMODE {
566    D3DSHADE_FLAT              = 1,
567    D3DSHADE_GOURAUD           = 2,
568    D3DSHADE_PHONG             = 3,
569} D3DSHADEMODE;
570
571typedef enum _D3DFILLMODE {
572    D3DFILL_POINT              = 1,
573    D3DFILL_WIREFRAME          = 2,
574    D3DFILL_SOLID              = 3,
575} D3DFILLMODE;
576
577typedef struct _D3DLINEPATTERN {
578    WORD        wRepeatFactor;
579    WORD        wLinePattern;
580} D3DLINEPATTERN;
581
582typedef enum _D3DTEXTUREFILTER {
583    D3DFILTER_NEAREST          = 1,
584    D3DFILTER_LINEAR           = 2,
585    D3DFILTER_MIPNEAREST       = 3,
586    D3DFILTER_MIPLINEAR        = 4,
587    D3DFILTER_LINEARMIPNEAREST = 5,
588    D3DFILTER_LINEARMIPLINEAR  = 6,
589} D3DTEXTUREFILTER;
590
591typedef enum _D3DBLEND {
592    D3DBLEND_ZERO              = 1,
593    D3DBLEND_ONE               = 2,
594    D3DBLEND_SRCCOLOR          = 3,
595    D3DBLEND_INVSRCCOLOR       = 4,
596    D3DBLEND_SRCALPHA          = 5,
597    D3DBLEND_INVSRCALPHA       = 6,
598    D3DBLEND_DESTALPHA         = 7,
599    D3DBLEND_INVDESTALPHA      = 8,
600    D3DBLEND_DESTCOLOR         = 9,
601    D3DBLEND_INVDESTCOLOR      = 10,
602    D3DBLEND_SRCALPHASAT       = 11,
603    D3DBLEND_BOTHSRCALPHA      = 12,
604    D3DBLEND_BOTHINVSRCALPHA   = 13,
605} D3DBLEND;
606
607typedef enum _D3DTEXTUREBLEND {
608    D3DTBLEND_DECAL            = 1,
609    D3DTBLEND_MODULATE         = 2,
610    D3DTBLEND_DECALALPHA       = 3,
611    D3DTBLEND_MODULATEALPHA    = 4,
612    D3DTBLEND_DECALMASK        = 5,
613    D3DTBLEND_MODULATEMASK     = 6,
614    D3DTBLEND_COPY             = 7,
615} D3DTEXTUREBLEND;
616
617typedef enum _D3DTEXTUREADDRESS {
618    D3DTADDRESS_WRAP           = 1,
619    D3DTADDRESS_MIRROR         = 2,
620    D3DTADDRESS_CLAMP          = 3,
621} D3DTEXTUREADDRESS;
622
623typedef enum _D3DCULL {
624    D3DCULL_NONE               = 1,
625    D3DCULL_CW                 = 2,
626    D3DCULL_CCW                = 3,
627} D3DCULL;
628
629typedef enum _D3DCMPFUNC {
630    D3DCMP_NEVER               = 1,
631    D3DCMP_LESS                = 2,
632    D3DCMP_EQUAL               = 3,
633    D3DCMP_LESSEQUAL           = 4,
634    D3DCMP_GREATER             = 5,
635    D3DCMP_NOTEQUAL            = 6,
636    D3DCMP_GREATEREQUAL        = 7,
637    D3DCMP_ALWAYS              = 8,
638} D3DCMPFUNC;
639
640typedef enum _D3DFOGMODE {
641    D3DFOG_NONE                = 0,
642    D3DFOG_EXP                 = 1,
643    D3DFOG_EXP2                = 2,
644    D3DFOG_LINEAR              = 3
645} D3DFOGMODE;
646
647/*
648 * Amount to add to a state to generate the override for that state.
649 */
650#define D3DSTATE_OVERRIDE_BIAS          256
651
652/*
653 * A state which sets the override flag for the specified state type.
654 */
655#define D3DSTATE_OVERRIDE(type) ((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)
656
657typedef enum _D3DTRANSFORMSTATETYPE {
658    D3DTRANSFORMSTATE_WORLD           = 1,
659    D3DTRANSFORMSTATE_VIEW            = 2,
660    D3DTRANSFORMSTATE_PROJECTION      = 3,
661} D3DTRANSFORMSTATETYPE;
662
663typedef enum _D3DLIGHTSTATETYPE {
664    D3DLIGHTSTATE_MATERIAL            = 1,
665    D3DLIGHTSTATE_AMBIENT             = 2,
666    D3DLIGHTSTATE_COLORMODEL          = 3,
667    D3DLIGHTSTATE_FOGMODE             = 4,
668    D3DLIGHTSTATE_FOGSTART            = 5,
669    D3DLIGHTSTATE_FOGEND              = 6,
670    D3DLIGHTSTATE_FOGDENSITY          = 7,
671} D3DLIGHTSTATETYPE;
672
673typedef enum _D3DRENDERSTATETYPE {
674    D3DRENDERSTATE_TEXTUREHANDLE      = 1,    /* Texture handle */
675    D3DRENDERSTATE_ANTIALIAS          = 2,    /* Antialiasing prim edges */
676    D3DRENDERSTATE_TEXTUREADDRESS     = 3,    /* D3DTEXTUREADDRESS      */
677    D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,    /* TRUE for perspective correction */
678    D3DRENDERSTATE_WRAPU              = 5,    /* TRUE for wrapping in u */
679    D3DRENDERSTATE_WRAPV              = 6,    /* TRUE for wrapping in v */
680    D3DRENDERSTATE_ZENABLE            = 7,    /* TRUE to enable z test */
681    D3DRENDERSTATE_FILLMODE           = 8,    /* D3DFILL_MODE            */
682    D3DRENDERSTATE_SHADEMODE          = 9,    /* D3DSHADEMODE */
683    D3DRENDERSTATE_LINEPATTERN        = 10,   /* D3DLINEPATTERN */
684    D3DRENDERSTATE_MONOENABLE         = 11,   /* TRUE to enable mono rasterization */
685    D3DRENDERSTATE_ROP2               = 12,   /* ROP2 */
686    D3DRENDERSTATE_PLANEMASK          = 13,   /* DWORD physical plane mask */
687    D3DRENDERSTATE_ZWRITEENABLE       = 14,   /* TRUE to enable z writes */
688    D3DRENDERSTATE_ALPHATESTENABLE    = 15,   /* TRUE to enable alpha tests */
689    D3DRENDERSTATE_LASTPIXEL          = 16,   /* TRUE for last-pixel on lines */
690    D3DRENDERSTATE_TEXTUREMAG         = 17,   /* D3DTEXTUREFILTER */
691    D3DRENDERSTATE_TEXTUREMIN         = 18,   /* D3DTEXTUREFILTER */
692    D3DRENDERSTATE_SRCBLEND           = 19,   /* D3DBLEND */
693    D3DRENDERSTATE_DESTBLEND          = 20,   /* D3DBLEND */
694    D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,   /* D3DTEXTUREBLEND */
695    D3DRENDERSTATE_CULLMODE           = 22,   /* D3DCULL */
696    D3DRENDERSTATE_ZFUNC              = 23,   /* D3DCMPFUNC */
697    D3DRENDERSTATE_ALPHAREF           = 24,   /* D3DFIXED */
698    D3DRENDERSTATE_ALPHAFUNC          = 25,   /* D3DCMPFUNC */
699    D3DRENDERSTATE_DITHERENABLE       = 26,   /* TRUE to enable dithering */
700    D3DRENDERSTATE_BLENDENABLE        = 27,   /* TRUE to enable alpha blending */
701    D3DRENDERSTATE_FOGENABLE          = 28,   /* TRUE to enable fog */
702    D3DRENDERSTATE_SPECULARENABLE     = 29,   /* TRUE to enable specular */
703    D3DRENDERSTATE_ZVISIBLE           = 30,   /* TRUE to enable z checking */
704    D3DRENDERSTATE_SUBPIXEL           = 31,   /* TRUE to enable subpixel correction */
705    D3DRENDERSTATE_SUBPIXELX          = 32,   /* TRUE to enable correction in X only */
706    D3DRENDERSTATE_STIPPLEDALPHA      = 33,   /* TRUE to enable stippled alpha */
707    D3DRENDERSTATE_FOGCOLOR           = 34,   /* D3DCOLOR */
708    D3DRENDERSTATE_FOGTABLEMODE       = 35,   /* D3DFOGMODE */
709    D3DRENDERSTATE_FOGTABLESTART      = 36,   /* Fog table start        */
710    D3DRENDERSTATE_FOGTABLEEND        = 37,   /* Fog table end          */
711    D3DRENDERSTATE_FOGTABLEDENSITY    = 38,   /* Fog table density      */
712    D3DRENDERSTATE_STIPPLEENABLE      = 39,   /* TRUE to enable stippling */
713    D3DRENDERSTATE_STIPPLEPATTERN00   = 64,   /* Stipple pattern 01...  */
714    D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
715    D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
716    D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
717    D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
718    D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
719    D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
720    D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
721    D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
722    D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
723    D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
724    D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
725    D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
726    D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
727    D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
728    D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
729    D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
730    D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
731    D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
732    D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
733    D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
734    D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
735    D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
736    D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
737    D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
738    D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
739    D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
740    D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
741    D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
742    D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
743    D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
744    D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
745} D3DRENDERSTATETYPE;
746
747#define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
748
749typedef struct _D3DSTATE {
750    union {
751        D3DTRANSFORMSTATETYPE   dtstTransformStateType;
752        D3DLIGHTSTATETYPE       dlstLightStateType;
753        D3DRENDERSTATETYPE      drstRenderStateType;
754    };
755    union {
756        DWORD                   dwArg[1];
757        D3DVALUE                dvArg[1];
758    };
759} D3DSTATE, *LPD3DSTATE;
760
761/*
762 * Operation used to load matrices
763 * hDstMat = hSrcMat
764 */
765typedef struct _D3DMATRIXLOAD {
766    D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
767    D3DMATRIXHANDLE hSrcMatrix;   /* Source matrix */
768} D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
769
770/*
771 * Operation used to multiply matrices
772 * hDstMat = hSrcMat1 * hSrcMat2
773 */
774typedef struct _D3DMATRIXMULTIPLY {
775    D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
776    D3DMATRIXHANDLE hSrcMatrix1;  /* First source matrix */
777    D3DMATRIXHANDLE hSrcMatrix2;  /* Second source matrix */
778} D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
779
780/*
781 * Operation used to transform and light vertices.
782 */
783typedef struct _D3DPROCESSVERTICES {
784    DWORD        dwFlags;    /* Do we transform or light or just copy? */
785    WORD         wStart;     /* Index to first vertex in source */
786    WORD         wDest;      /* Index to first vertex in local buffer */
787    DWORD        dwCount;    /* Number of vertices to be processed */
788    DWORD        dwReserved; /* Must be zero */
789} D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
790
791#define D3DPROCESSVERTICES_TRANSFORMLIGHT       0x00000000L
792#define D3DPROCESSVERTICES_TRANSFORM            0x00000001L
793#define D3DPROCESSVERTICES_COPY                 0x00000002L
794#define D3DPROCESSVERTICES_OPMASK               0x00000007L
795
796#define D3DPROCESSVERTICES_UPDATEEXTENTS        0x00000008L
797#define D3DPROCESSVERTICES_NOCOLOR              0x00000010L
798
799
800/*
801 * Triangle flags
802 */
803
804/*
805 * Tri strip and fan flags.
806 * START loads all three vertices
807 * EVEN and ODD load just v3 with even or odd culling
808 * START_FLAT contains a count from 0 to 29 that allows the
809 * whole strip or fan to be culled in one hit.
810 * e.g. for a quad len = 1
811 */
812#define D3DTRIFLAG_START                        0x00000000L
813#define D3DTRIFLAG_STARTFLAT(len) (len)         /* 0 < len < 30 */
814#define D3DTRIFLAG_ODD                          0x0000001eL
815#define D3DTRIFLAG_EVEN                         0x0000001fL
816
817/*
818 * Triangle edge flags
819 * enable edges for wireframe or antialiasing
820 */
821#define D3DTRIFLAG_EDGEENABLE1                  0x00000100L /* v0-v1 edge */
822#define D3DTRIFLAG_EDGEENABLE2                  0x00000200L /* v1-v2 edge */
823#define D3DTRIFLAG_EDGEENABLE3                  0x00000400L /* v2-v0 edge */
824#define D3DTRIFLAG_EDGEENABLETRIANGLE \
825        (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
826
827/*
828 * Primitive structures and related defines.  Vertex offsets are to types
829 * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
830 */
831
832/*
833 * Triangle list primitive structure
834 */
835typedef struct _D3DTRIANGLE {
836    union {
837        WORD    v1;            /* Vertex indices */
838        WORD    wV1;
839    };
840    union {
841        WORD    v2;
842        WORD    wV2;
843    };
844    union {
845        WORD    v3;
846        WORD    wV3;
847    };
848    WORD        wFlags;       /* Edge (and other) flags */
849} D3DTRIANGLE, *LPD3DTRIANGLE;
850
851/*
852 * Line strip structure.
853 * The instruction count - 1 defines the number of line segments.
854 */
855typedef struct _D3DLINE {
856    union {
857        WORD    v1;            /* Vertex indices */
858        WORD    wV1;
859    };
860    union {
861        WORD    v2;
862        WORD    wV2;
863    };
864} D3DLINE, *LPD3DLINE;
865
866/*
867 * Span structure
868 * Spans join a list of points with the same y value.
869 * If the y value changes, a new span is started.
870 */
871typedef struct _D3DSPAN {
872    WORD        wCount; /* Number of spans */
873    WORD        wFirst; /* Index to first vertex */
874} D3DSPAN, *LPD3DSPAN;
875
876/*
877 * Point structure
878 */
879typedef struct _D3DPOINT {
880    WORD        wCount;         /* number of points         */
881    WORD        wFirst;         /* index to first vertex    */
882} D3DPOINT, *LPD3DPOINT;
883
884
885/*
886 * Forward branch structure.
887 * Mask is logically anded with the driver status mask
888 * if the result equals 'value', the branch is taken.
889 */
890typedef struct _D3DBRANCH {
891    DWORD       dwMask;         /* Bitmask against D3D status */
892    DWORD       dwValue;
893    BOOL        bNegate;        /* TRUE to negate comparison */
894    DWORD       dwOffset;       /* How far to branch forward (0 for exit)*/
895} D3DBRANCH, *LPD3DBRANCH;
896
897/*
898 * Status used for set status instruction.
899 * The D3D status is initialised on device creation
900 * and is modified by all execute calls.
901 */
902typedef struct _D3DSTATUS {
903    DWORD       dwFlags;        /* Do we set extents or status */
904    DWORD       dwStatus;       /* D3D status */
905    D3DRECT     drExtent;
906} D3DSTATUS, *LPD3DSTATUS;
907
908#define D3DSETSTATUS_STATUS             0x00000001L
909#define D3DSETSTATUS_EXTENTS            0x00000002L
910#define D3DSETSTATUS_ALL        (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
911
912/*
913 * Statistics structure
914 */
915typedef struct _D3DSTATS {
916    DWORD        dwSize;
917    DWORD        dwTrianglesDrawn;
918    DWORD        dwLinesDrawn;
919    DWORD        dwPointsDrawn;
920    DWORD        dwSpansDrawn;
921    DWORD        dwVerticesProcessed;
922} D3DSTATS, *LPD3DSTATS;
923
924/*
925 * Execute options.
926 * When calling using D3DEXECUTE_UNCLIPPED all the primitives
927 * inside the buffer must be contained within the viewport.
928 */
929#define D3DEXECUTE_CLIPPED       0x00000001l
930#define D3DEXECUTE_UNCLIPPED     0x00000002l
931
932typedef struct _D3DEXECUTEDATA {
933    DWORD       dwSize;
934    DWORD       dwVertexOffset;
935    DWORD       dwVertexCount;
936    DWORD       dwInstructionOffset;
937    DWORD       dwInstructionLength;
938    DWORD       dwHVertexOffset;
939    D3DSTATUS   dsStatus;       /* Status after execute */
940} D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
941
942/*
943 * Palette flags.
944 * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
945 */
946#define D3DPAL_FREE     0x00    /* Renderer may use this entry freely */
947#define D3DPAL_READONLY 0x40    /* Renderer may not set this entry */
948#define D3DPAL_RESERVED 0x80    /* Renderer may not use this entry */
949
950#if defined(__cplusplus)
951};
952#endif
953
954#pragma pack()
955
956#endif /* _D3DTYPES_H_ */
957