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.

403 lines
13 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3drm.h
  6. * Content: Direct3DRM include file
  7. *
  8. ***************************************************************************/
  9. #ifndef __D3DRMDEFS_H__
  10. #define __D3DRMDEFS_H__
  11. #include <stddef.h>
  12. #include "d3dtypes.h"
  13. #ifdef WIN32
  14. #define D3DRMAPI __stdcall
  15. #else
  16. #define D3DRMAPI
  17. #endif
  18. #if defined(__cplusplus)
  19. extern "C" {
  20. #endif
  21. #ifndef TRUE
  22. #define FALSE 0
  23. #define TRUE 1
  24. #endif
  25. typedef struct _D3DRMVECTOR4D
  26. { D3DVALUE x, y, z, w;
  27. } D3DRMVECTOR4D, *LPD3DRMVECTOR4D;
  28. typedef D3DVALUE D3DRMMATRIX4D[4][4];
  29. typedef struct _D3DRMQUATERNION
  30. { D3DVALUE s;
  31. D3DVECTOR v;
  32. } D3DRMQUATERNION, *LPD3DRMQUATERNION;
  33. typedef struct _D3DRMBOX
  34. { D3DVECTOR min, max;
  35. } D3DRMBOX, *LPD3DRMBOX;
  36. typedef void (*D3DRMWRAPCALLBACK)
  37. (LPD3DVECTOR, int* u, int* v, LPD3DVECTOR a, LPD3DVECTOR b, LPVOID);
  38. typedef enum _D3DRMLIGHTTYPE
  39. { D3DRMLIGHT_AMBIENT,
  40. D3DRMLIGHT_POINT,
  41. D3DRMLIGHT_SPOT,
  42. D3DRMLIGHT_DIRECTIONAL,
  43. D3DRMLIGHT_PARALLELPOINT
  44. } D3DRMLIGHTTYPE, *LPD3DRMLIGHTTYPE;
  45. typedef enum _D3DRMSHADEMODE {
  46. D3DRMSHADE_FLAT = 0,
  47. D3DRMSHADE_GOURAUD = 1,
  48. D3DRMSHADE_PHONG = 2,
  49. D3DRMSHADE_MASK = 7,
  50. D3DRMSHADE_MAX = 8
  51. } D3DRMSHADEMODE, *LPD3DRMSHADEMODE;
  52. typedef enum _D3DRMLIGHTMODE {
  53. D3DRMLIGHT_OFF = 0 * D3DRMSHADE_MAX,
  54. D3DRMLIGHT_ON = 1 * D3DRMSHADE_MAX,
  55. D3DRMLIGHT_MASK = 7 * D3DRMSHADE_MAX,
  56. D3DRMLIGHT_MAX = 8 * D3DRMSHADE_MAX
  57. } D3DRMLIGHTMODE, *LPD3DRMLIGHTMODE;
  58. typedef enum _D3DRMFILLMODE {
  59. D3DRMFILL_POINTS = 0 * D3DRMLIGHT_MAX,
  60. D3DRMFILL_WIREFRAME = 1 * D3DRMLIGHT_MAX,
  61. D3DRMFILL_SOLID = 2 * D3DRMLIGHT_MAX,
  62. D3DRMFILL_MASK = 7 * D3DRMLIGHT_MAX,
  63. D3DRMFILL_MAX = 8 * D3DRMLIGHT_MAX
  64. } D3DRMFILLMODE, *LPD3DRMFILLMODE;
  65. typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY;
  66. #define D3DRMRENDER_WIREFRAME (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_WIREFRAME)
  67. #define D3DRMRENDER_UNLITFLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_SOLID)
  68. #define D3DRMRENDER_FLAT (D3DRMSHADE_FLAT+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
  69. #define D3DRMRENDER_GOURAUD (D3DRMSHADE_GOURAUD+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
  70. #define D3DRMRENDER_PHONG (D3DRMSHADE_PHONG+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
  71. typedef enum _D3DRMTEXTUREQUALITY
  72. { D3DRMTEXTURE_NEAREST, /* choose nearest texel */
  73. D3DRMTEXTURE_LINEAR, /* interpolate 4 texels */
  74. D3DRMTEXTURE_MIPNEAREST, /* nearest texel in nearest mipmap */
  75. D3DRMTEXTURE_MIPLINEAR, /* interpolate 2 texels from 2 mipmaps */
  76. D3DRMTEXTURE_LINEARMIPNEAREST, /* interpolate 4 texels in nearest mipmap */
  77. D3DRMTEXTURE_LINEARMIPLINEAR /* interpolate 8 texels from 2 mipmaps */
  78. } D3DRMTEXTUREQUALITY, *LPD3DRMTEXTUREQUALITY;
  79. typedef enum _D3DRMCOMBINETYPE
  80. { D3DRMCOMBINE_REPLACE,
  81. D3DRMCOMBINE_BEFORE,
  82. D3DRMCOMBINE_AFTER
  83. } D3DRMCOMBINETYPE, *LPD3DRMCOMBINETYPE;
  84. typedef D3DCOLORMODEL D3DRMCOLORMODEL, *LPD3DRMCOLORMODEL;
  85. typedef enum _D3DRMPALETTEFLAGS
  86. { D3DRMPALETTE_FREE, /* renderer may use this entry freely */
  87. D3DRMPALETTE_READONLY, /* fixed but may be used by renderer */
  88. D3DRMPALETTE_RESERVED /* may not be used by renderer */
  89. } D3DRMPALETTEFLAGS, *LPD3DRMPALETTEFLAGS;
  90. typedef struct _D3DRMPALETTEENTRY
  91. { unsigned char red; /* 0 .. 255 */
  92. unsigned char green; /* 0 .. 255 */
  93. unsigned char blue; /* 0 .. 255 */
  94. unsigned char flags; /* one of D3DRMPALETTEFLAGS */
  95. } D3DRMPALETTEENTRY, *LPD3DRMPALETTEENTRY;
  96. typedef struct _D3DRMIMAGE
  97. { int width, height; /* width and height in pixels */
  98. int aspectx, aspecty; /* aspect ratio for non-square pixels */
  99. int depth; /* bits per pixel */
  100. int rgb; /* if false, pixels are indices into a
  101. palette otherwise, pixels encode
  102. RGB values. */
  103. int bytes_per_line; /* number of bytes of memory for a
  104. scanline. This must be a multiple
  105. of 4. */
  106. void* buffer1; /* memory to render into (first buffer). */
  107. void* buffer2; /* second rendering buffer for double
  108. buffering, set to NULL for single
  109. buffering. */
  110. unsigned long red_mask;
  111. unsigned long green_mask;
  112. unsigned long blue_mask;
  113. unsigned long alpha_mask; /* if rgb is true, these are masks for
  114. the red, green and blue parts of a
  115. pixel. Otherwise, these are masks
  116. for the significant bits of the
  117. red, green and blue elements in the
  118. palette. For instance, most SVGA
  119. displays use 64 intensities of red,
  120. green and blue, so the masks should
  121. all be set to 0xfc. */
  122. int palette_size; /* number of entries in palette */
  123. D3DRMPALETTEENTRY* palette; /* description of the palette (only if
  124. rgb is false). Must be (1<<depth)
  125. elements. */
  126. } D3DRMIMAGE, *LPD3DRMIMAGE;
  127. typedef enum _D3DRMWRAPTYPE
  128. { D3DRMWRAP_FLAT,
  129. D3DRMWRAP_CYLINDER,
  130. D3DRMWRAP_SPHERE,
  131. D3DRMWRAP_CHROME
  132. } D3DRMWRAPTYPE, *LPD3DRMWRAPTYPE;
  133. #define D3DRMWIREFRAME_CULL 1 /* cull backfaces */
  134. #define D3DRMWIREFRAME_HIDDENLINE 2 /* lines are obscured by closer objects */
  135. typedef enum _D3DRMPROJECTIONTYPE
  136. { D3DRMPROJECT_PERSPECTIVE,
  137. D3DRMPROJECT_ORTHOGRAPHIC
  138. } D3DRMPROJECTIONTYPE, *LPD3DRMPROJECTIONTYPE;
  139. typedef enum _D3DRMXOFFORMAT
  140. { D3DRMXOF_BINARY,
  141. D3DRMXOF_COMPRESSED,
  142. D3DRMXOF_TEXT
  143. } D3DRMXOFFORMAT, *LPD3DRMXOFFORMAT;
  144. typedef DWORD D3DRMSAVEOPTIONS;
  145. #define D3DRMXOFSAVE_NORMALS 1
  146. #define D3DRMXOFSAVE_TEXTURECOORDINATES 2
  147. #define D3DRMXOFSAVE_MATERIALS 4
  148. #define D3DRMXOFSAVE_TEXTURENAMES 8
  149. #define D3DRMXOFSAVE_ALL 15
  150. #define D3DRMXOFSAVE_TEMPLATES 16
  151. typedef enum _D3DRMCOLORSOURCE
  152. { D3DRMCOLOR_FROMFACE,
  153. D3DRMCOLOR_FROMVERTEX
  154. } D3DRMCOLORSOURCE, *LPD3DRMCOLORSOURCE;
  155. typedef enum _D3DRMFRAMECONSTRAINT
  156. { D3DRMCONSTRAIN_Z, /* use only X and Y rotations */
  157. D3DRMCONSTRAIN_Y, /* use only X and Z rotations */
  158. D3DRMCONSTRAIN_X /* use only Y and Z rotations */
  159. } D3DRMFRAMECONSTRAINT, *LPD3DRMFRAMECONSTRAINT;
  160. typedef enum _D3DRMMATERIALMODE
  161. { D3DRMMATERIAL_FROMMESH,
  162. D3DRMMATERIAL_FROMPARENT,
  163. D3DRMMATERIAL_FROMFRAME
  164. } D3DRMMATERIALMODE, *LPD3DRMMATERIALMODE;
  165. typedef enum _D3DRMFOGMODE
  166. { D3DRMFOG_LINEAR, /* linear between start and end */
  167. D3DRMFOG_EXPONENTIAL, /* density * exp(-distance) */
  168. D3DRMFOG_EXPONENTIALSQUARED /* density * exp(-distance*distance) */
  169. } D3DRMFOGMODE, *LPD3DRMFOGMODE;
  170. typedef enum _D3DRMZBUFFERMODE {
  171. D3DRMZBUFFER_FROMPARENT, /* default */
  172. D3DRMZBUFFER_ENABLE, /* enable zbuffering */
  173. D3DRMZBUFFER_DISABLE /* disable zbuffering */
  174. } D3DRMZBUFFERMODE, *LPD3DRMZBUFFERMODE;
  175. typedef enum _D3DRMSORTMODE {
  176. D3DRMSORT_FROMPARENT, /* default */
  177. D3DRMSORT_NONE, /* don't sort child frames */
  178. D3DRMSORT_FRONTTOBACK, /* sort child frames front-to-back */
  179. D3DRMSORT_BACKTOFRONT /* sort child frames back-to-front */
  180. } D3DRMSORTMODE, *LPD3DRMSORTMODE;
  181. typedef DWORD D3DRMANIMATIONOPTIONS;
  182. #define D3DRMANIMATION_OPEN 0x01L
  183. #define D3DRMANIMATION_CLOSED 0x02L
  184. #define D3DRMANIMATION_LINEARPOSITION 0x04L
  185. #define D3DRMANIMATION_SPLINEPOSITION 0x08L
  186. #define D3DRMANIMATION_SCALEANDROTATION 0x00000010L
  187. #define D3DRMANIMATION_POSITION 0x00000020L
  188. typedef DWORD D3DRMLOADOPTIONS;
  189. #define D3DRMLOAD_FROMFILE 0x00L
  190. #define D3DRMLOAD_FROMRESOURCE 0x01L
  191. #define D3DRMLOAD_FROMMEMORY 0x02L
  192. #define D3DRMLOAD_FROMSTREAM 0x04L
  193. #define D3DRMLOAD_BYNAME 0x10L
  194. #define D3DRMLOAD_BYPOSITION 0x20L
  195. #define D3DRMLOAD_BYGUID 0x40L
  196. #define D3DRMLOAD_FIRST 0x80L
  197. #define D3DRMLOAD_INSTANCEBYREFERENCE 0x100L
  198. #define D3DRMLOAD_INSTANCEBYCOPYING 0x200L
  199. typedef struct _D3DRMLOADRESOURCE {
  200. HMODULE hModule;
  201. LPCTSTR lpName;
  202. LPCTSTR lpType;
  203. } D3DRMLOADRESOURCE, *LPD3DRMLOADRESOURCE;
  204. typedef struct _D3DRMLOADMEMORY {
  205. LPVOID lpMemory;
  206. DWORD dSize;
  207. } D3DRMLOADMEMORY, *LPD3DRMLOADMEMORY;
  208. typedef enum _D3DRMUSERVISUALREASON {
  209. D3DRMUSERVISUAL_CANSEE,
  210. D3DRMUSERVISUAL_RENDER
  211. } D3DRMUSERVISUALREASON, *LPD3DRMUSERVISUALREASON;
  212. typedef DWORD D3DRMMAPPING, D3DRMMAPPINGFLAG, *LPD3DRMMAPPING;
  213. static const D3DRMMAPPINGFLAG D3DRMMAP_WRAPU = 1;
  214. static const D3DRMMAPPINGFLAG D3DRMMAP_WRAPV = 2;
  215. static const D3DRMMAPPINGFLAG D3DRMMAP_PERSPCORRECT = 4;
  216. typedef struct _D3DRMVERTEX
  217. { D3DVECTOR position;
  218. D3DVECTOR normal;
  219. D3DVALUE tu, tv;
  220. D3DCOLOR color;
  221. } D3DRMVERTEX, *LPD3DRMVERTEX;
  222. typedef LONG D3DRMGROUPINDEX; /* group indexes begin a 0 */
  223. static const D3DRMGROUPINDEX D3DRMGROUP_ALLGROUPS = -1;
  224. /*
  225. * Create a color from three components in the range 0-1 inclusive.
  226. */
  227. extern D3DCOLOR D3DRMAPI D3DRMCreateColorRGB(D3DVALUE red,
  228. D3DVALUE green,
  229. D3DVALUE blue);
  230. /*
  231. * Create a color from four components in the range 0-1 inclusive.
  232. */
  233. extern D3DCOLOR D3DRMAPI D3DRMCreateColorRGBA(D3DVALUE red,
  234. D3DVALUE green,
  235. D3DVALUE blue,
  236. D3DVALUE alpha);
  237. /*
  238. * Get the red component of a color.
  239. */
  240. extern D3DVALUE D3DRMAPI D3DRMColorGetRed(D3DCOLOR);
  241. /*
  242. * Get the green component of a color.
  243. */
  244. extern D3DVALUE D3DRMAPI D3DRMColorGetGreen(D3DCOLOR);
  245. /*
  246. * Get the blue component of a color.
  247. */
  248. extern D3DVALUE D3DRMAPI D3DRMColorGetBlue(D3DCOLOR);
  249. /*
  250. * Get the alpha component of a color.
  251. */
  252. extern D3DVALUE D3DRMAPI D3DRMColorGetAlpha(D3DCOLOR);
  253. /*
  254. * Add two vectors. Returns its first argument.
  255. */
  256. extern LPD3DVECTOR D3DRMAPI D3DRMVectorAdd(LPD3DVECTOR d,
  257. LPD3DVECTOR s1,
  258. LPD3DVECTOR s2);
  259. /*
  260. * Subtract two vectors. Returns its first argument.
  261. */
  262. extern LPD3DVECTOR D3DRMAPI D3DRMVectorSubtract(LPD3DVECTOR d,
  263. LPD3DVECTOR s1,
  264. LPD3DVECTOR s2);
  265. /*
  266. * Reflect a ray about a given normal. Returns its first argument.
  267. */
  268. extern LPD3DVECTOR D3DRMAPI D3DRMVectorReflect(LPD3DVECTOR d,
  269. LPD3DVECTOR ray,
  270. LPD3DVECTOR norm);
  271. /*
  272. * Calculate the vector cross product. Returns its first argument.
  273. */
  274. extern LPD3DVECTOR D3DRMAPI D3DRMVectorCrossProduct(LPD3DVECTOR d,
  275. LPD3DVECTOR s1,
  276. LPD3DVECTOR s2);
  277. /*
  278. * Return the vector dot product.
  279. */
  280. extern D3DVALUE D3DRMAPI D3DRMVectorDotProduct(LPD3DVECTOR s1,
  281. LPD3DVECTOR s2);
  282. /*
  283. * Scale a vector so that its modulus is 1. Returns its argument or
  284. * NULL if there was an error (e.g. a zero vector was passed).
  285. */
  286. extern LPD3DVECTOR D3DRMAPI D3DRMVectorNormalize(LPD3DVECTOR);
  287. #define D3DRMVectorNormalise D3DRMVectorNormalize
  288. /*
  289. * Return the length of a vector (e.g. sqrt(x*x + y*y + z*z)).
  290. */
  291. extern D3DVALUE D3DRMAPI D3DRMVectorModulus(LPD3DVECTOR v);
  292. /*
  293. * Set the rotation part of a matrix to be a rotation of theta radians
  294. * around the given axis.
  295. */
  296. extern LPD3DVECTOR D3DRMAPI D3DRMVectorRotate(LPD3DVECTOR r, LPD3DVECTOR v, LPD3DVECTOR axis, D3DVALUE theta);
  297. /*
  298. * Scale a vector uniformly in all three axes
  299. */
  300. extern LPD3DVECTOR D3DRMAPI D3DRMVectorScale(LPD3DVECTOR d, LPD3DVECTOR s, D3DVALUE factor);
  301. /*
  302. * Return a random unit vector
  303. */
  304. extern LPD3DVECTOR D3DRMAPI D3DRMVectorRandom(LPD3DVECTOR d);
  305. /*
  306. * Returns a unit quaternion that represents a rotation of theta radians
  307. * around the given axis.
  308. */
  309. extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionFromRotation(LPD3DRMQUATERNION quat,
  310. LPD3DVECTOR v,
  311. D3DVALUE theta);
  312. /*
  313. * Calculate the product of two quaternions
  314. */
  315. extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionMultiply(LPD3DRMQUATERNION q,
  316. LPD3DRMQUATERNION a,
  317. LPD3DRMQUATERNION b);
  318. /*
  319. * Interpolate between two quaternions
  320. */
  321. extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionSlerp(LPD3DRMQUATERNION q,
  322. LPD3DRMQUATERNION a,
  323. LPD3DRMQUATERNION b,
  324. D3DVALUE alpha);
  325. /*
  326. * Calculate the matrix for the rotation that a unit quaternion represents
  327. */
  328. extern void D3DRMAPI D3DRMMatrixFromQuaternion(D3DRMMATRIX4D dmMat, LPD3DRMQUATERNION lpDqQuat);
  329. #if defined(__cplusplus)
  330. };
  331. #endif
  332. #endif