home *** CD-ROM | disk | FTP | other *** search
/ Microsoft DirectX SDK 6.1 / Dx6_1_Gold.iso / dxf / include / d3dtypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-14  |  53.1 KB  |  1,499 lines

  1. /*==========================================================================;
  2.  *
  3.  *  Copyright (C) 1995-1998 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. #include <windows.h>
  14.  
  15. #include <float.h>
  16. #include <ddraw.h>
  17.  
  18. #ifndef DIRECT3D_VERSION
  19. #define DIRECT3D_VERSION         0x0600
  20. #endif
  21.  
  22. #pragma pack(4)
  23.  
  24.  
  25. /* D3DVALUE is the fundamental Direct3D fractional data type */
  26.  
  27. #define D3DVALP(val, prec) ((float)(val))
  28. #define D3DVAL(val) ((float)(val))
  29. typedef float D3DVALUE, *LPD3DVALUE;
  30. #define D3DDivide(a, b)    (float)((double) (a) / (double) (b))
  31. #define D3DMultiply(a, b)    ((a) * (b))
  32.  
  33. typedef LONG D3DFIXED;
  34.  
  35. #ifndef RGB_MAKE
  36. /*
  37.  * Format of CI colors is
  38.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  39.  *  |    alpha      |         color index           |   fraction    |
  40.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  41.  */
  42. #define CI_GETALPHA(ci)    ((ci) >> 24)
  43. #define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
  44. #define CI_GETFRACTION(ci) ((ci) & 0xff)
  45. #define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
  46. #define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
  47. #define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
  48.  
  49. /*
  50.  * Format of RGBA colors is
  51.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  52.  *  |    alpha      |      red      |     green     |     blue      |
  53.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  54.  */
  55. #define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
  56. #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
  57. #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
  58. #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
  59. #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
  60.  
  61. /* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
  62.  * The float values must be in the range 0..1
  63.  */
  64. #define D3DRGB(r, g, b) \
  65.     (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
  66. #define D3DRGBA(r, g, b, a) \
  67.     (   (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
  68.     |   (((long)((g) * 255)) << 8) | (long)((b) * 255) \
  69.     )
  70.  
  71. /*
  72.  * Format of RGB colors is
  73.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  74.  *  |    ignored    |      red      |     green     |     blue      |
  75.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  76.  */
  77. #define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
  78. #define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
  79. #define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
  80. #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
  81. #define RGB_MAKE(r, g, b)       ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
  82. #define RGBA_TORGB(rgba)       ((D3DCOLOR) ((rgba) & 0xffffff))
  83. #define RGB_TORGBA(rgb)        ((D3DCOLOR) ((rgb) | 0xff000000))
  84.  
  85. #endif
  86.  
  87. /*
  88.  * Flags for Enumerate functions
  89.  */
  90.  
  91. /*
  92.  * Stop the enumeration
  93.  */
  94. #define D3DENUMRET_CANCEL                        DDENUMRET_CANCEL
  95.  
  96. /*
  97.  * Continue the enumeration
  98.  */
  99. #define D3DENUMRET_OK                            DDENUMRET_OK
  100.  
  101. typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
  102. typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
  103. typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext);
  104.  
  105. typedef DWORD D3DCOLOR, *LPD3DCOLOR;
  106.  
  107. typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
  108. typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
  109. typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
  110.  
  111. typedef struct _D3DCOLORVALUE {
  112.     union {
  113.     D3DVALUE r;
  114.     D3DVALUE dvR;
  115.     };
  116.     union {
  117.     D3DVALUE g;
  118.     D3DVALUE dvG;
  119.     };
  120.     union {
  121.     D3DVALUE b;
  122.     D3DVALUE dvB;
  123.     };
  124.     union {
  125.     D3DVALUE a;
  126.     D3DVALUE dvA;
  127.     };
  128. } D3DCOLORVALUE, *LPD3DCOLORVALUE;
  129.  
  130. typedef struct _D3DRECT {
  131.     union {
  132.     LONG x1;
  133.     LONG lX1;
  134.     };
  135.     union {
  136.     LONG y1;
  137.     LONG lY1;
  138.     };
  139.     union {
  140.     LONG x2;
  141.     LONG lX2;
  142.     };
  143.     union {
  144.     LONG y2;
  145.     LONG lY2;
  146.     };
  147. } D3DRECT, *LPD3DRECT;
  148.  
  149. typedef struct _D3DVECTOR {
  150.     union {
  151.     D3DVALUE x;
  152.     D3DVALUE dvX;
  153.     };
  154.     union {
  155.     D3DVALUE y;
  156.     D3DVALUE dvY;
  157.     };
  158.     union {
  159.     D3DVALUE z;
  160.     D3DVALUE dvZ;
  161.     };
  162. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  163.  
  164. public:
  165.  
  166.     // =====================================
  167.     // Constructors
  168.     // =====================================
  169.  
  170.     _D3DVECTOR() { }
  171.     _D3DVECTOR(D3DVALUE f);
  172.     _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
  173.     _D3DVECTOR(const D3DVALUE f[3]);
  174.  
  175.     // =====================================
  176.     // Access grants
  177.     // =====================================
  178.  
  179.     const D3DVALUE&operator[](int i) const;
  180.     D3DVALUE&operator[](int i);
  181.  
  182.     // =====================================
  183.     // Assignment operators
  184.     // =====================================
  185.  
  186.     _D3DVECTOR& operator += (const _D3DVECTOR& v);
  187.     _D3DVECTOR& operator -= (const _D3DVECTOR& v);
  188.     _D3DVECTOR& operator *= (const _D3DVECTOR& v);
  189.     _D3DVECTOR& operator /= (const _D3DVECTOR& v);
  190.     _D3DVECTOR& operator *= (D3DVALUE s);
  191.     _D3DVECTOR& operator /= (D3DVALUE s);
  192.  
  193.     // =====================================
  194.     // Unary operators
  195.     // =====================================
  196.  
  197.     friend _D3DVECTOR operator + (const _D3DVECTOR& v);
  198.     friend _D3DVECTOR operator - (const _D3DVECTOR& v);
  199.  
  200.  
  201.     // =====================================
  202.     // Binary operators
  203.     // =====================================
  204.  
  205.     // Addition and subtraction
  206.         friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  207.         friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  208.     // Scalar multiplication and division
  209.         friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
  210.         friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
  211.         friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
  212.     // Memberwise multiplication and division
  213.         friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  214.         friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  215.  
  216.     // Vector dominance
  217.         friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  218.         friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  219.  
  220.     // Bitwise equality
  221.         friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  222.  
  223.     // Length-related functions
  224.         friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
  225.         friend D3DVALUE Magnitude (const _D3DVECTOR& v);
  226.  
  227.     // Returns vector with same direction and unit length
  228.         friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
  229.  
  230.     // Return min/max component of the input vector
  231.         friend D3DVALUE Min (const _D3DVECTOR& v);
  232.         friend D3DVALUE Max (const _D3DVECTOR& v);
  233.  
  234.     // Return memberwise min/max of input vectors
  235.         friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  236.         friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  237.  
  238.     // Dot and cross product
  239.         friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  240.         friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
  241.  
  242. #endif
  243. } D3DVECTOR, *LPD3DVECTOR;
  244.  
  245. /*
  246.  * Vertex data types supported in an ExecuteBuffer.
  247.  */
  248.  
  249. /*
  250.  * Homogeneous vertices
  251.  */
  252.  
  253. typedef struct _D3DHVERTEX {
  254.     DWORD           dwFlags;        /* Homogeneous clipping flags */
  255.     union {
  256.     D3DVALUE    hx;
  257.     D3DVALUE    dvHX;
  258.     };
  259.     union {
  260.     D3DVALUE    hy;
  261.     D3DVALUE    dvHY;
  262.     };
  263.     union {
  264.     D3DVALUE    hz;
  265.     D3DVALUE    dvHZ;
  266.     };
  267. } D3DHVERTEX, *LPD3DHVERTEX;
  268.  
  269. /*
  270.  * Transformed/lit vertices
  271.  */
  272. typedef struct _D3DTLVERTEX {
  273.     union {
  274.     D3DVALUE    sx;             /* Screen coordinates */
  275.     D3DVALUE    dvSX;
  276.     };
  277.     union {
  278.     D3DVALUE    sy;
  279.     D3DVALUE    dvSY;
  280.     };
  281.     union {
  282.     D3DVALUE    sz;
  283.     D3DVALUE    dvSZ;
  284.     };
  285.     union {
  286.     D3DVALUE    rhw;        /* Reciprocal of homogeneous w */
  287.     D3DVALUE    dvRHW;
  288.     };
  289.     union {
  290.     D3DCOLOR    color;          /* Vertex color */
  291.     D3DCOLOR    dcColor;
  292.     };
  293.     union {
  294.     D3DCOLOR    specular;       /* Specular component of vertex */
  295.     D3DCOLOR    dcSpecular;
  296.     };
  297.     union {
  298.     D3DVALUE    tu;             /* Texture coordinates */
  299.     D3DVALUE    dvTU;
  300.     };
  301.     union {
  302.     D3DVALUE    tv;
  303.     D3DVALUE    dvTV;
  304.     };
  305. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  306.     _D3DTLVERTEX() { }
  307.     _D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
  308.                  D3DCOLOR _color, D3DCOLOR _specular,
  309.                  float _tu, float _tv)
  310.         { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
  311.           color = _color; specular = _specular;
  312.           tu = _tu; tv = _tv;
  313.         }
  314. #endif
  315. } D3DTLVERTEX, *LPD3DTLVERTEX;
  316.  
  317. /*
  318.  * Untransformed/lit vertices
  319.  */
  320. typedef struct _D3DLVERTEX {
  321.     union {
  322.     D3DVALUE     x;             /* Homogeneous coordinates */
  323.     D3DVALUE     dvX;
  324.     };
  325.     union {
  326.     D3DVALUE     y;
  327.     D3DVALUE     dvY;
  328.     };
  329.     union {
  330.     D3DVALUE     z;
  331.     D3DVALUE     dvZ;
  332.     };
  333.     DWORD            dwReserved;
  334.     union {
  335.     D3DCOLOR     color;         /* Vertex color */
  336.     D3DCOLOR     dcColor;
  337.     };
  338.     union {
  339.     D3DCOLOR     specular;      /* Specular component of vertex */
  340.     D3DCOLOR     dcSpecular;
  341.     };
  342.     union {
  343.     D3DVALUE     tu;            /* Texture coordinates */
  344.     D3DVALUE     dvTU;
  345.     };
  346.     union {
  347.     D3DVALUE     tv;
  348.     D3DVALUE     dvTV;
  349.     };
  350. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  351.     _D3DLVERTEX() { }
  352.     _D3DLVERTEX(const D3DVECTOR& v,
  353.                 D3DCOLOR _color, D3DCOLOR _specular,
  354.                 float _tu, float _tv)
  355.         { x = v.x; y = v.y; z = v.z; dwReserved = 0;
  356.           color = _color; specular = _specular;
  357.           tu = _tu; tv = _tv;
  358.         }
  359. #endif
  360. } D3DLVERTEX, *LPD3DLVERTEX;
  361.  
  362. /*
  363.  * Untransformed/unlit vertices
  364.  */
  365.  
  366. typedef struct _D3DVERTEX {
  367.     union {
  368.     D3DVALUE     x;             /* Homogeneous coordinates */
  369.     D3DVALUE     dvX;
  370.     };
  371.     union {
  372.     D3DVALUE     y;
  373.     D3DVALUE     dvY;
  374.     };
  375.     union {
  376.     D3DVALUE     z;
  377.     D3DVALUE     dvZ;
  378.     };
  379.     union {
  380.     D3DVALUE     nx;            /* Normal */
  381.     D3DVALUE     dvNX;
  382.     };
  383.     union {
  384.     D3DVALUE     ny;
  385.     D3DVALUE     dvNY;
  386.     };
  387.     union {
  388.     D3DVALUE     nz;
  389.     D3DVALUE     dvNZ;
  390.     };
  391.     union {
  392.     D3DVALUE     tu;            /* Texture coordinates */
  393.     D3DVALUE     dvTU;
  394.     };
  395.     union {
  396.     D3DVALUE     tv;
  397.     D3DVALUE     dvTV;
  398.     };
  399. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  400.     _D3DVERTEX() { }
  401.     _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv)
  402.         { x = v.x; y = v.y; z = v.z;
  403.           nx = n.x; ny = n.y; nz = n.z;
  404.           tu = _tu; tv = _tv;
  405.         }
  406. #endif
  407. } D3DVERTEX, *LPD3DVERTEX;
  408.  
  409.  
  410. /*
  411.  * Matrix, viewport, and tranformation structures and definitions.
  412.  */
  413.  
  414. typedef struct _D3DMATRIX {
  415. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  416.     union {
  417.         struct {
  418. #endif
  419.  
  420.             D3DVALUE        _11, _12, _13, _14;
  421.             D3DVALUE        _21, _22, _23, _24;
  422.             D3DVALUE        _31, _32, _33, _34;
  423.             D3DVALUE        _41, _42, _43, _44;
  424.  
  425. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  426.         };
  427.         D3DVALUE m[4][4];
  428.     };
  429.     _D3DMATRIX() { }
  430.     _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03,
  431.                 D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13,
  432.                 D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23,
  433.                 D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _m33
  434.         )
  435.         {
  436.                 m[0][0] = _m00; m[0][1] = _m01; m[0][2] = _m02; m[0][3] = _m03;
  437.                 m[1][0] = _m10; m[1][1] = _m11; m[1][2] = _m12; m[1][3] = _m13;
  438.                 m[2][0] = _m20; m[2][1] = _m21; m[2][2] = _m22; m[2][3] = _m23;
  439.                 m[3][0] = _m30; m[3][1] = _m31; m[3][2] = _m32; m[3][3] = _m33;
  440.         }
  441.  
  442.     D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; }
  443.     const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; }
  444.     friend _D3DMATRIX operator* (const _D3DMATRIX&, const _D3DMATRIX&);
  445. #endif
  446. } D3DMATRIX, *LPD3DMATRIX;
  447.  
  448. #if (defined __cplusplus) && (defined D3D_OVERLOADS)
  449. #include "d3dvec.inl"
  450. #endif
  451.  
  452. typedef struct _D3DVIEWPORT {
  453.     DWORD       dwSize;
  454.     DWORD       dwX;
  455.     DWORD       dwY;        /* Top left */
  456.     DWORD       dwWidth;
  457.     DWORD       dwHeight;   /* Dimensions */
  458.     D3DVALUE    dvScaleX;   /* Scale homogeneous to screen */
  459.     D3DVALUE    dvScaleY;   /* Scale homogeneous to screen */
  460.     D3DVALUE    dvMaxX;     /* Min/max homogeneous x coord */
  461.     D3DVALUE    dvMaxY;     /* Min/max homogeneous y coord */
  462.     D3DVALUE    dvMinZ;
  463.     D3DVALUE    dvMaxZ;     /* Min/max homogeneous z coord */
  464. } D3DVIEWPORT, *LPD3DVIEWPORT;
  465.  
  466. typedef struct _D3DVIEWPORT2 {
  467.     DWORD       dwSize;
  468.     DWORD       dwX;
  469.     DWORD       dwY;        /* Viewport Top left */
  470.     DWORD       dwWidth;
  471.     DWORD       dwHeight;   /* Viewport Dimensions */
  472.     D3DVALUE    dvClipX;        /* Top left of clip volume */
  473.     D3DVALUE    dvClipY;
  474.     D3DVALUE    dvClipWidth;    /* Clip Volume Dimensions */
  475.     D3DVALUE    dvClipHeight;
  476.     D3DVALUE    dvMinZ;         /* Min/max of clip Volume */
  477.     D3DVALUE    dvMaxZ;
  478. } D3DVIEWPORT2, *LPD3DVIEWPORT2;
  479.  
  480. /*
  481.  * Values for clip fields.
  482.  */
  483. #define D3DCLIP_LEFT                0x00000001L
  484. #define D3DCLIP_RIGHT               0x00000002L
  485. #define D3DCLIP_TOP             0x00000004L
  486. #define D3DCLIP_BOTTOM              0x00000008L
  487. #define D3DCLIP_FRONT               0x00000010L
  488. #define D3DCLIP_BACK                0x00000020L
  489. #define D3DCLIP_GEN0                0x00000040L
  490. #define D3DCLIP_GEN1                0x00000080L
  491. #define D3DCLIP_GEN2                0x00000100L
  492. #define D3DCLIP_GEN3                0x00000200L
  493. #define D3DCLIP_GEN4                0x00000400L
  494. #define D3DCLIP_GEN5                0x00000800L
  495.  
  496. /*
  497.  * Values for d3d status.
  498.  */
  499. #define D3DSTATUS_CLIPUNIONLEFT         D3DCLIP_LEFT
  500. #define D3DSTATUS_CLIPUNIONRIGHT        D3DCLIP_RIGHT
  501. #define D3DSTATUS_CLIPUNIONTOP          D3DCLIP_TOP
  502. #define D3DSTATUS_CLIPUNIONBOTTOM       D3DCLIP_BOTTOM
  503. #define D3DSTATUS_CLIPUNIONFRONT        D3DCLIP_FRONT
  504. #define D3DSTATUS_CLIPUNIONBACK         D3DCLIP_BACK
  505. #define D3DSTATUS_CLIPUNIONGEN0         D3DCLIP_GEN0
  506. #define D3DSTATUS_CLIPUNIONGEN1         D3DCLIP_GEN1
  507. #define D3DSTATUS_CLIPUNIONGEN2         D3DCLIP_GEN2
  508. #define D3DSTATUS_CLIPUNIONGEN3         D3DCLIP_GEN3
  509. #define D3DSTATUS_CLIPUNIONGEN4         D3DCLIP_GEN4
  510. #define D3DSTATUS_CLIPUNIONGEN5         D3DCLIP_GEN5
  511.  
  512. #define D3DSTATUS_CLIPINTERSECTIONLEFT      0x00001000L
  513. #define D3DSTATUS_CLIPINTERSECTIONRIGHT     0x00002000L
  514. #define D3DSTATUS_CLIPINTERSECTIONTOP       0x00004000L
  515. #define D3DSTATUS_CLIPINTERSECTIONBOTTOM    0x00008000L
  516. #define D3DSTATUS_CLIPINTERSECTIONFRONT     0x00010000L
  517. #define D3DSTATUS_CLIPINTERSECTIONBACK      0x00020000L
  518. #define D3DSTATUS_CLIPINTERSECTIONGEN0      0x00040000L
  519. #define D3DSTATUS_CLIPINTERSECTIONGEN1      0x00080000L
  520. #define D3DSTATUS_CLIPINTERSECTIONGEN2      0x00100000L
  521. #define D3DSTATUS_CLIPINTERSECTIONGEN3      0x00200000L
  522. #define D3DSTATUS_CLIPINTERSECTIONGEN4      0x00400000L
  523. #define D3DSTATUS_CLIPINTERSECTIONGEN5      0x00800000L
  524. #define D3DSTATUS_ZNOTVISIBLE               0x01000000L
  525. /* Do not use 0x80000000 for any status flags in future as it is reserved */
  526.  
  527. #define D3DSTATUS_CLIPUNIONALL  (       \
  528.         D3DSTATUS_CLIPUNIONLEFT |   \
  529.         D3DSTATUS_CLIPUNIONRIGHT    |   \
  530.         D3DSTATUS_CLIPUNIONTOP  |   \
  531.         D3DSTATUS_CLIPUNIONBOTTOM   |   \
  532.         D3DSTATUS_CLIPUNIONFRONT    |   \
  533.         D3DSTATUS_CLIPUNIONBACK |   \
  534.         D3DSTATUS_CLIPUNIONGEN0 |   \
  535.         D3DSTATUS_CLIPUNIONGEN1 |   \
  536.         D3DSTATUS_CLIPUNIONGEN2 |   \
  537.         D3DSTATUS_CLIPUNIONGEN3 |   \
  538.         D3DSTATUS_CLIPUNIONGEN4 |   \
  539.         D3DSTATUS_CLIPUNIONGEN5     \
  540.         )
  541.  
  542. #define D3DSTATUS_CLIPINTERSECTIONALL   (       \
  543.         D3DSTATUS_CLIPINTERSECTIONLEFT  |   \
  544.         D3DSTATUS_CLIPINTERSECTIONRIGHT |   \
  545.         D3DSTATUS_CLIPINTERSECTIONTOP   |   \
  546.         D3DSTATUS_CLIPINTERSECTIONBOTTOM    |   \
  547.         D3DSTATUS_CLIPINTERSECTIONFRONT |   \
  548.         D3DSTATUS_CLIPINTERSECTIONBACK  |   \
  549.         D3DSTATUS_CLIPINTERSECTIONGEN0  |   \
  550.         D3DSTATUS_CLIPINTERSECTIONGEN1  |   \
  551.         D3DSTATUS_CLIPINTERSECTIONGEN2  |   \
  552.         D3DSTATUS_CLIPINTERSECTIONGEN3  |   \
  553.         D3DSTATUS_CLIPINTERSECTIONGEN4  |   \
  554.         D3DSTATUS_CLIPINTERSECTIONGEN5      \
  555.         )
  556.  
  557. #define D3DSTATUS_DEFAULT   (           \
  558.         D3DSTATUS_CLIPINTERSECTIONALL   |   \
  559.         D3DSTATUS_ZNOTVISIBLE)
  560.  
  561.  
  562. /*
  563.  * Options for direct transform calls
  564.  */
  565. #define D3DTRANSFORM_CLIPPED       0x00000001l
  566. #define D3DTRANSFORM_UNCLIPPED     0x00000002l
  567.  
  568. typedef struct _D3DTRANSFORMDATA {
  569.     DWORD           dwSize;
  570.     LPVOID      lpIn;           /* Input vertices */
  571.     DWORD           dwInSize;       /* Stride of input vertices */
  572.     LPVOID      lpOut;          /* Output vertices */
  573.     DWORD           dwOutSize;      /* Stride of output vertices */
  574.     LPD3DHVERTEX    lpHOut;         /* Output homogeneous vertices */
  575.     DWORD           dwClip;         /* Clipping hint */
  576.     DWORD           dwClipIntersection;
  577.     DWORD           dwClipUnion;    /* Union of all clip flags */
  578.     D3DRECT         drExtent;       /* Extent of transformed vertices */
  579. } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
  580.  
  581. /*
  582.  * Structure defining position and direction properties for lighting.
  583.  */
  584. typedef struct _D3DLIGHTINGELEMENT {
  585.     D3DVECTOR dvPosition;           /* Lightable point in model space */
  586.     D3DVECTOR dvNormal;             /* Normalised unit vector */
  587. } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
  588.  
  589. /*
  590.  * Structure defining material properties for lighting.
  591.  */
  592. typedef struct _D3DMATERIAL {
  593.     DWORD           dwSize;
  594.     union {
  595.     D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
  596.     D3DCOLORVALUE   dcvDiffuse;
  597.     };
  598.     union {
  599.     D3DCOLORVALUE   ambient;        /* Ambient color RGB */
  600.     D3DCOLORVALUE   dcvAmbient;
  601.     };
  602.     union {
  603.     D3DCOLORVALUE   specular;       /* Specular 'shininess' */
  604.     D3DCOLORVALUE   dcvSpecular;
  605.     };
  606.     union {
  607.     D3DCOLORVALUE   emissive;       /* Emissive color RGB */
  608.     D3DCOLORVALUE   dcvEmissive;
  609.     };
  610.     union {
  611.     D3DVALUE        power;          /* Sharpness if specular highlight */
  612.     D3DVALUE        dvPower;
  613.     };
  614.     D3DTEXTUREHANDLE    hTexture;       /* Handle to texture map */
  615.     DWORD           dwRampSize;
  616. } D3DMATERIAL, *LPD3DMATERIAL;
  617.  
  618. typedef enum _D3DLIGHTTYPE {
  619.     D3DLIGHT_POINT          = 1,
  620.     D3DLIGHT_SPOT           = 2,
  621.     D3DLIGHT_DIRECTIONAL    = 3,
  622.     D3DLIGHT_PARALLELPOINT  = 4,
  623. #if(DIRECT3D_VERSION < 0x0500) // For backward compatible headers
  624.     D3DLIGHT_GLSPOT         = 5,
  625. #endif
  626.     D3DLIGHT_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
  627. } D3DLIGHTTYPE;
  628.  
  629. /*
  630.  * Structure defining a light source and its properties.
  631.  */
  632. typedef struct _D3DLIGHT {
  633.     DWORD           dwSize;
  634.     D3DLIGHTTYPE    dltType;            /* Type of light source */
  635.     D3DCOLORVALUE   dcvColor;       /* Color of light */
  636.     D3DVECTOR       dvPosition;     /* Position in world space */
  637.     D3DVECTOR       dvDirection;        /* Direction in world space */
  638.     D3DVALUE        dvRange;            /* Cutoff range */
  639.     D3DVALUE        dvFalloff;          /* Falloff */
  640.     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
  641.     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
  642.     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
  643.     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
  644.     D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
  645. } D3DLIGHT, *LPD3DLIGHT;
  646.  
  647. /*
  648.  * Structure defining a light source and its properties.
  649.  */
  650.  
  651. /* flags bits */
  652. #define D3DLIGHT_ACTIVE         0x00000001
  653. #define D3DLIGHT_NO_SPECULAR    0x00000002
  654.  
  655. /* maximum valid light range */
  656. #define D3DLIGHT_RANGE_MAX      ((float)sqrt(FLT_MAX))
  657.  
  658. typedef struct _D3DLIGHT2 {
  659.     DWORD           dwSize;
  660.     D3DLIGHTTYPE    dltType;        /* Type of light source */
  661.     D3DCOLORVALUE   dcvColor;       /* Color of light */
  662.     D3DVECTOR       dvPosition;     /* Position in world space */
  663.     D3DVECTOR       dvDirection;    /* Direction in world space */
  664.     D3DVALUE        dvRange;        /* Cutoff range */
  665.     D3DVALUE        dvFalloff;      /* Falloff */
  666.     D3DVALUE        dvAttenuation0; /* Constant attenuation */
  667.     D3DVALUE        dvAttenuation1; /* Linear attenuation */
  668.     D3DVALUE        dvAttenuation2; /* Quadratic attenuation */
  669.     D3DVALUE        dvTheta;        /* Inner angle of spotlight cone */
  670.     D3DVALUE        dvPhi;          /* Outer angle of spotlight cone */
  671.     DWORD           dwFlags;
  672. } D3DLIGHT2, *LPD3DLIGHT2;
  673.  
  674. typedef struct _D3DLIGHTDATA {
  675.     DWORD                dwSize;
  676.     LPD3DLIGHTINGELEMENT lpIn;      /* Input positions and normals */
  677.     DWORD                dwInSize;  /* Stride of input elements */
  678.     LPD3DTLVERTEX        lpOut;     /* Output colors */
  679.     DWORD                dwOutSize; /* Stride of output colors */
  680. } D3DLIGHTDATA, *LPD3DLIGHTDATA;
  681.  
  682. /*
  683.  * Before DX5, these values were in an enum called
  684.  * D3DCOLORMODEL. This was not correct, since they are
  685.  * bit flags. A driver can surface either or both flags
  686.  * in the dcmColorModel member of D3DDEVICEDESC.
  687.  */
  688. #define D3DCOLOR_MONO   1
  689. #define D3DCOLOR_RGB    2
  690.  
  691. typedef DWORD D3DCOLORMODEL;
  692.  
  693. /*
  694.  * Options for clearing
  695.  */
  696. #define D3DCLEAR_TARGET            0x00000001l  /* Clear target surface */
  697. #define D3DCLEAR_ZBUFFER           0x00000002l  /* Clear target z buffer */
  698. #define D3DCLEAR_STENCIL           0x00000004l  /* Clear stencil planes */
  699.  
  700. /*
  701.  * Execute buffers are allocated via Direct3D.  These buffers may then
  702.  * be filled by the application with instructions to execute along with
  703.  * vertex data.
  704.  */
  705.  
  706. /*
  707.  * Supported op codes for execute instructions.
  708.  */
  709. typedef enum _D3DOPCODE {
  710.     D3DOP_POINT                 = 1,
  711.     D3DOP_LINE                  = 2,
  712.     D3DOP_TRIANGLE      = 3,
  713.     D3DOP_MATRIXLOAD        = 4,
  714.     D3DOP_MATRIXMULTIPLY    = 5,
  715.     D3DOP_STATETRANSFORM        = 6,
  716.     D3DOP_STATELIGHT        = 7,
  717.     D3DOP_STATERENDER       = 8,
  718.     D3DOP_PROCESSVERTICES       = 9,
  719.     D3DOP_TEXTURELOAD       = 10,
  720.     D3DOP_EXIT                  = 11,
  721.     D3DOP_BRANCHFORWARD     = 12,
  722.     D3DOP_SPAN          = 13,
  723.     D3DOP_SETSTATUS     = 14,
  724.     D3DOP_FORCE_DWORD           = 0x7fffffff, /* force 32-bit size enum */
  725. } D3DOPCODE;
  726.  
  727. typedef struct _D3DINSTRUCTION {
  728.     BYTE bOpcode;   /* Instruction opcode */
  729.     BYTE bSize;     /* Size of each instruction data unit */
  730.     WORD wCount;    /* Count of instruction data units to follow */
  731. } D3DINSTRUCTION, *LPD3DINSTRUCTION;
  732.  
  733. /*
  734.  * Structure for texture loads
  735.  */
  736. typedef struct _D3DTEXTURELOAD {
  737.     D3DTEXTUREHANDLE hDestTexture;
  738.     D3DTEXTUREHANDLE hSrcTexture;
  739. } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
  740.  
  741. /*
  742.  * Structure for picking
  743.  */
  744. typedef struct _D3DPICKRECORD {
  745.     BYTE     bOpcode;
  746.     BYTE     bPad;
  747.     DWORD    dwOffset;
  748.     D3DVALUE dvZ;
  749. } D3DPICKRECORD, *LPD3DPICKRECORD;
  750.  
  751. /*
  752.  * The following defines the rendering states which can be set in the
  753.  * execute buffer.
  754.  */
  755.  
  756. typedef enum _D3DSHADEMODE {
  757.     D3DSHADE_FLAT              = 1,
  758.     D3DSHADE_GOURAUD           = 2,
  759.     D3DSHADE_PHONG             = 3,
  760.     D3DSHADE_FORCE_DWORD       = 0x7fffffff, /* force 32-bit size enum */
  761. } D3DSHADEMODE;
  762.  
  763. typedef enum _D3DFILLMODE {
  764.     D3DFILL_POINT          = 1,
  765.     D3DFILL_WIREFRAME          = 2,
  766.     D3DFILL_SOLID          = 3,
  767.     D3DFILL_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
  768. } D3DFILLMODE;
  769.  
  770. typedef struct _D3DLINEPATTERN {
  771.     WORD    wRepeatFactor;
  772.     WORD    wLinePattern;
  773. } D3DLINEPATTERN;
  774.  
  775. typedef enum _D3DTEXTUREFILTER {
  776.     D3DFILTER_NEAREST          = 1,
  777.     D3DFILTER_LINEAR           = 2,
  778.     D3DFILTER_MIPNEAREST       = 3,
  779.     D3DFILTER_MIPLINEAR        = 4,
  780.     D3DFILTER_LINEARMIPNEAREST = 5,
  781.     D3DFILTER_LINEARMIPLINEAR  = 6,
  782.     D3DFILTER_FORCE_DWORD      = 0x7fffffff, /* force 32-bit size enum */
  783. } D3DTEXTUREFILTER;
  784.  
  785. typedef enum _D3DBLEND {
  786.     D3DBLEND_ZERO              = 1,
  787.     D3DBLEND_ONE               = 2,
  788.     D3DBLEND_SRCCOLOR          = 3,
  789.     D3DBLEND_INVSRCCOLOR       = 4,
  790.     D3DBLEND_SRCALPHA          = 5,
  791.     D3DBLEND_INVSRCALPHA       = 6,
  792.     D3DBLEND_DESTALPHA         = 7,
  793.     D3DBLEND_INVDESTALPHA      = 8,
  794.     D3DBLEND_DESTCOLOR         = 9,
  795.     D3DBLEND_INVDESTCOLOR      = 10,
  796.     D3DBLEND_SRCALPHASAT       = 11,
  797.     D3DBLEND_BOTHSRCALPHA      = 12,
  798.     D3DBLEND_BOTHINVSRCALPHA   = 13,
  799.     D3DBLEND_FORCE_DWORD       = 0x7fffffff, /* force 32-bit size enum */
  800. } D3DBLEND;
  801.  
  802. typedef enum _D3DTEXTUREBLEND {
  803.     D3DTBLEND_DECAL            = 1,
  804.     D3DTBLEND_MODULATE         = 2,
  805.     D3DTBLEND_DECALALPHA       = 3,
  806.     D3DTBLEND_MODULATEALPHA    = 4,
  807.     D3DTBLEND_DECALMASK        = 5,
  808.     D3DTBLEND_MODULATEMASK     = 6,
  809.     D3DTBLEND_COPY             = 7,
  810.     D3DTBLEND_ADD              = 8,
  811.     D3DTBLEND_FORCE_DWORD      = 0x7fffffff, /* force 32-bit size enum */
  812. } D3DTEXTUREBLEND;
  813.  
  814. typedef enum _D3DTEXTUREADDRESS {
  815.     D3DTADDRESS_WRAP           = 1,
  816.     D3DTADDRESS_MIRROR         = 2,
  817.     D3DTADDRESS_CLAMP          = 3,
  818.     D3DTADDRESS_BORDER         = 4,
  819.     D3DTADDRESS_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
  820. } D3DTEXTUREADDRESS;
  821.  
  822. typedef enum _D3DCULL {
  823.     D3DCULL_NONE               = 1,
  824.     D3DCULL_CW                 = 2,
  825.     D3DCULL_CCW                = 3,
  826.     D3DCULL_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
  827. } D3DCULL;
  828.  
  829. typedef enum _D3DCMPFUNC {
  830.     D3DCMP_NEVER               = 1,
  831.     D3DCMP_LESS                = 2,
  832.     D3DCMP_EQUAL               = 3,
  833.     D3DCMP_LESSEQUAL           = 4,
  834.     D3DCMP_GREATER             = 5,
  835.     D3DCMP_NOTEQUAL            = 6,
  836.     D3DCMP_GREATEREQUAL        = 7,
  837.     D3DCMP_ALWAYS              = 8,
  838.     D3DCMP_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
  839. } D3DCMPFUNC;
  840.  
  841. typedef enum _D3DSTENCILOP {
  842.     D3DSTENCILOP_KEEP           = 1,
  843.     D3DSTENCILOP_ZERO           = 2,
  844.     D3DSTENCILOP_REPLACE        = 3,
  845.     D3DSTENCILOP_INCRSAT        = 4,
  846.     D3DSTENCILOP_DECRSAT        = 5,
  847.     D3DSTENCILOP_INVERT         = 6,
  848.     D3DSTENCILOP_INCR           = 7,
  849.     D3DSTENCILOP_DECR           = 8,
  850.     D3DSTENCILOP_FORCE_DWORD    = 0x7fffffff, /* force 32-bit size enum */
  851. } D3DSTENCILOP;
  852.  
  853. typedef enum _D3DFOGMODE {
  854.     D3DFOG_NONE                = 0,
  855.     D3DFOG_EXP                 = 1,
  856.     D3DFOG_EXP2                = 2,
  857.     D3DFOG_LINEAR              = 3,
  858.     D3DFOG_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
  859. } D3DFOGMODE;
  860.  
  861. typedef enum _D3DZBUFFERTYPE {
  862.     D3DZB_FALSE                 = 0,
  863.     D3DZB_TRUE                  = 1, // Z buffering
  864.     D3DZB_USEW                  = 2, // W buffering
  865.     D3DZB_FORCE_DWORD           = 0x7fffffff, /* force 32-bit size enum */
  866. } D3DZBUFFERTYPE;
  867.  
  868. typedef enum _D3DANTIALIASMODE {
  869.     D3DANTIALIAS_NONE          = 0,
  870.     D3DANTIALIAS_SORTDEPENDENT = 1,
  871.     D3DANTIALIAS_SORTINDEPENDENT = 2,
  872.     D3DANTIALIAS_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  873. } D3DANTIALIASMODE;
  874.  
  875. // Vertex types supported by Direct3D
  876. typedef enum _D3DVERTEXTYPE {
  877.     D3DVT_VERTEX        = 1,
  878.     D3DVT_LVERTEX       = 2,
  879.     D3DVT_TLVERTEX      = 3,
  880.     D3DVT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  881. } D3DVERTEXTYPE;
  882.  
  883. // Primitives supported by draw-primitive API
  884. typedef enum _D3DPRIMITIVETYPE {
  885.     D3DPT_POINTLIST     = 1,
  886.     D3DPT_LINELIST      = 2,
  887.     D3DPT_LINESTRIP     = 3,
  888.     D3DPT_TRIANGLELIST  = 4,
  889.     D3DPT_TRIANGLESTRIP = 5,
  890.     D3DPT_TRIANGLEFAN   = 6,
  891.     D3DPT_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  892. } D3DPRIMITIVETYPE;
  893.  
  894. /*
  895.  * Amount to add to a state to generate the override for that state.
  896.  */
  897. #define D3DSTATE_OVERRIDE_BIAS      256
  898.  
  899. /*
  900.  * A state which sets the override flag for the specified state type.
  901.  */
  902. #define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS))
  903.  
  904. typedef enum _D3DTRANSFORMSTATETYPE {
  905.     D3DTRANSFORMSTATE_WORLD           = 1,
  906.     D3DTRANSFORMSTATE_VIEW            = 2,
  907.     D3DTRANSFORMSTATE_PROJECTION      = 3,
  908.     D3DTRANSFORMSTATE_FORCE_DWORD     = 0x7fffffff, /* force 32-bit size enum */
  909. } D3DTRANSFORMSTATETYPE;
  910.  
  911. typedef enum _D3DLIGHTSTATETYPE {
  912.     D3DLIGHTSTATE_MATERIAL          = 1,
  913.     D3DLIGHTSTATE_AMBIENT           = 2,
  914.     D3DLIGHTSTATE_COLORMODEL        = 3,
  915.     D3DLIGHTSTATE_FOGMODE           = 4,
  916.     D3DLIGHTSTATE_FOGSTART          = 5,
  917.     D3DLIGHTSTATE_FOGEND            = 6,
  918.     D3DLIGHTSTATE_FOGDENSITY        = 7,
  919.     D3DLIGHTSTATE_COLORVERTEX       = 8,
  920.     D3DLIGHTSTATE_FORCE_DWORD         = 0x7fffffff, /* force 32-bit size enum */
  921. } D3DLIGHTSTATETYPE;
  922.  
  923. typedef enum _D3DRENDERSTATETYPE {
  924.     D3DRENDERSTATE_TEXTUREHANDLE      = 1,    /* Texture handle for legacy interfaces (Texture,Texture2) */
  925.     D3DRENDERSTATE_ANTIALIAS          = 2,    /* D3DANTIALIASMODE */
  926.     D3DRENDERSTATE_TEXTUREADDRESS     = 3,    /* D3DTEXTUREADDRESS  */
  927.     D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,    /* TRUE for perspective correction */
  928.     D3DRENDERSTATE_WRAPU          = 5,    /* TRUE for wrapping in u */
  929.     D3DRENDERSTATE_WRAPV          = 6,    /* TRUE for wrapping in v */
  930.     D3DRENDERSTATE_ZENABLE            = 7,    /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
  931.     D3DRENDERSTATE_FILLMODE           = 8,    /* D3DFILL_MODE        */
  932.     D3DRENDERSTATE_SHADEMODE          = 9,    /* D3DSHADEMODE */
  933.     D3DRENDERSTATE_LINEPATTERN        = 10,   /* D3DLINEPATTERN */
  934.     D3DRENDERSTATE_MONOENABLE         = 11,   /* TRUE to enable mono rasterization */
  935.     D3DRENDERSTATE_ROP2               = 12,   /* ROP2 */
  936.     D3DRENDERSTATE_PLANEMASK          = 13,   /* DWORD physical plane mask */
  937.     D3DRENDERSTATE_ZWRITEENABLE       = 14,   /* TRUE to enable z writes */
  938.     D3DRENDERSTATE_ALPHATESTENABLE    = 15,   /* TRUE to enable alpha tests */
  939.     D3DRENDERSTATE_LASTPIXEL          = 16,   /* TRUE for last-pixel on lines */
  940.     D3DRENDERSTATE_TEXTUREMAG         = 17,   /* D3DTEXTUREFILTER */
  941.     D3DRENDERSTATE_TEXTUREMIN         = 18,   /* D3DTEXTUREFILTER */
  942.     D3DRENDERSTATE_SRCBLEND           = 19,   /* D3DBLEND */
  943.     D3DRENDERSTATE_DESTBLEND          = 20,   /* D3DBLEND */
  944.     D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,   /* D3DTEXTUREBLEND */
  945.     D3DRENDERSTATE_CULLMODE           = 22,   /* D3DCULL */
  946.     D3DRENDERSTATE_ZFUNC              = 23,   /* D3DCMPFUNC */
  947.     D3DRENDERSTATE_ALPHAREF           = 24,   /* D3DFIXED */
  948.     D3DRENDERSTATE_ALPHAFUNC          = 25,   /* D3DCMPFUNC */
  949.     D3DRENDERSTATE_DITHERENABLE       = 26,   /* TRUE to enable dithering */
  950.     D3DRENDERSTATE_ALPHABLENDENABLE        = 27,   /* TRUE to enable alpha blending */
  951.     D3DRENDERSTATE_FOGENABLE          = 28,   /* TRUE to enable fog */
  952.     D3DRENDERSTATE_SPECULARENABLE     = 29,   /* TRUE to enable specular */
  953.     D3DRENDERSTATE_ZVISIBLE           = 30,   /* TRUE to enable z checking */
  954.     D3DRENDERSTATE_SUBPIXEL       = 31,   /* TRUE to enable subpixel correction */
  955.     D3DRENDERSTATE_SUBPIXELX          = 32,   /* TRUE to enable correction in X only */
  956.     D3DRENDERSTATE_STIPPLEDALPHA      = 33,   /* TRUE to enable stippled alpha */
  957.     D3DRENDERSTATE_FOGCOLOR           = 34,   /* D3DCOLOR */
  958.     D3DRENDERSTATE_FOGTABLEMODE       = 35,   /* D3DFOGMODE */
  959.     D3DRENDERSTATE_FOGTABLESTART      = 36,   /* Fog table start    */
  960.     D3DRENDERSTATE_FOGTABLEEND        = 37,   /* Fog table end      */
  961.     D3DRENDERSTATE_FOGTABLEDENSITY    = 38,   /* Fog table density  */
  962.     D3DRENDERSTATE_STIPPLEENABLE      = 39,   /* TRUE to enable stippling */
  963.     D3DRENDERSTATE_EDGEANTIALIAS      = 40,   /* TRUE to enable edge antialiasing */
  964.     D3DRENDERSTATE_COLORKEYENABLE     = 41,   /* TRUE to enable source colorkeyed textures */
  965.     D3DRENDERSTATE_BORDERCOLOR        = 43,   /* Border color for texturing w/border */
  966.     D3DRENDERSTATE_TEXTUREADDRESSU    = 44,   /* Texture addressing mode for U coordinate */
  967.     D3DRENDERSTATE_TEXTUREADDRESSV    = 45,   /* Texture addressing mode for V coordinate */
  968.     D3DRENDERSTATE_MIPMAPLODBIAS      = 46,   /* D3DVALUE Mipmap LOD bias */
  969.     D3DRENDERSTATE_ZBIAS              = 47,   /* LONG Z bias */
  970.     D3DRENDERSTATE_RANGEFOGENABLE     = 48,   /* Enables range-based fog */
  971.     D3DRENDERSTATE_ANISOTROPY         = 49,   /* Max. anisotropy. 1 = no anisotropy */
  972.     D3DRENDERSTATE_FLUSHBATCH         = 50,   /* Explicit flush for DP batching (DX5 Only) */
  973.     D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, /* BOOL enable sort-independent transparency */
  974.     D3DRENDERSTATE_STENCILENABLE      = 52,   /* BOOL enable/disable stenciling */
  975.     D3DRENDERSTATE_STENCILFAIL        = 53,   /* D3DSTENCILOP to do if stencil test fails */
  976.     D3DRENDERSTATE_STENCILZFAIL       = 54,   /* D3DSTENCILOP to do if stencil test passes and Z test fails */
  977.     D3DRENDERSTATE_STENCILPASS        = 55,   /* D3DSTENCILOP to do if both stencil and Z tests pass */
  978.     D3DRENDERSTATE_STENCILFUNC        = 56,   /* D3DCMPFUNC fn.  Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
  979.     D3DRENDERSTATE_STENCILREF         = 57,   /* Reference value used in stencil test */
  980.     D3DRENDERSTATE_STENCILMASK        = 58,   /* Mask value used in stencil test */
  981.     D3DRENDERSTATE_STENCILWRITEMASK   = 59,   /* Write mask applied to values written to stencil buffer */
  982.     D3DRENDERSTATE_TEXTUREFACTOR      = 60,   /* D3DCOLOR used for multi-texture blend */
  983.     D3DRENDERSTATE_STIPPLEPATTERN00   = 64,   /* Stipple pattern 01...  */
  984.     D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
  985.     D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
  986.     D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
  987.     D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
  988.     D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
  989.     D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
  990.     D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
  991.     D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
  992.     D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
  993.     D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
  994.     D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
  995.     D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
  996.     D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
  997.     D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
  998.     D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
  999.     D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
  1000.     D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
  1001.     D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
  1002.     D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
  1003.     D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
  1004.     D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
  1005.     D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
  1006.     D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
  1007.     D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
  1008.     D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
  1009.     D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
  1010.     D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
  1011.     D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
  1012.     D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
  1013.     D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
  1014.     D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
  1015.  
  1016.     /*
  1017.      * 128 values [128, 255] are reserved for texture coordinate wrap flags.
  1018.      * These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using
  1019.      * a flags word preserves forward compatibility with texture coordinates
  1020.      * that are >2D.
  1021.      */
  1022.     D3DRENDERSTATE_WRAP0              = 128,  /* wrap for 1st texture coord. set */
  1023.     D3DRENDERSTATE_WRAP1              = 129,  /* wrap for 2nd texture coord. set */
  1024.     D3DRENDERSTATE_WRAP2              = 130,  /* wrap for 3rd texture coord. set */
  1025.     D3DRENDERSTATE_WRAP3              = 131,  /* wrap for 4th texture coord. set */
  1026.     D3DRENDERSTATE_WRAP4              = 132,  /* wrap for 5th texture coord. set */
  1027.     D3DRENDERSTATE_WRAP5              = 133,  /* wrap for 6th texture coord. set */
  1028.     D3DRENDERSTATE_WRAP6              = 134,  /* wrap for 7th texture coord. set */
  1029.     D3DRENDERSTATE_WRAP7              = 135,  /* wrap for 8th texture coord. set */
  1030.     D3DRENDERSTATE_FORCE_DWORD        = 0x7fffffff, /* force 32-bit size enum */
  1031. } D3DRENDERSTATETYPE;
  1032.  
  1033. // For back-compatibility with legacy compilations
  1034. #define D3DRENDERSTATE_BLENDENABLE      D3DRENDERSTATE_ALPHABLENDENABLE
  1035.  
  1036.  
  1037. // Bias to apply to the texture coordinate set to apply a wrap to.
  1038. #define D3DRENDERSTATE_WRAPBIAS                 128UL
  1039.  
  1040. /* Flags to construct the WRAP render states */
  1041. #define D3DWRAP_U   0x00000001L
  1042. #define D3DWRAP_V   0x00000002L
  1043.  
  1044.  
  1045. #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
  1046.  
  1047. typedef struct _D3DSTATE {
  1048.     union {
  1049.     D3DTRANSFORMSTATETYPE   dtstTransformStateType;
  1050.     D3DLIGHTSTATETYPE   dlstLightStateType;
  1051.     D3DRENDERSTATETYPE  drstRenderStateType;
  1052.     };
  1053.     union {
  1054.     DWORD           dwArg[1];
  1055.     D3DVALUE        dvArg[1];
  1056.     };
  1057. } D3DSTATE, *LPD3DSTATE;
  1058.  
  1059. /*
  1060.  * Operation used to load matrices
  1061.  * hDstMat = hSrcMat
  1062.  */
  1063. typedef struct _D3DMATRIXLOAD {
  1064.     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
  1065.     D3DMATRIXHANDLE hSrcMatrix;   /* Source matrix */
  1066. } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
  1067.  
  1068. /*
  1069.  * Operation used to multiply matrices
  1070.  * hDstMat = hSrcMat1 * hSrcMat2
  1071.  */
  1072. typedef struct _D3DMATRIXMULTIPLY {
  1073.     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
  1074.     D3DMATRIXHANDLE hSrcMatrix1;  /* First source matrix */
  1075.     D3DMATRIXHANDLE hSrcMatrix2;  /* Second source matrix */
  1076. } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
  1077.  
  1078. /*
  1079.  * Operation used to transform and light vertices.
  1080.  */
  1081. typedef struct _D3DPROCESSVERTICES {
  1082.     DWORD        dwFlags;    /* Do we transform or light or just copy? */
  1083.     WORD         wStart;     /* Index to first vertex in source */
  1084.     WORD         wDest;      /* Index to first vertex in local buffer */
  1085.     DWORD        dwCount;    /* Number of vertices to be processed */
  1086.     DWORD    dwReserved; /* Must be zero */
  1087. } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
  1088.  
  1089. #define D3DPROCESSVERTICES_TRANSFORMLIGHT   0x00000000L
  1090. #define D3DPROCESSVERTICES_TRANSFORM        0x00000001L
  1091. #define D3DPROCESSVERTICES_COPY         0x00000002L
  1092. #define D3DPROCESSVERTICES_OPMASK       0x00000007L
  1093.  
  1094. #define D3DPROCESSVERTICES_UPDATEEXTENTS    0x00000008L
  1095. #define D3DPROCESSVERTICES_NOCOLOR      0x00000010L
  1096.  
  1097.  
  1098.  
  1099.  
  1100. /*
  1101.  * State enumerants for per-stage texture processing.
  1102.  */
  1103. typedef enum _D3DTEXTURESTAGESTATETYPE
  1104. {
  1105.     D3DTSS_COLOROP        =  1, /* D3DTEXTUREOP - per-stage blending controls for color channels */
  1106.     D3DTSS_COLORARG1      =  2, /* D3DTA_* (texture arg) */
  1107.     D3DTSS_COLORARG2      =  3, /* D3DTA_* (texture arg) */
  1108.     D3DTSS_ALPHAOP        =  4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */
  1109.     D3DTSS_ALPHAARG1      =  5, /* D3DTA_* (texture arg) */
  1110.     D3DTSS_ALPHAARG2      =  6, /* D3DTA_* (texture arg) */
  1111.     D3DTSS_BUMPENVMAT00   =  7, /* D3DVALUE (bump mapping matrix) */
  1112.     D3DTSS_BUMPENVMAT01   =  8, /* D3DVALUE (bump mapping matrix) */
  1113.     D3DTSS_BUMPENVMAT10   =  9, /* D3DVALUE (bump mapping matrix) */
  1114.     D3DTSS_BUMPENVMAT11   = 10, /* D3DVALUE (bump mapping matrix) */
  1115.     D3DTSS_TEXCOORDINDEX  = 11, /* identifies which set of texture coordinates index this texture */
  1116.     D3DTSS_ADDRESS        = 12, /* D3DTEXTUREADDRESS for both coordinates */
  1117.     D3DTSS_ADDRESSU       = 13, /* D3DTEXTUREADDRESS for U coordinate */
  1118.     D3DTSS_ADDRESSV       = 14, /* D3DTEXTUREADDRESS for V coordinate */
  1119.     D3DTSS_BORDERCOLOR    = 15, /* D3DCOLOR */
  1120.     D3DTSS_MAGFILTER      = 16, /* D3DTEXTUREMAGFILTER filter to use for magnification */
  1121.     D3DTSS_MINFILTER      = 17, /* D3DTEXTUREMINFILTER filter to use for minification */
  1122.     D3DTSS_MIPFILTER      = 18, /* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification */
  1123.     D3DTSS_MIPMAPLODBIAS  = 19, /* D3DVALUE Mipmap LOD bias */
  1124.     D3DTSS_MAXMIPLEVEL    = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */
  1125.     D3DTSS_MAXANISOTROPY  = 21, /* DWORD maximum anisotropy */
  1126.     D3DTSS_BUMPENVLSCALE  = 22, /* D3DVALUE scale for bump map luminance */
  1127.     D3DTSS_BUMPENVLOFFSET = 23, /* D3DVALUE offset for bump map luminance */
  1128.     D3DTSS_FORCE_DWORD   = 0x7fffffff, /* force 32-bit size enum */
  1129. } D3DTEXTURESTAGESTATETYPE;
  1130.  
  1131. /*
  1132.  * Enumerations for COLOROP and ALPHAOP texture blending operations set in
  1133.  * texture processing stage controls in D3DRENDERSTATE.
  1134.  */
  1135. typedef enum _D3DTEXTUREOP
  1136. {
  1137. // Control
  1138.     D3DTOP_DISABLE    = 1,      // disables stage
  1139.     D3DTOP_SELECTARG1 = 2,      // the default
  1140.     D3DTOP_SELECTARG2 = 3,
  1141.  
  1142. // Modulate
  1143.     D3DTOP_MODULATE   = 4,      // multiply args together
  1144.     D3DTOP_MODULATE2X = 5,      // multiply and  1 bit
  1145.     D3DTOP_MODULATE4X = 6,      // multiply and  2 bits
  1146.  
  1147. // Add
  1148.     D3DTOP_ADD          =  7,   // add arguments together
  1149.     D3DTOP_ADDSIGNED    =  8,   // add with -0.5 bias
  1150.     D3DTOP_ADDSIGNED2X  =  9,   // as above but left  1 bit
  1151.     D3DTOP_SUBTRACT     = 10,   // Arg1 - Arg2, with no saturation
  1152.     D3DTOP_ADDSMOOTH    = 11,   // add 2 args, subtract product
  1153.                                 // Arg1 + Arg2 - Arg1*Arg2
  1154.                                 // = Arg1 + (1-Arg1)*Arg2
  1155.  
  1156. // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
  1157.     D3DTOP_BLENDDIFFUSEALPHA    = 12, // iterated alpha
  1158.     D3DTOP_BLENDTEXTUREALPHA    = 13, // texture alpha
  1159.     D3DTOP_BLENDFACTORALPHA     = 14, // alpha from D3DRENDERSTATE_TEXTUREFACTOR
  1160.     // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
  1161.     D3DTOP_BLENDTEXTUREALPHAPM  = 15, // texture alpha
  1162.     D3DTOP_BLENDCURRENTALPHA    = 16, // by alpha of current color
  1163.  
  1164. // Specular mapping
  1165.     D3DTOP_PREMODULATE            = 17,     // modulate with next texture before use
  1166.     D3DTOP_MODULATEALPHA_ADDCOLOR = 18,     // Arg1.RGB + Arg1.A*Arg2.RGB
  1167.                                             // COLOROP only
  1168.     D3DTOP_MODULATECOLOR_ADDALPHA = 19,     // Arg1.RGB*Arg2.RGB + Arg1.A
  1169.                                             // COLOROP only
  1170.     D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,  // (1-Arg1.A)*Arg2.RGB + Arg1.RGB
  1171.                                             // COLOROP only
  1172.     D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,  // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
  1173.                                             // COLOROP only
  1174.  
  1175. // Bump mapping
  1176.     D3DTOP_BUMPENVMAP           = 22, // per pixel env map perturbation
  1177.     D3DTOP_BUMPENVMAPLUMINANCE  = 23, // with luminance channel
  1178.     // This can do either diffuse or specular bump mapping with correct input.
  1179.     // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
  1180.     // where each component has been scaled and offset to make it signed.
  1181.     // The result is replicated into all four (including alpha) channels.
  1182.     // This is a valid COLOROP only.
  1183.     D3DTOP_DOTPRODUCT3          = 24,
  1184.  
  1185.     D3DTOP_FORCE_DWORD = 0x7fffffff,
  1186. } D3DTEXTUREOP;
  1187.  
  1188. /*
  1189.  * Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations
  1190.  * set in texture processing stage controls in D3DRENDERSTATE.
  1191.  */
  1192. #define D3DTA_SELECTMASK        0x0000000f  // mask for arg selector
  1193. #define D3DTA_DIFFUSE           0x00000000  // select diffuse color
  1194. #define D3DTA_CURRENT           0x00000001  // select result of previous stage
  1195. #define D3DTA_TEXTURE           0x00000002  // select texture color
  1196. #define D3DTA_TFACTOR           0x00000003  // select RENDERSTATE_TEXTUREFACTOR
  1197.  
  1198. #define D3DTA_COMPLEMENT        0x00000010  // take 1.0 - x
  1199. #define D3DTA_ALPHAREPLICATE    0x00000020  // replicate alpha to color components
  1200.  
  1201. /*
  1202.  *  IDirect3DTexture2 State Filter Types
  1203.  */
  1204. typedef enum _D3DTEXTUREMAGFILTER
  1205. {
  1206.     D3DTFG_POINT        = 1,    // nearest
  1207.     D3DTFG_LINEAR       = 2,    // linear interpolation
  1208.     D3DTFG_FLATCUBIC    = 3,    // cubic
  1209.     D3DTFG_GAUSSIANCUBIC = 4,   // different cubic kernel
  1210.     D3DTFG_ANISOTROPIC  = 5,    //
  1211.     D3DTFG_FORCE_DWORD  = 0x7fffffff,   // force 32-bit size enum
  1212. } D3DTEXTUREMAGFILTER;
  1213.  
  1214. typedef enum _D3DTEXTUREMINFILTER
  1215. {
  1216.     D3DTFN_POINT        = 1,    // nearest
  1217.     D3DTFN_LINEAR       = 2,    // linear interpolation
  1218.     D3DTFN_ANISOTROPIC  = 3,    //
  1219.     D3DTFN_FORCE_DWORD  = 0x7fffffff,   // force 32-bit size enum
  1220. } D3DTEXTUREMINFILTER;
  1221.  
  1222. typedef enum _D3DTEXTUREMIPFILTER
  1223. {
  1224.     D3DTFP_NONE         = 1,    // mipmapping disabled (use MAG filter)
  1225.     D3DTFP_POINT        = 2,    // nearest
  1226.     D3DTFP_LINEAR       = 3,    // linear interpolation
  1227.     D3DTFP_FORCE_DWORD  = 0x7fffffff,   // force 32-bit size enum
  1228. } D3DTEXTUREMIPFILTER;
  1229.  
  1230.  
  1231. /*
  1232.  * Triangle flags
  1233.  */
  1234.  
  1235. /*
  1236.  * Tri strip and fan flags.
  1237.  * START loads all three vertices
  1238.  * EVEN and ODD load just v3 with even or odd culling
  1239.  * START_FLAT contains a count from 0 to 29 that allows the
  1240.  * whole strip or fan to be culled in one hit.
  1241.  * e.g. for a quad len = 1
  1242.  */
  1243. #define D3DTRIFLAG_START            0x00000000L
  1244. #define D3DTRIFLAG_STARTFLAT(len) (len)     /* 0 < len < 30 */
  1245. #define D3DTRIFLAG_ODD              0x0000001eL
  1246. #define D3DTRIFLAG_EVEN             0x0000001fL
  1247.  
  1248. /*
  1249.  * Triangle edge flags
  1250.  * enable edges for wireframe or antialiasing
  1251.  */
  1252. #define D3DTRIFLAG_EDGEENABLE1          0x00000100L /* v0-v1 edge */
  1253. #define D3DTRIFLAG_EDGEENABLE2          0x00000200L /* v1-v2 edge */
  1254. #define D3DTRIFLAG_EDGEENABLE3          0x00000400L /* v2-v0 edge */
  1255. #define D3DTRIFLAG_EDGEENABLETRIANGLE \
  1256.         (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
  1257.  
  1258. /*
  1259.  * Primitive structures and related defines.  Vertex offsets are to types
  1260.  * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
  1261.  */
  1262.  
  1263. /*
  1264.  * Triangle list primitive structure
  1265.  */
  1266. typedef struct _D3DTRIANGLE {
  1267.     union {
  1268.     WORD    v1;            /* Vertex indices */
  1269.     WORD    wV1;
  1270.     };
  1271.     union {
  1272.     WORD    v2;
  1273.     WORD    wV2;
  1274.     };
  1275.     union {
  1276.     WORD    v3;
  1277.     WORD    wV3;
  1278.     };
  1279.     WORD        wFlags;       /* Edge (and other) flags */
  1280. } D3DTRIANGLE, *LPD3DTRIANGLE;
  1281.  
  1282. /*
  1283.  * Line list structure.
  1284.  * The instruction count defines the number of line segments.
  1285.  */
  1286. typedef struct _D3DLINE {
  1287.     union {
  1288.     WORD    v1;            /* Vertex indices */
  1289.     WORD    wV1;
  1290.     };
  1291.     union {
  1292.     WORD    v2;
  1293.     WORD    wV2;
  1294.     };
  1295. } D3DLINE, *LPD3DLINE;
  1296.  
  1297. /*
  1298.  * Span structure
  1299.  * Spans join a list of points with the same y value.
  1300.  * If the y value changes, a new span is started.
  1301.  */
  1302. typedef struct _D3DSPAN {
  1303.     WORD    wCount; /* Number of spans */
  1304.     WORD    wFirst; /* Index to first vertex */
  1305. } D3DSPAN, *LPD3DSPAN;
  1306.  
  1307. /*
  1308.  * Point structure
  1309.  */
  1310. typedef struct _D3DPOINT {
  1311.     WORD    wCount;     /* number of points     */
  1312.     WORD    wFirst;     /* index to first vertex    */
  1313. } D3DPOINT, *LPD3DPOINT;
  1314.  
  1315.  
  1316. /*
  1317.  * Forward branch structure.
  1318.  * Mask is logically anded with the driver status mask
  1319.  * if the result equals 'value', the branch is taken.
  1320.  */
  1321. typedef struct _D3DBRANCH {
  1322.     DWORD   dwMask;     /* Bitmask against D3D status */
  1323.     DWORD   dwValue;
  1324.     BOOL    bNegate;        /* TRUE to negate comparison */
  1325.     DWORD   dwOffset;   /* How far to branch forward (0 for exit)*/
  1326. } D3DBRANCH, *LPD3DBRANCH;
  1327.  
  1328. /*
  1329.  * Status used for set status instruction.
  1330.  * The D3D status is initialised on device creation
  1331.  * and is modified by all execute calls.
  1332.  */
  1333. typedef struct _D3DSTATUS {
  1334.     DWORD       dwFlags;    /* Do we set extents or status */
  1335.     DWORD   dwStatus;   /* D3D status */
  1336.     D3DRECT drExtent;
  1337. } D3DSTATUS, *LPD3DSTATUS;
  1338.  
  1339. #define D3DSETSTATUS_STATUS     0x00000001L
  1340. #define D3DSETSTATUS_EXTENTS        0x00000002L
  1341. #define D3DSETSTATUS_ALL    (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
  1342.  
  1343. typedef struct _D3DCLIPSTATUS {
  1344.     DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
  1345.     DWORD dwStatus; /* Clip status */
  1346.     float minx, maxx; /* X extents */
  1347.     float miny, maxy; /* Y extents */
  1348.     float minz, maxz; /* Z extents */
  1349. } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
  1350.  
  1351. #define D3DCLIPSTATUS_STATUS        0x00000001L
  1352. #define D3DCLIPSTATUS_EXTENTS2      0x00000002L
  1353. #define D3DCLIPSTATUS_EXTENTS3      0x00000004L
  1354.  
  1355. /*
  1356.  * Statistics structure
  1357.  */
  1358. typedef struct _D3DSTATS {
  1359.     DWORD        dwSize;
  1360.     DWORD        dwTrianglesDrawn;
  1361.     DWORD        dwLinesDrawn;
  1362.     DWORD        dwPointsDrawn;
  1363.     DWORD        dwSpansDrawn;
  1364.     DWORD        dwVerticesProcessed;
  1365. } D3DSTATS, *LPD3DSTATS;
  1366.  
  1367. /*
  1368.  * Execute options.
  1369.  * When calling using D3DEXECUTE_UNCLIPPED all the primitives
  1370.  * inside the buffer must be contained within the viewport.
  1371.  */
  1372. #define D3DEXECUTE_CLIPPED       0x00000001l
  1373. #define D3DEXECUTE_UNCLIPPED     0x00000002l
  1374.  
  1375. typedef struct _D3DEXECUTEDATA {
  1376.     DWORD       dwSize;
  1377.     DWORD       dwVertexOffset;
  1378.     DWORD       dwVertexCount;
  1379.     DWORD       dwInstructionOffset;
  1380.     DWORD       dwInstructionLength;
  1381.     DWORD       dwHVertexOffset;
  1382.     D3DSTATUS   dsStatus;   /* Status after execute */
  1383. } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
  1384.  
  1385. /*
  1386.  * Palette flags.
  1387.  * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
  1388.  */
  1389. #define D3DPAL_FREE 0x00    /* Renderer may use this entry freely */
  1390. #define D3DPAL_READONLY 0x40    /* Renderer may not set this entry */
  1391. #define D3DPAL_RESERVED 0x80    /* Renderer may not use this entry */
  1392.  
  1393.  
  1394.  
  1395. typedef struct _D3DVERTEXBUFFERDESC {
  1396.     DWORD dwSize;
  1397.     DWORD dwCaps;
  1398.     DWORD dwFVF;
  1399.     DWORD dwNumVertices;
  1400. } D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC;
  1401.  
  1402. /* These correspond to DDSCAPS_* flags */
  1403. #define D3DVBCAPS_SYSTEMMEMORY      0x00000800l
  1404. #define D3DVBCAPS_WRITEONLY         0x00010000l
  1405. #define D3DVBCAPS_OPTIMIZED         0x80000000l
  1406.  
  1407. /* Vertex Operations for ProcessVertices */
  1408. #define D3DVOP_LIGHT       (1 << 10)
  1409. #define D3DVOP_TRANSFORM   (1 << 0)
  1410. #define D3DVOP_CLIP        (1 << 2)
  1411. #define D3DVOP_EXTENTS     (1 << 3)
  1412.  
  1413. //-------------------------------------------------------------------
  1414.  
  1415. // Flexible vertex format bits
  1416. //
  1417. #define D3DFVF_RESERVED0        0x001
  1418. #define D3DFVF_POSITION_MASK    0x00E
  1419. #define D3DFVF_XYZ              0x002
  1420. #define D3DFVF_XYZRHW           0x004
  1421. #define D3DFVF_NORMAL           0x010
  1422. #define D3DFVF_RESERVED1        0x020
  1423. #define D3DFVF_DIFFUSE          0x040
  1424. #define D3DFVF_SPECULAR         0x080
  1425.  
  1426. #define D3DFVF_TEXCOUNT_MASK    0xf00
  1427. #define D3DFVF_TEXCOUNT_SHIFT   8
  1428. #define D3DFVF_TEX0             0x000
  1429. #define D3DFVF_TEX1             0x100
  1430. #define D3DFVF_TEX2             0x200
  1431. #define D3DFVF_TEX3             0x300
  1432. #define D3DFVF_TEX4             0x400
  1433. #define D3DFVF_TEX5             0x500
  1434. #define D3DFVF_TEX6             0x600
  1435. #define D3DFVF_TEX7             0x700
  1436. #define D3DFVF_TEX8             0x800
  1437.  
  1438. #define D3DFVF_RESERVED2        0xf000  // 4 reserved bits
  1439.  
  1440. #define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
  1441. #define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \
  1442.                          D3DFVF_SPECULAR | D3DFVF_TEX1 )
  1443. #define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \
  1444.                           D3DFVF_TEX1 )
  1445.  
  1446. typedef struct _D3DDP_PTRSTRIDE
  1447. {
  1448.     LPVOID lpvData;
  1449.     DWORD  dwStride;
  1450. } D3DDP_PTRSTRIDE;
  1451.  
  1452. #define D3DDP_MAXTEXCOORD 8
  1453.  
  1454. typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA
  1455. {
  1456.     D3DDP_PTRSTRIDE position;
  1457.     D3DDP_PTRSTRIDE normal;
  1458.     D3DDP_PTRSTRIDE diffuse;
  1459.     D3DDP_PTRSTRIDE specular;
  1460.     D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD];
  1461. } D3DDRAWPRIMITIVESTRIDEDDATA, *LPD3DDRAWPRIMITIVESTRIDEDDATA;
  1462. //---------------------------------------------------------------------
  1463. // ComputeSphereVisibility return values
  1464. //
  1465. #define D3DVIS_INSIDE_FRUSTUM       0
  1466. #define D3DVIS_INTERSECT_FRUSTUM    1
  1467. #define D3DVIS_OUTSIDE_FRUSTUM      2
  1468. #define D3DVIS_INSIDE_LEFT          0
  1469. #define D3DVIS_INTERSECT_LEFT       (1 << 2)
  1470. #define D3DVIS_OUTSIDE_LEFT         (2 << 2)
  1471. #define D3DVIS_INSIDE_RIGHT         0
  1472. #define D3DVIS_INTERSECT_RIGHT      (1 << 4)
  1473. #define D3DVIS_OUTSIDE_RIGHT        (2 << 4)
  1474. #define D3DVIS_INSIDE_TOP           0
  1475. #define D3DVIS_INTERSECT_TOP        (1 << 6)
  1476. #define D3DVIS_OUTSIDE_TOP          (2 << 6)
  1477. #define D3DVIS_INSIDE_BOTTOM        0
  1478. #define D3DVIS_INTERSECT_BOTTOM     (1 << 8)
  1479. #define D3DVIS_OUTSIDE_BOTTOM       (2 << 8)
  1480. #define D3DVIS_INSIDE_NEAR          0
  1481. #define D3DVIS_INTERSECT_NEAR       (1 << 10)
  1482. #define D3DVIS_OUTSIDE_NEAR         (2 << 10)
  1483. #define D3DVIS_INSIDE_FAR           0
  1484. #define D3DVIS_INTERSECT_FAR        (1 << 12)
  1485. #define D3DVIS_OUTSIDE_FAR          (2 << 12)
  1486.  
  1487. #define D3DVIS_MASK_FRUSTUM         (3 << 0)
  1488. #define D3DVIS_MASK_LEFT            (3 << 2)
  1489. #define D3DVIS_MASK_RIGHT           (3 << 4)
  1490. #define D3DVIS_MASK_TOP             (3 << 6)
  1491. #define D3DVIS_MASK_BOTTOM          (3 << 8)
  1492. #define D3DVIS_MASK_NEAR            (3 << 10)
  1493. #define D3DVIS_MASK_FAR             (3 << 12)
  1494.  
  1495.  
  1496. #pragma pack()
  1497. #endif /* _D3DTYPES_H_ */
  1498.  
  1499.