1 /*==========================================================================;
3 * Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
6 * Content: Direct3D types include file
8 ***************************************************************************/
13 #if (! defined WIN32) && (! defined WIN95)
24 /* D3DVALUE is the fundamental Direct3D fractional data type */
26 #define D3DVALP(val, prec) ((float)(val))
27 #define D3DVAL(val) ((float)(val))
28 typedef float D3DVALUE, *LPD3DVALUE;
29 #define D3DDivide(a, b) (float)((double) (a) / (double) (b))
30 #define D3DMultiply(a, b) ((a) * (b))
32 typedef LONG D3DFIXED;
36 * Format of CI colors is
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 * | alpha | color index | fraction |
39 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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))
49 * Format of RGBA colors is
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 * | alpha | red | green | blue |
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 #define RGBA_GETALPHA(rgb) ((rgb) >> 24)
55 #define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff)
56 #define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
57 #define RGBA_GETBLUE(rgb) ((rgb) & 0xff)
58 #define RGBA_MAKE(r, g, b, a) ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
60 /* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
61 * The float values must be in the range 0..1
63 #define D3DRGB(r, g, b) \
64 (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
65 #define D3DRGBA(r, g, b, a) \
66 ( (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
67 | (((long)((g) * 255)) << 8) | (long)((b) * 255) \
71 * Format of RGB colors is
72 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73 * | ignored | red | green | blue |
74 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 #define RGB_GETRED(rgb) (((rgb) >> 16) & 0xff)
77 #define RGB_GETGREEN(rgb) (((rgb) >> 8) & 0xff)
78 #define RGB_GETBLUE(rgb) ((rgb) & 0xff)
79 #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
80 #define RGB_MAKE(r, g, b) ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
81 #define RGBA_TORGB(rgba) ((D3DCOLOR) ((rgba) & 0xffffff))
82 #define RGB_TORGBA(rgb) ((D3DCOLOR) ((rgb) | 0xff000000))
87 * Flags for Enumerate functions
91 * Stop the enumeration
93 #define D3DENUMRET_CANCEL DDENUMRET_CANCEL
96 * Continue the enumeration
98 #define D3DENUMRET_OK DDENUMRET_OK
100 typedef HRESULT (WINAPI* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
101 typedef HRESULT (WINAPI* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
103 typedef DWORD D3DCOLOR, *LPD3DCOLOR;
105 typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
106 typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
107 typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
109 typedef struct _D3DCOLORVALUE {
126 } D3DCOLORVALUE, *LPD3DCOLORVALUE;
128 typedef struct _D3DRECT {
145 } D3DRECT, *LPD3DRECT;
147 typedef struct _D3DVECTOR {
160 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
164 // =====================================
166 // =====================================
169 _D3DVECTOR(D3DVALUE f);
170 _D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z);
171 _D3DVECTOR(const D3DVALUE f[3]);
173 // =====================================
175 // =====================================
177 const D3DVALUE&operator[](int i) const;
178 D3DVALUE&operator[](int i);
180 // =====================================
181 // Assignment operators
182 // =====================================
184 _D3DVECTOR& operator += (const _D3DVECTOR& v);
185 _D3DVECTOR& operator -= (const _D3DVECTOR& v);
186 _D3DVECTOR& operator *= (const _D3DVECTOR& v);
187 _D3DVECTOR& operator /= (const _D3DVECTOR& v);
188 _D3DVECTOR& operator *= (D3DVALUE s);
189 _D3DVECTOR& operator /= (D3DVALUE s);
191 // =====================================
193 // =====================================
195 friend _D3DVECTOR operator + (const _D3DVECTOR& v);
196 friend _D3DVECTOR operator - (const _D3DVECTOR& v);
199 // =====================================
201 // =====================================
203 // Addition and subtraction
204 friend _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
205 friend _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
206 // Scalar multiplication and division
207 friend _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s);
208 friend _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v);
209 friend _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s);
210 // Memberwise multiplication and division
211 friend _D3DVECTOR operator * (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
212 friend _D3DVECTOR operator / (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
215 friend int operator < (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
216 friend int operator <= (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
219 friend int operator == (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
221 // Length-related functions
222 friend D3DVALUE SquareMagnitude (const _D3DVECTOR& v);
223 friend D3DVALUE Magnitude (const _D3DVECTOR& v);
225 // Returns vector with same direction and unit length
226 friend _D3DVECTOR Normalize (const _D3DVECTOR& v);
228 // Return min/max component of the input vector
229 friend D3DVALUE Min (const _D3DVECTOR& v);
230 friend D3DVALUE Max (const _D3DVECTOR& v);
232 // Return memberwise min/max of input vectors
233 friend _D3DVECTOR Minimize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
234 friend _D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
236 // Dot and cross product
237 friend D3DVALUE DotProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
238 friend _D3DVECTOR CrossProduct (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
242 } D3DVECTOR, *LPD3DVECTOR;
244 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
245 #include "vd3dvec.inl"
249 * Vertex data types supported in an ExecuteBuffer.
253 * Homogeneous vertices
256 typedef struct _D3DHVERTEX {
257 DWORD dwFlags; /* Homogeneous clipping flags */
270 } D3DHVERTEX, *LPD3DHVERTEX;
273 * Transformed/lit vertices
275 typedef struct _D3DTLVERTEX {
277 D3DVALUE sx; /* Screen coordinates */
289 D3DVALUE rhw; /* Reciprocal of homogeneous w */
293 D3DCOLOR color; /* Vertex color */
297 D3DCOLOR specular; /* Specular component of vertex */
301 D3DVALUE tu; /* Texture coordinates */
308 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
310 _D3DTLVERTEX(const D3DVECTOR& v, float _rhw,
311 D3DCOLOR _color, D3DCOLOR _specular,
312 float _tu, float _tv)
313 { sx = v.x; sy = v.y; sz = v.z; rhw = _rhw;
314 color = _color; specular = _specular;
318 } D3DTLVERTEX, *LPD3DTLVERTEX;
321 * Untransformed/lit vertices
323 typedef struct _D3DLVERTEX {
325 D3DVALUE x; /* Homogeneous coordinates */
338 D3DCOLOR color; /* Vertex color */
342 D3DCOLOR specular; /* Specular component of vertex */
346 D3DVALUE tu; /* Texture coordinates */
353 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
355 _D3DLVERTEX(const D3DVECTOR& v,
356 D3DCOLOR _color, D3DCOLOR _specular,
357 float _tu, float _tv)
358 { x = v.x; y = v.y; z = v.z; dwReserved = 0;
359 color = _color; specular = _specular;
363 } D3DLVERTEX, *LPD3DLVERTEX;
366 * Untransformed/unlit vertices
369 typedef struct _D3DVERTEX {
371 D3DVALUE x; /* Homogeneous coordinates */
383 D3DVALUE nx; /* Normal */
395 D3DVALUE tu; /* Texture coordinates */
402 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
404 _D3DVERTEX(const D3DVECTOR& v, const D3DVECTOR& n, float _tu, float _tv)
405 { x = v.x; y = v.y; z = v.z;
406 nx = n.x; ny = n.y; nz = n.z;
410 } D3DVERTEX, *LPD3DVERTEX;
413 * Matrix, viewport, and tranformation structures and definitions.
416 typedef struct _D3DMATRIX {
417 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
422 D3DVALUE _11, _12, _13, _14;
423 D3DVALUE _21, _22, _23, _24;
424 D3DVALUE _31, _32, _33, _34;
425 D3DVALUE _41, _42, _43, _44;
427 #if (defined __cplusplus) && (defined D3D_OVERLOADS)
432 _D3DMATRIX( D3DVALUE _m00, D3DVALUE _m01, D3DVALUE _m02, D3DVALUE _m03,
433 D3DVALUE _m10, D3DVALUE _m11, D3DVALUE _m12, D3DVALUE _m13,
434 D3DVALUE _m20, D3DVALUE _m21, D3DVALUE _m22, D3DVALUE _m23,
435 D3DVALUE _m30, D3DVALUE _m31, D3DVALUE _m32, D3DVALUE _m33
438 m[0][0] = _m00; m[0][1] = _m01; m[0][2] = _m02; m[0][3] = _m03;
439 m[1][0] = _m10; m[1][1] = _m11; m[1][2] = _m12; m[1][3] = _m13;
440 m[2][0] = _m20; m[2][1] = _m21; m[2][2] = _m22; m[2][3] = _m23;
441 m[3][0] = _m30; m[3][1] = _m31; m[3][2] = _m32; m[3][3] = _m33;
444 D3DVALUE& operator()(int iRow, int iColumn) { return m[iRow][iColumn]; }
445 const D3DVALUE& operator()(int iRow, int iColumn) const { return m[iRow][iColumn]; }
447 } D3DMATRIX, *LPD3DMATRIX;
449 typedef struct _D3DVIEWPORT {
452 DWORD dwY; /* Top left */
454 DWORD dwHeight; /* Dimensions */
455 D3DVALUE dvScaleX; /* Scale homogeneous to screen */
456 D3DVALUE dvScaleY; /* Scale homogeneous to screen */
457 D3DVALUE dvMaxX; /* Min/max homogeneous x coord */
458 D3DVALUE dvMaxY; /* Min/max homogeneous y coord */
460 D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */
461 } D3DVIEWPORT, *LPD3DVIEWPORT;
463 typedef struct _D3DVIEWPORT2 {
466 DWORD dwY; /* Viewport Top left */
468 DWORD dwHeight; /* Viewport Dimensions */
469 D3DVALUE dvClipX; /* Top left of clip volume */
471 D3DVALUE dvClipWidth; /* Clip Volume Dimensions */
472 D3DVALUE dvClipHeight;
473 D3DVALUE dvMinZ; /* Min/max of clip Volume */
475 } D3DVIEWPORT2, *LPD3DVIEWPORT2;
478 * Values for clip fields.
480 #define D3DCLIP_LEFT 0x00000001L
481 #define D3DCLIP_RIGHT 0x00000002L
482 #define D3DCLIP_TOP 0x00000004L
483 #define D3DCLIP_BOTTOM 0x00000008L
484 #define D3DCLIP_FRONT 0x00000010L
485 #define D3DCLIP_BACK 0x00000020L
486 #define D3DCLIP_GEN0 0x00000040L
487 #define D3DCLIP_GEN1 0x00000080L
488 #define D3DCLIP_GEN2 0x00000100L
489 #define D3DCLIP_GEN3 0x00000200L
490 #define D3DCLIP_GEN4 0x00000400L
491 #define D3DCLIP_GEN5 0x00000800L
494 * Values for d3d status.
496 #define D3DSTATUS_CLIPUNIONLEFT D3DCLIP_LEFT
497 #define D3DSTATUS_CLIPUNIONRIGHT D3DCLIP_RIGHT
498 #define D3DSTATUS_CLIPUNIONTOP D3DCLIP_TOP
499 #define D3DSTATUS_CLIPUNIONBOTTOM D3DCLIP_BOTTOM
500 #define D3DSTATUS_CLIPUNIONFRONT D3DCLIP_FRONT
501 #define D3DSTATUS_CLIPUNIONBACK D3DCLIP_BACK
502 #define D3DSTATUS_CLIPUNIONGEN0 D3DCLIP_GEN0
503 #define D3DSTATUS_CLIPUNIONGEN1 D3DCLIP_GEN1
504 #define D3DSTATUS_CLIPUNIONGEN2 D3DCLIP_GEN2
505 #define D3DSTATUS_CLIPUNIONGEN3 D3DCLIP_GEN3
506 #define D3DSTATUS_CLIPUNIONGEN4 D3DCLIP_GEN4
507 #define D3DSTATUS_CLIPUNIONGEN5 D3DCLIP_GEN5
509 #define D3DSTATUS_CLIPINTERSECTIONLEFT 0x00001000L
510 #define D3DSTATUS_CLIPINTERSECTIONRIGHT 0x00002000L
511 #define D3DSTATUS_CLIPINTERSECTIONTOP 0x00004000L
512 #define D3DSTATUS_CLIPINTERSECTIONBOTTOM 0x00008000L
513 #define D3DSTATUS_CLIPINTERSECTIONFRONT 0x00010000L
514 #define D3DSTATUS_CLIPINTERSECTIONBACK 0x00020000L
515 #define D3DSTATUS_CLIPINTERSECTIONGEN0 0x00040000L
516 #define D3DSTATUS_CLIPINTERSECTIONGEN1 0x00080000L
517 #define D3DSTATUS_CLIPINTERSECTIONGEN2 0x00100000L
518 #define D3DSTATUS_CLIPINTERSECTIONGEN3 0x00200000L
519 #define D3DSTATUS_CLIPINTERSECTIONGEN4 0x00400000L
520 #define D3DSTATUS_CLIPINTERSECTIONGEN5 0x00800000L
521 #define D3DSTATUS_ZNOTVISIBLE 0x01000000L
522 /* Do not use 0x80000000 for any status flags in future as it is reserved */
524 #define D3DSTATUS_CLIPUNIONALL ( \
525 D3DSTATUS_CLIPUNIONLEFT | \
526 D3DSTATUS_CLIPUNIONRIGHT | \
527 D3DSTATUS_CLIPUNIONTOP | \
528 D3DSTATUS_CLIPUNIONBOTTOM | \
529 D3DSTATUS_CLIPUNIONFRONT | \
530 D3DSTATUS_CLIPUNIONBACK | \
531 D3DSTATUS_CLIPUNIONGEN0 | \
532 D3DSTATUS_CLIPUNIONGEN1 | \
533 D3DSTATUS_CLIPUNIONGEN2 | \
534 D3DSTATUS_CLIPUNIONGEN3 | \
535 D3DSTATUS_CLIPUNIONGEN4 | \
536 D3DSTATUS_CLIPUNIONGEN5 \
539 #define D3DSTATUS_CLIPINTERSECTIONALL ( \
540 D3DSTATUS_CLIPINTERSECTIONLEFT | \
541 D3DSTATUS_CLIPINTERSECTIONRIGHT | \
542 D3DSTATUS_CLIPINTERSECTIONTOP | \
543 D3DSTATUS_CLIPINTERSECTIONBOTTOM | \
544 D3DSTATUS_CLIPINTERSECTIONFRONT | \
545 D3DSTATUS_CLIPINTERSECTIONBACK | \
546 D3DSTATUS_CLIPINTERSECTIONGEN0 | \
547 D3DSTATUS_CLIPINTERSECTIONGEN1 | \
548 D3DSTATUS_CLIPINTERSECTIONGEN2 | \
549 D3DSTATUS_CLIPINTERSECTIONGEN3 | \
550 D3DSTATUS_CLIPINTERSECTIONGEN4 | \
551 D3DSTATUS_CLIPINTERSECTIONGEN5 \
554 #define D3DSTATUS_DEFAULT ( \
555 D3DSTATUS_CLIPINTERSECTIONALL | \
556 D3DSTATUS_ZNOTVISIBLE)
560 * Options for direct transform calls
562 #define D3DTRANSFORM_CLIPPED 0x00000001l
563 #define D3DTRANSFORM_UNCLIPPED 0x00000002l
565 typedef struct _D3DTRANSFORMDATA {
567 LPVOID lpIn; /* Input vertices */
568 DWORD dwInSize; /* Stride of input vertices */
569 LPVOID lpOut; /* Output vertices */
570 DWORD dwOutSize; /* Stride of output vertices */
571 LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */
572 DWORD dwClip; /* Clipping hint */
573 DWORD dwClipIntersection;
574 DWORD dwClipUnion; /* Union of all clip flags */
575 D3DRECT drExtent; /* Extent of transformed vertices */
576 } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
579 * Structure defining position and direction properties for lighting.
581 typedef struct _D3DLIGHTINGELEMENT {
582 D3DVECTOR dvPosition; /* Lightable point in model space */
583 D3DVECTOR dvNormal; /* Normalised unit vector */
584 } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
587 * Structure defining material properties for lighting.
589 typedef struct _D3DMATERIAL {
592 D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
593 D3DCOLORVALUE dcvDiffuse;
596 D3DCOLORVALUE ambient; /* Ambient color RGB */
597 D3DCOLORVALUE dcvAmbient;
600 D3DCOLORVALUE specular; /* Specular 'shininess' */
601 D3DCOLORVALUE dcvSpecular;
604 D3DCOLORVALUE emissive; /* Emissive color RGB */
605 D3DCOLORVALUE dcvEmissive;
608 D3DVALUE power; /* Sharpness if specular highlight */
611 D3DTEXTUREHANDLE hTexture; /* Handle to texture map */
613 } D3DMATERIAL, *LPD3DMATERIAL;
615 typedef enum _D3DLIGHTTYPE {
618 D3DLIGHT_DIRECTIONAL = 3,
619 D3DLIGHT_PARALLELPOINT = 4,
620 D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
624 * Structure defining a light source and its properties.
626 typedef struct _D3DLIGHT {
628 D3DLIGHTTYPE dltType; /* Type of light source */
629 D3DCOLORVALUE dcvColor; /* Color of light */
630 D3DVECTOR dvPosition; /* Position in world space */
631 D3DVECTOR dvDirection; /* Direction in world space */
632 D3DVALUE dvRange; /* Cutoff range */
633 D3DVALUE dvFalloff; /* Falloff */
634 D3DVALUE dvAttenuation0; /* Constant attenuation */
635 D3DVALUE dvAttenuation1; /* Linear attenuation */
636 D3DVALUE dvAttenuation2; /* Quadratic attenuation */
637 D3DVALUE dvTheta; /* Inner angle of spotlight cone */
638 D3DVALUE dvPhi; /* Outer angle of spotlight cone */
639 } D3DLIGHT, *LPD3DLIGHT;
642 * Structure defining a light source and its properties.
646 #define D3DLIGHT_ACTIVE 0x00000001
647 #define D3DLIGHT_NO_SPECULAR 0x00000002
649 /* maximum valid light range */
650 #define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX))
652 typedef struct _D3DLIGHT2 {
654 D3DLIGHTTYPE dltType; /* Type of light source */
655 D3DCOLORVALUE dcvColor; /* Color of light */
656 D3DVECTOR dvPosition; /* Position in world space */
657 D3DVECTOR dvDirection; /* Direction in world space */
658 D3DVALUE dvRange; /* Cutoff range */
659 D3DVALUE dvFalloff; /* Falloff */
660 D3DVALUE dvAttenuation0; /* Constant attenuation */
661 D3DVALUE dvAttenuation1; /* Linear attenuation */
662 D3DVALUE dvAttenuation2; /* Quadratic attenuation */
663 D3DVALUE dvTheta; /* Inner angle of spotlight cone */
664 D3DVALUE dvPhi; /* Outer angle of spotlight cone */
666 } D3DLIGHT2, *LPD3DLIGHT2;
668 typedef struct _D3DLIGHTDATA {
670 LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */
671 DWORD dwInSize; /* Stride of input elements */
672 LPD3DTLVERTEX lpOut; /* Output colors */
673 DWORD dwOutSize; /* Stride of output colors */
674 } D3DLIGHTDATA, *LPD3DLIGHTDATA;
677 * Before DX5, these values were in an enum called
678 * D3DCOLORMODEL. This was not correct, since they are
679 * bit flags. A driver can surface either or both flags
680 * in the dcmColorModel member of D3DDEVICEDESC.
682 #define D3DCOLOR_MONO 1
683 #define D3DCOLOR_RGB 2
685 typedef DWORD D3DCOLORMODEL;
688 * Options for clearing
690 #define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */
691 #define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */
694 * Execute buffers are allocated via Direct3D. These buffers may then
695 * be filled by the application with instructions to execute along with
700 * Supported op codes for execute instructions.
702 typedef enum _D3DOPCODE {
706 D3DOP_MATRIXLOAD = 4,
707 D3DOP_MATRIXMULTIPLY = 5,
708 D3DOP_STATETRANSFORM = 6,
709 D3DOP_STATELIGHT = 7,
710 D3DOP_STATERENDER = 8,
711 D3DOP_PROCESSVERTICES = 9,
712 D3DOP_TEXTURELOAD = 10,
714 D3DOP_BRANCHFORWARD = 12,
716 D3DOP_SETSTATUS = 14,
717 D3DOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
720 typedef struct _D3DINSTRUCTION {
721 BYTE bOpcode; /* Instruction opcode */
722 BYTE bSize; /* Size of each instruction data unit */
723 WORD wCount; /* Count of instruction data units to follow */
724 } D3DINSTRUCTION, *LPD3DINSTRUCTION;
727 * Structure for texture loads
729 typedef struct _D3DTEXTURELOAD {
730 D3DTEXTUREHANDLE hDestTexture;
731 D3DTEXTUREHANDLE hSrcTexture;
732 } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
735 * Structure for picking
737 typedef struct _D3DPICKRECORD {
742 } D3DPICKRECORD, *LPD3DPICKRECORD;
745 * The following defines the rendering states which can be set in the
749 typedef enum _D3DSHADEMODE {
751 D3DSHADE_GOURAUD = 2,
753 D3DSHADE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
756 typedef enum _D3DFILLMODE {
758 D3DFILL_WIREFRAME = 2,
760 D3DFILL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
763 typedef struct _D3DLINEPATTERN {
768 typedef enum _D3DTEXTUREFILTER {
769 D3DFILTER_NEAREST = 1,
770 D3DFILTER_LINEAR = 2,
771 D3DFILTER_MIPNEAREST = 3,
772 D3DFILTER_MIPLINEAR = 4,
773 D3DFILTER_LINEARMIPNEAREST = 5,
774 D3DFILTER_LINEARMIPLINEAR = 6,
775 D3DFILTER_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
778 typedef enum _D3DBLEND {
781 D3DBLEND_SRCCOLOR = 3,
782 D3DBLEND_INVSRCCOLOR = 4,
783 D3DBLEND_SRCALPHA = 5,
784 D3DBLEND_INVSRCALPHA = 6,
785 D3DBLEND_DESTALPHA = 7,
786 D3DBLEND_INVDESTALPHA = 8,
787 D3DBLEND_DESTCOLOR = 9,
788 D3DBLEND_INVDESTCOLOR = 10,
789 D3DBLEND_SRCALPHASAT = 11,
790 D3DBLEND_BOTHSRCALPHA = 12,
791 D3DBLEND_BOTHINVSRCALPHA = 13,
792 D3DBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
795 typedef enum _D3DTEXTUREBLEND {
797 D3DTBLEND_MODULATE = 2,
798 D3DTBLEND_DECALALPHA = 3,
799 D3DTBLEND_MODULATEALPHA = 4,
800 D3DTBLEND_DECALMASK = 5,
801 D3DTBLEND_MODULATEMASK = 6,
804 D3DTBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
807 typedef enum _D3DTEXTUREADDRESS {
808 D3DTADDRESS_WRAP = 1,
809 D3DTADDRESS_MIRROR = 2,
810 D3DTADDRESS_CLAMP = 3,
811 D3DTADDRESS_BORDER = 4,
812 D3DTADDRESS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
815 typedef enum _D3DCULL {
819 D3DCULL_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
822 typedef enum _D3DCMPFUNC {
826 D3DCMP_LESSEQUAL = 4,
829 D3DCMP_GREATEREQUAL = 7,
831 D3DCMP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
834 typedef enum _D3DFOGMODE {
839 D3DFOG_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
842 typedef enum _D3DANTIALIASMODE {
843 D3DANTIALIAS_NONE = 0,
844 D3DANTIALIAS_SORTDEPENDENT = 1,
845 D3DANTIALIAS_SORTINDEPENDENT = 2,
846 D3DANTIALIAS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
849 // Vertex types supported by Direct3D
850 typedef enum _D3DVERTEXTYPE {
854 D3DVT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
857 // Primitives supported by draw-primitive API
858 typedef enum _D3DPRIMITIVETYPE {
862 D3DPT_TRIANGLELIST = 4,
863 D3DPT_TRIANGLESTRIP = 5,
864 D3DPT_TRIANGLEFAN = 6,
865 D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
869 * Amount to add to a state to generate the override for that state.
871 #define D3DSTATE_OVERRIDE_BIAS 256
874 * A state which sets the override flag for the specified state type.
876 #define D3DSTATE_OVERRIDE(type) ((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)
878 typedef enum _D3DTRANSFORMSTATETYPE {
879 D3DTRANSFORMSTATE_WORLD = 1,
880 D3DTRANSFORMSTATE_VIEW = 2,
881 D3DTRANSFORMSTATE_PROJECTION = 3,
882 D3DTRANSFORMSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
883 } D3DTRANSFORMSTATETYPE;
885 typedef enum _D3DLIGHTSTATETYPE {
886 D3DLIGHTSTATE_MATERIAL = 1,
887 D3DLIGHTSTATE_AMBIENT = 2,
888 D3DLIGHTSTATE_COLORMODEL = 3,
889 D3DLIGHTSTATE_FOGMODE = 4,
890 D3DLIGHTSTATE_FOGSTART = 5,
891 D3DLIGHTSTATE_FOGEND = 6,
892 D3DLIGHTSTATE_FOGDENSITY = 7,
893 D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
896 typedef enum _D3DRENDERSTATETYPE {
897 D3DRENDERSTATE_TEXTUREHANDLE = 1, /* Texture handle */
898 D3DRENDERSTATE_ANTIALIAS = 2, /* D3DANTIALIASMODE */
899 D3DRENDERSTATE_TEXTUREADDRESS = 3, /* D3DTEXTUREADDRESS */
900 D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4, /* TRUE for perspective correction */
901 D3DRENDERSTATE_WRAPU = 5, /* TRUE for wrapping in u */
902 D3DRENDERSTATE_WRAPV = 6, /* TRUE for wrapping in v */
903 D3DRENDERSTATE_ZENABLE = 7, /* TRUE to enable z test */
904 D3DRENDERSTATE_FILLMODE = 8, /* D3DFILL_MODE */
905 D3DRENDERSTATE_SHADEMODE = 9, /* D3DSHADEMODE */
906 D3DRENDERSTATE_LINEPATTERN = 10, /* D3DLINEPATTERN */
907 D3DRENDERSTATE_MONOENABLE = 11, /* TRUE to enable mono rasterization */
908 D3DRENDERSTATE_ROP2 = 12, /* ROP2 */
909 D3DRENDERSTATE_PLANEMASK = 13, /* DWORD physical plane mask */
910 D3DRENDERSTATE_ZWRITEENABLE = 14, /* TRUE to enable z writes */
911 D3DRENDERSTATE_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */
912 D3DRENDERSTATE_LASTPIXEL = 16, /* TRUE for last-pixel on lines */
913 D3DRENDERSTATE_TEXTUREMAG = 17, /* D3DTEXTUREFILTER */
914 D3DRENDERSTATE_TEXTUREMIN = 18, /* D3DTEXTUREFILTER */
915 D3DRENDERSTATE_SRCBLEND = 19, /* D3DBLEND */
916 D3DRENDERSTATE_DESTBLEND = 20, /* D3DBLEND */
917 D3DRENDERSTATE_TEXTUREMAPBLEND = 21, /* D3DTEXTUREBLEND */
918 D3DRENDERSTATE_CULLMODE = 22, /* D3DCULL */
919 D3DRENDERSTATE_ZFUNC = 23, /* D3DCMPFUNC */
920 D3DRENDERSTATE_ALPHAREF = 24, /* D3DFIXED */
921 D3DRENDERSTATE_ALPHAFUNC = 25, /* D3DCMPFUNC */
922 D3DRENDERSTATE_DITHERENABLE = 26, /* TRUE to enable dithering */
923 D3DRENDERSTATE_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */
924 D3DRENDERSTATE_FOGENABLE = 28, /* TRUE to enable fog */
925 D3DRENDERSTATE_SPECULARENABLE = 29, /* TRUE to enable specular */
926 D3DRENDERSTATE_ZVISIBLE = 30, /* TRUE to enable z checking */
927 D3DRENDERSTATE_SUBPIXEL = 31, /* TRUE to enable subpixel correction */
928 D3DRENDERSTATE_SUBPIXELX = 32, /* TRUE to enable correction in X only */
929 D3DRENDERSTATE_STIPPLEDALPHA = 33, /* TRUE to enable stippled alpha */
930 D3DRENDERSTATE_FOGCOLOR = 34, /* D3DCOLOR */
931 D3DRENDERSTATE_FOGTABLEMODE = 35, /* D3DFOGMODE */
932 D3DRENDERSTATE_FOGTABLESTART = 36, /* Fog table start */
933 D3DRENDERSTATE_FOGTABLEEND = 37, /* Fog table end */
934 D3DRENDERSTATE_FOGTABLEDENSITY = 38, /* Fog table density */
935 D3DRENDERSTATE_STIPPLEENABLE = 39, /* TRUE to enable stippling */
936 D3DRENDERSTATE_EDGEANTIALIAS = 40, /* TRUE to enable edge antialiasing */
937 D3DRENDERSTATE_COLORKEYENABLE = 41, /* TRUE to enable source colorkeyed textures */
938 D3DRENDERSTATE_BORDERCOLOR = 43, /* Border color for texturing w/border */
939 D3DRENDERSTATE_TEXTUREADDRESSU = 44, /* Texture addressing mode for U coordinate */
940 D3DRENDERSTATE_TEXTUREADDRESSV = 45, /* Texture addressing mode for V coordinate */
941 D3DRENDERSTATE_MIPMAPLODBIAS = 46, /* D3DVALUE Mipmap LOD bias */
942 D3DRENDERSTATE_ZBIAS = 47, /* LONG Z bias */
943 D3DRENDERSTATE_RANGEFOGENABLE = 48, /* Enables range-based fog */
944 D3DRENDERSTATE_ANISOTROPY = 49, /* Max. anisotropy. 1 = no anisotropy */
945 D3DRENDERSTATE_FLUSHBATCH = 50, /* Explicit flush for DP batching (DX5 Only) */
946 D3DRENDERSTATE_STIPPLEPATTERN00 = 64, /* Stipple pattern 01... */
947 D3DRENDERSTATE_STIPPLEPATTERN01 = 65,
948 D3DRENDERSTATE_STIPPLEPATTERN02 = 66,
949 D3DRENDERSTATE_STIPPLEPATTERN03 = 67,
950 D3DRENDERSTATE_STIPPLEPATTERN04 = 68,
951 D3DRENDERSTATE_STIPPLEPATTERN05 = 69,
952 D3DRENDERSTATE_STIPPLEPATTERN06 = 70,
953 D3DRENDERSTATE_STIPPLEPATTERN07 = 71,
954 D3DRENDERSTATE_STIPPLEPATTERN08 = 72,
955 D3DRENDERSTATE_STIPPLEPATTERN09 = 73,
956 D3DRENDERSTATE_STIPPLEPATTERN10 = 74,
957 D3DRENDERSTATE_STIPPLEPATTERN11 = 75,
958 D3DRENDERSTATE_STIPPLEPATTERN12 = 76,
959 D3DRENDERSTATE_STIPPLEPATTERN13 = 77,
960 D3DRENDERSTATE_STIPPLEPATTERN14 = 78,
961 D3DRENDERSTATE_STIPPLEPATTERN15 = 79,
962 D3DRENDERSTATE_STIPPLEPATTERN16 = 80,
963 D3DRENDERSTATE_STIPPLEPATTERN17 = 81,
964 D3DRENDERSTATE_STIPPLEPATTERN18 = 82,
965 D3DRENDERSTATE_STIPPLEPATTERN19 = 83,
966 D3DRENDERSTATE_STIPPLEPATTERN20 = 84,
967 D3DRENDERSTATE_STIPPLEPATTERN21 = 85,
968 D3DRENDERSTATE_STIPPLEPATTERN22 = 86,
969 D3DRENDERSTATE_STIPPLEPATTERN23 = 87,
970 D3DRENDERSTATE_STIPPLEPATTERN24 = 88,
971 D3DRENDERSTATE_STIPPLEPATTERN25 = 89,
972 D3DRENDERSTATE_STIPPLEPATTERN26 = 90,
973 D3DRENDERSTATE_STIPPLEPATTERN27 = 91,
974 D3DRENDERSTATE_STIPPLEPATTERN28 = 92,
975 D3DRENDERSTATE_STIPPLEPATTERN29 = 93,
976 D3DRENDERSTATE_STIPPLEPATTERN30 = 94,
977 D3DRENDERSTATE_STIPPLEPATTERN31 = 95,
978 D3DRENDERSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
979 } D3DRENDERSTATETYPE;
981 // For back-compatibility with legacy compilations
982 #define D3DRENDERSTATE_BLENDENABLE D3DRENDERSTATE_ALPHABLENDENABLE
984 #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
986 typedef struct _D3DSTATE {
988 D3DTRANSFORMSTATETYPE dtstTransformStateType;
989 D3DLIGHTSTATETYPE dlstLightStateType;
990 D3DRENDERSTATETYPE drstRenderStateType;
996 } D3DSTATE, *LPD3DSTATE;
999 * Operation used to load matrices
1002 typedef struct _D3DMATRIXLOAD {
1003 D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
1004 D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */
1005 } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
1008 * Operation used to multiply matrices
1009 * hDstMat = hSrcMat1 * hSrcMat2
1011 typedef struct _D3DMATRIXMULTIPLY {
1012 D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
1013 D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */
1014 D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */
1015 } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
1018 * Operation used to transform and light vertices.
1020 typedef struct _D3DPROCESSVERTICES {
1021 DWORD dwFlags; /* Do we transform or light or just copy? */
1022 WORD wStart; /* Index to first vertex in source */
1023 WORD wDest; /* Index to first vertex in local buffer */
1024 DWORD dwCount; /* Number of vertices to be processed */
1025 DWORD dwReserved; /* Must be zero */
1026 } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
1028 #define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L
1029 #define D3DPROCESSVERTICES_TRANSFORM 0x00000001L
1030 #define D3DPROCESSVERTICES_COPY 0x00000002L
1031 #define D3DPROCESSVERTICES_OPMASK 0x00000007L
1033 #define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L
1034 #define D3DPROCESSVERTICES_NOCOLOR 0x00000010L
1042 * Tri strip and fan flags.
1043 * START loads all three vertices
1044 * EVEN and ODD load just v3 with even or odd culling
1045 * START_FLAT contains a count from 0 to 29 that allows the
1046 * whole strip or fan to be culled in one hit.
1047 * e.g. for a quad len = 1
1049 #define D3DTRIFLAG_START 0x00000000L
1050 #define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */
1051 #define D3DTRIFLAG_ODD 0x0000001eL
1052 #define D3DTRIFLAG_EVEN 0x0000001fL
1055 * Triangle edge flags
1056 * enable edges for wireframe or antialiasing
1058 #define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */
1059 #define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */
1060 #define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */
1061 #define D3DTRIFLAG_EDGEENABLETRIANGLE \
1062 (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
1065 * Primitive structures and related defines. Vertex offsets are to types
1066 * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
1070 * Triangle list primitive structure
1072 typedef struct _D3DTRIANGLE {
1074 WORD v1; /* Vertex indices */
1085 WORD wFlags; /* Edge (and other) flags */
1086 } D3DTRIANGLE, *LPD3DTRIANGLE;
1089 * Line list structure.
1090 * The instruction count defines the number of line segments.
1092 typedef struct _D3DLINE {
1094 WORD v1; /* Vertex indices */
1101 } D3DLINE, *LPD3DLINE;
1105 * Spans join a list of points with the same y value.
1106 * If the y value changes, a new span is started.
1108 typedef struct _D3DSPAN {
1109 WORD wCount; /* Number of spans */
1110 WORD wFirst; /* Index to first vertex */
1111 } D3DSPAN, *LPD3DSPAN;
1116 typedef struct _D3DPOINT {
1117 WORD wCount; /* number of points */
1118 WORD wFirst; /* index to first vertex */
1119 } D3DPOINT, *LPD3DPOINT;
1123 * Forward branch structure.
1124 * Mask is logically anded with the driver status mask
1125 * if the result equals 'value', the branch is taken.
1127 typedef struct _D3DBRANCH {
1128 DWORD dwMask; /* Bitmask against D3D status */
1130 BOOL bNegate; /* TRUE to negate comparison */
1131 DWORD dwOffset; /* How far to branch forward (0 for exit)*/
1132 } D3DBRANCH, *LPD3DBRANCH;
1135 * Status used for set status instruction.
1136 * The D3D status is initialised on device creation
1137 * and is modified by all execute calls.
1139 typedef struct _D3DSTATUS {
1140 DWORD dwFlags; /* Do we set extents or status */
1141 DWORD dwStatus; /* D3D status */
1143 } D3DSTATUS, *LPD3DSTATUS;
1145 #define D3DSETSTATUS_STATUS 0x00000001L
1146 #define D3DSETSTATUS_EXTENTS 0x00000002L
1147 #define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
1149 typedef struct _D3DCLIPSTATUS {
1150 DWORD dwFlags; /* Do we set 2d extents, 3D extents or status */
1151 DWORD dwStatus; /* Clip status */
1152 float minx, maxx; /* X extents */
1153 float miny, maxy; /* Y extents */
1154 float minz, maxz; /* Z extents */
1155 } D3DCLIPSTATUS, *LPD3DCLIPSTATUS;
1157 #define D3DCLIPSTATUS_STATUS 0x00000001L
1158 #define D3DCLIPSTATUS_EXTENTS2 0x00000002L
1159 #define D3DCLIPSTATUS_EXTENTS3 0x00000004L
1162 * Statistics structure
1164 typedef struct _D3DSTATS {
1166 DWORD dwTrianglesDrawn;
1168 DWORD dwPointsDrawn;
1170 DWORD dwVerticesProcessed;
1171 } D3DSTATS, *LPD3DSTATS;
1175 * When calling using D3DEXECUTE_UNCLIPPED all the primitives
1176 * inside the buffer must be contained within the viewport.
1178 #define D3DEXECUTE_CLIPPED 0x00000001l
1179 #define D3DEXECUTE_UNCLIPPED 0x00000002l
1181 typedef struct _D3DEXECUTEDATA {
1183 DWORD dwVertexOffset;
1184 DWORD dwVertexCount;
1185 DWORD dwInstructionOffset;
1186 DWORD dwInstructionLength;
1187 DWORD dwHVertexOffset;
1188 D3DSTATUS dsStatus; /* Status after execute */
1189 } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
1193 * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
1195 #define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */
1196 #define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */
1197 #define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */
1201 #endif /* _D3DTYPES_H_ */