Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2000 Peter Hunnisett
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Lesser General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2.1 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Lesser General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Lesser General Public
     15  * License along with this library; if not, write to the Free Software
     16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
     17  */
     18 
     19 /* FIXME: Need to add C++ code for certain structs for headers - this is going to be a problem
     20           if WINE continues to only use C code  - I suppose that we could always inline in
     21           the header file to get around that little problem... */
     22 /* FIXME: We need to implement versioning on everything directx 5 and up if these headers
     23           are going to be generically useful for directx stuff */
     24 
     25 #ifndef __WINE_D3DTYPES_H
     26 #define __WINE_D3DTYPES_H
     27 
     28 #include <windows.h>
     29 #include <float.h>
     30 #include <ddraw.h>
     31 
     32 #define D3DVALP(val, prec)      ((float)(val))
     33 #define D3DVAL(val)             ((float)(val))
     34 #define D3DDivide(a, b)         (float)((double) (a) / (double) (b))
     35 #define D3DMultiply(a, b)       ((a) * (b))
     36 
     37 typedef LONG D3DFIXED;
     38 
     39 
     40 #ifndef RGB_MAKE
     41 #define CI_GETALPHA(ci)    ((ci) >> 24)
     42 #define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
     43 #define CI_GETFRACTION(ci) ((ci) & 0xff)
     44 #define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
     45 #define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
     46 #define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
     47 
     48 #define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
     49 #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
     50 #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
     51 #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
     52 #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
     53 
     54 #define D3DRGB(r, g, b) \
     55     (0xff000000 | ( ((LONG)((r) * 255)) << 16) | (((LONG)((g) * 255)) << 8) | (LONG)((b) * 255))
     56 #define D3DRGBA(r, g, b, a) \
     57     (   (((LONG)((a) * 255)) << 24) | (((LONG)((r) * 255)) << 16) \
     58     |   (((LONG)((g) * 255)) << 8) | (LONG)((b) * 255) \
     59     )
     60 
     61 #define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
     62 #define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
     63 #define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
     64 #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
     65 #define RGB_MAKE(r, g, b)       ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
     66 #define RGBA_TORGB(rgba)       ((D3DCOLOR) ((rgba) & 0xffffff))
     67 #define RGB_TORGBA(rgb)        ((D3DCOLOR) ((rgb) | 0xff000000))
     68 
     69 #endif
     70 
     71 #define D3DENUMRET_CANCEL                        DDENUMRET_CANCEL
     72 #define D3DENUMRET_OK                            DDENUMRET_OK
     73 
     74 typedef HRESULT (CALLBACK *LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
     75 typedef HRESULT (CALLBACK *LPD3DENUMTEXTUREFORMATSCALLBACK)(DDSURFACEDESC *surface_desc, void *ctx);
     76 typedef HRESULT (CALLBACK *LPD3DENUMPIXELFORMATSCALLBACK)(DDPIXELFORMAT *format, void *ctx);
     77 
     78 #ifndef DX_SHARED_DEFINES
     79 
     80 typedef float D3DVALUE,*LPD3DVALUE;
     81 
     82 #ifndef D3DCOLOR_DEFINED
     83 typedef DWORD D3DCOLOR, *LPD3DCOLOR;
     84 #define D3DCOLOR_DEFINED
     85 #endif
     86 
     87 #ifndef D3DVECTOR_DEFINED
     88 typedef struct _D3DVECTOR {
     89   union {
     90         D3DVALUE        x;
     91     D3DVALUE dvX;
     92   } DUMMYUNIONNAME1;
     93   union {
     94         D3DVALUE        y;
     95     D3DVALUE dvY;
     96   } DUMMYUNIONNAME2;
     97   union {
     98         D3DVALUE        z;
     99     D3DVALUE dvZ;
    100   } DUMMYUNIONNAME3;
    101 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
    102   /* the definitions for these methods are in d3dvec.inl */
    103 public:
    104   /*** constructors ***/
    105   _D3DVECTOR() {}
    106   _D3DVECTOR(D3DVALUE f);
    107   _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
    108   _D3DVECTOR(const D3DVALUE f[3]);
    109 
    110   /*** assignment operators ***/
    111   _D3DVECTOR& operator += (const _D3DVECTOR& v);
    112   _D3DVECTOR& operator -= (const _D3DVECTOR& v);
    113   _D3DVECTOR& operator *= (const _D3DVECTOR& v);
    114   _D3DVECTOR& operator /= (const _D3DVECTOR& v);
    115   _D3DVECTOR& operator *= (D3DVALUE s);
    116   _D3DVECTOR& operator /= (D3DVALUE s);
    117 
    118   /*** unary operators ***/
    119   friend _D3DVECTOR operator + (const _D3DVECTOR& v);
    120   friend _D3DVECTOR operator - (const _D3DVECTOR& v);
    121 
    122   /*** binary operators ***/
    123   friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
    124   friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
    125 
    126   friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
    127   friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
    128   friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
    129 
    130   friend D3DVALUE SquareMagnitude(const _D3DVECTOR& v);
    131   friend D3DVALUE Magnitude(const _D3DVECTOR& v);
    132 
    133   friend _D3DVECTOR Normalize(const _D3DVECTOR& v);
    134 
    135   friend D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2);
    136   friend _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2);
    137 #endif
    138 } D3DVECTOR,*LPD3DVECTOR;
    139 #define D3DVECTOR_DEFINED
    140 #endif
    141 
    142 #define DX_SHARED_DEFINES
    143 #endif /* DX_SHARED_DEFINES */
    144 
    145 typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
    146 typedef DWORD D3DTEXTUREHANDLE,  *LPD3DTEXTUREHANDLE;
    147 typedef DWORD D3DMATRIXHANDLE,   *LPD3DMATRIXHANDLE;
    148 
    149 typedef struct _D3DCOLORVALUE {
    150         union {
    151                 D3DVALUE r;
    152                 D3DVALUE dvR;
    153         } DUMMYUNIONNAME1;
    154         union {
    155                 D3DVALUE g;
    156                 D3DVALUE dvG;
    157         } DUMMYUNIONNAME2;
    158         union {
    159                 D3DVALUE b;
    160                 D3DVALUE dvB;
    161         } DUMMYUNIONNAME3;
    162         union {
    163                 D3DVALUE a;
    164                 D3DVALUE dvA;
    165         } DUMMYUNIONNAME4;
    166 } D3DCOLORVALUE,*LPD3DCOLORVALUE;
    167 
    168 typedef struct _D3DRECT {
    169   union {
    170     LONG x1;
    171     LONG lX1;
    172   } DUMMYUNIONNAME1;
    173   union {
    174     LONG y1;
    175     LONG lY1;
    176   } DUMMYUNIONNAME2;
    177   union {
    178     LONG x2;
    179     LONG lX2;
    180   } DUMMYUNIONNAME3;
    181   union {
    182     LONG y2;
    183     LONG lY2;
    184   } DUMMYUNIONNAME4;
    185 } D3DRECT, *LPD3DRECT;
    186 
    187 typedef struct _D3DHVERTEX {
    188     DWORD         dwFlags;
    189  union {
    190     D3DVALUE    hx;
    191     D3DVALUE    dvHX;
    192   } DUMMYUNIONNAME1;
    193   union {
    194     D3DVALUE    hy;
    195     D3DVALUE    dvHY;
    196   } DUMMYUNIONNAME2;
    197   union {
    198     D3DVALUE    hz;
    199     D3DVALUE    dvHZ;
    200   } DUMMYUNIONNAME3;
    201 } D3DHVERTEX, *LPD3DHVERTEX;
    202 
    203 /*
    204  * Transformed/lit vertices
    205  */
    206 typedef struct _D3DTLVERTEX {
    207   union {
    208     D3DVALUE    sx;
    209     D3DVALUE    dvSX;
    210   } DUMMYUNIONNAME1;
    211   union {
    212     D3DVALUE    sy;
    213     D3DVALUE    dvSY;
    214   } DUMMYUNIONNAME2;
    215   union {
    216     D3DVALUE    sz;
    217     D3DVALUE    dvSZ;
    218   } DUMMYUNIONNAME3;
    219   union {
    220     D3DVALUE    rhw;
    221     D3DVALUE    dvRHW;
    222   } DUMMYUNIONNAME4;
    223   union {
    224     D3DCOLOR    color;
    225     D3DCOLOR    dcColor;
    226   } DUMMYUNIONNAME5;
    227   union {
    228     D3DCOLOR    specular;
    229     D3DCOLOR    dcSpecular;
    230   } DUMMYUNIONNAME6;
    231   union {
    232     D3DVALUE    tu;
    233     D3DVALUE    dvTU;
    234   } DUMMYUNIONNAME7;
    235   union {
    236     D3DVALUE    tv;
    237     D3DVALUE    dvTV;
    238   } DUMMYUNIONNAME8;
    239 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
    240 public:
    241   _D3DTLVERTEX() {}
    242   _D3DTLVERTEX(const D3DVECTOR& v, float _rhw, D3DCOLOR _color, D3DCOLOR _specular, float _tu, float _tv) {
    243     sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
    244     color = _color; specular = _specular;
    245     tu = _tu; tv = _tv;
    246   }
    247 #endif
    248 } D3DTLVERTEX, *LPD3DTLVERTEX;
    249 
    250 typedef struct _D3DLVERTEX {
    251   union {
    252     D3DVALUE x;
    253     D3DVALUE dvX;
    254   } DUMMYUNIONNAME1;
    255   union {
    256     D3DVALUE y;
    257     D3DVALUE dvY;
    258   } DUMMYUNIONNAME2;
    259   union {
    260     D3DVALUE z;
    261     D3DVALUE dvZ;
    262   } DUMMYUNIONNAME3;
    263   DWORD            dwReserved;
    264   union {
    265     D3DCOLOR     color;
    266     D3DCOLOR     dcColor;
    267   } DUMMYUNIONNAME4;
    268   union {
    269     D3DCOLOR     specular;
    270     D3DCOLOR     dcSpecular;
    271   } DUMMYUNIONNAME5;
    272   union {
    273     D3DVALUE     tu;
    274     D3DVALUE     dvTU;
    275   } DUMMYUNIONNAME6;
    276   union {
    277     D3DVALUE     tv;
    278     D3DVALUE     dvTV;
    279   } DUMMYUNIONNAME7;
    280 } D3DLVERTEX, *LPD3DLVERTEX;
    281 
    282 typedef struct _D3DVERTEX {
    283   union {
    284     D3DVALUE     x;
    285     D3DVALUE     dvX;
    286   } DUMMYUNIONNAME1;
    287   union {
    288     D3DVALUE     y;
    289     D3DVALUE     dvY;
    290   } DUMMYUNIONNAME2;
    291   union {
    292     D3DVALUE     z;
    293     D3DVALUE     dvZ;
    294   } DUMMYUNIONNAME3;
    295   union {
    296     D3DVALUE     nx;
    297     D3DVALUE     dvNX;
    298   } DUMMYUNIONNAME4;
    299   union {
    300     D3DVALUE     ny;
    301     D3DVALUE     dvNY;
    302   } DUMMYUNIONNAME5;
    303   union {
    304     D3DVALUE     nz;
    305     D3DVALUE     dvNZ;
    306   } DUMMYUNIONNAME6;
    307   union {
    308     D3DVALUE     tu;
    309     D3DVALUE     dvTU;
    310   } DUMMYUNIONNAME7;
    311   union {
    312     D3DVALUE     tv;
    313     D3DVALUE     dvTV;
    314   } DUMMYUNIONNAME8;
    315 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
    316 public:
    317   _D3DVERTEX() {}
    318   _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv) {
    319     x  = v.x; y  = v.y; z  = v.z;
    320     nx = n.x; ny = n.y; nz = n.z;
    321     tu = _tu; tv = _tv;
    322   }
    323 #endif
    324 } D3DVERTEX, *LPD3DVERTEX;
    325 
    326 typedef struct _D3DMATRIX {
    327   D3DVALUE        _11, _12, _13, _14;
    328   D3DVALUE        _21, _22, _23, _24;
    329   D3DVALUE        _31, _32, _33, _34;
    330   D3DVALUE        _41, _42, _43, _44;
    331 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
    332   _D3DMATRIX() { }
    333 
    334     /* This is different from MS, but avoids anonymous structs. */
    335     D3DVALUE &operator () (int r, int c)
    336 	{ return (&_11)[r*4 + c]; }
    337     const D3DVALUE &operator() (int r, int c) const
    338 	{ return (&_11)[r*4 + c]; }
    339 #endif
    340 } D3DMATRIX, *LPD3DMATRIX;
    341 
    342 #if defined(__cplusplus) && defined(D3D_OVERLOADS)
    343 #include <d3dvec.inl>
    344 #endif
    345 
    346 typedef struct _D3DVIEWPORT {
    347   DWORD       dwSize;
    348   DWORD       dwX;
    349   DWORD       dwY;
    350   DWORD       dwWidth;
    351   DWORD       dwHeight;
    352   D3DVALUE    dvScaleX;
    353   D3DVALUE    dvScaleY;
    354   D3DVALUE    dvMaxX;
    355   D3DVALUE    dvMaxY;
    356   D3DVALUE    dvMinZ;
    357   D3DVALUE    dvMaxZ;
    358 } D3DVIEWPORT, *LPD3DVIEWPORT;
    359 
    360 typedef struct _D3DVIEWPORT2 {
    361   DWORD       dwSize;
    362   DWORD       dwX;
    363   DWORD       dwY;
    364   DWORD       dwWidth;
    365   DWORD       dwHeight;
    366   D3DVALUE    dvClipX;
    367   D3DVALUE    dvClipY;
    368   D3DVALUE    dvClipWidth;
    369   D3DVALUE    dvClipHeight;
    370   D3DVALUE    dvMinZ;
    371   D3DVALUE    dvMaxZ;
    372 } D3DVIEWPORT2, *LPD3DVIEWPORT2;
    373 
    374 typedef struct _D3DVIEWPORT7 {
    375   DWORD       dwX;
    376   DWORD       dwY;
    377   DWORD       dwWidth;
    378   DWORD       dwHeight;
    379   D3DVALUE    dvMinZ;
    380   D3DVALUE    dvMaxZ;
    381 } D3DVIEWPORT7, *LPD3DVIEWPORT7;
    382 
    383 #define D3DMAXUSERCLIPPLANES 32
    384 
    385 #define D3DCLIPPLANE0 (1 << 0)
    386 #define D3DCLIPPLANE1 (1 << 1)
    387 #define D3DCLIPPLANE2 (1 << 2)
    388 #define D3DCLIPPLANE3 (1 << 3)
    389 #define D3DCLIPPLANE4 (1 << 4)
    390 #define D3DCLIPPLANE5 (1 << 5)
    391 
    392 #define D3DCLIP_LEFT     0x00000001
    393 #define D3DCLIP_RIGHT    0x00000002
    394 #define D3DCLIP_TOP      0x00000004
    395 #define D3DCLIP_BOTTOM   0x00000008
    396 #define D3DCLIP_FRONT    0x00000010
    397 #define D3DCLIP_BACK     0x00000020
    398 #define D3DCLIP_GEN0     0x00000040
    399 #define D3DCLIP_GEN1     0x00000080
    400 #define D3DCLIP_GEN2     0x00000100
    401 #define D3DCLIP_GEN3     0x00000200
    402 #define D3DCLIP_GEN4     0x00000400
    403 #define D3DCLIP_GEN5     0x00000800
    404 
    405 #define D3DSTATUS_CLIPUNIONLEFT                 D3DCLIP_LEFT
    406 #define D3DSTATUS_CLIPUNIONRIGHT                D3DCLIP_RIGHT
    407 #define D3DSTATUS_CLIPUNIONTOP                  D3DCLIP_TOP
    408 #define D3DSTATUS_CLIPUNIONBOTTOM               D3DCLIP_BOTTOM
    409 #define D3DSTATUS_CLIPUNIONFRONT                D3DCLIP_FRONT
    410 #define D3DSTATUS_CLIPUNIONBACK                 D3DCLIP_BACK
    411 #define D3DSTATUS_CLIPUNIONGEN0                 D3DCLIP_GEN0
    412 #define D3DSTATUS_CLIPUNIONGEN1                 D3DCLIP_GEN1
    413 #define D3DSTATUS_CLIPUNIONGEN2                 D3DCLIP_GEN2
    414 #define D3DSTATUS_CLIPUNIONGEN3                 D3DCLIP_GEN3
    415 #define D3DSTATUS_CLIPUNIONGEN4                 D3DCLIP_GEN4
    416 #define D3DSTATUS_CLIPUNIONGEN5                 D3DCLIP_GEN5
    417 
    418 #define D3DSTATUS_CLIPINTERSECTIONLEFT          0x00001000
    419 #define D3DSTATUS_CLIPINTERSECTIONRIGHT         0x00002000
    420 #define D3DSTATUS_CLIPINTERSECTIONTOP           0x00004000
    421 #define D3DSTATUS_CLIPINTERSECTIONBOTTOM        0x00008000
    422 #define D3DSTATUS_CLIPINTERSECTIONFRONT         0x00010000
    423 #define D3DSTATUS_CLIPINTERSECTIONBACK          0x00020000
    424 #define D3DSTATUS_CLIPINTERSECTIONGEN0          0x00040000
    425 #define D3DSTATUS_CLIPINTERSECTIONGEN1          0x00080000
    426 #define D3DSTATUS_CLIPINTERSECTIONGEN2          0x00100000
    427 #define D3DSTATUS_CLIPINTERSECTIONGEN3          0x00200000
    428 #define D3DSTATUS_CLIPINTERSECTIONGEN4          0x00400000
    429 #define D3DSTATUS_CLIPINTERSECTIONGEN5          0x00800000
    430 #define D3DSTATUS_ZNOTVISIBLE                   0x01000000
    431 
    432 #define D3DSTATUS_CLIPUNIONALL  (               \
    433             D3DSTATUS_CLIPUNIONLEFT     |       \
    434             D3DSTATUS_CLIPUNIONRIGHT    |       \
    435             D3DSTATUS_CLIPUNIONTOP      |       \
    436             D3DSTATUS_CLIPUNIONBOTTOM   |       \
    437             D3DSTATUS_CLIPUNIONFRONT    |       \
    438             D3DSTATUS_CLIPUNIONBACK     |       \
    439             D3DSTATUS_CLIPUNIONGEN0     |       \
    440             D3DSTATUS_CLIPUNIONGEN1     |       \
    441             D3DSTATUS_CLIPUNIONGEN2     |       \
    442             D3DSTATUS_CLIPUNIONGEN3     |       \
    443             D3DSTATUS_CLIPUNIONGEN4     |       \
    444             D3DSTATUS_CLIPUNIONGEN5             \
    445             )
    446 
    447 #define D3DSTATUS_CLIPINTERSECTIONALL   (               \
    448             D3DSTATUS_CLIPINTERSECTIONLEFT      |       \
    449             D3DSTATUS_CLIPINTERSECTIONRIGHT     |       \
    450             D3DSTATUS_CLIPINTERSECTIONTOP       |       \
    451             D3DSTATUS_CLIPINTERSECTIONBOTTOM    |       \
    452             D3DSTATUS_CLIPINTERSECTIONFRONT     |       \
    453             D3DSTATUS_CLIPINTERSECTIONBACK      |       \
    454             D3DSTATUS_CLIPINTERSECTIONGEN0      |       \
    455             D3DSTATUS_CLIPINTERSECTIONGEN1      |       \
    456             D3DSTATUS_CLIPINTERSECTIONGEN2      |       \
    457             D3DSTATUS_CLIPINTERSECTIONGEN3      |       \
    458             D3DSTATUS_CLIPINTERSECTIONGEN4      |       \
    459             D3DSTATUS_CLIPINTERSECTIONGEN5              \
    460             )
    461 
    462 #define D3DSTATUS_DEFAULT       (                       \
    463             D3DSTATUS_CLIPINTERSECTIONALL       |       \
    464             D3DSTATUS_ZNOTVISIBLE)
    465 
    466 #define D3DTRANSFORM_CLIPPED       0x00000001
    467 #define D3DTRANSFORM_UNCLIPPED     0x00000002
    468 
    469 typedef struct _D3DTRANSFORMDATA {
    470   DWORD           dwSize;
    471   LPVOID          lpIn;
    472   DWORD           dwInSize;
    473   LPVOID          lpOut;
    474   DWORD           dwOutSize;
    475   D3DHVERTEX      *lpHOut;
    476   DWORD           dwClip;
    477   DWORD           dwClipIntersection;
    478   DWORD           dwClipUnion;
    479   D3DRECT         drExtent;
    480 } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
    481 
    482 typedef struct _D3DLIGHTINGELEMENT {
    483   D3DVECTOR dvPosition;
    484   D3DVECTOR dvNormal;
    485 } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
    486 
    487 typedef struct _D3DMATERIAL {
    488   DWORD               dwSize;
    489   union {
    490     D3DCOLORVALUE   diffuse;
    491     D3DCOLORVALUE   dcvDiffuse;
    492   } DUMMYUNIONNAME;
    493   union {
    494     D3DCOLORVALUE   ambient;
    495     D3DCOLORVALUE   dcvAmbient;
    496   } DUMMYUNIONNAME1;
    497   union {
    498     D3DCOLORVALUE   specular;
    499     D3DCOLORVALUE   dcvSpecular;
    500   } DUMMYUNIONNAME2;
    501   union {
    502     D3DCOLORVALUE   emissive;
    503     D3DCOLORVALUE   dcvEmissive;
    504   } DUMMYUNIONNAME3;
    505   union {
    506     D3DVALUE        power;
    507     D3DVALUE        dvPower;
    508   } DUMMYUNIONNAME4;
    509   D3DTEXTUREHANDLE    hTexture;
    510   DWORD               dwRampSize;
    511 } D3DMATERIAL, *LPD3DMATERIAL;
    512 
    513 typedef struct _D3DMATERIAL7 {
    514   union {
    515     D3DCOLORVALUE   diffuse;
    516     D3DCOLORVALUE   dcvDiffuse;
    517   } DUMMYUNIONNAME;
    518   union {
    519     D3DCOLORVALUE   ambient;
    520     D3DCOLORVALUE   dcvAmbient;
    521   } DUMMYUNIONNAME1;
    522   union {
    523     D3DCOLORVALUE   specular;
    524     D3DCOLORVALUE   dcvSpecular;
    525   } DUMMYUNIONNAME2;
    526   union {
    527     D3DCOLORVALUE   emissive;
    528     D3DCOLORVALUE   dcvEmissive;
    529   } DUMMYUNIONNAME3;
    530   union {
    531     D3DVALUE        power;
    532     D3DVALUE        dvPower;
    533   } DUMMYUNIONNAME4;
    534 } D3DMATERIAL7, *LPD3DMATERIAL7;
    535 
    536 typedef enum {
    537   D3DLIGHT_POINT          = 1,
    538   D3DLIGHT_SPOT           = 2,
    539   D3DLIGHT_DIRECTIONAL    = 3,
    540   D3DLIGHT_PARALLELPOINT  = 4,
    541   D3DLIGHT_GLSPOT         = 5,
    542   D3DLIGHT_FORCE_DWORD    = 0x7fffffff
    543 } D3DLIGHTTYPE;
    544 
    545 typedef struct _D3DLIGHT {
    546     DWORD           dwSize;
    547     D3DLIGHTTYPE    dltType;
    548     D3DCOLORVALUE   dcvColor;
    549     D3DVECTOR       dvPosition;
    550     D3DVECTOR       dvDirection;
    551     D3DVALUE        dvRange;
    552     D3DVALUE        dvFalloff;
    553     D3DVALUE        dvAttenuation0;
    554     D3DVALUE        dvAttenuation1;
    555     D3DVALUE        dvAttenuation2;
    556     D3DVALUE        dvTheta;
    557     D3DVALUE        dvPhi;
    558 } D3DLIGHT,*LPD3DLIGHT;
    559 
    560 typedef struct _D3DLIGHT7 {
    561     D3DLIGHTTYPE    dltType;
    562     D3DCOLORVALUE   dcvDiffuse;
    563     D3DCOLORVALUE   dcvSpecular;
    564     D3DCOLORVALUE   dcvAmbient;
    565     D3DVECTOR       dvPosition;
    566     D3DVECTOR       dvDirection;
    567     D3DVALUE        dvRange;
    568     D3DVALUE        dvFalloff;
    569     D3DVALUE        dvAttenuation0;
    570     D3DVALUE        dvAttenuation1;
    571     D3DVALUE        dvAttenuation2;
    572     D3DVALUE        dvTheta;
    573     D3DVALUE        dvPhi;
    574 } D3DLIGHT7, *LPD3DLIGHT7;
    575 
    576 #define D3DLIGHT_ACTIVE         0x00000001
    577 #define D3DLIGHT_NO_SPECULAR    0x00000002
    578 #define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR) /* 0x3 */
    579 
    580 #define D3DLIGHT_RANGE_MAX              ((float)sqrt(FLT_MAX))
    581 
    582 typedef struct _D3DLIGHT2 {
    583   DWORD           dwSize;
    584   D3DLIGHTTYPE    dltType;
    585   D3DCOLORVALUE   dcvColor;
    586   D3DVECTOR       dvPosition;
    587   D3DVECTOR       dvDirection;
    588   D3DVALUE        dvRange;
    589   D3DVALUE        dvFalloff;
    590   D3DVALUE        dvAttenuation0;
    591   D3DVALUE        dvAttenuation1;
    592   D3DVALUE        dvAttenuation2;
    593   D3DVALUE        dvTheta;
    594   D3DVALUE        dvPhi;
    595   DWORD           dwFlags;
    596 } D3DLIGHT2, *LPD3DLIGHT2;
    597 
    598 typedef struct _D3DLIGHTDATA {
    599   DWORD                dwSize;
    600   D3DLIGHTINGELEMENT   *lpIn;
    601   DWORD                dwInSize;
    602   D3DTLVERTEX          *lpOut;
    603   DWORD                dwOutSize;
    604 } D3DLIGHTDATA, *LPD3DLIGHTDATA;
    605 
    606 #define D3DCOLOR_MONO   1
    607 #define D3DCOLOR_RGB    2
    608 
    609 typedef DWORD D3DCOLORMODEL;
    610 
    611 
    612 #define D3DCLEAR_TARGET   0x00000001
    613 #define D3DCLEAR_ZBUFFER  0x00000002
    614 #define D3DCLEAR_STENCIL  0x00000004
    615 
    616 typedef enum _D3DOPCODE {
    617   D3DOP_POINT           = 1,
    618   D3DOP_LINE            = 2,
    619   D3DOP_TRIANGLE        = 3,
    620   D3DOP_MATRIXLOAD      = 4,
    621   D3DOP_MATRIXMULTIPLY  = 5,
    622   D3DOP_STATETRANSFORM  = 6,
    623   D3DOP_STATELIGHT      = 7,
    624   D3DOP_STATERENDER     = 8,
    625   D3DOP_PROCESSVERTICES = 9,
    626   D3DOP_TEXTURELOAD     = 10,
    627   D3DOP_EXIT            = 11,
    628   D3DOP_BRANCHFORWARD   = 12,
    629   D3DOP_SPAN            = 13,
    630   D3DOP_SETSTATUS       = 14,
    631 
    632   D3DOP_FORCE_DWORD     = 0x7fffffff
    633 } D3DOPCODE;
    634 
    635 typedef struct _D3DINSTRUCTION {
    636   BYTE bOpcode;
    637   BYTE bSize;
    638   WORD wCount;
    639 } D3DINSTRUCTION, *LPD3DINSTRUCTION;
    640 
    641 typedef struct _D3DTEXTURELOAD {
    642   D3DTEXTUREHANDLE hDestTexture;
    643   D3DTEXTUREHANDLE hSrcTexture;
    644 } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
    645 
    646 typedef struct _D3DPICKRECORD {
    647   BYTE     bOpcode;
    648   BYTE     bPad;
    649   DWORD    dwOffset;
    650   D3DVALUE dvZ;
    651 } D3DPICKRECORD, *LPD3DPICKRECORD;
    652 
    653 typedef enum {
    654   D3DSHADE_FLAT         = 1,
    655   D3DSHADE_GOURAUD      = 2,
    656   D3DSHADE_PHONG        = 3,
    657   D3DSHADE_FORCE_DWORD  = 0x7fffffff
    658 } D3DSHADEMODE;
    659 
    660 typedef enum {
    661   D3DFILL_POINT         = 1,
    662   D3DFILL_WIREFRAME     = 2,
    663   D3DFILL_SOLID         = 3,
    664   D3DFILL_FORCE_DWORD   = 0x7fffffff
    665 } D3DFILLMODE;
    666 
    667 typedef struct _D3DLINEPATTERN {
    668   WORD    wRepeatFactor;
    669   WORD    wLinePattern;
    670 } D3DLINEPATTERN;
    671 
    672 typedef enum {
    673   D3DFILTER_NEAREST          = 1,
    674   D3DFILTER_LINEAR           = 2,
    675   D3DFILTER_MIPNEAREST       = 3,
    676   D3DFILTER_MIPLINEAR        = 4,
    677   D3DFILTER_LINEARMIPNEAREST = 5,
    678   D3DFILTER_LINEARMIPLINEAR  = 6,
    679   D3DFILTER_FORCE_DWORD      = 0x7fffffff
    680 } D3DTEXTUREFILTER;
    681 
    682 typedef enum {
    683   D3DBLEND_ZERO            = 1,
    684   D3DBLEND_ONE             = 2,
    685   D3DBLEND_SRCCOLOR        = 3,
    686   D3DBLEND_INVSRCCOLOR     = 4,
    687   D3DBLEND_SRCALPHA        = 5,
    688   D3DBLEND_INVSRCALPHA     = 6,
    689   D3DBLEND_DESTALPHA       = 7,
    690   D3DBLEND_INVDESTALPHA    = 8,
    691   D3DBLEND_DESTCOLOR       = 9,
    692   D3DBLEND_INVDESTCOLOR    = 10,
    693   D3DBLEND_SRCALPHASAT     = 11,
    694   D3DBLEND_BOTHSRCALPHA    = 12,
    695   D3DBLEND_BOTHINVSRCALPHA = 13,
    696   D3DBLEND_FORCE_DWORD     = 0x7fffffff
    697 } D3DBLEND;
    698 
    699 typedef enum {
    700   D3DTBLEND_DECAL         = 1,
    701   D3DTBLEND_MODULATE      = 2,
    702   D3DTBLEND_DECALALPHA    = 3,
    703   D3DTBLEND_MODULATEALPHA = 4,
    704   D3DTBLEND_DECALMASK     = 5,
    705   D3DTBLEND_MODULATEMASK  = 6,
    706   D3DTBLEND_COPY          = 7,
    707   D3DTBLEND_ADD           = 8,
    708   D3DTBLEND_FORCE_DWORD   = 0x7fffffff
    709 } D3DTEXTUREBLEND;
    710 
    711 typedef enum _D3DTEXTUREADDRESS {
    712     D3DTADDRESS_WRAP           = 1,
    713     D3DTADDRESS_MIRROR         = 2,
    714     D3DTADDRESS_CLAMP          = 3,
    715     D3DTADDRESS_BORDER         = 4,
    716     D3DTADDRESS_FORCE_DWORD    = 0x7fffffff
    717 } D3DTEXTUREADDRESS;
    718 
    719 typedef enum {
    720   D3DCULL_NONE        = 1,
    721   D3DCULL_CW          = 2,
    722   D3DCULL_CCW         = 3,
    723   D3DCULL_FORCE_DWORD = 0x7fffffff
    724 } D3DCULL;
    725 
    726 typedef enum {
    727   D3DCMP_NEVER        = 1,
    728   D3DCMP_LESS         = 2,
    729   D3DCMP_EQUAL        = 3,
    730   D3DCMP_LESSEQUAL    = 4,
    731   D3DCMP_GREATER      = 5,
    732   D3DCMP_NOTEQUAL     = 6,
    733   D3DCMP_GREATEREQUAL = 7,
    734   D3DCMP_ALWAYS       = 8,
    735   D3DCMP_FORCE_DWORD  = 0x7fffffff
    736 } D3DCMPFUNC;
    737 
    738 typedef enum _D3DSTENCILOP {
    739   D3DSTENCILOP_KEEP        = 1,
    740   D3DSTENCILOP_ZERO        = 2,
    741   D3DSTENCILOP_REPLACE     = 3,
    742   D3DSTENCILOP_INCRSAT     = 4,
    743   D3DSTENCILOP_DECRSAT     = 5,
    744   D3DSTENCILOP_INVERT      = 6,
    745   D3DSTENCILOP_INCR        = 7,
    746   D3DSTENCILOP_DECR        = 8,
    747   D3DSTENCILOP_FORCE_DWORD = 0x7fffffff
    748 } D3DSTENCILOP;
    749 
    750 typedef enum _D3DFOGMODE {
    751   D3DFOG_NONE         = 0,
    752   D3DFOG_EXP          = 1,
    753   D3DFOG_EXP2         = 2,
    754   D3DFOG_LINEAR       = 3,
    755   D3DFOG_FORCE_DWORD  = 0x7fffffff
    756 } D3DFOGMODE;
    757 
    758 typedef enum _D3DZBUFFERTYPE {
    759   D3DZB_FALSE        = 0,
    760   D3DZB_TRUE         = 1,
    761   D3DZB_USEW         = 2,
    762   D3DZB_FORCE_DWORD  = 0x7fffffff
    763 } D3DZBUFFERTYPE;
    764 
    765 typedef enum _D3DANTIALIASMODE {
    766   D3DANTIALIAS_NONE            = 0,
    767   D3DANTIALIAS_SORTDEPENDENT   = 1,
    768   D3DANTIALIAS_SORTINDEPENDENT = 2,
    769   D3DANTIALIAS_FORCE_DWORD     = 0x7fffffff
    770 } D3DANTIALIASMODE;
    771 
    772 typedef enum {
    773   D3DVT_VERTEX        = 1,
    774   D3DVT_LVERTEX       = 2,
    775   D3DVT_TLVERTEX      = 3,
    776   D3DVT_FORCE_DWORD   = 0x7fffffff
    777 } D3DVERTEXTYPE;
    778 
    779 typedef enum {
    780   D3DPT_POINTLIST     = 1,
    781   D3DPT_LINELIST      = 2,
    782   D3DPT_LINESTRIP     = 3,
    783   D3DPT_TRIANGLELIST  = 4,
    784   D3DPT_TRIANGLESTRIP = 5,
    785   D3DPT_TRIANGLEFAN   = 6,
    786   D3DPT_FORCE_DWORD   = 0x7fffffff
    787 } D3DPRIMITIVETYPE;
    788 
    789 #define D3DSTATE_OVERRIDE_BIAS      256
    790 
    791 #define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS))
    792 
    793 typedef enum _D3DTRANSFORMSTATETYPE {
    794     D3DTRANSFORMSTATE_WORLD         = 1,
    795     D3DTRANSFORMSTATE_VIEW          = 2,
    796     D3DTRANSFORMSTATE_PROJECTION    = 3,
    797     D3DTRANSFORMSTATE_WORLD1        = 4,
    798     D3DTRANSFORMSTATE_WORLD2        = 5,
    799     D3DTRANSFORMSTATE_WORLD3        = 6,
    800     D3DTRANSFORMSTATE_TEXTURE0      = 16,
    801     D3DTRANSFORMSTATE_TEXTURE1      = 17,
    802     D3DTRANSFORMSTATE_TEXTURE2      = 18,
    803     D3DTRANSFORMSTATE_TEXTURE3      = 19,
    804     D3DTRANSFORMSTATE_TEXTURE4      = 20,
    805     D3DTRANSFORMSTATE_TEXTURE5      = 21,
    806     D3DTRANSFORMSTATE_TEXTURE6      = 22,
    807     D3DTRANSFORMSTATE_TEXTURE7      = 23,
    808     D3DTRANSFORMSTATE_FORCE_DWORD   = 0x7fffffff
    809 } D3DTRANSFORMSTATETYPE;
    810 
    811 typedef enum {
    812   D3DLIGHTSTATE_MATERIAL      = 1,
    813   D3DLIGHTSTATE_AMBIENT       = 2,
    814   D3DLIGHTSTATE_COLORMODEL    = 3,
    815   D3DLIGHTSTATE_FOGMODE       = 4,
    816   D3DLIGHTSTATE_FOGSTART      = 5,
    817   D3DLIGHTSTATE_FOGEND        = 6,
    818   D3DLIGHTSTATE_FOGDENSITY    = 7,
    819   D3DLIGHTSTATE_COLORVERTEX   = 8,
    820   D3DLIGHTSTATE_FORCE_DWORD   = 0x7fffffff
    821 } D3DLIGHTSTATETYPE;
    822 
    823 typedef enum {
    824   D3DRENDERSTATE_TEXTUREHANDLE      = 1,
    825   D3DRENDERSTATE_ANTIALIAS          = 2,
    826   D3DRENDERSTATE_TEXTUREADDRESS     = 3,
    827   D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,
    828   D3DRENDERSTATE_WRAPU              = 5,
    829   D3DRENDERSTATE_WRAPV              = 6,
    830   D3DRENDERSTATE_ZENABLE            = 7,
    831   D3DRENDERSTATE_FILLMODE           = 8,
    832   D3DRENDERSTATE_SHADEMODE          = 9,
    833   D3DRENDERSTATE_LINEPATTERN        = 10,
    834   D3DRENDERSTATE_MONOENABLE         = 11,
    835   D3DRENDERSTATE_ROP2               = 12,
    836   D3DRENDERSTATE_PLANEMASK          = 13,
    837   D3DRENDERSTATE_ZWRITEENABLE       = 14,
    838   D3DRENDERSTATE_ALPHATESTENABLE    = 15,
    839   D3DRENDERSTATE_LASTPIXEL          = 16,
    840   D3DRENDERSTATE_TEXTUREMAG         = 17,
    841   D3DRENDERSTATE_TEXTUREMIN         = 18,
    842   D3DRENDERSTATE_SRCBLEND           = 19,
    843   D3DRENDERSTATE_DESTBLEND          = 20,
    844   D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,
    845   D3DRENDERSTATE_CULLMODE           = 22,
    846   D3DRENDERSTATE_ZFUNC              = 23,
    847   D3DRENDERSTATE_ALPHAREF           = 24,
    848   D3DRENDERSTATE_ALPHAFUNC          = 25,
    849   D3DRENDERSTATE_DITHERENABLE       = 26,
    850   D3DRENDERSTATE_ALPHABLENDENABLE   = 27,
    851   D3DRENDERSTATE_FOGENABLE          = 28,
    852   D3DRENDERSTATE_SPECULARENABLE     = 29,
    853   D3DRENDERSTATE_ZVISIBLE           = 30,
    854   D3DRENDERSTATE_SUBPIXEL           = 31,
    855   D3DRENDERSTATE_SUBPIXELX          = 32,
    856   D3DRENDERSTATE_STIPPLEDALPHA      = 33,
    857   D3DRENDERSTATE_FOGCOLOR           = 34,
    858   D3DRENDERSTATE_FOGTABLEMODE       = 35,
    859   D3DRENDERSTATE_FOGTABLESTART      = 36,
    860   D3DRENDERSTATE_FOGTABLEEND        = 37,
    861   D3DRENDERSTATE_FOGTABLEDENSITY    = 38,
    862   D3DRENDERSTATE_FOGSTART           = 36,
    863   D3DRENDERSTATE_FOGEND             = 37,
    864   D3DRENDERSTATE_FOGDENSITY         = 38,
    865   D3DRENDERSTATE_STIPPLEENABLE      = 39,
    866   D3DRENDERSTATE_EDGEANTIALIAS      = 40,
    867   D3DRENDERSTATE_COLORKEYENABLE     = 41,
    868   D3DRENDERSTATE_BORDERCOLOR        = 43,
    869   D3DRENDERSTATE_TEXTUREADDRESSU    = 44,
    870   D3DRENDERSTATE_TEXTUREADDRESSV    = 45,
    871   D3DRENDERSTATE_MIPMAPLODBIAS      = 46,
    872   D3DRENDERSTATE_ZBIAS              = 47,
    873   D3DRENDERSTATE_RANGEFOGENABLE     = 48,
    874   D3DRENDERSTATE_ANISOTROPY         = 49,
    875   D3DRENDERSTATE_FLUSHBATCH         = 50,
    876   D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT = 51,
    877 
    878   D3DRENDERSTATE_STENCILENABLE      = 52,
    879   D3DRENDERSTATE_STENCILFAIL        = 53,
    880   D3DRENDERSTATE_STENCILZFAIL       = 54,
    881   D3DRENDERSTATE_STENCILPASS        = 55,
    882   D3DRENDERSTATE_STENCILFUNC        = 56,
    883   D3DRENDERSTATE_STENCILREF         = 57,
    884   D3DRENDERSTATE_STENCILMASK        = 58,
    885   D3DRENDERSTATE_STENCILWRITEMASK   = 59,
    886   D3DRENDERSTATE_TEXTUREFACTOR      = 60,
    887 
    888   D3DRENDERSTATE_STIPPLEPATTERN00   = 64,
    889   D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
    890   D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
    891   D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
    892   D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
    893   D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
    894   D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
    895   D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
    896   D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
    897   D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
    898   D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
    899   D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
    900   D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
    901   D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
    902   D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
    903   D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
    904   D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
    905   D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
    906   D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
    907   D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
    908   D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
    909   D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
    910   D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
    911   D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
    912   D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
    913   D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
    914   D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
    915   D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
    916   D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
    917   D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
    918   D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
    919   D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
    920 
    921   D3DRENDERSTATE_WRAP0              = 128,
    922   D3DRENDERSTATE_WRAP1              = 129,
    923   D3DRENDERSTATE_WRAP2              = 130,
    924   D3DRENDERSTATE_WRAP3              = 131,
    925   D3DRENDERSTATE_WRAP4              = 132,
    926   D3DRENDERSTATE_WRAP5              = 133,
    927   D3DRENDERSTATE_WRAP6              = 134,
    928   D3DRENDERSTATE_WRAP7              = 135,
    929   D3DRENDERSTATE_CLIPPING            = 136,
    930   D3DRENDERSTATE_LIGHTING            = 137,
    931   D3DRENDERSTATE_EXTENTS             = 138,
    932   D3DRENDERSTATE_AMBIENT             = 139,
    933   D3DRENDERSTATE_FOGVERTEXMODE       = 140,
    934   D3DRENDERSTATE_COLORVERTEX         = 141,
    935   D3DRENDERSTATE_LOCALVIEWER         = 142,
    936   D3DRENDERSTATE_NORMALIZENORMALS    = 143,
    937   D3DRENDERSTATE_COLORKEYBLENDENABLE = 144,
    938   D3DRENDERSTATE_DIFFUSEMATERIALSOURCE    = 145,
    939   D3DRENDERSTATE_SPECULARMATERIALSOURCE   = 146,
    940   D3DRENDERSTATE_AMBIENTMATERIALSOURCE    = 147,
    941   D3DRENDERSTATE_EMISSIVEMATERIALSOURCE   = 148,
    942   D3DRENDERSTATE_VERTEXBLEND              = 151,
    943   D3DRENDERSTATE_CLIPPLANEENABLE          = 152,
    944 
    945   D3DRENDERSTATE_FORCE_DWORD        = 0x7fffffff
    946 
    947   /* FIXME: We have some retired values that are being reused for DirectX 7 */
    948 } D3DRENDERSTATETYPE;
    949 
    950 typedef enum _D3DMATERIALCOLORSOURCE
    951 {
    952     D3DMCS_MATERIAL = 0,
    953     D3DMCS_COLOR1   = 1,
    954     D3DMCS_COLOR2   = 2,
    955     D3DMCS_FORCE_DWORD = 0x7fffffff
    956 } D3DMATERIALCOLORSOURCE;
    957 
    958 #define D3DRENDERSTATE_BLENDENABLE      D3DRENDERSTATE_ALPHABLENDENABLE
    959 #define D3DRENDERSTATE_WRAPBIAS         __MSABI_LONG(128U)
    960 #define D3DWRAP_U   __MSABI_LONG(0x00000001)
    961 #define D3DWRAP_V   __MSABI_LONG(0x00000002)
    962 
    963 #define D3DWRAPCOORD_0   __MSABI_LONG(0x00000001)
    964 #define D3DWRAPCOORD_1   __MSABI_LONG(0x00000002)
    965 #define D3DWRAPCOORD_2   __MSABI_LONG(0x00000004)
    966 #define D3DWRAPCOORD_3   __MSABI_LONG(0x00000008)
    967 
    968 #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
    969 
    970 typedef struct _D3DSTATE {
    971   union {
    972     D3DTRANSFORMSTATETYPE dtstTransformStateType;
    973     D3DLIGHTSTATETYPE     dlstLightStateType;
    974     D3DRENDERSTATETYPE    drstRenderStateType;
    975   } DUMMYUNIONNAME1;
    976   union {
    977     DWORD                 dwArg[1];
    978     D3DVALUE              dvArg[1];
    979   } DUMMYUNIONNAME2;
    980 } D3DSTATE, *LPD3DSTATE;
    981 
    982 typedef struct _D3DMATRIXLOAD {
    983   D3DMATRIXHANDLE hDestMatrix;
    984   D3DMATRIXHANDLE hSrcMatrix;
    985 } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
    986 
    987 typedef struct _D3DMATRIXMULTIPLY {
    988   D3DMATRIXHANDLE hDestMatrix;
    989   D3DMATRIXHANDLE hSrcMatrix1;
    990   D3DMATRIXHANDLE hSrcMatrix2;
    991 } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
    992 
    993 typedef struct _D3DPROCESSVERTICES {
    994   DWORD dwFlags;
    995   WORD  wStart;
    996   WORD  wDest;
    997   DWORD dwCount;
    998   DWORD dwReserved;
    999 } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
   1000 
   1001 #define D3DPROCESSVERTICES_TRANSFORMLIGHT       __MSABI_LONG(0x00000000)
   1002 #define D3DPROCESSVERTICES_TRANSFORM            __MSABI_LONG(0x00000001)
   1003 #define D3DPROCESSVERTICES_COPY                 __MSABI_LONG(0x00000002)
   1004 #define D3DPROCESSVERTICES_OPMASK               __MSABI_LONG(0x00000007)
   1005 
   1006 #define D3DPROCESSVERTICES_UPDATEEXTENTS        __MSABI_LONG(0x00000008)
   1007 #define D3DPROCESSVERTICES_NOCOLOR              __MSABI_LONG(0x00000010)
   1008 
   1009 typedef enum _D3DTEXTURESTAGESTATETYPE
   1010 {
   1011     D3DTSS_COLOROP        =  1,
   1012     D3DTSS_COLORARG1      =  2,
   1013     D3DTSS_COLORARG2      =  3,
   1014     D3DTSS_ALPHAOP        =  4,
   1015     D3DTSS_ALPHAARG1      =  5,
   1016     D3DTSS_ALPHAARG2      =  6,
   1017     D3DTSS_BUMPENVMAT00   =  7,
   1018     D3DTSS_BUMPENVMAT01   =  8,
   1019     D3DTSS_BUMPENVMAT10   =  9,
   1020     D3DTSS_BUMPENVMAT11   = 10,
   1021     D3DTSS_TEXCOORDINDEX  = 11,
   1022     D3DTSS_ADDRESS        = 12,
   1023     D3DTSS_ADDRESSU       = 13,
   1024     D3DTSS_ADDRESSV       = 14,
   1025     D3DTSS_BORDERCOLOR    = 15,
   1026     D3DTSS_MAGFILTER      = 16,
   1027     D3DTSS_MINFILTER      = 17,
   1028     D3DTSS_MIPFILTER      = 18,
   1029     D3DTSS_MIPMAPLODBIAS  = 19,
   1030     D3DTSS_MAXMIPLEVEL    = 20,
   1031     D3DTSS_MAXANISOTROPY  = 21,
   1032     D3DTSS_BUMPENVLSCALE  = 22,
   1033     D3DTSS_BUMPENVLOFFSET = 23,
   1034     D3DTSS_TEXTURETRANSFORMFLAGS = 24,
   1035     D3DTSS_FORCE_DWORD   = 0x7fffffff
   1036 } D3DTEXTURESTAGESTATETYPE;
   1037 
   1038 #define D3DTSS_TCI_PASSTHRU                             0x00000000
   1039 #define D3DTSS_TCI_CAMERASPACENORMAL                    0x00010000
   1040 #define D3DTSS_TCI_CAMERASPACEPOSITION                  0x00020000
   1041 #define D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR          0x00030000
   1042 
   1043 typedef enum _D3DTEXTUREOP
   1044 {
   1045     D3DTOP_DISABLE    = 1,
   1046     D3DTOP_SELECTARG1 = 2,
   1047     D3DTOP_SELECTARG2 = 3,
   1048 
   1049     D3DTOP_MODULATE   = 4,
   1050     D3DTOP_MODULATE2X = 5,
   1051     D3DTOP_MODULATE4X = 6,
   1052 
   1053     D3DTOP_ADD          =  7,
   1054     D3DTOP_ADDSIGNED    =  8,
   1055     D3DTOP_ADDSIGNED2X  =  9,
   1056     D3DTOP_SUBTRACT     = 10,
   1057     D3DTOP_ADDSMOOTH    = 11,
   1058 
   1059     D3DTOP_BLENDDIFFUSEALPHA    = 12,
   1060     D3DTOP_BLENDTEXTUREALPHA    = 13,
   1061     D3DTOP_BLENDFACTORALPHA     = 14,
   1062     D3DTOP_BLENDTEXTUREALPHAPM  = 15,
   1063     D3DTOP_BLENDCURRENTALPHA    = 16,
   1064 
   1065     D3DTOP_PREMODULATE            = 17,
   1066     D3DTOP_MODULATEALPHA_ADDCOLOR = 18,
   1067     D3DTOP_MODULATECOLOR_ADDALPHA = 19,
   1068     D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20,
   1069     D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21,
   1070 
   1071     D3DTOP_BUMPENVMAP           = 22,
   1072     D3DTOP_BUMPENVMAPLUMINANCE  = 23,
   1073     D3DTOP_DOTPRODUCT3          = 24,
   1074 
   1075     D3DTOP_FORCE_DWORD = 0x7fffffff
   1076 } D3DTEXTUREOP;
   1077 
   1078 #define D3DTA_SELECTMASK        0x0000000f
   1079 #define D3DTA_DIFFUSE           0x00000000
   1080 #define D3DTA_CURRENT           0x00000001
   1081 #define D3DTA_TEXTURE           0x00000002
   1082 #define D3DTA_TFACTOR           0x00000003
   1083 #define D3DTA_SPECULAR          0x00000004
   1084 #define D3DTA_COMPLEMENT        0x00000010
   1085 #define D3DTA_ALPHAREPLICATE    0x00000020
   1086 
   1087 typedef enum _D3DTEXTUREMAGFILTER
   1088 {
   1089     D3DTFG_POINT        = 1,
   1090     D3DTFG_LINEAR       = 2,
   1091     D3DTFG_FLATCUBIC    = 3,
   1092     D3DTFG_GAUSSIANCUBIC = 4,
   1093     D3DTFG_ANISOTROPIC  = 5,
   1094     D3DTFG_FORCE_DWORD  = 0x7fffffff
   1095 } D3DTEXTUREMAGFILTER;
   1096 
   1097 typedef enum _D3DTEXTUREMINFILTER
   1098 {
   1099     D3DTFN_POINT        = 1,
   1100     D3DTFN_LINEAR       = 2,
   1101     D3DTFN_ANISOTROPIC  = 3,
   1102     D3DTFN_FORCE_DWORD  = 0x7fffffff
   1103 } D3DTEXTUREMINFILTER;
   1104 
   1105 typedef enum _D3DTEXTUREMIPFILTER
   1106 {
   1107     D3DTFP_NONE         = 1,
   1108     D3DTFP_POINT        = 2,
   1109     D3DTFP_LINEAR       = 3,
   1110     D3DTFP_FORCE_DWORD  = 0x7fffffff
   1111 } D3DTEXTUREMIPFILTER;
   1112 
   1113 #define D3DTRIFLAG_START                        __MSABI_LONG(0x00000000)
   1114 #define D3DTRIFLAG_STARTFLAT(len) (len)
   1115 #define D3DTRIFLAG_ODD                          __MSABI_LONG(0x0000001e)
   1116 #define D3DTRIFLAG_EVEN                         __MSABI_LONG(0x0000001f)
   1117 
   1118 #define D3DTRIFLAG_EDGEENABLE1                  __MSABI_LONG(0x00000100)
   1119 #define D3DTRIFLAG_EDGEENABLE2                  __MSABI_LONG(0x00000200)
   1120 #define D3DTRIFLAG_EDGEENABLE3                  __MSABI_LONG(0x00000400)
   1121 #define D3DTRIFLAG_EDGEENABLETRIANGLE \
   1122         (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
   1123 
   1124 typedef struct _D3DTRIANGLE {
   1125   union {
   1126     WORD v1;
   1127     WORD wV1;
   1128   } DUMMYUNIONNAME1;
   1129   union {
   1130     WORD v2;
   1131     WORD wV2;
   1132   } DUMMYUNIONNAME2;
   1133   union {
   1134     WORD v3;
   1135     WORD wV3;
   1136   } DUMMYUNIONNAME3;
   1137   WORD     wFlags;
   1138 } D3DTRIANGLE, *LPD3DTRIANGLE;
   1139 
   1140 typedef struct _D3DLINE {
   1141   union {
   1142     WORD v1;
   1143     WORD wV1;
   1144   } DUMMYUNIONNAME1;
   1145   union {
   1146     WORD v2;
   1147     WORD wV2;
   1148   } DUMMYUNIONNAME2;
   1149 } D3DLINE, *LPD3DLINE;
   1150 
   1151 typedef struct _D3DSPAN {
   1152   WORD wCount;
   1153   WORD wFirst;
   1154 } D3DSPAN, *LPD3DSPAN;
   1155 
   1156 typedef struct _D3DPOINT {
   1157   WORD wCount;
   1158   WORD wFirst;
   1159 } D3DPOINT, *LPD3DPOINT;
   1160 
   1161 typedef struct _D3DBRANCH {
   1162   DWORD dwMask;
   1163   DWORD dwValue;
   1164   WINBOOL  bNegate;
   1165   DWORD dwOffset;
   1166 } D3DBRANCH, *LPD3DBRANCH;
   1167 
   1168 typedef struct _D3DSTATUS {
   1169   DWORD   dwFlags;
   1170   DWORD   dwStatus;
   1171   D3DRECT drExtent;
   1172 } D3DSTATUS, *LPD3DSTATUS;
   1173 
   1174 #define D3DSETSTATUS_STATUS   __MSABI_LONG(0x00000001)
   1175 #define D3DSETSTATUS_EXTENTS  __MSABI_LONG(0x00000002)
   1176 #define D3DSETSTATUS_ALL      (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
   1177 
   1178 typedef struct _D3DCLIPSTATUS {
   1179   DWORD dwFlags;
   1180   DWORD dwStatus;
   1181   float minx, maxx;
   1182   float miny, maxy;
   1183   float minz, maxz;
   1184 } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
   1185 
   1186 #define D3DCLIPSTATUS_STATUS        __MSABI_LONG(0x00000001)
   1187 #define D3DCLIPSTATUS_EXTENTS2      __MSABI_LONG(0x00000002)
   1188 #define D3DCLIPSTATUS_EXTENTS3      __MSABI_LONG(0x00000004)
   1189 
   1190 typedef struct {
   1191   DWORD        dwSize;
   1192   DWORD        dwTrianglesDrawn;
   1193   DWORD        dwLinesDrawn;
   1194   DWORD        dwPointsDrawn;
   1195   DWORD        dwSpansDrawn;
   1196   DWORD        dwVerticesProcessed;
   1197 } D3DSTATS, *LPD3DSTATS;
   1198 
   1199 #define D3DEXECUTE_CLIPPED       __MSABI_LONG(0x00000001)
   1200 #define D3DEXECUTE_UNCLIPPED     __MSABI_LONG(0x00000002)
   1201 
   1202 typedef struct _D3DEXECUTEDATA {
   1203   DWORD     dwSize;
   1204   DWORD     dwVertexOffset;
   1205   DWORD     dwVertexCount;
   1206   DWORD     dwInstructionOffset;
   1207   DWORD     dwInstructionLength;
   1208   DWORD     dwHVertexOffset;
   1209   D3DSTATUS dsStatus;
   1210 } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
   1211 
   1212 #define D3DPAL_FREE 0x00
   1213 #define D3DPAL_READONLY 0x40
   1214 #define D3DPAL_RESERVED 0x80
   1215 
   1216 typedef struct _D3DVERTEXBUFFERDESC {
   1217   DWORD dwSize;
   1218   DWORD dwCaps;
   1219   DWORD dwFVF;
   1220   DWORD dwNumVertices;
   1221 } D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC;
   1222 
   1223 #define D3DVBCAPS_SYSTEMMEMORY      __MSABI_LONG(0x00000800)
   1224 #define D3DVBCAPS_WRITEONLY         __MSABI_LONG(0x00010000)
   1225 #define D3DVBCAPS_OPTIMIZED         __MSABI_LONG(0x80000000)
   1226 #define D3DVBCAPS_DONOTCLIP         __MSABI_LONG(0x00000001)
   1227 
   1228 #define D3DVOP_LIGHT       (1 << 10)
   1229 #define D3DVOP_TRANSFORM   (1 << 0)
   1230 #define D3DVOP_CLIP        (1 << 2)
   1231 #define D3DVOP_EXTENTS     (1 << 3)
   1232 
   1233 #define D3DMAXNUMVERTICES    ((1<<16) - 1)
   1234 
   1235 #define D3DMAXNUMPRIMITIVES  ((1<<16) - 1)
   1236 
   1237 #define D3DPV_DONOTCOPYDATA (1 << 0)
   1238 
   1239 #define D3DFVF_RESERVED0        0x001
   1240 #define D3DFVF_POSITION_MASK    0x00E
   1241 #define D3DFVF_XYZ              0x002
   1242 #define D3DFVF_XYZRHW           0x004
   1243 #define D3DFVF_XYZB1            0x006
   1244 #define D3DFVF_XYZB2            0x008
   1245 #define D3DFVF_XYZB3            0x00a
   1246 #define D3DFVF_XYZB4            0x00c
   1247 #define D3DFVF_XYZB5            0x00e
   1248 
   1249 #define D3DFVF_NORMAL           0x010
   1250 #define D3DFVF_RESERVED1        0x020
   1251 #define D3DFVF_DIFFUSE          0x040
   1252 #define D3DFVF_SPECULAR         0x080
   1253 #define D3DFVF_TEXCOUNT_MASK    0xf00
   1254 #define D3DFVF_TEXCOUNT_SHIFT   8
   1255 #define D3DFVF_TEX0             0x000
   1256 #define D3DFVF_TEX1             0x100
   1257 #define D3DFVF_TEX2             0x200
   1258 #define D3DFVF_TEX3             0x300
   1259 #define D3DFVF_TEX4             0x400
   1260 #define D3DFVF_TEX5             0x500
   1261 #define D3DFVF_TEX6             0x600
   1262 #define D3DFVF_TEX7             0x700
   1263 #define D3DFVF_TEX8             0x800
   1264 
   1265 #define D3DFVF_RESERVED2        0xf000
   1266 
   1267 #define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
   1268 #define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \
   1269                          D3DFVF_SPECULAR | D3DFVF_TEX1 )
   1270 #define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \
   1271                           D3DFVF_TEX1 )
   1272 
   1273 typedef struct _D3DDP_PTRSTRIDE {
   1274   LPVOID lpvData;
   1275   DWORD  dwStride;
   1276 } D3DDP_PTRSTRIDE;
   1277 
   1278 #define D3DDP_MAXTEXCOORD 8
   1279 
   1280 typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA  {
   1281   D3DDP_PTRSTRIDE position;
   1282   D3DDP_PTRSTRIDE normal;
   1283   D3DDP_PTRSTRIDE diffuse;
   1284   D3DDP_PTRSTRIDE specular;
   1285   D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD];
   1286 } D3DDRAWPRIMITIVESTRIDEDDATA ,*LPD3DDRAWPRIMITIVESTRIDEDDATA;
   1287 
   1288 #define D3DVIS_INSIDE_FRUSTUM       0
   1289 #define D3DVIS_INTERSECT_FRUSTUM    1
   1290 #define D3DVIS_OUTSIDE_FRUSTUM      2
   1291 #define D3DVIS_INSIDE_LEFT          0
   1292 #define D3DVIS_INTERSECT_LEFT       (1 << 2)
   1293 #define D3DVIS_OUTSIDE_LEFT         (2 << 2)
   1294 #define D3DVIS_INSIDE_RIGHT         0
   1295 #define D3DVIS_INTERSECT_RIGHT      (1 << 4)
   1296 #define D3DVIS_OUTSIDE_RIGHT        (2 << 4)
   1297 #define D3DVIS_INSIDE_TOP           0
   1298 #define D3DVIS_INTERSECT_TOP        (1 << 6)
   1299 #define D3DVIS_OUTSIDE_TOP          (2 << 6)
   1300 #define D3DVIS_INSIDE_BOTTOM        0
   1301 #define D3DVIS_INTERSECT_BOTTOM     (1 << 8)
   1302 #define D3DVIS_OUTSIDE_BOTTOM       (2 << 8)
   1303 #define D3DVIS_INSIDE_NEAR          0
   1304 #define D3DVIS_INTERSECT_NEAR       (1 << 10)
   1305 #define D3DVIS_OUTSIDE_NEAR         (2 << 10)
   1306 #define D3DVIS_INSIDE_FAR           0
   1307 #define D3DVIS_INTERSECT_FAR        (1 << 12)
   1308 #define D3DVIS_OUTSIDE_FAR          (2 << 12)
   1309 
   1310 #define D3DVIS_MASK_FRUSTUM         (3 << 0)
   1311 #define D3DVIS_MASK_LEFT            (3 << 2)
   1312 #define D3DVIS_MASK_RIGHT           (3 << 4)
   1313 #define D3DVIS_MASK_TOP             (3 << 6)
   1314 #define D3DVIS_MASK_BOTTOM          (3 << 8)
   1315 #define D3DVIS_MASK_NEAR            (3 << 10)
   1316 #define D3DVIS_MASK_FAR             (3 << 12)
   1317 
   1318 #define D3DDEVINFOID_TEXTUREMANAGER    1
   1319 #define D3DDEVINFOID_D3DTEXTUREMANAGER 2
   1320 #define D3DDEVINFOID_TEXTURING         3
   1321 
   1322 typedef enum _D3DSTATEBLOCKTYPE
   1323 {
   1324     D3DSBT_ALL           = 1,
   1325     D3DSBT_PIXELSTATE    = 2,
   1326     D3DSBT_VERTEXSTATE   = 3,
   1327     D3DSBT_FORCE_DWORD   = 0xffffffff
   1328 } D3DSTATEBLOCKTYPE;
   1329 
   1330 typedef enum _D3DVERTEXBLENDFLAGS
   1331 {
   1332     D3DVBLEND_DISABLE  = 0,
   1333     D3DVBLEND_1WEIGHT  = 1,
   1334     D3DVBLEND_2WEIGHTS = 2,
   1335     D3DVBLEND_3WEIGHTS = 3,
   1336 } D3DVERTEXBLENDFLAGS;
   1337 
   1338 typedef enum _D3DTEXTURETRANSFORMFLAGS {
   1339     D3DTTFF_DISABLE         = 0,
   1340     D3DTTFF_COUNT1          = 1,
   1341     D3DTTFF_COUNT2          = 2,
   1342     D3DTTFF_COUNT3          = 3,
   1343     D3DTTFF_COUNT4          = 4,
   1344     D3DTTFF_PROJECTED       = 256,
   1345     D3DTTFF_FORCE_DWORD     = 0x7fffffff
   1346 } D3DTEXTURETRANSFORMFLAGS;
   1347 
   1348 #define D3DFVF_TEXTUREFORMAT2 0
   1349 #define D3DFVF_TEXTUREFORMAT1 3
   1350 #define D3DFVF_TEXTUREFORMAT3 1
   1351 #define D3DFVF_TEXTUREFORMAT4 2
   1352 
   1353 #define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
   1354 #define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
   1355 #define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
   1356 #define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
   1357 
   1358 #endif
   1359