Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

873 lines
30 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3dlegacy.h
  6. * Content: Direct3D Legacy
  7. *
  8. ***************************************************************************/
  9. #pragma message( "**** including " __FILE__ )
  10. #ifndef _D3DLEGACY_H_
  11. #define _D3DLEGACY_H_
  12. #include <windows.h>
  13. #include <float.h>
  14. #include "ddraw.h"
  15. #pragma warning(disable:4201) // anonymous unions warning
  16. #pragma pack(4)
  17. #define D3DVALP(val, prec) ((float)(val))
  18. #define D3DVAL(val) ((float)(val))
  19. #define D3DDivide(a, b) (float)((double) (a) / (double) (b))
  20. #define D3DMultiply(a, b) ((a) * (b))
  21. typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
  22. typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
  23. typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
  24. typedef struct _D3DRECT* LPD3DRECT;
  25. typedef struct _D3DMATRIX* LPD3DMATRIX;
  26. typedef DWORD* LPD3DCOLOR;
  27. typedef struct _D3DCOLORVALUE* LPD3DCOLORVALUE;
  28. typedef struct _D3DVIEWPORT {
  29. DWORD dwSize;
  30. DWORD dwX;
  31. DWORD dwY; /* Top left */
  32. DWORD dwWidth;
  33. DWORD dwHeight; /* Dimensions */
  34. D3DVALUE dvScaleX; /* Scale homogeneous to screen */
  35. D3DVALUE dvScaleY; /* Scale homogeneous to screen */
  36. D3DVALUE dvMaxX; /* Min/max homogeneous x coord */
  37. D3DVALUE dvMaxY; /* Min/max homogeneous y coord */
  38. D3DVALUE dvMinZ;
  39. D3DVALUE dvMaxZ; /* Min/max homogeneous z coord */
  40. } D3DVIEWPORT, *LPD3DVIEWPORT;
  41. typedef struct _D3DVIEWPORT2 {
  42. DWORD dwSize;
  43. DWORD dwX;
  44. DWORD dwY; /* Viewport Top left */
  45. DWORD dwWidth;
  46. DWORD dwHeight; /* Viewport Dimensions */
  47. D3DVALUE dvClipX; /* Top left of clip volume */
  48. D3DVALUE dvClipY;
  49. D3DVALUE dvClipWidth; /* Clip Volume Dimensions */
  50. D3DVALUE dvClipHeight;
  51. D3DVALUE dvMinZ; /* Min/max of clip Volume */
  52. D3DVALUE dvMaxZ;
  53. } D3DVIEWPORT2, *LPD3DVIEWPORT2;
  54. typedef struct _D3DVIEWPORT7 {
  55. DWORD dwX;
  56. DWORD dwY; /* Viewport Top left */
  57. DWORD dwWidth;
  58. DWORD dwHeight; /* Viewport Dimensions */
  59. D3DVALUE dvMinZ; /* Min/max of clip Volume */
  60. D3DVALUE dvMaxZ;
  61. } D3DVIEWPORT7, *LPD3DVIEWPORT7;
  62. /*
  63. * Options for direct transform calls
  64. */
  65. #define D3DTRANSFORM_CLIPPED 0x00000001l
  66. #define D3DTRANSFORM_UNCLIPPED 0x00000002l
  67. /*
  68. * Homogeneous vertices
  69. */
  70. typedef struct _D3DHVERTEX {
  71. DWORD dwFlags; /* Homogeneous clipping flags */
  72. union {
  73. D3DVALUE hx;
  74. D3DVALUE dvHX;
  75. };
  76. union {
  77. D3DVALUE hy;
  78. D3DVALUE dvHY;
  79. };
  80. union {
  81. D3DVALUE hz;
  82. D3DVALUE dvHZ;
  83. };
  84. } D3DHVERTEX, *LPD3DHVERTEX;
  85. typedef struct _D3DTRANSFORMDATA {
  86. DWORD dwSize;
  87. LPVOID lpIn; /* Input vertices */
  88. DWORD dwInSize; /* Stride of input vertices */
  89. LPVOID lpOut; /* Output vertices */
  90. DWORD dwOutSize; /* Stride of output vertices */
  91. LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */
  92. DWORD dwClip; /* Clipping hint */
  93. DWORD dwClipIntersection;
  94. DWORD dwClipUnion; /* Union of all clip flags */
  95. D3DRECT drExtent; /* Extent of transformed vertices */
  96. } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
  97. /*
  98. * Structure defining position and direction properties for lighting.
  99. */
  100. typedef struct _D3DLIGHTINGELEMENT {
  101. D3DVECTOR dvPosition; /* Lightable point in model space */
  102. D3DVECTOR dvNormal; /* Normalised unit vector */
  103. } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
  104. /*
  105. * Structure defining material properties for lighting.
  106. */
  107. typedef struct _D3DMATERIAL {
  108. DWORD dwSize;
  109. union {
  110. D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
  111. D3DCOLORVALUE dcvDiffuse;
  112. };
  113. union {
  114. D3DCOLORVALUE ambient; /* Ambient color RGB */
  115. D3DCOLORVALUE dcvAmbient;
  116. };
  117. union {
  118. D3DCOLORVALUE specular; /* Specular 'shininess' */
  119. D3DCOLORVALUE dcvSpecular;
  120. };
  121. union {
  122. D3DCOLORVALUE emissive; /* Emissive color RGB */
  123. D3DCOLORVALUE dcvEmissive;
  124. };
  125. union {
  126. D3DVALUE power; /* Sharpness if specular highlight */
  127. D3DVALUE dvPower;
  128. };
  129. D3DTEXTUREHANDLE hTexture; /* Handle to texture map */
  130. DWORD dwRampSize;
  131. } D3DMATERIAL, *LPD3DMATERIAL;
  132. typedef struct _D3DMATERIAL7 {
  133. union {
  134. D3DCOLORVALUE diffuse; /* Diffuse color RGBA */
  135. D3DCOLORVALUE dcvDiffuse;
  136. };
  137. union {
  138. D3DCOLORVALUE ambient; /* Ambient color RGB */
  139. D3DCOLORVALUE dcvAmbient;
  140. };
  141. union {
  142. D3DCOLORVALUE specular; /* Specular 'shininess' */
  143. D3DCOLORVALUE dcvSpecular;
  144. };
  145. union {
  146. D3DCOLORVALUE emissive; /* Emissive color RGB */
  147. D3DCOLORVALUE dcvEmissive;
  148. };
  149. union {
  150. D3DVALUE power; /* Sharpness if specular highlight */
  151. D3DVALUE dvPower;
  152. };
  153. } D3DMATERIAL7, *LPD3DMATERIAL7;
  154. /*
  155. * Structure defining a light source and its properties.
  156. */
  157. typedef struct _D3DLIGHT {
  158. DWORD dwSize;
  159. D3DLIGHTTYPE dltType; /* Type of light source */
  160. D3DCOLORVALUE dcvColor; /* Color of light */
  161. D3DVECTOR dvPosition; /* Position in world space */
  162. D3DVECTOR dvDirection; /* Direction in world space */
  163. D3DVALUE dvRange; /* Cutoff range */
  164. D3DVALUE dvFalloff; /* Falloff */
  165. D3DVALUE dvAttenuation0; /* Constant attenuation */
  166. D3DVALUE dvAttenuation1; /* Linear attenuation */
  167. D3DVALUE dvAttenuation2; /* Quadratic attenuation */
  168. D3DVALUE dvTheta; /* Inner angle of spotlight cone */
  169. D3DVALUE dvPhi; /* Outer angle of spotlight cone */
  170. } D3DLIGHT, *LPD3DLIGHT;
  171. /*
  172. * Structure defining a light source and its properties.
  173. */
  174. /* flags bits */
  175. #define D3DLIGHT_ACTIVE 0x00000001
  176. #define D3DLIGHT_NO_SPECULAR 0x00000002
  177. #define D3DLIGHT_ALL (D3DLIGHT_ACTIVE | D3DLIGHT_NO_SPECULAR)
  178. /* maximum valid light range */
  179. #define D3DLIGHT_RANGE_MAX ((float)sqrt(FLT_MAX))
  180. typedef struct _D3DLIGHT2 {
  181. DWORD dwSize;
  182. D3DLIGHTTYPE dltType; /* Type of light source */
  183. D3DCOLORVALUE dcvColor; /* Color of light */
  184. D3DVECTOR dvPosition; /* Position in world space */
  185. D3DVECTOR dvDirection; /* Direction in world space */
  186. D3DVALUE dvRange; /* Cutoff range */
  187. D3DVALUE dvFalloff; /* Falloff */
  188. D3DVALUE dvAttenuation0; /* Constant attenuation */
  189. D3DVALUE dvAttenuation1; /* Linear attenuation */
  190. D3DVALUE dvAttenuation2; /* Quadratic attenuation */
  191. D3DVALUE dvTheta; /* Inner angle of spotlight cone */
  192. D3DVALUE dvPhi; /* Outer angle of spotlight cone */
  193. DWORD dwFlags;
  194. } D3DLIGHT2, *LPD3DLIGHT2;
  195. typedef struct _D3DLIGHT7 {
  196. D3DLIGHTTYPE dltType; /* Type of light source */
  197. D3DCOLORVALUE dcvDiffuse; /* Diffuse color of light */
  198. D3DCOLORVALUE dcvSpecular; /* Specular color of light */
  199. D3DCOLORVALUE dcvAmbient; /* Ambient color of light */
  200. D3DVECTOR dvPosition; /* Position in world space */
  201. D3DVECTOR dvDirection; /* Direction in world space */
  202. D3DVALUE dvRange; /* Cutoff range */
  203. D3DVALUE dvFalloff; /* Falloff */
  204. D3DVALUE dvAttenuation0; /* Constant attenuation */
  205. D3DVALUE dvAttenuation1; /* Linear attenuation */
  206. D3DVALUE dvAttenuation2; /* Quadratic attenuation */
  207. D3DVALUE dvTheta; /* Inner angle of spotlight cone */
  208. D3DVALUE dvPhi; /* Outer angle of spotlight cone */
  209. } D3DLIGHT7, *LPD3DLIGHT7;
  210. typedef struct _D3DLIGHTDATA {
  211. DWORD dwSize;
  212. LPD3DLIGHTINGELEMENT lpIn; /* Input positions and normals */
  213. DWORD dwInSize; /* Stride of input elements */
  214. D3DTLVERTEX* lpOut; /* Output colors */
  215. DWORD dwOutSize; /* Stride of output colors */
  216. } D3DLIGHTDATA, *LPD3DLIGHTDATA;
  217. /*
  218. * Before DX5, these values were in an enum called
  219. * D3DCOLORMODEL. This was not correct, since they are
  220. * bit flags. A driver can surface either or both flags
  221. * in the dcmColorModel member of D3DDEVICEDESC.
  222. */
  223. #define D3DCOLOR_MONO 1
  224. #define D3DCOLOR_RGB 2
  225. typedef DWORD D3DCOLORMODEL;
  226. typedef enum _D3DTEXTUREFILTER {
  227. D3DFILTER_NEAREST = 1,
  228. D3DFILTER_LINEAR = 2,
  229. D3DFILTER_MIPNEAREST = 3,
  230. D3DFILTER_MIPLINEAR = 4,
  231. D3DFILTER_LINEARMIPNEAREST = 5,
  232. D3DFILTER_LINEARMIPLINEAR = 6,
  233. D3DFILTER_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  234. } D3DTEXTUREFILTER;
  235. typedef enum _D3DTEXTUREBLEND {
  236. D3DTBLEND_DECAL = 1,
  237. D3DTBLEND_MODULATE = 2,
  238. D3DTBLEND_DECALALPHA = 3,
  239. D3DTBLEND_MODULATEALPHA = 4,
  240. D3DTBLEND_DECALMASK = 5,
  241. D3DTBLEND_MODULATEMASK = 6,
  242. D3DTBLEND_COPY = 7,
  243. D3DTBLEND_ADD = 8,
  244. D3DTBLEND_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  245. } D3DTEXTUREBLEND;
  246. typedef enum _D3DANTIALIASMODE {
  247. D3DANTIALIAS_NONE = 0,
  248. D3DANTIALIAS_SORTDEPENDENT = 1,
  249. D3DANTIALIAS_SORTINDEPENDENT = 2,
  250. D3DANTIALIAS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  251. } D3DANTIALIASMODE;
  252. /*
  253. * Amount to add to a state to generate the override for that state.
  254. */
  255. #define D3DSTATE_OVERRIDE_BIAS 256
  256. /*
  257. * A state which sets the override flag for the specified state type.
  258. */
  259. #define D3DSTATE_OVERRIDE(type) (D3DRENDERSTATETYPE)(((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS))
  260. /*
  261. * Execute buffers are allocated via Direct3D. These buffers may then
  262. * be filled by the application with instructions to execute along with
  263. * vertex data.
  264. */
  265. /*
  266. * Supported op codes for execute instructions.
  267. */
  268. typedef enum _D3DOPCODE {
  269. D3DOP_POINT = 1,
  270. D3DOP_LINE = 2,
  271. D3DOP_TRIANGLE = 3,
  272. D3DOP_MATRIXLOAD = 4,
  273. D3DOP_MATRIXMULTIPLY = 5,
  274. D3DOP_STATETRANSFORM = 6,
  275. D3DOP_STATELIGHT = 7,
  276. D3DOP_STATERENDER = 8,
  277. D3DOP_PROCESSVERTICES = 9,
  278. D3DOP_TEXTURELOAD = 10,
  279. D3DOP_EXIT = 11,
  280. D3DOP_BRANCHFORWARD = 12,
  281. D3DOP_SPAN = 13,
  282. D3DOP_SETSTATUS = 14,
  283. D3DOP_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  284. } D3DOPCODE;
  285. typedef struct _D3DINSTRUCTION {
  286. BYTE bOpcode; /* Instruction opcode */
  287. BYTE bSize; /* Size of each instruction data unit */
  288. WORD wCount; /* Count of instruction data units to follow */
  289. } D3DINSTRUCTION, *LPD3DINSTRUCTION;
  290. /*
  291. * Structure for texture loads
  292. */
  293. typedef struct _D3DTEXTURELOAD {
  294. D3DTEXTUREHANDLE hDestTexture;
  295. D3DTEXTUREHANDLE hSrcTexture;
  296. } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
  297. /*
  298. * Structure for picking
  299. */
  300. typedef struct _D3DPICKRECORD {
  301. BYTE bOpcode;
  302. BYTE bPad;
  303. DWORD dwOffset;
  304. D3DVALUE dvZ;
  305. } D3DPICKRECORD, *LPD3DPICKRECORD;
  306. // Vertex types supported by Direct3D
  307. typedef enum _D3DVERTEXTYPE {
  308. D3DVT_VERTEX = 1,
  309. D3DVT_LVERTEX = 2,
  310. D3DVT_TLVERTEX = 3,
  311. D3DVT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  312. } D3DVERTEXTYPE;
  313. typedef enum _D3DLIGHTSTATETYPE {
  314. D3DLIGHTSTATE_MATERIAL = 1,
  315. D3DLIGHTSTATE_AMBIENT = 2,
  316. D3DLIGHTSTATE_COLORMODEL = 3,
  317. D3DLIGHTSTATE_FOGMODE = 4,
  318. D3DLIGHTSTATE_FOGSTART = 5,
  319. D3DLIGHTSTATE_FOGEND = 6,
  320. D3DLIGHTSTATE_FOGDENSITY = 7,
  321. D3DLIGHTSTATE_COLORVERTEX = 8,
  322. D3DLIGHTSTATE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
  323. } D3DLIGHTSTATETYPE;
  324. //
  325. // retired renderstates - not supported for DX7 interfaces
  326. //
  327. #define D3DRENDERSTATE_TEXTUREHANDLE (D3DRENDERSTATETYPE)1
  328. #define D3DRENDERSTATE_ANTIALIAS (D3DRENDERSTATETYPE)2
  329. #define D3DRENDERSTATE_TEXTUREADDRESS (D3DRENDERSTATETYPE)3
  330. #define D3DRENDERSTATE_WRAPU (D3DRENDERSTATETYPE)5
  331. #define D3DRENDERSTATE_WRAPV (D3DRENDERSTATETYPE)6
  332. #define D3DRENDERSTATE_MONOENABLE (D3DRENDERSTATETYPE)11
  333. #define D3DRENDERSTATE_ROP2 (D3DRENDERSTATETYPE)12
  334. #define D3DRENDERSTATE_PLANEMASK (D3DRENDERSTATETYPE)13
  335. #define D3DRENDERSTATE_TEXTUREMAG (D3DRENDERSTATETYPE)17
  336. #define D3DRENDERSTATE_TEXTUREMIN (D3DRENDERSTATETYPE)18
  337. #define D3DRENDERSTATE_TEXTUREMAPBLEND (D3DRENDERSTATETYPE)21
  338. #define D3DRENDERSTATE_SUBPIXEL (D3DRENDERSTATETYPE)31
  339. #define D3DRENDERSTATE_SUBPIXELX (D3DRENDERSTATETYPE)32
  340. #define D3DRENDERSTATE_STIPPLEENABLE (D3DRENDERSTATETYPE)39
  341. #define D3DRENDERSTATE_OLDALPHABLENDENABLE (D3DRENDERSTATETYPE)42
  342. #define D3DRENDERSTATE_BORDERCOLOR (D3DRENDERSTATETYPE)43
  343. #define D3DRENDERSTATE_TEXTUREADDRESSU (D3DRENDERSTATETYPE)44
  344. #define D3DRENDERSTATE_TEXTUREADDRESSV (D3DRENDERSTATETYPE)45
  345. #define D3DRENDERSTATE_MIPMAPLODBIAS (D3DRENDERSTATETYPE)46
  346. #define D3DRENDERSTATE_ANISOTROPY (D3DRENDERSTATETYPE)49
  347. #define D3DRENDERSTATE_FLUSHBATCH (D3DRENDERSTATETYPE)50
  348. #define D3DRENDERSTATE_TRANSLUCENTSORTINDEPENDENT (D3DRENDERSTATETYPE)51
  349. #define D3DRENDERSTATE_STIPPLEPATTERN00 (D3DRENDERSTATETYPE)64
  350. #define D3DRENDERSTATE_STIPPLEPATTERN01 (D3DRENDERSTATETYPE)65
  351. #define D3DRENDERSTATE_STIPPLEPATTERN02 (D3DRENDERSTATETYPE)66
  352. #define D3DRENDERSTATE_STIPPLEPATTERN03 (D3DRENDERSTATETYPE)67
  353. #define D3DRENDERSTATE_STIPPLEPATTERN04 (D3DRENDERSTATETYPE)68
  354. #define D3DRENDERSTATE_STIPPLEPATTERN05 (D3DRENDERSTATETYPE)69
  355. #define D3DRENDERSTATE_STIPPLEPATTERN06 (D3DRENDERSTATETYPE)70
  356. #define D3DRENDERSTATE_STIPPLEPATTERN07 (D3DRENDERSTATETYPE)71
  357. #define D3DRENDERSTATE_STIPPLEPATTERN08 (D3DRENDERSTATETYPE)72
  358. #define D3DRENDERSTATE_STIPPLEPATTERN09 (D3DRENDERSTATETYPE)73
  359. #define D3DRENDERSTATE_STIPPLEPATTERN10 (D3DRENDERSTATETYPE)74
  360. #define D3DRENDERSTATE_STIPPLEPATTERN11 (D3DRENDERSTATETYPE)75
  361. #define D3DRENDERSTATE_STIPPLEPATTERN12 (D3DRENDERSTATETYPE)76
  362. #define D3DRENDERSTATE_STIPPLEPATTERN13 (D3DRENDERSTATETYPE)77
  363. #define D3DRENDERSTATE_STIPPLEPATTERN14 (D3DRENDERSTATETYPE)78
  364. #define D3DRENDERSTATE_STIPPLEPATTERN15 (D3DRENDERSTATETYPE)79
  365. #define D3DRENDERSTATE_STIPPLEPATTERN16 (D3DRENDERSTATETYPE)80
  366. #define D3DRENDERSTATE_STIPPLEPATTERN17 (D3DRENDERSTATETYPE)81
  367. #define D3DRENDERSTATE_STIPPLEPATTERN18 (D3DRENDERSTATETYPE)82
  368. #define D3DRENDERSTATE_STIPPLEPATTERN19 (D3DRENDERSTATETYPE)83
  369. #define D3DRENDERSTATE_STIPPLEPATTERN20 (D3DRENDERSTATETYPE)84
  370. #define D3DRENDERSTATE_STIPPLEPATTERN21 (D3DRENDERSTATETYPE)85
  371. #define D3DRENDERSTATE_STIPPLEPATTERN22 (D3DRENDERSTATETYPE)86
  372. #define D3DRENDERSTATE_STIPPLEPATTERN23 (D3DRENDERSTATETYPE)87
  373. #define D3DRENDERSTATE_STIPPLEPATTERN24 (D3DRENDERSTATETYPE)88
  374. #define D3DRENDERSTATE_STIPPLEPATTERN25 (D3DRENDERSTATETYPE)89
  375. #define D3DRENDERSTATE_STIPPLEPATTERN26 (D3DRENDERSTATETYPE)90
  376. #define D3DRENDERSTATE_STIPPLEPATTERN27 (D3DRENDERSTATETYPE)91
  377. #define D3DRENDERSTATE_STIPPLEPATTERN28 (D3DRENDERSTATETYPE)92
  378. #define D3DRENDERSTATE_STIPPLEPATTERN29 (D3DRENDERSTATETYPE)93
  379. #define D3DRENDERSTATE_STIPPLEPATTERN30 (D3DRENDERSTATETYPE)94
  380. #define D3DRENDERSTATE_STIPPLEPATTERN31 (D3DRENDERSTATETYPE)95
  381. //
  382. // retired renderstates - not supported for DX8 interfaces
  383. //
  384. #define D3DRENDERSTATE_COLORKEYENABLE (D3DRENDERSTATETYPE)41
  385. #define D3DRENDERSTATE_COLORKEYBLENDENABLE (D3DRENDERSTATETYPE)144
  386. //
  387. // retired renderstate names - the values are still used under new naming conventions
  388. //
  389. #define D3DRENDERSTATE_BLENDENABLE (D3DRENDERSTATETYPE)27
  390. #define D3DRENDERSTATE_FOGTABLESTART (D3DRENDERSTATETYPE)36
  391. #define D3DRENDERSTATE_FOGTABLEEND (D3DRENDERSTATETYPE)37
  392. #define D3DRENDERSTATE_FOGTABLEDENSITY (D3DRENDERSTATETYPE)38
  393. #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
  394. typedef struct _D3DSTATE {
  395. union {
  396. D3DTRANSFORMSTATETYPE dtstTransformStateType;
  397. D3DLIGHTSTATETYPE dlstLightStateType;
  398. D3DRENDERSTATETYPE drstRenderStateType;
  399. };
  400. union {
  401. DWORD dwArg[1];
  402. D3DVALUE dvArg[1];
  403. };
  404. } D3DSTATE, *LPD3DSTATE;
  405. /*
  406. * Operation used to load matrices
  407. * hDstMat = hSrcMat
  408. */
  409. typedef struct _D3DMATRIXLOAD {
  410. D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
  411. D3DMATRIXHANDLE hSrcMatrix; /* Source matrix */
  412. } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
  413. /*
  414. * Operation used to multiply matrices
  415. * hDstMat = hSrcMat1 * hSrcMat2
  416. */
  417. typedef struct _D3DMATRIXMULTIPLY {
  418. D3DMATRIXHANDLE hDestMatrix; /* Destination matrix */
  419. D3DMATRIXHANDLE hSrcMatrix1; /* First source matrix */
  420. D3DMATRIXHANDLE hSrcMatrix2; /* Second source matrix */
  421. } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
  422. /*
  423. * Operation used to transform and light vertices.
  424. */
  425. typedef struct _D3DPROCESSVERTICES {
  426. DWORD dwFlags; /* Do we transform or light or just copy? */
  427. WORD wStart; /* Index to first vertex in source */
  428. WORD wDest; /* Index to first vertex in local buffer */
  429. DWORD dwCount; /* Number of vertices to be processed */
  430. DWORD dwReserved; /* Must be zero */
  431. } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
  432. #define D3DPROCESSVERTICES_TRANSFORMLIGHT 0x00000000L
  433. #define D3DPROCESSVERTICES_TRANSFORM 0x00000001L
  434. #define D3DPROCESSVERTICES_COPY 0x00000002L
  435. #define D3DPROCESSVERTICES_OPMASK 0x00000007L
  436. #define D3DPROCESSVERTICES_UPDATEEXTENTS 0x00000008L
  437. #define D3DPROCESSVERTICES_NOCOLOR 0x00000010L
  438. /*
  439. * Triangle flags
  440. */
  441. /*
  442. * Tri strip and fan flags.
  443. * START loads all three vertices
  444. * EVEN and ODD load just v3 with even or odd culling
  445. * START_FLAT contains a count from 0 to 29 that allows the
  446. * whole strip or fan to be culled in one hit.
  447. * e.g. for a quad len = 1
  448. */
  449. #define D3DTRIFLAG_START 0x00000000L
  450. #define D3DTRIFLAG_STARTFLAT(len) (len) /* 0 < len < 30 */
  451. #define D3DTRIFLAG_ODD 0x0000001eL
  452. #define D3DTRIFLAG_EVEN 0x0000001fL
  453. /*
  454. * Triangle edge flags
  455. * enable edges for wireframe or antialiasing
  456. */
  457. #define D3DTRIFLAG_EDGEENABLE1 0x00000100L /* v0-v1 edge */
  458. #define D3DTRIFLAG_EDGEENABLE2 0x00000200L /* v1-v2 edge */
  459. #define D3DTRIFLAG_EDGEENABLE3 0x00000400L /* v2-v0 edge */
  460. #define D3DTRIFLAG_EDGEENABLETRIANGLE \
  461. (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
  462. /*
  463. * Primitive structures and related defines. Vertex offsets are to types
  464. * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
  465. */
  466. /*
  467. * Triangle list primitive structure
  468. */
  469. typedef struct _D3DTRIANGLE {
  470. union {
  471. WORD v1; /* Vertex indices */
  472. WORD wV1;
  473. };
  474. union {
  475. WORD v2;
  476. WORD wV2;
  477. };
  478. union {
  479. WORD v3;
  480. WORD wV3;
  481. };
  482. WORD wFlags; /* Edge (and other) flags */
  483. } D3DTRIANGLE, *LPD3DTRIANGLE;
  484. /*
  485. * Line list structure.
  486. * The instruction count defines the number of line segments.
  487. */
  488. typedef struct _D3DLINE {
  489. union {
  490. WORD v1; /* Vertex indices */
  491. WORD wV1;
  492. };
  493. union {
  494. WORD v2;
  495. WORD wV2;
  496. };
  497. } D3DLINE, *LPD3DLINE;
  498. /*
  499. * Span structure
  500. * Spans join a list of points with the same y value.
  501. * If the y value changes, a new span is started.
  502. */
  503. typedef struct _D3DSPAN {
  504. WORD wCount; /* Number of spans */
  505. WORD wFirst; /* Index to first vertex */
  506. } D3DSPAN, *LPD3DSPAN;
  507. /*
  508. * Point structure
  509. */
  510. typedef struct _D3DPOINT {
  511. WORD wCount; /* number of points */
  512. WORD wFirst; /* index to first vertex */
  513. } D3DPOINT, *LPD3DPOINT;
  514. /*
  515. * Forward branch structure.
  516. * Mask is logically anded with the driver status mask
  517. * if the result equals 'value', the branch is taken.
  518. */
  519. typedef struct _D3DBRANCH {
  520. DWORD dwMask; /* Bitmask against D3D status */
  521. DWORD dwValue;
  522. BOOL bNegate; /* TRUE to negate comparison */
  523. DWORD dwOffset; /* How far to branch forward (0 for exit)*/
  524. } D3DBRANCH, *LPD3DBRANCH;
  525. /*
  526. * Status used for set status instruction.
  527. * The D3D status is initialised on device creation
  528. * and is modified by all execute calls.
  529. */
  530. typedef struct _D3DSTATUS {
  531. DWORD dwFlags; /* Do we set extents or status */
  532. DWORD dwStatus; /* D3D status */
  533. D3DRECT drExtent;
  534. } D3DSTATUS, *LPD3DSTATUS;
  535. #define D3DSETSTATUS_STATUS 0x00000001L
  536. #define D3DSETSTATUS_EXTENTS 0x00000002L
  537. #define D3DSETSTATUS_ALL (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
  538. /*
  539. * Statistics structure
  540. */
  541. typedef struct _D3DSTATS {
  542. DWORD dwSize;
  543. DWORD dwTrianglesDrawn;
  544. DWORD dwLinesDrawn;
  545. DWORD dwPointsDrawn;
  546. DWORD dwSpansDrawn;
  547. DWORD dwVerticesProcessed;
  548. } D3DSTATS, *LPD3DSTATS;
  549. /*
  550. * Execute options.
  551. * When calling using D3DEXECUTE_UNCLIPPED all the primitives
  552. * inside the buffer must be contained within the viewport.
  553. */
  554. #define D3DEXECUTE_CLIPPED 0x00000001l
  555. #define D3DEXECUTE_UNCLIPPED 0x00000002l
  556. typedef struct _D3DEXECUTEDATA {
  557. DWORD dwSize;
  558. DWORD dwVertexOffset;
  559. DWORD dwVertexCount;
  560. DWORD dwInstructionOffset;
  561. DWORD dwInstructionLength;
  562. DWORD dwHVertexOffset;
  563. D3DSTATUS dsStatus; /* Status after execute */
  564. } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
  565. //
  566. // Values for texture stage states
  567. //
  568. typedef enum _D3DTEXTUREMAGFILTER
  569. {
  570. D3DTFG_POINT = 1, // nearest
  571. D3DTFG_LINEAR = 2, // linear interpolation
  572. D3DTFG_FLATCUBIC = 3, // cubic
  573. D3DTFG_GAUSSIANCUBIC = 4, // different cubic kernel
  574. D3DTFG_ANISOTROPIC = 5, //
  575. D3DTFG_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  576. } D3DTEXTUREMAGFILTER;
  577. typedef enum _D3DTEXTUREMINFILTER
  578. {
  579. D3DTFN_POINT = 1, // nearest
  580. D3DTFN_LINEAR = 2, // linear interpolation
  581. D3DTFN_ANISOTROPIC = 3, //
  582. D3DTFN_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  583. } D3DTEXTUREMINFILTER;
  584. typedef enum _D3DTEXTUREMIPFILTER
  585. {
  586. D3DTFP_NONE = 1, // mipmapping disabled (use MAG filter)
  587. D3DTFP_POINT = 2, // nearest
  588. D3DTFP_LINEAR = 3, // linear interpolation
  589. D3DTFP_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
  590. } D3DTEXTUREMIPFILTER;
  591. /*
  592. * Palette flags.
  593. * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
  594. */
  595. #define D3DPAL_FREE 0x00 /* Renderer may use this entry freely */
  596. #define D3DPAL_READONLY 0x40 /* Renderer may not set this entry */
  597. #define D3DPAL_RESERVED 0x80 /* Renderer may not use this entry */
  598. typedef struct _D3DPrimCaps {
  599. DWORD dwSize;
  600. DWORD dwMiscCaps; /* Capability flags */
  601. DWORD dwRasterCaps;
  602. DWORD dwZCmpCaps;
  603. DWORD dwSrcBlendCaps;
  604. DWORD dwDestBlendCaps;
  605. DWORD dwAlphaCmpCaps;
  606. DWORD dwShadeCaps;
  607. DWORD dwTextureCaps;
  608. DWORD dwTextureFilterCaps;
  609. DWORD dwTextureBlendCaps;
  610. DWORD dwTextureAddressCaps;
  611. DWORD dwStippleWidth; /* maximum width and height of */
  612. DWORD dwStippleHeight; /* of supported stipple (up to 32x32) */
  613. } D3DPRIMCAPS, *LPD3DPRIMCAPS;
  614. #define D3DPMISCCAPS_MASKPLANES 0x00000001L
  615. #define D3DPMISCCAPS_CONFORMANT 0x00000008L
  616. #define D3DPRASTERCAPS_SUBPIXEL 0x00000020L
  617. #define D3DPRASTERCAPS_SUBPIXELX 0x00000040L
  618. #define D3DPRASTERCAPS_STIPPLE 0x00000200L
  619. #define D3DPRASTERCAPS_ANTIALIASSORTDEPENDENT 0x00000400L
  620. #define D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT 0x00000800L
  621. #define D3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT 0x00080000L
  622. #define D3DPSHADECAPS_COLORFLATMONO 0x00000001L
  623. #define D3DPSHADECAPS_COLORFLATRGB 0x00000002L
  624. #define D3DPSHADECAPS_COLORGOURAUDMONO 0x00000004L
  625. #define D3DPSHADECAPS_COLORPHONGMONO 0x00000010L
  626. #define D3DPSHADECAPS_COLORPHONGRGB 0x00000020L
  627. #define D3DPSHADECAPS_SPECULARFLATMONO 0x00000040L
  628. #define D3DPSHADECAPS_SPECULARFLATRGB 0x00000080L
  629. #define D3DPSHADECAPS_SPECULARGOURAUDMONO 0x00000100L
  630. #define D3DPSHADECAPS_SPECULARPHONGMONO 0x00000400L
  631. #define D3DPSHADECAPS_SPECULARPHONGRGB 0x00000800L
  632. #define D3DPSHADECAPS_ALPHAFLATBLEND 0x00001000L
  633. #define D3DPSHADECAPS_ALPHAFLATSTIPPLED 0x00002000L
  634. #define D3DPSHADECAPS_ALPHAGOURAUDSTIPPLED 0x00008000L
  635. #define D3DPSHADECAPS_ALPHAPHONGBLEND 0x00010000L
  636. #define D3DPSHADECAPS_ALPHAPHONGSTIPPLED 0x00020000L
  637. #define D3DPSHADECAPS_FOGFLAT 0x00040000L
  638. #define D3DPSHADECAPS_FOGPHONG 0x00100000L
  639. #define D3DPTEXTURECAPS_BORDER 0x00000010L
  640. #define D3DPTEXTURECAPS_COLORKEYBLEND 0x00001000L
  641. #define D3DPTFILTERCAPS_NEAREST 0x00000001L
  642. #define D3DPTFILTERCAPS_LINEAR 0x00000002L
  643. #define D3DPTFILTERCAPS_MIPNEAREST 0x00000004L
  644. #define D3DPTFILTERCAPS_MIPLINEAR 0x00000008L
  645. #define D3DPTFILTERCAPS_LINEARMIPNEAREST 0x00000010L
  646. #define D3DPTFILTERCAPS_LINEARMIPLINEAR 0x00000020L
  647. #define D3DPTBLENDCAPS_DECAL 0x00000001L
  648. #define D3DPTBLENDCAPS_MODULATE 0x00000002L
  649. #define D3DPTBLENDCAPS_DECALALPHA 0x00000004L
  650. #define D3DPTBLENDCAPS_MODULATEALPHA 0x00000008L
  651. #define D3DPTBLENDCAPS_DECALMASK 0x00000010L
  652. #define D3DPTBLENDCAPS_MODULATEMASK 0x00000020L
  653. #define D3DPTBLENDCAPS_COPY 0x00000040L
  654. #define D3DPTBLENDCAPS_ADD 0x00000080L
  655. #define D3DDEVCAPS_FLOATTLVERTEX 0x00000001L
  656. #define D3DDEVCAPS_SORTINCREASINGZ 0x00000002L
  657. #define D3DDEVCAPS_SORTDECREASINGZ 0X00000004L
  658. #define D3DDEVCAPS_SORTEXACT 0x00000008L
  659. /* Description of capabilities of transform */
  660. typedef struct _D3DTRANSFORMCAPS {
  661. DWORD dwSize;
  662. DWORD dwCaps;
  663. } D3DTRANSFORMCAPS, *LPD3DTRANSFORMCAPS;
  664. #define D3DTRANSFORMCAPS_CLIP 0x00000001L /* Will clip whilst transforming */
  665. /* Description of capabilities of lighting */
  666. typedef struct _D3DLIGHTINGCAPS {
  667. DWORD dwSize;
  668. DWORD dwCaps; /* Lighting caps */
  669. DWORD dwLightingModel; /* Lighting model - RGB or mono */
  670. DWORD dwNumLights; /* Number of lights that can be handled */
  671. } D3DLIGHTINGCAPS, *LPD3DLIGHTINGCAPS;
  672. #define D3DLIGHTINGMODEL_RGB 0x00000001L
  673. #define D3DLIGHTINGMODEL_MONO 0x00000002L
  674. #define D3DLIGHTCAPS_POINT 0x00000001L /* Point lights supported */
  675. #define D3DLIGHTCAPS_SPOT 0x00000002L /* Spot lights supported */
  676. #define D3DLIGHTCAPS_DIRECTIONAL 0x00000004L /* Directional lights supported */
  677. #define D3DLIGHTCAPS_PARALLELPOINT 0x00000008L /* Parallel point lights supported */
  678. #define D3DLIGHTCAPS_GLSPOT 0x00000010L /* GL syle spot lights supported */
  679. /*
  680. * Description for a device.
  681. * This is used to describe a device that is to be created or to query
  682. * the current device.
  683. */
  684. typedef struct _D3DDeviceDesc {
  685. DWORD dwSize; /* Size of D3DDEVICEDESC structure */
  686. DWORD dwFlags; /* Indicates which fields have valid data */
  687. D3DCOLORMODEL dcmColorModel; /* Color model of device */
  688. DWORD dwDevCaps; /* Capabilities of device */
  689. D3DTRANSFORMCAPS dtcTransformCaps; /* Capabilities of transform */
  690. BOOL bClipping; /* Device can do 3D clipping */
  691. D3DLIGHTINGCAPS dlcLightingCaps; /* Capabilities of lighting */
  692. D3DPRIMCAPS dpcLineCaps;
  693. D3DPRIMCAPS dpcTriCaps;
  694. DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */
  695. DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
  696. DWORD dwMaxBufferSize; /* Maximum execute buffer size */
  697. DWORD dwMaxVertexCount; /* Maximum vertex count */
  698. // *** New fields for DX5 *** //
  699. // Width and height caps are 0 for legacy HALs.
  700. DWORD dwMinTextureWidth, dwMinTextureHeight;
  701. DWORD dwMaxTextureWidth, dwMaxTextureHeight;
  702. DWORD dwMinStippleWidth, dwMaxStippleWidth;
  703. DWORD dwMinStippleHeight, dwMaxStippleHeight;
  704. // New fields for DX6
  705. DWORD dwMaxTextureRepeat;
  706. DWORD dwMaxTextureAspectRatio;
  707. DWORD dwMaxAnisotropy;
  708. // Guard band that the rasterizer can accommodate
  709. // Screen-space vertices inside this space but outside the viewport
  710. // will get clipped properly.
  711. D3DVALUE dvGuardBandLeft;
  712. D3DVALUE dvGuardBandTop;
  713. D3DVALUE dvGuardBandRight;
  714. D3DVALUE dvGuardBandBottom;
  715. D3DVALUE dvExtentsAdjust;
  716. DWORD dwStencilCaps;
  717. DWORD dwFVFCaps;
  718. DWORD dwTextureOpCaps;
  719. WORD wMaxTextureBlendStages;
  720. WORD wMaxSimultaneousTextures;
  721. } D3DDEVICEDESC, *LPD3DDEVICEDESC;
  722. #define D3DDEVICEDESCSIZE (sizeof(D3DDEVICEDESC))
  723. typedef struct _D3DDeviceDesc7 {
  724. DWORD dwDevCaps; /* Capabilities of device */
  725. D3DPRIMCAPS dpcLineCaps;
  726. D3DPRIMCAPS dpcTriCaps;
  727. DWORD dwDeviceRenderBitDepth; /* One of DDBB_8, 16, etc.. */
  728. DWORD dwDeviceZBufferBitDepth;/* One of DDBD_16, 32, etc.. */
  729. DWORD dwMinTextureWidth, dwMinTextureHeight;
  730. DWORD dwMaxTextureWidth, dwMaxTextureHeight;
  731. DWORD dwMaxTextureRepeat;
  732. DWORD dwMaxTextureAspectRatio;
  733. DWORD dwMaxAnisotropy;
  734. D3DVALUE dvGuardBandLeft;
  735. D3DVALUE dvGuardBandTop;
  736. D3DVALUE dvGuardBandRight;
  737. D3DVALUE dvGuardBandBottom;
  738. D3DVALUE dvExtentsAdjust;
  739. DWORD dwStencilCaps;
  740. DWORD dwFVFCaps;
  741. DWORD dwTextureOpCaps;
  742. WORD wMaxTextureBlendStages;
  743. WORD wMaxSimultaneousTextures;
  744. DWORD dwMaxActiveLights;
  745. D3DVALUE dvMaxVertexW;
  746. GUID deviceGUID;
  747. WORD wMaxUserClipPlanes;
  748. WORD wMaxVertexBlendMatrices;
  749. DWORD dwVertexProcessingCaps;
  750. DWORD dwReserved1;
  751. DWORD dwReserved2;
  752. DWORD dwReserved3;
  753. DWORD dwReserved4;
  754. } D3DDEVICEDESC7, *LPD3DDEVICEDESC7;
  755. #define D3DDEVICEDESC7SIZE (sizeof(D3DDEVICEDESC7))
  756. typedef struct _D3DDP_PTRSTRIDE
  757. {
  758. LPVOID lpvData;
  759. DWORD dwStride;
  760. } D3DDP_PTRSTRIDE;
  761. #pragma pack()
  762. #pragma warning(default:4201)
  763. #endif /* _D3DLEGACY_H_ */