home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / MSINC.PAK / D3DTYPES.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  31.4 KB  |  965 lines

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