1 /*==========================================================================;
3 * Copyright (C) 1995-1998 Microsoft Corporation. All Rights Reserved.
6 * Content: Direct3D types include file
8 ***************************************************************************/
18 #ifndef DIRECT3D_VERSION
19 #define DIRECT3D_VERSION 0x0600
25 /* D3DVALUE is the fundamental Direct3D fractional data type */
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))
33 typedef LONG D3DFIXED;
37 * Format of CI colors is
38 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * | alpha | color index | fraction |
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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))
50 * Format of RGBA colors is
51 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * | alpha | red | green | blue |
53 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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)))
61 /* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
62 * The float values must be in the range 0..1
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) \
72 * Format of RGB colors is
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 * | ignored | red | green | blue |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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))
88 * Flags for Enumerate functions
92 * Stop the enumeration
94 #define D3DENUMRET_CANCEL DDENUMRET_CANCEL
97 * Continue the enumeration
99 #define D3DENUMRET_OK DDENUMRET_OK
101 typedef HRESULT (CALLBACK* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
102 typedef HRESULT (CALLBACK* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
103 typedef HRESULT (CALLBACK* LPD3DENUMPIXELFORMATSCALLBACK)(LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext);
105 typedef DWORD D3DCOLOR, *LPD3DCOLOR;
107 typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
108 typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
109 typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
111 typedef struct _D3DCOLORVALUE {
115 #if defined(NONAMELESSUNION)
123 #if defined(NONAMELESSUNION)
131 #if defined(NONAMELESSUNION)
139 #if defined(NONAMELESSUNION)
144 } D3DCOLORVALUE, *LPD3DCOLORVALUE;
146 typedef struct _D3DRECT {
150 #if defined(NONAMELESSUNION)
158 #if defined(NONAMELESSUNION)
166 #if defined(NONAMELESSUNION)
174 #if defined(NONAMELESSUNION)
179 } D3DRECT, *LPD3DRECT;
181 typedef struct _D3DVECTOR {
185 #if defined(NONAMELESSUNION)
193 #if defined(NONAMELESSUNION)
201 #if defined(NONAMELESSUNION)
206 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
210 // =====================================
212 // =====================================
215 _D3DVECTOR(D3DVALUE f);
216 _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
217 _D3DVECTOR(const D3DVALUE f[3]);
219 // =====================================
221 // =====================================
223 const D3DVALUE&operator[](int i) const;
224 D3DVALUE&operator[](int i);
226 // =====================================
227 // Assignment operators
228 // =====================================
230 _D3DVECTOR& operator += (const _D3DVECTOR& v);
231 _D3DVECTOR& operator -= (const _D3DVECTOR& v);
232 _D3DVECTOR& operator *= (const _D3DVECTOR& v);
233 _D3DVECTOR& operator /= (const _D3DVECTOR& v);
234 _D3DVECTOR& operator *= (D3DVALUE s);
235 _D3DVECTOR& operator /= (D3DVALUE s);
237 // =====================================
239 // =====================================
241 friend _D3DVECTOR operator + (const _D3DVECTOR& v);
242 friend _D3DVECTOR operator - (const _D3DVECTOR& v);
245 // =====================================
247 // =====================================
249 // Addition and subtraction
250 friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
251 friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
252 // Scalar multiplication and division
253 friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
254 friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
255 friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
256 // Memberwise multiplication and division
257 friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
258 friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
261 friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
262 friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
265 friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
267 // Length-related functions
268 friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
269 friend D3DVALUE Magnitude (const _D3DVECTOR& v);
271 // Returns vector with same direction and unit length
272 friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
274 // Return min/max component of the input vector
275 friend D3DVALUE Min (const _D3DVECTOR& v);
276 friend D3DVALUE Max (const _D3DVECTOR& v);
278 // Return memberwise min/max of input vectors
279 friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
280 friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
282 // Dot and cross product
283 friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
284 friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
287 } D3DVECTOR, *LPD3DVECTOR;
290 * Vertex data types supported in an ExecuteBuffer.
294 * Homogeneous vertices
297 typedef struct _D3DHVERTEX {
298 DWORD dwFlags; /* Homogeneous clipping flags */
302 #if defined(NONAMELESSUNION)
310 #if defined(NONAMELESSUNION)
318 #if defined(NONAMELESSUNION)
323 } D3DHVERTEX, *LPD3DHVERTEX;
326 * Transformed/lit vertices
328 typedef struct _D3DTLVERTEX {
330 D3DVALUE sx; /* Screen coordinates */
332 #if defined(NONAMELESSUNION)
340 #if defined(NONAMELESSUNION)
348 #if defined(NONAMELESSUNION)
354 D3DVALUE rhw; /* Reciprocal of homogeneous w */
356 #if defined(NONAMELESSUNION)
362 D3DCOLOR color; /* Vertex color */
364 #if defined(NONAMELESSUNION)
370 D3DCOLOR specular; /* Specular component of vertex */
372 #if defined(NONAMELESSUNION)
378 D3DVALUE tu; /* Texture coordinates */
380 #if defined(NONAMELESSUNION)
388 #if defined(NONAMELESSUNION)
393 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
395 _D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
396 D3DCOLOR _color, D3DCOLOR _specular,
397 float _tu, float _tv)
398 { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
399 color = _color; specular = _specular;
403 } D3DTLVERTEX, *LPD3DTLVERTEX;
406 * Untransformed/lit vertices
408 typedef struct _D3DLVERTEX {
410 D3DVALUE x; /* Homogeneous coordinates */
412 #if defined(NONAMELESSUNION)
420 #if defined(NONAMELESSUNION)
428 #if defined(NONAMELESSUNION)
435 D3DCOLOR color; /* Vertex color */
437 #if defined(NONAMELESSUNION)
443 D3DCOLOR specular; /* Specular component of vertex */
445 #if defined(NONAMELESSUNION)
451 D3DVALUE tu; /* Texture coordinates */
453 #if defined(NONAMELESSUNION)
461 #if defined(NONAMELESSUNION)
466 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
468 _D3DLVERTEX(const D3DVECTOR& v,
469 D3DCOLOR _color, D3DCOLOR _specular,
470 float _tu, float _tv)
471 { x = v.x; y = v.y; z = v.z; dwReserved = 0;
472 color = _color; specular = _specular;
476 } D3DLVERTEX, *LPD3DLVERTEX;
479 * Untransformed/unlit vertices
482 typedef struct _D3DVERTEX {
484 D3DVALUE x; /* Homogeneous coordinates */
486 #if defined(NONAMELESSUNION)
494 #if defined(NONAMELESSUNION)
502 #if defined(NONAMELESSUNION)
508 D3DVALUE nx; /* Normal */
510 #if defined(NONAMELESSUNION)
518 #if defined(NONAMELESSUNION)
526 #if defined(NONAMELESSUNION)
532 D3DVALUE tu; /* Texture coordinates */
534 #if defined(NONAMELESSUNION)
542 #if defined(NONAMELESSUNION)
547 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
549 _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv)
550 { x = v.x; y = v.y; z = v.z;
551 nx = n.x; ny = n.y; nz = n.z;
555 } D3DVERTEX, *LPD3DVERTEX;
559 * Matrix, viewport, and tranformation structures and definitions.
562 typedef struct _D3DMATRIX {
563 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
568 D3DVALUE _11, _12, _13, _14;
569 D3DVALUE _21, _22, _23, _24;
570 D3DVALUE _31, _32, _33, _34;
571 D3DVALUE _41, _42, _43, _44;
573 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
574 #if defined(NONAMELESSUNION)
582 _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03,
583 D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13,
584 D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23,
585 D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _m33
588 m[0][0] = _m00; m[0][1] = _m01; m[0][2] = _m02; m[0][3] = _m03;
589 m[1][0] = _m10; m[1][1] = _m11; m[1][2] = _m12; m[1][3] = _m13;
590 m[2][0] = _m20; m[2][1] = _m21; m[2][2] = _m22; m[2][3] = _m23;
591 m[3][0] = _m30; m[3][1] = _m31; m[3][2] = _m32; m[3][3] = _m33;
594 D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; }
595 const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; }
596 friend _D3DMATRIX operator* (const _D3DMATRIX&, const _D3DMATRIX&);
598 } D3DMATRIX, *LPD3DMATRIX;
600 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
601 #include "d3dvec.inl"
604 typedef struct _D3DVIEWPORT {
607 DWORD dwY; /* Top left */
609 DWORD dwHeight; /* Dimensions */
610 D3DVALUE dvScaleX; /* Scale homogeneous to screen */
611 D3DVALUE dvScaleY; /* Scale homogeneous to screen */
612 D3DVALUE dvMaxX; /* Min/max homogeneous x coord */
613 D3DVALUE dvMaxY; /* Min/max homogeneous y coord */
615 D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */
616 } D3DVIEWPORT, *LPD3DVIEWPORT;
618 typedef struct _D3DVIEWPORT2 {
621 DWORD dwY; /* Viewport Top left */
623 DWORD dwHeight; /* Viewport Dimensions */
624 D3DVALUE dvClipX; /* Top left of clip volume */
626 D3DVALUE dvClipWidth; /* Clip Volume Dimensions */
627 D3DVALUE dvClipHeight;
628 D3DVALUE dvMinZ; /* Min/max of clip Volume */
630 } D3DVIEWPORT2, *LPD3DVIEWPORT2;
633 * Values for clip fields.
635 #define D3DCLIP_LEFT 0x00000001L
636 #define D3DCLIP_RIGHT 0x00000002L
637 #define D3DCLIP_TOP 0x00000004L
638 #define D3DCLIP_BOTTOM 0x00000008L
639 #define D3DCLIP_FRONT 0x00000010L
640 #define D3DCLIP_BACK 0x00000020L
641 #define D3DCLIP_GEN0 0x00000040L
642 #define D3DCLIP_GEN1 0x00000080L
643 #define D3DCLIP_GEN2 0x00000100L
644 #define D3DCLIP_GEN3 0x00000200L
645 #define D3DCLIP_GEN4 0x00000400L
646 #define D3DCLIP_GEN5 0x00000800L
649 * Values for d3d status.
651 #define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT
652 #define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT
653 #define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP
654 #define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM
655 #define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT
656 #define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK
657 #define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0
658 #define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1
659 #define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2
660 #define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3
661 #define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4
662 #define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5
664 #define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000L
665 #define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000L
666 #define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000L
667 #define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000L
668 #define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000L
669 #define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000L
670 #define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000L
671 #define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000L
672 #define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000L
673 #define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000L
674 #define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000L
675 #define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000L
676 #define D3DSTATUS_ZNOTVISIBLE 0x01000000L
677 /* Do not use 0x80000000 for any status flags in future as it is reserved */
679 #define D3DSTATUS_CLIPUNIONALL ( \
680 D3DSTATUS_CLIPUNIONLEFT | \
681 D3DSTATUS_CLIPUNIONRIGHT | \
682 D3DSTATUS_CLIPUNIONTOP | \
683 D3DSTATUS_CLIPUNIONBOTTOM | \
684 D3DSTATUS_CLIPUNIONFRONT | \
685 D3DSTATUS_CLIPUNIONBACK | \
686 D3DSTATUS_CLIPUNIONGEN0 | \
687 D3DSTATUS_CLIPUNIONGEN1 | \
688 D3DSTATUS_CLIPUNIONGEN2 | \
689 D3DSTATUS_CLIPUNIONGEN3 | \
690 D3DSTATUS_CLIPUNIONGEN4 | \
691 D3DSTATUS_CLIPUNIONGEN5 \
694 #define D3DSTATUS_CLIPINTERSECTIONALL ( \
695 D3DSTATUS_CLIPINTERSECTIONLEFT | \
696 D3DSTATUS_CLIPINTERSECTIONRIGHT | \
697 D3DSTATUS_CLIPINTERSECTIONTOP | \
698 D3DSTATUS_CLIPINTERSECTIONBOTTOM | \
699 D3DSTATUS_CLIPINTERSECTIONFRONT | \
700 D3DSTATUS_CLIPINTERSECTIONBACK | \
701 D3DSTATUS_CLIPINTERSECTIONGEN0 | \
702 D3DSTATUS_CLIPINTERSECTIONGEN1 | \
703 D3DSTATUS_CLIPINTERSECTIONGEN2 | \
704 D3DSTATUS_CLIPINTERSECTIONGEN3 | \
705 D3DSTATUS_CLIPINTERSECTIONGEN4 | \
706 D3DSTATUS_CLIPINTERSECTIONGEN5 \
709 #define D3DSTATUS_DEFAULT ( \
710 D3DSTATUS_CLIPINTERSECTIONALL | \
711 D3DSTATUS_ZNOTVISIBLE)
715 * Options for direct transform calls
717 #define D3DTRANSFORM_CLIPPED 0x00000001l
718 #define D3DTRANSFORM_UNCLIPPED 0x00000002l
720 typedef struct _D3DTRANSFORMDATA {
722 LPVOID lpIn; /* Input vertices */
723 DWORD dwInSize; /* Stride of input vertices */
724 LPVOID lpOut; /* Output vertices */
725 DWORD dwOutSize; /* Stride of output vertices */
726 LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */
727 DWORD dwClip; /* Clipping hint */
728 DWORD dwClipIntersection;
729 DWORD dwClipUnion; /* Union of all clip flags */
730 D3DRECT drExtent; /* Extent of transformed vertices */
731 } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
734 * Structure defining position and direction properties for lighting.
736 typedef struct _D3DLIGHTINGELEMENT {
737 D3DVECTOR dvPosition; /* Lightable point in model space */
738 D3DVECTOR dvNormal; /* Normalised unit vector */
739 } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
742 * Structure defining material properties for lighting.
744 typedef struct _D3DMATERIAL {
747 D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
748 D3DCOLORVALUE dcvDiffuse;
749 #if defined(NONAMELESSUNION)
755 D3DCOLORVALUE ambient; /* Ambient color RGB */
756 D3DCOLORVALUE dcvAmbient;
757 #if defined(NONAMELESSUNION)
763 D3DCOLORVALUE specular; /* Specular 'shininess' */
764 D3DCOLORVALUE dcvSpecular;
765 #if defined(NONAMELESSUNION)
771 D3DCOLORVALUE emissive; /* Emissive color RGB */
772 D3DCOLORVALUE dcvEmissive;
773 #if defined(NONAMELESSUNION)
779 D3DVALUE power; /* Sharpness if specular highlight */
781 #if defined(NONAMELESSUNION)
786 D3DTEXTUREHANDLE hTexture; /* Handle to texture map */
788 } D3DMATERIAL, *LPD3DMATERIAL;
790 typedef enum _D3DLIGHTTYPE {
793 D3DLIGHT_DIRECTIONAL = 3,
794 D3DLIGHT_PARALLELPOINT = 4,
795 #if(DIRECT3D_VERSION < 0x0500) // For backward compatible headers
798 D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
802 * Structure defining a light source and its properties.
804 typedef struct _D3DLIGHT {
806 D3DLIGHTTYPE dltType; /* Type of light source */
807 D3DCOLORVALUE dcvColor; /* Color of light */
808 D3DVECTOR dvPosition; /* Position in world space */
809 D3DVECTOR dvDirection; /* Direction in world space */
810 D3DVALUE dvRange; /* Cutoff range */
811 D3DVALUE dvFalloff; /* Falloff */
812 D3DVALUE dvAttenuation0; /* Constant attenuation */
813 D3DVALUE dvAttenuation1; /* Linear attenuation */
814 D3DVALUE dvAttenuation2; /* Quadratic attenuation */
815 D3DVALUE dvTheta; /* Inner angle of spotlight cone */
816 D3DVALUE dvPhi; /* Outer angle of spotlight cone */
817 } D3DLIGHT, *LPD3DLIGHT;
820 * Structure defining a light source and its properties.
824 #define D3DLIGHT_ACTIVE 0x00000001
825 #define D3DLIGHT_NO_SPECULAR 0x00000002
827 /* maximum valid light range */
828 #define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX))
830 typedef struct _D3DLIGHT2 {
832 D3DLIGHTTYPE dltType; /* Type of light source */
833 D3DCOLORVALUE dcvColor; /* Color of light */
834 D3DVECTOR dvPosition; /* Position in world space */
835 D3DVECTOR dvDirection; /* Direction in world space */
836 D3DVALUE dvRange; /* Cutoff range */
837 D3DVALUE dvFalloff; /* Falloff */
838 D3DVALUE dvAttenuation0; /* Constant attenuation */
839 D3DVALUE dvAttenuation1; /* Linear attenuation */
840 D3DVALUE dvAttenuation2; /* Quadratic attenuation */
841 D3DVALUE dvTheta; /* Inner angle of spotlight cone */
842 D3DVALUE dvPhi; /* Outer angle of spotlight cone */
844 } D3DLIGHT2, *LPD3DLIGHT2;
846 typedef struct _D3DLIGHTDATA {
848 LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */
849 DWORD dwInSize; /* Stride of input elements */
850 LPD3DTLVERTEX lpOut; /* Output colors */
851 DWORD dwOutSize; /* Stride of output colors */
852 } D3DLIGHTDATA, *LPD3DLIGHTDATA;
855 * Before DX5, these values were in an enum called
856 * D3DCOLORMODEL. This was not correct, since they are
857 * bit flags. A driver can surface either or both flags
858 * in the dcmColorModel member of D3DDEVICEDESC.
860 #define D3DCOLOR_MONO 1
861 #define D3DCOLOR_RGB 2
863 typedef DWORD D3DCOLORMODEL;
866 * Options for clearing
868 #define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */
869 #define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */
870 #define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */
873 * Execute buffers are allocated via Direct3D. These buffers may then
874 * be filled by the application with instructions to execute along with
879 * Supported op codes for execute instructions.
881 typedef enum _D3DOPCODE {
885 D3DOP_MATRIXLOAD = 4,
886 D3DOP_MATRIXMULTIPLY = 5,
887 D3DOP_STATETRANSFORM = 6,
888 D3DOP_STATELIGHT = 7,
889 D3DOP_STATERENDER = 8,
890 D3DOP_PROCESSVERTICES = 9,
891 D3DOP_TEXTURELOAD = 10,
893 D3DOP_BRANCHFORWARD = 12,
895 D3DOP_SETSTATUS = 14,
896 D3DOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
899 typedef struct _D3DINSTRUCTION {
900 BYTE bOpcode; /* Instruction opcode */
901 BYTE bSize; /* Size of each instruction data unit */
902 WORD wCount; /* Count of instruction data units to follow */
903 } D3DINSTRUCTION, *LPD3DINSTRUCTION;
906 * Structure for texture loads
908 typedef struct _D3DTEXTURELOAD {
909 D3DTEXTUREHANDLE hDestTexture;
910 D3DTEXTUREHANDLE hSrcTexture;
911 } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
914 * Structure for picking
916 typedef struct _D3DPICKRECORD {
921 } D3DPICKRECORD, *LPD3DPICKRECORD;
924 * The following defines the rendering states which can be set in the
928 typedef enum _D3DSHADEMODE {
930 D3DSHADE_GOURAUD = 2,
932 D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
935 typedef enum _D3DFILLMODE {
937 D3DFILL_WIREFRAME = 2,
939 D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
942 typedef struct _D3DLINEPATTERN {
947 typedef enum _D3DTEXTUREFILTER {
948 D3DFILTER_NEAREST = 1,
949 D3DFILTER_LINEAR = 2,
950 D3DFILTER_MIPNEAREST = 3,
951 D3DFILTER_MIPLINEAR = 4,
952 D3DFILTER_LINEARMIPNEAREST = 5,
953 D3DFILTER_LINEARMIPLINEAR = 6,
954 D3DFILTER_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
957 typedef enum _D3DBLEND {
960 D3DBLEND_SRCCOLOR = 3,
961 D3DBLEND_INVSRCCOLOR = 4,
962 D3DBLEND_SRCALPHA = 5,
963 D3DBLEND_INVSRCALPHA = 6,
964 D3DBLEND_DESTALPHA = 7,
965 D3DBLEND_INVDESTALPHA = 8,
966 D3DBLEND_DESTCOLOR = 9,
967 D3DBLEND_INVDESTCOLOR = 10,
968 D3DBLEND_SRCALPHASAT = 11,
969 D3DBLEND_BOTHSRCALPHA = 12,
970 D3DBLEND_BOTHINVSRCALPHA = 13,
971 D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
974 typedef enum _D3DTEXTUREBLEND {
976 D3DTBLEND_MODULATE = 2,
977 D3DTBLEND_DECALALPHA = 3,
978 D3DTBLEND_MODULATEALPHA = 4,
979 D3DTBLEND_DECALMASK = 5,
980 D3DTBLEND_MODULATEMASK = 6,
983 D3DTBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
986 typedef enum _D3DTEXTUREADDRESS {
987 D3DTADDRESS_WRAP = 1,
988 D3DTADDRESS_MIRROR = 2,
989 D3DTADDRESS_CLAMP = 3,
990 D3DTADDRESS_BORDER = 4,
991 D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
994 typedef enum _D3DCULL {
998 D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1001 typedef enum _D3DCMPFUNC {
1005 D3DCMP_LESSEQUAL = 4,
1007 D3DCMP_NOTEQUAL = 6,
1008 D3DCMP_GREATEREQUAL = 7,
1010 D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1013 typedef enum _D3DSTENCILOP {
1014 D3DSTENCILOP_KEEP = 1,
1015 D3DSTENCILOP_ZERO = 2,
1016 D3DSTENCILOP_REPLACE = 3,
1017 D3DSTENCILOP_INCRSAT = 4,
1018 D3DSTENCILOP_DECRSAT = 5,
1019 D3DSTENCILOP_INVERT = 6,
1020 D3DSTENCILOP_INCR = 7,
1021 D3DSTENCILOP_DECR = 8,
1022 D3DSTENCILOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1025 typedef enum _D3DFOGMODE {
1030 D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1033 typedef enum _D3DZBUFFERTYPE {
1035 D3DZB_TRUE = 1, // Z buffering
1036 D3DZB_USEW = 2, // W buffering
1037 D3DZB_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1040 typedef enum _D3DANTIALIASMODE {
1041 D3DANTIALIAS_NONE = 0,
1042 D3DANTIALIAS_SORTDEPENDENT = 1,
1043 D3DANTIALIAS_SORTINDEPENDENT = 2,
1044 D3DANTIALIAS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1047 // Vertex types supported by Direct3D
1048 typedef enum _D3DVERTEXTYPE {
1052 D3DVT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1055 // Primitives supported by draw-primitive API
1056 typedef enum _D3DPRIMITIVETYPE {
1057 D3DPT_POINTLIST = 1,
1059 D3DPT_LINESTRIP = 3,
1060 D3DPT_TRIANGLELIST = 4,
1061 D3DPT_TRIANGLESTRIP = 5,
1062 D3DPT_TRIANGLEFAN = 6,
1063 D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1067 * Amount to add to a state to generate the override for that state.
1069 #define D3DSTATE_OVERRIDE_BIAS 256
1072 * A state which sets the override flag for the specified state type.
1074 #define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS))
1076 typedef enum _D3DTRANSFORMSTATETYPE {
1077 D3DTRANSFORMSTATE_WORLD = 1,
1078 D3DTRANSFORMSTATE_VIEW = 2,
1079 D3DTRANSFORMSTATE_PROJECTION = 3,
1080 D3DTRANSFORMSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1081 } D3DTRANSFORMSTATETYPE;
1083 typedef enum _D3DLIGHTSTATETYPE {
1084 D3DLIGHTSTATE_MATERIAL = 1,
1085 D3DLIGHTSTATE_AMBIENT = 2,
1086 D3DLIGHTSTATE_COLORMODEL = 3,
1087 D3DLIGHTSTATE_FOGMODE = 4,
1088 D3DLIGHTSTATE_FOGSTART = 5,
1089 D3DLIGHTSTATE_FOGEND = 6,
1090 D3DLIGHTSTATE_FOGDENSITY = 7,
1091 D3DLIGHTSTATE_COLORVERTEX = 8,
1092 D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1093 } D3DLIGHTSTATETYPE;
1095 typedef enum _D3DRENDERSTATETYPE {
1096 D3DRENDERSTATE_TEXTUREHANDLE = 1, /* Texture handle for legacy interfaces (Texture,Texture2) */
1097 D3DRENDERSTATE_ANTIALIAS = 2, /* D3DANTIALIASMODE */
1098 D3DRENDERSTATE_TEXTUREADDRESS = 3, /* D3DTEXTUREADDRESS */
1099 D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, /* TRUE for perspective correction */
1100 D3DRENDERSTATE_WRAPU = 5, /* TRUE for wrapping in u */
1101 D3DRENDERSTATE_WRAPV = 6, /* TRUE for wrapping in v */
1102 D3DRENDERSTATE_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */
1103 D3DRENDERSTATE_FILLMODE = 8, /* D3DFILL_MODE */
1104 D3DRENDERSTATE_SHADEMODE = 9, /* D3DSHADEMODE */
1105 D3DRENDERSTATE_LINEPATTERN = 10, /* D3DLINEPATTERN */
1106 D3DRENDERSTATE_MONOENABLE = 11, /* TRUE to enable mono rasterization */
1107 D3DRENDERSTATE_ROP2 = 12, /* ROP2 */
1108 D3DRENDERSTATE_PLANEMASK = 13, /* DWORD physical plane mask */
1109 D3DRENDERSTATE_ZWRITEENABLE = 14, /* TRUE to enable z writes */
1110 D3DRENDERSTATE_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */
1111 D3DRENDERSTATE_LASTPIXEL = 16, /* TRUE for last-pixel on lines */
1112 D3DRENDERSTATE_TEXTUREMAG = 17, /* D3DTEXTUREFILTER */
1113 D3DRENDERSTATE_TEXTUREMIN = 18, /* D3DTEXTUREFILTER */
1114 D3DRENDERSTATE_SRCBLEND = 19, /* D3DBLEND */
1115 D3DRENDERSTATE_DESTBLEND = 20, /* D3DBLEND */
1116 D3DRENDERSTATE_TEXTUREMAPBLEND = 21, /* D3DTEXTUREBLEND */
1117 D3DRENDERSTATE_CULLMODE = 22, /* D3DCULL */
1118 D3DRENDERSTATE_ZFUNC = 23, /* D3DCMPFUNC */
1119 D3DRENDERSTATE_ALPHAREF = 24, /* D3DFIXED */
1120 D3DRENDERSTATE_ALPHAFUNC = 25, /* D3DCMPFUNC */
1121 D3DRENDERSTATE_DITHERENABLE = 26, /* TRUE to enable dithering */
1122 D3DRENDERSTATE_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */
1123 D3DRENDERSTATE_FOGENABLE = 28, /* TRUE to enable fog */
1124 D3DRENDERSTATE_SPECULARENABLE = 29, /* TRUE to enable specular */
1125 D3DRENDERSTATE_ZVISIBLE = 30, /* TRUE to enable z checking */
1126 D3DRENDERSTATE_SUBPIXEL = 31, /* TRUE to enable subpixel correction */
1127 D3DRENDERSTATE_SUBPIXELX = 32, /* TRUE to enable correction in X only */
1128 D3DRENDERSTATE_STIPPLEDALPHA = 33, /* TRUE to enable stippled alpha */
1129 D3DRENDERSTATE_FOGCOLOR = 34, /* D3DCOLOR */
1130 D3DRENDERSTATE_FOGTABLEMODE = 35, /* D3DFOGMODE */
1131 D3DRENDERSTATE_FOGTABLESTART = 36, /* Fog table start */
1132 D3DRENDERSTATE_FOGTABLEEND = 37, /* Fog table end */
1133 D3DRENDERSTATE_FOGTABLEDENSITY = 38, /* Fog table density */
1134 D3DRENDERSTATE_STIPPLEENABLE = 39, /* TRUE to enable stippling */
1135 D3DRENDERSTATE_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */
1136 D3DRENDERSTATE_COLORKEYENABLE = 41, /* TRUE to enable source colorkeyed textures */
1137 D3DRENDERSTATE_BORDERCOLOR = 43, /* Border color for texturing w/border */
1138 D3DRENDERSTATE_TEXTUREADDRESSU = 44, /* Texture addressing mode for U coordinate */
1139 D3DRENDERSTATE_TEXTUREADDRESSV = 45, /* Texture addressing mode for V coordinate */
1140 D3DRENDERSTATE_MIPMAPLODBIAS = 46, /* D3DVALUE Mipmap LOD bias */
1141 D3DRENDERSTATE_ZBIAS = 47, /* LONG Z bias */
1142 D3DRENDERSTATE_RANGEFOGENABLE = 48, /* Enables range-based fog */
1143 D3DRENDERSTATE_ANISOTROPY = 49, /* Max. anisotropy. 1 = no anisotropy */
1144 D3DRENDERSTATE_FLUSHBATCH = 50, /* Explicit flush for DP batching (DX5 Only) */
1145 D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT=51, /* BOOL enable sort-independent transparency */
1146 D3DRENDERSTATE_STENCILENABLE = 52, /* BOOL enable/disable stenciling */
1147 D3DRENDERSTATE_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */
1148 D3DRENDERSTATE_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */
1149 D3DRENDERSTATE_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */
1150 D3DRENDERSTATE_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */
1151 D3DRENDERSTATE_STENCILREF = 57, /* Reference value used in stencil test */
1152 D3DRENDERSTATE_STENCILMASK = 58, /* Mask value used in stencil test */
1153 D3DRENDERSTATE_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */
1154 D3DRENDERSTATE_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */
1155 D3DRENDERSTATE_STIPPLEPATTERN00 = 64, /* Stipple pattern 01... */
1156 D3DRENDERSTATE_STIPPLEPATTERN01 = 65,
1157 D3DRENDERSTATE_STIPPLEPATTERN02 = 66,
1158 D3DRENDERSTATE_STIPPLEPATTERN03 = 67,
1159 D3DRENDERSTATE_STIPPLEPATTERN04 = 68,
1160 D3DRENDERSTATE_STIPPLEPATTERN05 = 69,
1161 D3DRENDERSTATE_STIPPLEPATTERN06 = 70,
1162 D3DRENDERSTATE_STIPPLEPATTERN07 = 71,
1163 D3DRENDERSTATE_STIPPLEPATTERN08 = 72,
1164 D3DRENDERSTATE_STIPPLEPATTERN09 = 73,
1165 D3DRENDERSTATE_STIPPLEPATTERN10 = 74,
1166 D3DRENDERSTATE_STIPPLEPATTERN11 = 75,
1167 D3DRENDERSTATE_STIPPLEPATTERN12 = 76,
1168 D3DRENDERSTATE_STIPPLEPATTERN13 = 77,
1169 D3DRENDERSTATE_STIPPLEPATTERN14 = 78,
1170 D3DRENDERSTATE_STIPPLEPATTERN15 = 79,
1171 D3DRENDERSTATE_STIPPLEPATTERN16 = 80,
1172 D3DRENDERSTATE_STIPPLEPATTERN17 = 81,
1173 D3DRENDERSTATE_STIPPLEPATTERN18 = 82,
1174 D3DRENDERSTATE_STIPPLEPATTERN19 = 83,
1175 D3DRENDERSTATE_STIPPLEPATTERN20 = 84,
1176 D3DRENDERSTATE_STIPPLEPATTERN21 = 85,
1177 D3DRENDERSTATE_STIPPLEPATTERN22 = 86,
1178 D3DRENDERSTATE_STIPPLEPATTERN23 = 87,
1179 D3DRENDERSTATE_STIPPLEPATTERN24 = 88,
1180 D3DRENDERSTATE_STIPPLEPATTERN25 = 89,
1181 D3DRENDERSTATE_STIPPLEPATTERN26 = 90,
1182 D3DRENDERSTATE_STIPPLEPATTERN27 = 91,
1183 D3DRENDERSTATE_STIPPLEPATTERN28 = 92,
1184 D3DRENDERSTATE_STIPPLEPATTERN29 = 93,
1185 D3DRENDERSTATE_STIPPLEPATTERN30 = 94,
1186 D3DRENDERSTATE_STIPPLEPATTERN31 = 95,
1189 * 128 values [128, 255] are reserved for texture coordinate wrap flags.
1190 * These are constructed with the D3DWRAP_U and D3DWRAP_V macros. Using
1191 * a flags word preserves forward compatibility with texture coordinates
1194 D3DRENDERSTATE_WRAP0 = 128, /* wrap for 1st texture coord. set */
1195 D3DRENDERSTATE_WRAP1 = 129, /* wrap for 2nd texture coord. set */
1196 D3DRENDERSTATE_WRAP2 = 130, /* wrap for 3rd texture coord. set */
1197 D3DRENDERSTATE_WRAP3 = 131, /* wrap for 4th texture coord. set */
1198 D3DRENDERSTATE_WRAP4 = 132, /* wrap for 5th texture coord. set */
1199 D3DRENDERSTATE_WRAP5 = 133, /* wrap for 6th texture coord. set */
1200 D3DRENDERSTATE_WRAP6 = 134, /* wrap for 7th texture coord. set */
1201 D3DRENDERSTATE_WRAP7 = 135, /* wrap for 8th texture coord. set */
1202 D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1203 } D3DRENDERSTATETYPE;
1205 // For back-compatibility with legacy compilations
1206 #define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE
1209 // Bias to apply to the texture coordinate set to apply a wrap to.
1210 #define D3DRENDERSTATE_WRAPBIAS 128UL
1212 /* Flags to construct the WRAP render states */
1213 #define D3DWRAP_U 0x00000001L
1214 #define D3DWRAP_V 0x00000002L
1217 #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
1219 typedef struct _D3DSTATE {
1221 D3DTRANSFORMSTATETYPE dtstTransformStateType;
1222 D3DLIGHTSTATETYPE dlstLightStateType;
1223 D3DRENDERSTATETYPE drstRenderStateType;
1224 #if defined(NONAMELESSUNION)
1232 #if defined(NONAMELESSUNION)
1237 } D3DSTATE, *LPD3DSTATE;
1240 * Operation used to load matrices
1243 typedef struct _D3DMATRIXLOAD {
1244 D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
1245 D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */
1246 } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
1249 * Operation used to multiply matrices
1250 * hDstMat = hSrcMat1 * hSrcMat2
1252 typedef struct _D3DMATRIXMULTIPLY {
1253 D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
1254 D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */
1255 D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */
1256 } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
1259 * Operation used to transform and light vertices.
1261 typedef struct _D3DPROCESSVERTICES {
1262 DWORD dwFlags; /* Do we transform or light or just copy? */
1263 WORD wStart; /* Index to first vertex in source */
1264 WORD wDest; /* Index to first vertex in local buffer */
1265 DWORD dwCount; /* Number of vertices to be processed */
1266 DWORD dwReserved; /* Must be zero */
1267 } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
1269 #define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L
1270 #define D3DPROCESSVERTICES_TRANSFORM 0x00000001L
1271 #define D3DPROCESSVERTICES_COPY 0x00000002L
1272 #define D3DPROCESSVERTICES_OPMASK 0x00000007L
1274 #define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L
1275 #define D3DPROCESSVERTICES_NOCOLOR 0x00000010L
1281 * State enumerants for per-stage texture processing.
1283 typedef enum _D3DTEXTURESTAGESTATETYPE
1285 D3DTSS_COLOROP = 1, /* D3DTEXTUREOP - per-stage blending controls for color channels */
1286 D3DTSS_COLORARG1 = 2, /* D3DTA_* (texture arg) */
1287 D3DTSS_COLORARG2 = 3, /* D3DTA_* (texture arg) */
1288 D3DTSS_ALPHAOP = 4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */
1289 D3DTSS_ALPHAARG1 = 5, /* D3DTA_* (texture arg) */
1290 D3DTSS_ALPHAARG2 = 6, /* D3DTA_* (texture arg) */
1291 D3DTSS_BUMPENVMAT00 = 7, /* D3DVALUE (bump mapping matrix) */
1292 D3DTSS_BUMPENVMAT01 = 8, /* D3DVALUE (bump mapping matrix) */
1293 D3DTSS_BUMPENVMAT10 = 9, /* D3DVALUE (bump mapping matrix) */
1294 D3DTSS_BUMPENVMAT11 = 10, /* D3DVALUE (bump mapping matrix) */
1295 D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */
1296 D3DTSS_ADDRESS = 12, /* D3DTEXTUREADDRESS for both coordinates */
1297 D3DTSS_ADDRESSU = 13, /* D3DTEXTUREADDRESS for U coordinate */
1298 D3DTSS_ADDRESSV = 14, /* D3DTEXTUREADDRESS for V coordinate */
1299 D3DTSS_BORDERCOLOR = 15, /* D3DCOLOR */
1300 D3DTSS_MAGFILTER = 16, /* D3DTEXTUREMAGFILTER filter to use for magnification */
1301 D3DTSS_MINFILTER = 17, /* D3DTEXTUREMINFILTER filter to use for minification */
1302 D3DTSS_MIPFILTER = 18, /* D3DTEXTUREMIPFILTER filter to use between mipmaps during minification */
1303 D3DTSS_MIPMAPLODBIAS = 19, /* D3DVALUE Mipmap LOD bias */
1304 D3DTSS_MAXMIPLEVEL = 20, /* DWORD 0..(n-1) LOD index of largest map to use (0 == largest) */
1305 D3DTSS_MAXANISOTROPY = 21, /* DWORD maximum anisotropy */
1306 D3DTSS_BUMPENVLSCALE = 22, /* D3DVALUE scale for bump map luminance */
1307 D3DTSS_BUMPENVLOFFSET = 23, /* D3DVALUE offset for bump map luminance */
1308 D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
1309 } D3DTEXTURESTAGESTATETYPE;
1312 * Enumerations for COLOROP and ALPHAOP texture blending operations set in
1313 * texture processing stage controls in D3DRENDERSTATE.
1315 typedef enum _D3DTEXTUREOP
1318 D3DTOP_DISABLE = 1, // disables stage
1319 D3DTOP_SELECTARG1 = 2, // the default
1320 D3DTOP_SELECTARG2 = 3,
1323 D3DTOP_MODULATE = 4, // multiply args together
1324 D3DTOP_MODULATE2X = 5, // multiply and 1 bit
1325 D3DTOP_MODULATE4X = 6, // multiply and 2 bits
1328 D3DTOP_ADD = 7, // add arguments together
1329 D3DTOP_ADDSIGNED = 8, // add with -0.5 bias
1330 D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit
1331 D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation
1332 D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product
1333 // Arg1 + Arg2 - Arg1*Arg2
1334 // = Arg1 + (1-Arg1)*Arg2
1336 // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
1337 D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha
1338 D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha
1339 D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRENDERSTATE_TEXTUREFACTOR
1340 // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
1341 D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha
1342 D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color
1345 D3DTOP_PREMODULATE = 17, // modulate with next texture before use
1346 D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB
1348 D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A
1350 D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, // (1-Arg1.A)*Arg2.RGB + Arg1.RGB
1352 D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A
1356 D3DTOP_BUMPENVMAP = 22, // per pixel env map perturbation
1357 D3DTOP_BUMPENVMAPLUMINANCE = 23, // with luminance channel
1358 // This can do either diffuse or specular bump mapping with correct input.
1359 // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
1360 // where each component has been scaled and offset to make it signed.
1361 // The result is replicated into all four (including alpha) channels.
1362 // This is a valid COLOROP only.
1363 D3DTOP_DOTPRODUCT3 = 24,
1365 D3DTOP_FORCE_DWORD = 0x7fffffff,
1369 * Values for COLORARG1,2 and ALPHAARG1,2 texture blending operations
1370 * set in texture processing stage controls in D3DRENDERSTATE.
1372 #define D3DTA_SELECTMASK 0x0000000f // mask for arg selector
1373 #define D3DTA_DIFFUSE 0x00000000 // select diffuse color
1374 #define D3DTA_CURRENT 0x00000001 // select result of previous stage
1375 #define D3DTA_TEXTURE 0x00000002 // select texture color
1376 #define D3DTA_TFACTOR 0x00000003 // select RENDERSTATE_TEXTUREFACTOR
1378 #define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x
1379 #define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components
1382 * IDirect3DTexture2 State Filter Types
1384 typedef enum _D3DTEXTUREMAGFILTER
1386 D3DTFG_POINT = 1, // nearest
1387 D3DTFG_LINEAR = 2, // linear interpolation
1388 D3DTFG_FLATCUBIC = 3, // cubic
1389 D3DTFG_GAUSSIANCUBIC = 4, // different cubic kernel
1390 D3DTFG_ANISOTROPIC = 5, //
1391 D3DTFG_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
1392 } D3DTEXTUREMAGFILTER;
1394 typedef enum _D3DTEXTUREMINFILTER
1396 D3DTFN_POINT = 1, // nearest
1397 D3DTFN_LINEAR = 2, // linear interpolation
1398 D3DTFN_ANISOTROPIC = 3, //
1399 D3DTFN_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
1400 } D3DTEXTUREMINFILTER;
1402 typedef enum _D3DTEXTUREMIPFILTER
1404 D3DTFP_NONE = 1, // mipmapping disabled (use MAG filter)
1405 D3DTFP_POINT = 2, // nearest
1406 D3DTFP_LINEAR = 3, // linear interpolation
1407 D3DTFP_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
1408 } D3DTEXTUREMIPFILTER;
1416 * Tri strip and fan flags.
1417 * START loads all three vertices
1418 * EVEN and ODD load just v3 with even or odd culling
1419 * START_FLAT contains a count from 0 to 29 that allows the
1420 * whole strip or fan to be culled in one hit.
1421 * e.g. for a quad len = 1
1423 #define D3DTRIFLAG_START 0x00000000L
1424 #define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */
1425 #define D3DTRIFLAG_ODD 0x0000001eL
1426 #define D3DTRIFLAG_EVEN 0x0000001fL
1429 * Triangle edge flags
1430 * enable edges for wireframe or antialiasing
1432 #define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */
1433 #define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */
1434 #define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */
1435 #define D3DTRIFLAG_EDGEENABLETRIANGLE \
1436 (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
1439 * Primitive structures and related defines. Vertex offsets are to types
1440 * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
1444 * Triangle list primitive structure
1446 typedef struct _D3DTRIANGLE {
1448 WORD v1; /* Vertex indices */
1450 #if defined(NONAMELESSUNION)
1458 #if defined(NONAMELESSUNION)
1466 #if defined(NONAMELESSUNION)
1471 WORD wFlags; /* Edge (and other) flags */
1472 } D3DTRIANGLE, *LPD3DTRIANGLE;
1475 * Line list structure.
1476 * The instruction count defines the number of line segments.
1478 typedef struct _D3DLINE {
1480 WORD v1; /* Vertex indices */
1482 #if defined(NONAMELESSUNION)
1490 #if defined(NONAMELESSUNION)
1495 } D3DLINE, *LPD3DLINE;
1499 * Spans join a list of points with the same y value.
1500 * If the y value changes, a new span is started.
1502 typedef struct _D3DSPAN {
1503 WORD wCount; /* Number of spans */
1504 WORD wFirst; /* Index to first vertex */
1505 } D3DSPAN, *LPD3DSPAN;
1510 typedef struct _D3DPOINT {
1511 WORD wCount; /* number of points */
1512 WORD wFirst; /* index to first vertex */
1513 } D3DPOINT, *LPD3DPOINT;
1517 * Forward branch structure.
1518 * Mask is logically anded with the driver status mask
1519 * if the result equals 'value', the branch is taken.
1521 typedef struct _D3DBRANCH {
1522 DWORD dwMask; /* Bitmask against D3D status */
1524 BOOL bNegate; /* TRUE to negate comparison */
1525 DWORD dwOffset; /* How far to branch forward (0 for exit)*/
1526 } D3DBRANCH, *LPD3DBRANCH;
1529 * Status used for set status instruction.
1530 * The D3D status is initialised on device creation
1531 * and is modified by all execute calls.
1533 typedef struct _D3DSTATUS {
1534 DWORD dwFlags; /* Do we set extents or status */
1535 DWORD dwStatus; /* D3D status */
1537 } D3DSTATUS, *LPD3DSTATUS;
1539 #define D3DSETSTATUS_STATUS 0x00000001L
1540 #define D3DSETSTATUS_EXTENTS 0x00000002L
1541 #define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
1543 typedef struct _D3DCLIPSTATUS {
1544 DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
1545 DWORD dwStatus; /* Clip status */
1546 float minx, maxx; /* X extents */
1547 float miny, maxy; /* Y extents */
1548 float minz, maxz; /* Z extents */
1549 } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
1551 #define D3DCLIPSTATUS_STATUS 0x00000001L
1552 #define D3DCLIPSTATUS_EXTENTS2 0x00000002L
1553 #define D3DCLIPSTATUS_EXTENTS3 0x00000004L
1556 * Statistics structure
1558 typedef struct _D3DSTATS {
1560 DWORD dwTrianglesDrawn;
1562 DWORD dwPointsDrawn;
1564 DWORD dwVerticesProcessed;
1565 } D3DSTATS, *LPD3DSTATS;
1569 * When calling using D3DEXECUTE_UNCLIPPED all the primitives
1570 * inside the buffer must be contained within the viewport.
1572 #define D3DEXECUTE_CLIPPED 0x00000001l
1573 #define D3DEXECUTE_UNCLIPPED 0x00000002l
1575 typedef struct _D3DEXECUTEDATA {
1577 DWORD dwVertexOffset;
1578 DWORD dwVertexCount;
1579 DWORD dwInstructionOffset;
1580 DWORD dwInstructionLength;
1581 DWORD dwHVertexOffset;
1582 D3DSTATUS dsStatus; /* Status after execute */
1583 } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
1587 * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
1589 #define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */
1590 #define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */
1591 #define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */
1595 typedef struct _D3DVERTEXBUFFERDESC {
1599 DWORD dwNumVertices;
1600 } D3DVERTEXBUFFERDESC, *LPD3DVERTEXBUFFERDESC;
1602 /* These correspond to DDSCAPS_* flags */
1603 #define D3DVBCAPS_SYSTEMMEMORY 0x00000800l
1604 #define D3DVBCAPS_WRITEONLY 0x00010000l
1605 #define D3DVBCAPS_OPTIMIZED 0x80000000l
1607 /* Vertex Operations for ProcessVertices */
1608 #define D3DVOP_LIGHT (1 << 10)
1609 #define D3DVOP_TRANSFORM (1 << 0)
1610 #define D3DVOP_CLIP (1 << 2)
1611 #define D3DVOP_EXTENTS (1 << 3)
1613 //-------------------------------------------------------------------
1615 // Flexible vertex format bits
1617 #define D3DFVF_RESERVED0 0x001
1618 #define D3DFVF_POSITION_MASK 0x00E
1619 #define D3DFVF_XYZ 0x002
1620 #define D3DFVF_XYZRHW 0x004
1621 #define D3DFVF_NORMAL 0x010
1622 #define D3DFVF_RESERVED1 0x020
1623 #define D3DFVF_DIFFUSE 0x040
1624 #define D3DFVF_SPECULAR 0x080
1626 #define D3DFVF_TEXCOUNT_MASK 0xf00
1627 #define D3DFVF_TEXCOUNT_SHIFT 8
1628 #define D3DFVF_TEX0 0x000
1629 #define D3DFVF_TEX1 0x100
1630 #define D3DFVF_TEX2 0x200
1631 #define D3DFVF_TEX3 0x300
1632 #define D3DFVF_TEX4 0x400
1633 #define D3DFVF_TEX5 0x500
1634 #define D3DFVF_TEX6 0x600
1635 #define D3DFVF_TEX7 0x700
1636 #define D3DFVF_TEX8 0x800
1638 #define D3DFVF_RESERVED2 0xf000 // 4 reserved bits
1640 #define D3DFVF_VERTEX ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 )
1641 #define D3DFVF_LVERTEX ( D3DFVF_XYZ | D3DFVF_RESERVED1 | D3DFVF_DIFFUSE | \
1642 D3DFVF_SPECULAR | D3DFVF_TEX1 )
1643 #define D3DFVF_TLVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | \
1646 typedef struct _D3DDP_PTRSTRIDE
1652 #define D3DDP_MAXTEXCOORD 8
1654 typedef struct _D3DDRAWPRIMITIVESTRIDEDDATA
1656 D3DDP_PTRSTRIDE position;
1657 D3DDP_PTRSTRIDE normal;
1658 D3DDP_PTRSTRIDE diffuse;
1659 D3DDP_PTRSTRIDE specular;
1660 D3DDP_PTRSTRIDE textureCoords[D3DDP_MAXTEXCOORD];
1661 } D3DDRAWPRIMITIVESTRIDEDDATA, *LPD3DDRAWPRIMITIVESTRIDEDDATA;
1662 //---------------------------------------------------------------------
1663 // ComputeSphereVisibility return values
1665 #define D3DVIS_INSIDE_FRUSTUM 0
1666 #define D3DVIS_INTERSECT_FRUSTUM 1
1667 #define D3DVIS_OUTSIDE_FRUSTUM 2
1668 #define D3DVIS_INSIDE_LEFT 0
1669 #define D3DVIS_INTERSECT_LEFT (1 << 2)
1670 #define D3DVIS_OUTSIDE_LEFT (2 << 2)
1671 #define D3DVIS_INSIDE_RIGHT 0
1672 #define D3DVIS_INTERSECT_RIGHT (1 << 4)
1673 #define D3DVIS_OUTSIDE_RIGHT (2 << 4)
1674 #define D3DVIS_INSIDE_TOP 0
1675 #define D3DVIS_INTERSECT_TOP (1 << 6)
1676 #define D3DVIS_OUTSIDE_TOP (2 << 6)
1677 #define D3DVIS_INSIDE_BOTTOM 0
1678 #define D3DVIS_INTERSECT_BOTTOM (1 << 8)
1679 #define D3DVIS_OUTSIDE_BOTTOM (2 << 8)
1680 #define D3DVIS_INSIDE_NEAR 0
1681 #define D3DVIS_INTERSECT_NEAR (1 << 10)
1682 #define D3DVIS_OUTSIDE_NEAR (2 << 10)
1683 #define D3DVIS_INSIDE_FAR 0
1684 #define D3DVIS_INTERSECT_FAR (1 << 12)
1685 #define D3DVIS_OUTSIDE_FAR (2 << 12)
1687 #define D3DVIS_MASK_FRUSTUM (3 << 0)
1688 #define D3DVIS_MASK_LEFT (3 << 2)
1689 #define D3DVIS_MASK_RIGHT (3 << 4)
1690 #define D3DVIS_MASK_TOP (3 << 6)
1691 #define D3DVIS_MASK_BOTTOM (3 << 8)
1692 #define D3DVIS_MASK_NEAR (3 << 10)
1693 #define D3DVIS_MASK_FAR (3 << 12)
1697 #endif /* _D3DTYPES_H_ */