home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / D3DTYPES.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  39.0 KB  |  1,204 lines

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