Leaked source code of windows server 2003
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.

1027 lines
45 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: d3dxcore.h
  6. // Content: D3DX core types and functions
  7. //
  8. ///////////////////////////////////////////////////////////////////////////
  9. #ifndef __D3DXCORE_H__
  10. #define __D3DXCORE_H__
  11. #include <d3d.h>
  12. #include <limits.h>
  13. #include "d3dxerr.h"
  14. typedef struct ID3DXContext *LPD3DXCONTEXT;
  15. // {9B74ED7A-BBEF-11d2-9F8E-0000F8080835}
  16. DEFINE_GUID(IID_ID3DXContext,
  17. 0x9b74ed7a, 0xbbef, 0x11d2, 0x9f, 0x8e, 0x0, 0x0, 0xf8, 0x8, 0x8, 0x35);
  18. ///////////////////////////////////////////////////////////////////////////
  19. // Defines and Enumerators used below:
  20. ///////////////////////////////////////////////////////////////////////////
  21. //-------------------------------------------------------------------------
  22. // D3DX_DEFAULT:
  23. // ---------
  24. // A predefined value that could be used for any parameter in D3DX APIs or
  25. // member functions that is an enumerant or a handle. The D3DX
  26. // documentation indicates wherever D3DX_DEFAULT may be used,
  27. // and how it will be interpreted in each situation.
  28. //-------------------------------------------------------------------------
  29. #define D3DX_DEFAULT ULONG_MAX
  30. //-------------------------------------------------------------------------
  31. // D3DX_DEFAULT_FLOAT:
  32. // ------------------
  33. // Similar to D3DX_DEFAULT, but used for floating point parameters.
  34. // The D3DX documentation indicates wherever D3DX_DEFAULT_FLOAT may be used,
  35. // and how it will be interpreted in each situation.
  36. //-------------------------------------------------------------------------
  37. #define D3DX_DEFAULT_FLOAT FLT_MAX
  38. //-------------------------------------------------------------------------
  39. // Hardware Acceleration Level:
  40. // ---------------------------
  41. // These constants represent pre-defined hardware acceleration levels,
  42. // and may be used as a default anywhere a (DWORD) deviceIndex is required.
  43. // Each pre-define indicates a different level of hardware acceleration.
  44. // They are an alternative to using explicit deviceIndices retrieved by
  45. // D3DXGetDeviceDescription().
  46. //
  47. // The only case these pre-defines should be used as device indices is if
  48. // a particular level of acceleration is required, and given more than
  49. // one capable device on the computer, it does not matter which one
  50. // is used.
  51. //
  52. // The method of selection is as follows: If one of the D3DX devices on
  53. // the primary DDraw device supports a requested hardware acceleration
  54. // level, it will be used. Otherwise, the first matching device discovered
  55. // by D3DX will be used.
  56. //
  57. // Of course, it is possible for no match to exist for any of the
  58. // pre-defines on a particular computer. Passing such a value into the
  59. // D3DX apis will simply cause them to fail, reporting that no match
  60. // is available.
  61. //
  62. // D3DX_HWLEVEL_NULL: Null implementation (draws nothing)
  63. // D3DX_HWLEVEL_REFERENCE: Reference implementation (slowest)
  64. // D3DX_HWLEVEL_2D: 2D acceleration only (RGB rasterizer used)
  65. // D3DX_HWLEVEL_RASTER: Rasterization acceleration (likely most useful)
  66. // D3DX_HWLEVEL_TL: Transform and lighting acceleration
  67. // D3DX_DEFAULT: The highest level of acceleration available
  68. // on the primary DDraw device.
  69. //-------------------------------------------------------------------------
  70. #define D3DX_HWLEVEL_NULL (D3DX_DEFAULT - 1)
  71. #define D3DX_HWLEVEL_REFERENCE (D3DX_DEFAULT - 2)
  72. #define D3DX_HWLEVEL_2D (D3DX_DEFAULT - 3)
  73. #define D3DX_HWLEVEL_RASTER (D3DX_DEFAULT - 4)
  74. #define D3DX_HWLEVEL_TL (D3DX_DEFAULT - 5)
  75. //-------------------------------------------------------------------------
  76. // Surface Class:
  77. // -------------
  78. // These are the various types of 2D-surfaces classified according to their
  79. // usage. Note that a number of them overlap. e.g. STENCILBUFFERS and
  80. // DEPTHBUFFERS overlap (since in DX7 implementation the stencil and depth
  81. // bits are part of the same pixel format).
  82. //
  83. // Mapping to the DX7 DDPIXELFORMAT concepts:
  84. // -----------------------------------------
  85. // D3DX_SC_DEPTHBUFFER: All ddpfs which have the DDPF_ZPIXELS or the
  86. // DDPF_ZBUFFER flags set.
  87. // D3DX_SC_STENCILBUFFER: All ddpfs which have the DDPF_STENCILBUFFER
  88. // flag set.
  89. // D3DX_SC_BUMPMAP: All ddpfs which have the DDPF_BUMPLUMINANCE
  90. // or the DDPF_BUMPDUDV flags set.
  91. // D3DX_SC_LUMINANCEMAP: All ddpfs which have the DDPF_BUMPLUMINANCE
  92. // or the DDPF_LUMINANCE flags set.
  93. // D3DX_SC_COLORTEXTURE: All the surfaces that have color information in
  94. // them and can be used for texturing.
  95. // D3DX_SC_COLORRENDERTGT: All the surfaces that contain color
  96. // information and can be used as render targets.
  97. //-------------------------------------------------------------------------
  98. #define D3DX_SC_DEPTHBUFFER 0x01
  99. #define D3DX_SC_STENCILBUFFER 0x02
  100. #define D3DX_SC_COLORTEXTURE 0x04
  101. #define D3DX_SC_BUMPMAP 0x08
  102. #define D3DX_SC_LUMINANCEMAP 0x10
  103. #define D3DX_SC_COLORRENDERTGT 0x20
  104. //-------------------------------------------------------------------------
  105. // Surface Formats:
  106. // ---------------
  107. // These are the various types of surface formats that can be enumerated,
  108. // there is no DDPIXELFORMAT structure in D3DX, the enums carry the meaning
  109. // (like FOURCCs).
  110. //
  111. // All the surface classes are represented here.
  112. //
  113. //-------------------------------------------------------------------------
  114. typedef enum _D3DX_SURFACEFORMAT
  115. {
  116. D3DX_SF_UNKNOWN = 0,
  117. D3DX_SF_R8G8B8 = 1,
  118. D3DX_SF_A8R8G8B8 = 2,
  119. D3DX_SF_X8R8G8B8 = 3,
  120. D3DX_SF_R5G6B5 = 4,
  121. D3DX_SF_R5G5B5 = 5,
  122. D3DX_SF_PALETTE4 = 6,
  123. D3DX_SF_PALETTE8 = 7,
  124. D3DX_SF_A1R5G5B5 = 8,
  125. D3DX_SF_X4R4G4B4 = 9,
  126. D3DX_SF_A4R4G4B4 =10,
  127. D3DX_SF_L8 =11, // 8 bit luminance-only
  128. D3DX_SF_A8L8 =12, // 16 bit alpha-luminance
  129. D3DX_SF_U8V8 =13, // 16 bit bump map format
  130. D3DX_SF_U5V5L6 =14, // 16 bit bump map format with luminance
  131. D3DX_SF_U8V8L8 =15, // 24 bit bump map format with luminance
  132. D3DX_SF_UYVY =16, // UYVY format (PC98 compliance)
  133. D3DX_SF_YUY2 =17, // YUY2 format (PC98 compliance)
  134. D3DX_SF_DXT1 =18, // S3 texture compression technique 1
  135. D3DX_SF_DXT3 =19, // S3 texture compression technique 3
  136. D3DX_SF_DXT5 =20, // S3 texture compression technique 5
  137. D3DX_SF_R3G3B2 =21, // 8 bit RGB texture format
  138. D3DX_SF_A8 =22, // 8 bit alpha-only
  139. D3DX_SF_TEXTUREMAX =23, // Last texture format
  140. D3DX_SF_Z16S0 =256,
  141. D3DX_SF_Z32S0 =257,
  142. D3DX_SF_Z15S1 =258,
  143. D3DX_SF_Z24S8 =259,
  144. D3DX_SF_S1Z15 =260,
  145. D3DX_SF_S8Z24 =261,
  146. D3DX_SF_DEPTHMAX =262, // Last depth format
  147. D3DX_SF_FORCEMAX = (DWORD)(-1)
  148. } D3DX_SURFACEFORMAT;
  149. //-------------------------------------------------------------------------
  150. // Filtering types for Texture APIs
  151. //
  152. // -------------
  153. // These are the various filter types for generation of mip-maps
  154. //
  155. // D3DX_FILTERTYPE
  156. // -----------------------------------------
  157. // D3DX_FT_POINT: Point sampling only - no filtering
  158. // D3DX_FT_LINEAR: Bi-linear filtering
  159. //
  160. //-------------------------------------------------------------------------
  161. typedef enum _D3DX_FILTERTYPE
  162. {
  163. D3DX_FT_POINT = 0x01,
  164. D3DX_FT_LINEAR = 0x02,
  165. D3DX_FT_DEFAULT = D3DX_DEFAULT
  166. } D3DX_FILTERTYPE;
  167. ///////////////////////////////////////////////////////////////////////////
  168. // Structures used below:
  169. ///////////////////////////////////////////////////////////////////////////
  170. //-------------------------------------------------------------------------
  171. // D3DX_VIDMODEDESC: Display mode description.
  172. // ----------------
  173. // width: Screen Width
  174. // height: Screen Height
  175. // bpp: Bits per pixel
  176. // refreshRate: Refresh rate
  177. //-------------------------------------------------------------------------
  178. typedef struct _D3DX_VIDMODEDESC
  179. {
  180. DWORD width;
  181. DWORD height;
  182. DWORD bpp;
  183. DWORD refreshRate;
  184. } D3DX_VIDMODEDESC;
  185. //-------------------------------------------------------------------------
  186. // D3DX_DEVICEDESC: Description of a device that can do 3D
  187. // ---------------
  188. // deviceIndex: Unique (DWORD) number for the device.
  189. // hwLevel: Level of acceleration afforded. This is one of the
  190. // predefined Device Indices, and exists in this
  191. // structure for informational purposes only. More than
  192. // one device on the system may have the same hwLevel.
  193. // To refer to a particular device with the D3DX apis,
  194. // use the value in the deviceIndex member instead.
  195. // ddGuid: The ddraw GUID
  196. // d3dDeviceGuid: Direct3D Device GUID
  197. // ddDeviceID: DDraw's GetDeviceIdentifier GUID. This GUID is unique to
  198. // a particular driver revision on a particular video card.
  199. // driverDesc: String describing the driver
  200. // monitor: Handle to the video monitor used by this device (multimon
  201. // specific). Devices that use different monitors on a
  202. // multimon system report different values in this field.
  203. // Therefore, to test for a multimon system, an application
  204. // should look for more than one different monitor handle in
  205. // the list of D3DX devices.
  206. // onPrimary: Indicates if this device is on the primary monitor
  207. // (multimon specific).
  208. //-------------------------------------------------------------------------
  209. #define D3DX_DRIVERDESC_LENGTH 256
  210. typedef struct _D3DX_DEVICEDESC
  211. {
  212. DWORD deviceIndex;
  213. DWORD hwLevel;
  214. GUID ddGuid;
  215. GUID d3dDeviceGuid;
  216. GUID ddDeviceID;
  217. char driverDesc[D3DX_DRIVERDESC_LENGTH];
  218. HMONITOR monitor;
  219. BOOL onPrimary;
  220. } D3DX_DEVICEDESC;
  221. ///////////////////////////////////////////////////////////////////////////
  222. // APIs:
  223. ///////////////////////////////////////////////////////////////////////////
  224. #ifdef __cplusplus
  225. extern "C" {
  226. #endif //__cplusplus
  227. //-------------------------------------------------------------------------
  228. // D3DXInitialize: The very first call a D3DX app must make.
  229. //-------------------------------------------------------------------------
  230. HRESULT WINAPI
  231. D3DXInitialize();
  232. //-------------------------------------------------------------------------
  233. // D3DXUninitialize: The very last call a D3DX app must make.
  234. //-------------------------------------------------------------------------
  235. HRESULT WINAPI
  236. D3DXUninitialize();
  237. //-------------------------------------------------------------------------
  238. // D3DXGetDeviceCount: Returns the maximum number of D3DXdevices
  239. // ------------------ available.
  240. //
  241. // D3DXGetDeviceDescription: Lists the 2D and 3D capabilities of the devices.
  242. // ------------------------ Also, the various guids needed by ddraw and d3d.
  243. //
  244. // Params:
  245. // [in] DWORD deviceIndex: Which device? Starts at 0.
  246. // [in] D3DX_DEVICEDESC* pd3dxDevice: Pointer to the D3DX_DEVICEDESC
  247. // structure to be filled in.
  248. //-------------------------------------------------------------------------
  249. DWORD WINAPI
  250. D3DXGetDeviceCount();
  251. HRESULT WINAPI
  252. D3DXGetDeviceDescription(DWORD deviceIndex,
  253. D3DX_DEVICEDESC* pd3dxDeviceDesc);
  254. //-------------------------------------------------------------------------
  255. // D3DXGetMaxNumVideoModes: Returns the maximum number of video-modes .
  256. // -----------------------
  257. //
  258. // Params:
  259. // [in] DWORD deviceIndex: The device being referred to.
  260. // [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh
  261. // rates are not ignored.
  262. //
  263. // D3DXGetVideoMode: Describes a particular video mode for this device
  264. // ----------------
  265. //
  266. // Note: These queries will simply give you a list of modes that the
  267. // display adapter tells DirectX that it supports.
  268. // There is no guarantee that D3DXCreateContext(Ex) will succeed
  269. // with all listed video modes. This is a fundamental limitation
  270. // of the current DirectX architecture which D3DX cannot hide in
  271. // any clean way.
  272. //
  273. // Params:
  274. // [in] DWORD deviceIndex: The device being referred to.
  275. // [in] DWORD flags: If D3DX_GVM_REFRESHRATE is set, then the refresh
  276. // rates are returned
  277. // [in] DWORD which: Which VideoMode ? Starts at 0.
  278. // [out] D3DX_VIDMODEDESC* pModeList: Pointer to the D3DX_VIDMODEDESC
  279. // structure that will be filled in.
  280. //-------------------------------------------------------------------------
  281. DWORD WINAPI
  282. D3DXGetMaxNumVideoModes(DWORD deviceIndex,
  283. DWORD flags);
  284. HRESULT WINAPI
  285. D3DXGetVideoMode(DWORD deviceIndex,
  286. DWORD flags,
  287. DWORD modeIndex,
  288. D3DX_VIDMODEDESC* pModeDesc);
  289. #define D3DX_GVM_REFRESHRATE 0x00000001
  290. //-------------------------------------------------------------------------
  291. // D3DXGetMaxSurfaceFormats: Returns the maximum number of surface
  292. // ------------------------ formats supported by the device at that
  293. // video mode.
  294. //
  295. // D3DXGetSurfaceFormat: Describes one of the supported surface formats.
  296. // ---------------------
  297. //
  298. // Params:
  299. // [in] DWORD deviceIndex: The device being referred to.
  300. // [in] D3DX_VIDMODEDESC* pDesc: The display mode at which the supported
  301. // surface formats are requested. If it is
  302. // NULL, the current display mode is
  303. // assumed.
  304. // [in] DWORD surfClassFlags: Required surface classes. Only surface
  305. // formats which support all specified
  306. // surface classes will be returned.
  307. // (Multiple surface classes may be specified
  308. // using bitwise OR.)
  309. // [in] DWORD which: Which surface formats to retrieve. Starts at 0.
  310. // [out] D3DX_SURFACEFORMAT* pFormat: The surface format
  311. //-------------------------------------------------------------------------
  312. DWORD WINAPI
  313. D3DXGetMaxSurfaceFormats(DWORD deviceIndex,
  314. D3DX_VIDMODEDESC* pDesc,
  315. DWORD surfClassFlags);
  316. HRESULT WINAPI
  317. D3DXGetSurfaceFormat(DWORD deviceIndex,
  318. D3DX_VIDMODEDESC* pDesc,
  319. DWORD surfClassFlags,
  320. DWORD surfaceIndex,
  321. D3DX_SURFACEFORMAT* pFormat);
  322. //-------------------------------------------------------------------------
  323. // D3DXGetCurrentVideoMode: Retrieves the current video mode for this device.
  324. // -------------------
  325. //
  326. // Params:
  327. // [in] DWORD deviceIndex: The device being referred to.
  328. // [out] D3DX_VIDMODEDESC* pVidMode: The current video mode
  329. //-------------------------------------------------------------------------
  330. HRESULT WINAPI
  331. D3DXGetCurrentVideoMode(DWORD deviceIndex,
  332. D3DX_VIDMODEDESC* pVidMode);
  333. //-------------------------------------------------------------------------
  334. // D3DXGetDeviceCaps: Lists all the capabilities of a device at a display
  335. // mode.
  336. // ----------------
  337. //
  338. // Params:
  339. // [in] DWORD deviceIndex: The device being referred to.
  340. // [in] D3DX_VIDMODEDESC* pDesc: If this is NULL, we will return the
  341. // caps at the current display mode of
  342. // the device.
  343. // [out] D3DDEVICEDESC7* pD3DDeviceDesc7: D3D Caps ( NULL to ignore
  344. // parameter)
  345. // [out] DDCAPS7* pDDHalCaps: DDraw HAL Caps (NULL to ignore parameter)
  346. // [out] DDCAPS7* pDDHelCaps: DDraw HEL Caps (NULL to ignore paramter)
  347. //-------------------------------------------------------------------------
  348. HRESULT WINAPI
  349. D3DXGetDeviceCaps(DWORD deviceIndex,
  350. D3DX_VIDMODEDESC* pVidMode,
  351. D3DDEVICEDESC7* pD3DCaps,
  352. DDCAPS* pDDHALCaps,
  353. DDCAPS* pDDHELCaps);
  354. //-------------------------------------------------------------------------
  355. // D3DXCreateContext: Initializes the chosen device. It is the simplest init
  356. // ----------------- function available. Parameters are treated the same
  357. // as the matching subset of parameters in
  358. // D3DXCreateContextEx, documented below.
  359. // Remaining D3DXCreateContextEx parameters that are
  360. // not present in D3DXCreateContext are treated as
  361. // D3DX_DEFAULT. Note that multimon is not supported
  362. // with D3DXCreateContext.
  363. //
  364. // D3DXCreateContextEx: A more advanced function to initialize the device.
  365. // ------------------- Also accepts D3DX_DEFAULT for most of the parameters
  366. // and then will do what D3DXCreateContext did.
  367. //
  368. // Note: Do not expect D3DXCreateContext(Ex) to be fail-safe (as with any
  369. // API). Supported device capablilites should be used as a guide
  370. // for choosing parameter values. Keep in mind that there will
  371. // inevitably be some combinations of parameters that just do not work.
  372. //
  373. // Params:
  374. // [in] DWORD deviceIndex: The device being referred to.
  375. // [in] DWORD flags: The valid flags are D3DX_CONTEXT_FULLSCREEN, and
  376. // D3DX_CONTEXT_OFFSCREEN. These flags cannot both
  377. // be specified. If no flags are specified, the
  378. // context defaults to windowed mode.
  379. //
  380. // [in] HWND hwnd: Device window. See note.
  381. // [in] HWND hwndFocus: Window which receives keyboard messages from
  382. // the device window. The device window should be
  383. // a child of focus window. Useful for multimon
  384. // applications. See note.
  385. // NOTE:
  386. // windowed:
  387. // hwnd must be a valid window. hwndFocus must be NULL or
  388. // D3DX_DEFAULT.
  389. //
  390. // fullscreen:
  391. // Either hwnd or hwndFocus must be a valid window. (Both cannot
  392. // be NULL or D3DX_DEFAULT). If hwnd is NULL or D3DX_DEFAULT,
  393. // a default device window will be created as a child of hwndFocus.
  394. //
  395. // offscreen:
  396. // Both hwnd and hwndFocus must be NULL or D3DX_DEFAULT
  397. //
  398. // [in] DWORD numColorBits: If D3DX_DEFAULT is passed for windowed mode,
  399. // the current desktop's color depth is chosen.
  400. // For full screen mode, D3DX_DEFAULT causes 16
  401. // bit color to be used.
  402. // [in] DWORD numAlphaBits: If D3DX_DEFAULT is passed, 0 is chosen.
  403. // [in] DWORD numDepthbits: If D3DX_DEFAULT is passed,
  404. // the highest available number of depth bits
  405. // is chosen. See note.
  406. // [in] DWORD numStencilBits: If D3DX_DEFAULT is passed, the highest
  407. // available number of stencil bits is chosen.
  408. // See note.
  409. //
  410. // NOTE: If both numDepthBits and numStencilBits are D3DX_DEFAULT,
  411. // D3DX first picks the highest available number of stencil
  412. // bits. Then, for the chosen number of stencil bits,
  413. // the highest available number of depth bits is chosen.
  414. // If only one of numStencilBits or numDepthBits
  415. // is D3DX_DEFAULT, the highest number of bits available
  416. // for this parameter is chosen out of only the formats
  417. // that support the number of bits requested for the
  418. // fixed parameter.
  419. //
  420. // [in] DWORD numBackBuffers: Number of back buffers, or D3DX_DEFAULT.
  421. // See note.
  422. //
  423. // NOTE:
  424. // windowed: D3DX_DEFAULT means 1. You must specify one back buffer.
  425. //
  426. // fullscreen: D3DX_DEFAULT means 1. Any number of back buffers can be
  427. // specified.
  428. //
  429. // offscreen: D3DX_DEFAULT means 0. You cannot specify additional back
  430. // buffers.
  431. //
  432. // [in] DWORD width: Width, in pixels, or D3DX_DEFAULT. See note.
  433. // [in] DWORD height: Height, in pixels, or D3DX_DEFAULT. See note.
  434. //
  435. // NOTE:
  436. // windowed: If either width or height is D3DX_DEFAULT, both values
  437. // default to the dimensions of the client area of hwnd.
  438. //
  439. // fullscreen: If either width or height is D3DX_DEFAULT, width
  440. // defaults to 640, and height defaults to 480.
  441. //
  442. // offscreen: An error is returned if either width or height is
  443. // D3DX_DEFAULT.
  444. //
  445. // [in] DWORD refreshRate: D3DX_DEFAULT means we let ddraw choose for
  446. // us. Ignored for windowed and offscreen modes.
  447. // [out] LPD3DXCONTEXT* ppCtx: This is the Context object that is used for
  448. // rendering on that device.
  449. //
  450. //-------------------------------------------------------------------------
  451. HRESULT WINAPI
  452. D3DXCreateContext(DWORD deviceIndex,
  453. DWORD flags,
  454. HWND hwnd,
  455. DWORD width,
  456. DWORD height,
  457. LPD3DXCONTEXT* ppCtx);
  458. HRESULT WINAPI
  459. D3DXCreateContextEx(DWORD deviceIndex,
  460. DWORD flags,
  461. HWND hwnd,
  462. HWND hwndFocus,
  463. DWORD numColorBits,
  464. DWORD numAlphaBits,
  465. DWORD numDepthbits,
  466. DWORD numStencilBits,
  467. DWORD numBackBuffers,
  468. DWORD width,
  469. DWORD height,
  470. DWORD refreshRate,
  471. LPD3DXCONTEXT* ppCtx);
  472. // The D3DXCreateContext(Ex) flags are:
  473. #define D3DX_CONTEXT_FULLSCREEN 0x00000001
  474. #define D3DX_CONTEXT_OFFSCREEN 0x00000002
  475. //-------------------------------------------------------------------------
  476. // D3DXGetErrorString: Prints out the error string given an hresult. Prints
  477. // ------------------ Win32 as well as DX6 error messages besides the D3DX
  478. // messages.
  479. //
  480. // Params:
  481. // [in] HRESULT hr: The error code to be deciphered.
  482. // [in] DWORD strLength: Length of the string passed in.
  483. // [out] LPSTR pStr: The string output. This string of appropriate
  484. // size needs to be passed in.
  485. //-------------------------------------------------------------------------
  486. void WINAPI
  487. D3DXGetErrorString(HRESULT hr,
  488. DWORD strLength,
  489. LPSTR pStr);
  490. //-------------------------------------------------------------------------
  491. // D3DXMakeDDPixelFormat: Fills in a DDPIXELFORMAT structure based on the
  492. // --------------------- D3DX surface format requested.
  493. //
  494. // Params:
  495. // [in] D3DX_SURFACEFORMAT d3dxFormat: Surface format.
  496. // [out] DDPIXELFORMAT* pddpf: Pixel format matching the given
  497. // surface format.
  498. //-------------------------------------------------------------------------
  499. HRESULT WINAPI
  500. D3DXMakeDDPixelFormat(D3DX_SURFACEFORMAT d3dxFormat,
  501. DDPIXELFORMAT* pddpf);
  502. //-------------------------------------------------------------------------
  503. // D3DXMakeSurfaceFormat: Determines the surface format corresponding to
  504. // --------------------- a given DDPIXELFORMAT.
  505. //
  506. // Params:
  507. // [in] DDPIXELFORMAT* pddpf: Pixel format.
  508. // Return Value:
  509. // D3DX_SURFACEFORMAT: Surface format matching the given pixel format.
  510. // D3DX_SF_UNKNOWN if the format is not supported
  511. //-------------------------------------------------------------------------
  512. D3DX_SURFACEFORMAT WINAPI
  513. D3DXMakeSurfaceFormat(DDPIXELFORMAT* pddpf);
  514. #ifdef __cplusplus
  515. }
  516. #endif //__cplusplus
  517. ///////////////////////////////////////////////////////////////////////////
  518. // Interfaces:
  519. ///////////////////////////////////////////////////////////////////////////
  520. //-------------------------------------------------------------------------
  521. // ID3DXContext interface:
  522. //
  523. // This encapsulates all the stuff that the app might
  524. // want to do at initialization time and any global control over d3d and
  525. // ddraw.
  526. //-------------------------------------------------------------------------
  527. DECLARE_INTERFACE_(ID3DXContext, IUnknown)
  528. {
  529. //
  530. // IUnknown methods
  531. //
  532. STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID* ppvObj) PURE;
  533. STDMETHOD_(ULONG,AddRef)(THIS) PURE;
  534. STDMETHOD_(ULONG,Release)(THIS) PURE;
  535. // Get the DDraw and Direct3D objects to call DirectDraw or
  536. // Direct3D Immediate Mode functions.
  537. // If the objects don't exist (because they have not
  538. // been created for some reason) NULL is returned.
  539. // All the objects returned in the following Get* functions
  540. // are addref'ed. It is the application's responsibility to
  541. // release them when no longer needed.
  542. STDMETHOD_(LPDIRECTDRAW7,GetDD)(THIS) PURE;
  543. STDMETHOD_(LPDIRECT3D7,GetD3D)(THIS) PURE;
  544. STDMETHOD_(LPDIRECT3DDEVICE7,GetD3DDevice)(THIS) PURE;
  545. // Get the various buffers that get created at the init time
  546. // These are addref'ed as well. It is the application's responsibility
  547. // to release them before the app quits or when it needs a resize.
  548. STDMETHOD_(LPDIRECTDRAWSURFACE7,GetPrimary)(THIS) PURE;
  549. STDMETHOD_(LPDIRECTDRAWSURFACE7,GetZBuffer)(THIS) PURE;
  550. STDMETHOD_(LPDIRECTDRAWSURFACE7,GetBackBuffer)(THIS_ DWORD which) PURE;
  551. // Get the associated window handles
  552. STDMETHOD_(HWND,GetWindow)(THIS) PURE;
  553. STDMETHOD_(HWND,GetFocusWindow)(THIS) PURE;
  554. //
  555. // Various Get methods, in case the user had specified default
  556. // parameters
  557. //
  558. STDMETHOD(GetDeviceIndex)(THIS_
  559. LPDWORD pDeviceIndex,
  560. LPDWORD pHwLevel) PURE;
  561. STDMETHOD_(DWORD, GetNumBackBuffers)(THIS) PURE;
  562. STDMETHOD(GetNumBits)(THIS_
  563. LPDWORD pColorBits,
  564. LPDWORD pDepthBits,
  565. LPDWORD pAlphaBits,
  566. LPDWORD pStencilBits) PURE;
  567. STDMETHOD(GetBufferSize)(THIS_
  568. LPDWORD pWidth,
  569. LPDWORD pHeight) PURE;
  570. // Get the flags that were used to create this context
  571. STDMETHOD_(DWORD, GetCreationFlags)(THIS) PURE;
  572. STDMETHOD_(DWORD, GetRefreshRate)(THIS) PURE;
  573. // Restoring surfaces in case stuff is lost
  574. STDMETHOD(RestoreSurfaces)(THIS) PURE;
  575. // Resize all the buffers to the new width and height
  576. STDMETHOD(Resize)(THIS_ DWORD width, DWORD height) PURE;
  577. // Update the frame using a flip or a blit,
  578. // If the D3DX_UPDATE_NOVSYNC flag is set, blit is used if the
  579. // driver cannot flip without waiting for vsync in full-screen mode.
  580. STDMETHOD(UpdateFrame)(THIS_ DWORD flags) PURE;
  581. // Render a string at the specified coordinates, with the specified
  582. // colour. This is only provided as a convenience for
  583. // debugging/information during development.
  584. // topLeftX and topLeftY represent the location of the top left corner
  585. // of the string, on the render target.
  586. // The coordinate and color parameters each have a range of 0.0-1.0
  587. STDMETHOD(DrawDebugText)(THIS_
  588. float topLeftX,
  589. float topLeftY,
  590. D3DCOLOR color,
  591. LPSTR pString) PURE;
  592. // Clears to the current viewport
  593. // The following are the valid flags:
  594. // D3DCLEAR_TARGET (to clear the render target )
  595. // D3DCLEAR_ZBUFFER (to clear the depth-buffer )
  596. // D3DCLEAR_STENCIL (to clear the stencil-buffer )
  597. STDMETHOD(Clear)(THIS_ DWORD ClearFlags) PURE;
  598. STDMETHOD(SetClearColor)(THIS_ D3DCOLOR color ) PURE;
  599. STDMETHOD(SetClearDepth)(THIS_ float z) PURE;
  600. STDMETHOD(SetClearStencil)(THIS_ DWORD stencil) PURE;
  601. };
  602. //-------------------------------------------------------------------------
  603. // Flags for Update member function:
  604. //
  605. // Flag to indicate that blit should be used instead of a flip
  606. // for full-screen rendering.
  607. #define D3DX_UPDATE_NOVSYNC (1<<0)
  608. ///////////////////////////////////////////////////////////////////////////
  609. // Texturing APIs:
  610. ///////////////////////////////////////////////////////////////////////////
  611. #ifdef __cplusplus
  612. extern "C" {
  613. #endif //__cplusplus
  614. //-------------------------------------------------------------------------
  615. // D3DXCheckTextureRequirements: Return information about texture creation
  616. // ---------------------------- (used by CreateTexture, CreateTextureFromFile
  617. // and CreateCubeMapTexture)
  618. //
  619. // Parameters:
  620. //
  621. // pd3dDevice
  622. // The D3D device with which the texture is going to be used.
  623. // pFlags
  624. // allows specification of D3DX_TEXTURE_NOMIPMAP
  625. // D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
  626. // is not supported.
  627. // pWidth
  628. // width in pixels or NULL
  629. // returns corrected width
  630. // pHeight
  631. // height in pixels or NULL
  632. // returns corrected height
  633. // pPixelFormat
  634. // surface format
  635. // returns best match to input format
  636. //
  637. // Notes: 1. Unless the flags is set to specifically prevent creating
  638. // mipmaps, mipmaps are generated all the way till 1x1 surface.
  639. // 2. width, height and pixelformat are altered based on available
  640. // hardware. For example:
  641. // a. Texture dimensions may be required to be powers of 2
  642. // b. We may require width == height for some devices
  643. // c. If PixelFormat is unavailable, a best fit is made
  644. //-------------------------------------------------------------------------
  645. HRESULT WINAPI
  646. D3DXCheckTextureRequirements( LPDIRECT3DDEVICE7 pd3dDevice,
  647. LPDWORD pFlags,
  648. LPDWORD pWidth,
  649. LPDWORD pHeight,
  650. D3DX_SURFACEFORMAT* pPixelFormat);
  651. //-------------------------------------------------------------------------
  652. // D3DXCreateTexture: Create an empty texture object
  653. // -----------------
  654. //
  655. // Parameters:
  656. //
  657. // pd3dDevice
  658. // The D3D device with which the texture is going to be used.
  659. // pFlags
  660. // allows specification of D3DX_TEXTURE_NOMIPMAP
  661. // D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
  662. // is not supported. Additionally, D3DX_TEXTURE_STAGE<n> can be specified
  663. // to indicate which texture stage the texture is for e.g.
  664. // D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture
  665. // stage one. Stage Zero is the default if no TEXTURE_STAGE flags are
  666. // set.
  667. // pWidth
  668. // width in pixels; 0 or NULL is unacceptable
  669. // returns corrected width
  670. // pHeight
  671. // height in pixels; 0 or NULL is unacceptable
  672. // returns corrected height
  673. // pPixelFormat
  674. // surface format. D3DX_DEFAULT is unacceptable.
  675. // returns actual format that was used
  676. // pDDPal
  677. // DDraw palette that is set (if present) on paletted surfaces.
  678. // It is ignored even if it is set, for non-paletted surfaces.
  679. // ppDDSurf
  680. // The ddraw surface that will be created
  681. // pNumMipMaps
  682. // the number of mipmaps actually generated
  683. //
  684. // Notes: See notes for D3DXCheckTextureRequirements.
  685. //-------------------------------------------------------------------------
  686. HRESULT WINAPI
  687. D3DXCreateTexture( LPDIRECT3DDEVICE7 pd3dDevice,
  688. LPDWORD pFlags,
  689. LPDWORD pWidth,
  690. LPDWORD pHeight,
  691. D3DX_SURFACEFORMAT* pPixelFormat,
  692. LPDIRECTDRAWPALETTE pDDPal,
  693. LPDIRECTDRAWSURFACE7* ppDDSurf,
  694. LPDWORD pNumMipMaps);
  695. //-------------------------------------------------------------------------
  696. // D3DXCreateCubeMapTexture: Create blank cube-map texture
  697. // ------------------------
  698. //
  699. // Parameters:
  700. //
  701. // pd3dDevice
  702. // The D3D device with which the texture is going to be used.
  703. // pFlags
  704. // allows specification of D3DX_TEXTURE_NOMIPMAP
  705. // D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
  706. // is not supported. Additionally, D3DX_TEXTURE_STAGE<n> can be specified
  707. // to indicate which texture stage the texture is for e.g.
  708. // D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture
  709. // stage one. Stage Zero is the default if no TEXTURE_STAGE flags are
  710. // set.
  711. // cubefaces
  712. // allows specification of which faces of the cube-map to generate.
  713. // D3DX_DEFAULT, 0, and DDSCAPS2_CUBEMAP_ALLFACES all mean
  714. // "create all 6 faces of the cubemap". Any combination of
  715. // DDSCAPS2_CUBEMAP_POSITIVEX, DDSCAPS2_CUBEMAP_NEGATIVEX,
  716. // DDSCAPS2_CUBEMAP_POSITIVEY, DDSCAPS2_CUBEMAP_NEGATIVEY,
  717. // DDSCAPS2_CUBEMAP_POSITIVEZ, or DDSCAPS2_CUBEMAP_NEGATIVEZ, is
  718. // valid.
  719. // colorEmptyFaces
  720. // allows specification of the color to use for the faces that were not
  721. // specified in the cubefaces parameter.
  722. // pWidth
  723. // width in pixels; 0 or NULL is unacceptable
  724. // returns corrected width
  725. // pHeight
  726. // height in pixels; 0 or NULL is unacceptable
  727. // returns corrected height
  728. // pPixelFormat
  729. // surface format. D3DX_DEFAULT is unacceptable.
  730. // returns actual format that was used
  731. // pDDPal
  732. // DDraw palette that is set (if present) on paletted surfaces.
  733. // It is ignored even if it is set, for non-paletted surfaces.
  734. // ppDDSurf
  735. // the ddraw surface that will be created
  736. // pNumMipMaps
  737. // the number of mipmaps generated for a particular face of the
  738. // cubemap.
  739. //
  740. // Notes: See notes for D3DXCheckTextureRequirements.
  741. //-------------------------------------------------------------------------
  742. HRESULT WINAPI
  743. D3DXCreateCubeMapTexture( LPDIRECT3DDEVICE7 pd3dDevice,
  744. LPDWORD pFlags,
  745. DWORD cubefaces,
  746. D3DCOLOR colorEmptyFaces,
  747. LPDWORD pWidth,
  748. LPDWORD pHeight,
  749. D3DX_SURFACEFORMAT *pPixelFormat,
  750. LPDIRECTDRAWPALETTE pDDPal,
  751. LPDIRECTDRAWSURFACE7* ppDDSurf,
  752. LPDWORD pNumMipMaps);
  753. //-------------------------------------------------------------------------
  754. // D3DXCreateTextureFromFile: Create a texture object from a file or from the
  755. // ------------------------- resource. Only BMP and DIB are supported from the
  756. // resource portion of the executable.
  757. //
  758. // Parameters:
  759. //
  760. // pd3dDevice
  761. // The D3D device with which the texture is going to be used.
  762. // pFlags
  763. // allows specification of D3DX_TEXTURE_NOMIPMAP
  764. // D3DX_TEXTURE_NOMIPMAP may be returned in the case where mipmap creation
  765. // is not supported. Additionally, D3DX_TEXTURE_STAGE<n> can be specified
  766. // to indicate which texture stage the texture is for e.g.
  767. // D3D_TEXTURE_STAGE1 indicates that the texture is for use with texture
  768. // stage one. Stage Zero is the default if no TEXTURE_STAGE flags are
  769. // set.
  770. // pWidth
  771. // Width in pixels. If 0 or D3DX_DEFAULT, the width will be taken
  772. // from the file
  773. // returns corrected width
  774. // pHeight
  775. // Height in pixels. If 0 or D3DX_DEFAULT, the height will be taken
  776. // from the file
  777. // returns corrected height
  778. // pPixelFormat
  779. // If D3DX_SF_UNKNOWN is passed in, pixel format closest to the bitmap
  780. // will be chosen
  781. // returns actual format that was used
  782. // pDDPal
  783. // DDraw palette that is set (if present) on paletted surfaces.
  784. // It is ignored even if it is set, for non-paletted surfaces.
  785. // ppDDSurf
  786. // The ddraw surface that will be created.
  787. // pNumMipMaps
  788. // The number of mipmaps generated.
  789. // pSrcName
  790. // File name. BMP, DIB, DDS, are supported.
  791. //
  792. // TGA is supported for the following cases: 16, 24, 32bpp direct color and 8bpp palettized.
  793. // Also, 8, 16bpp grayscale is supported. RLE versions of the above
  794. // TGA formats are also supported. ColorKey and Premultiplied Alpha
  795. // are not currently supported for TGA files.
  796. // returns created format
  797. //
  798. // Notes: See notes for D3DXCheckTextureRequirements.
  799. //-------------------------------------------------------------------------
  800. HRESULT WINAPI
  801. D3DXCreateTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice,
  802. LPDWORD pFlags,
  803. LPDWORD pWidth,
  804. LPDWORD pHeight,
  805. D3DX_SURFACEFORMAT* pPixelFormat,
  806. LPDIRECTDRAWPALETTE pDDPal,
  807. LPDIRECTDRAWSURFACE7* ppDDSurf,
  808. LPDWORD pNumMipMaps,
  809. LPSTR pSrcName,
  810. D3DX_FILTERTYPE filterType);
  811. //-------------------------------------------------------------------------
  812. // D3DXLoadTextureFromFile: Load from a file into a mipmap level. Doing the
  813. // ----------------------- necessary color conversion and rescaling. File
  814. // format support is identical to
  815. // D3DXCreateTextureFromFile's.
  816. //
  817. // pd3dDevice
  818. // The D3D device with which the texture is going to be used.
  819. // pTexture
  820. // a pointer to a DD7Surface which was created with either
  821. // CreateTextureFromFile or CreateTexture.
  822. // mipMapLevel
  823. // indicates mipmap level
  824. // Note:
  825. // 1. Error if mipmap level doesn't exist
  826. // 2. If D3DX_DEFAULT and equal number of mipmap levels exist
  827. // then all the source mip-levels are loaded
  828. // 3. If the source has mipmaps and the dest doesn't, use the top one
  829. // 4. If the dest has miplevels and source doesn't, we expand
  830. // 5. If there are unequal numbers of miplevels, we expand
  831. // pSrcName
  832. // File name. BMP, DIB, DDS, are supported.
  833. // For details on TGA support, refer to the comments for
  834. // D3DXCreateTextureFromFile
  835. // pSrcRect
  836. // the source rectangle or null (whole surface)
  837. // pDestRect
  838. // the destination rectangle or null (whole surface)
  839. // filterType
  840. // filter used for mipmap generation
  841. //-------------------------------------------------------------------------
  842. HRESULT WINAPI
  843. D3DXLoadTextureFromFile( LPDIRECT3DDEVICE7 pd3dDevice,
  844. LPDIRECTDRAWSURFACE7 pTexture,
  845. DWORD mipMapLevel,
  846. LPSTR pSrcName,
  847. RECT* pSrcRect,
  848. RECT* pDestRect,
  849. D3DX_FILTERTYPE filterType);
  850. //-------------------------------------------------------------------------
  851. // D3DXLoadTextureFromSurface: Load from a DDraw Surface into a mipmap level.
  852. // -------------------------- Doing the necessary color conversion.
  853. //
  854. // pd3dDevice
  855. // The D3D device with which the texture is going to be used.
  856. // pTexture
  857. // a pointer to a DD7Surface which was created with either
  858. // CreateTextureFromFile or CreateTexture.
  859. // mipMapLevel
  860. // indicates mipmap level
  861. // Note:
  862. // 1. Error if mipmap level doesn't exist
  863. // 2. If D3DX_DEFAULT and equal number of mipmap levels exist
  864. // then all the source mip-levels are loaded
  865. // 3. If the source has mipmaps and the dest doesn't, use the top one
  866. // 4. If the dest has miplevels and source doesn't, we expand
  867. // 5. If there are unequal numbers of miplevels, we expand
  868. // pSurfaceSrc
  869. // the source surface
  870. // pSrcRect
  871. // the source rectangle or null (whole surface)
  872. // pDestRect
  873. // the destination rectangle or null (whole surface)
  874. // filterType
  875. // filter used for mipmap generation
  876. //-------------------------------------------------------------------------
  877. HRESULT WINAPI
  878. D3DXLoadTextureFromSurface( LPDIRECT3DDEVICE7 pd3dDevice,
  879. LPDIRECTDRAWSURFACE7 pTexture,
  880. DWORD mipMapLevel,
  881. LPDIRECTDRAWSURFACE7 pSurfaceSrc,
  882. RECT* pSrcRect,
  883. RECT* pDestRect,
  884. D3DX_FILTERTYPE filterType);
  885. //-------------------------------------------------------------------------
  886. // D3DXLoadTextureFromMemory: Load a mip level from memory. Doing the necessary
  887. // ------------------------- color conversion.
  888. //
  889. // pd3dDevice
  890. // The D3D device with which the texture is going to be used.
  891. // pTexture
  892. // a pointer to a DD7Surface which was created with either
  893. // CreateTextureFromFile or CreateTexture.
  894. // mipMapLevel
  895. // indicates mipmap level
  896. // Note:
  897. // 1. Error if mipmap level doesn't exist
  898. // 2. If D3DX_DEFAULT and equal number of mipmap levels exist
  899. // then all the source mip-levels are loaded
  900. // 3. If the source has mipmaps and the dest doesn't, use the top one
  901. // 4. If the dest has miplevels and source doesn't, we expand
  902. // 5. If there are unequal numbers of miplevels, we expand
  903. // pMemory
  904. // pointer to source memory from which the texture will be loaded
  905. // pDDPal
  906. // DirectDraw Palette, that the app passes in optionally if the memory is
  907. // supposed to be paletteized.
  908. // srcPixelFormat
  909. // PixelFormat of the source.
  910. // srcPitch
  911. // The pitch of the memory or D3DX_DEFAULT (based on srcPixelFormat)
  912. // pDestRect
  913. // The destination rectangle or null (whole surface)
  914. // filterType
  915. // filter used for mipmap generation
  916. //
  917. // Assumptions: The source (memory) is loaded in full
  918. //-------------------------------------------------------------------------
  919. HRESULT WINAPI
  920. D3DXLoadTextureFromMemory( LPDIRECT3DDEVICE7 pd3dDevice,
  921. LPDIRECTDRAWSURFACE7 pTexture,
  922. DWORD mipMapLevel,
  923. LPVOID pMemory,
  924. LPDIRECTDRAWPALETTE pDDPal,
  925. D3DX_SURFACEFORMAT srcPixelFormat,
  926. DWORD srcPitch,
  927. RECT* pDestRect,
  928. D3DX_FILTERTYPE filterType);
  929. #ifdef __cplusplus
  930. }
  931. #endif //__cplusplus
  932. //-------------------------------------------------------------------------
  933. // Flags for texture create functions; applies to
  934. // D3DXCreateTexture, D3DXCreateCubeMapTexture and D3DXCreateTextureFromFile.
  935. //
  936. // Flag to indicate that mipmap generation is not desired.
  937. #define D3DX_TEXTURE_NOMIPMAP (1 << 8)
  938. // Flags to indicate which texture stage the texture is
  939. // intended for use with. Specifying the stage is necessary at
  940. // texture creation time for HW devices that expose the
  941. // D3DDEVCAPS_SEPARATETEXTUREMEMORIES bit in their D3DDEVICEDESC
  942. // structure.
  943. #define D3DX_TEXTURE_STAGE0 (0)
  944. #define D3DX_TEXTURE_STAGE1 (1)
  945. #define D3DX_TEXTURE_STAGE2 (2)
  946. #define D3DX_TEXTURE_STAGE3 (3)
  947. #define D3DX_TEXTURE_STAGE4 (4)
  948. #define D3DX_TEXTURE_STAGE5 (5)
  949. #define D3DX_TEXTURE_STAGE6 (6)
  950. #define D3DX_TEXTURE_STAGE7 (7)
  951. // Mask to extract the texture stage value out of the flags to
  952. // the texture create functions.
  953. #define D3DX_TEXTURE_STAGE_MASK (0x7)
  954. #endif //__D3DXCORE_H__