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.

563 lines
17 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: d3dx8core.h
  6. // Content: D3DX core types and functions
  7. //
  8. ///////////////////////////////////////////////////////////////////////////
  9. #include "d3dx8.h"
  10. #ifndef __D3DX8CORE_H__
  11. #define __D3DX8CORE_H__
  12. ///////////////////////////////////////////////////////////////////////////
  13. // ID3DXBuffer:
  14. // ------------
  15. // The buffer object is used by D3DX to return arbitrary size data.
  16. //
  17. // GetBufferPointer -
  18. // Returns a pointer to the beginning of the buffer.
  19. //
  20. // GetBufferSize -
  21. // Returns the size of the buffer, in bytes.
  22. ///////////////////////////////////////////////////////////////////////////
  23. typedef interface ID3DXBuffer ID3DXBuffer;
  24. typedef interface ID3DXBuffer *LPD3DXBUFFER;
  25. // {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F}
  26. DEFINE_GUID(IID_ID3DXBuffer,
  27. 0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f);
  28. #undef INTERFACE
  29. #define INTERFACE ID3DXBuffer
  30. DECLARE_INTERFACE_(ID3DXBuffer, IUnknown)
  31. {
  32. // IUnknown
  33. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  34. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  35. STDMETHOD_(ULONG, Release)(THIS) PURE;
  36. // ID3DXBuffer
  37. STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
  38. STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
  39. };
  40. ///////////////////////////////////////////////////////////////////////////
  41. // ID3DXFont:
  42. // ----------
  43. // Font objects contain the textures and resources needed to render
  44. // a specific font on a specific device.
  45. //
  46. // Begin -
  47. // Prepartes device for drawing text. This is optional.. if DrawText
  48. // is called outside of Begin/End, it will call Begin and End for you.
  49. //
  50. // DrawText -
  51. // Draws formatted text on a D3D device. Some parameters are
  52. // surprisingly similar to those of GDI's DrawText function. See GDI
  53. // documentation for a detailed description of these parameters.
  54. //
  55. // End -
  56. // Restores device state to how it was when Begin was called.
  57. //
  58. // OnLostDevice, OnResetDevice -
  59. // Call OnLostDevice() on this object before calling Reset() on the
  60. // device, so that this object can release any stateblocks and video
  61. // memory resources. After Reset(), the call OnResetDevice().
  62. //
  63. ///////////////////////////////////////////////////////////////////////////
  64. typedef interface ID3DXFont ID3DXFont;
  65. typedef interface ID3DXFont *LPD3DXFONT;
  66. // {2D501DF7-D253-4414-865F-A6D54A753138}
  67. DEFINE_GUID( IID_ID3DXFont,
  68. 0x2d501df7, 0xd253, 0x4414, 0x86, 0x5f, 0xa6, 0xd5, 0x4a, 0x75, 0x31, 0x38);
  69. #undef INTERFACE
  70. #define INTERFACE ID3DXFont
  71. DECLARE_INTERFACE_(ID3DXFont, IUnknown)
  72. {
  73. // IUnknown
  74. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  75. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  76. STDMETHOD_(ULONG, Release)(THIS) PURE;
  77. // ID3DXFont
  78. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  79. STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE;
  80. STDMETHOD(Begin)(THIS) PURE;
  81. STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
  82. STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE;
  83. STDMETHOD(End)(THIS) PURE;
  84. STDMETHOD(OnLostDevice)(THIS) PURE;
  85. STDMETHOD(OnResetDevice)(THIS) PURE;
  86. };
  87. #ifndef DrawText
  88. #ifdef UNICODE
  89. #define DrawText DrawTextW
  90. #else
  91. #define DrawText DrawTextA
  92. #endif
  93. #endif
  94. #ifdef __cplusplus
  95. extern "C" {
  96. #endif //__cplusplus
  97. HRESULT WINAPI
  98. D3DXCreateFont(
  99. LPDIRECT3DDEVICE8 pDevice,
  100. HFONT hFont,
  101. LPD3DXFONT* ppFont);
  102. HRESULT WINAPI
  103. D3DXCreateFontIndirect(
  104. LPDIRECT3DDEVICE8 pDevice,
  105. CONST LOGFONT* pLogFont,
  106. LPD3DXFONT* ppFont);
  107. #ifdef __cplusplus
  108. }
  109. #endif //__cplusplus
  110. ///////////////////////////////////////////////////////////////////////////
  111. // ID3DXSprite:
  112. // ------------
  113. // This object intends to provide an easy way to drawing sprites using D3D.
  114. //
  115. // Begin -
  116. // Prepares device for drawing sprites
  117. //
  118. // Draw, DrawAffine, DrawTransform -
  119. // Draws a sprite in screen-space. Before transformation, the sprite is
  120. // the size of SrcRect, with its top-left corner at the origin (0,0).
  121. // The color and alpha channels are modulated by Color.
  122. //
  123. // End -
  124. // Restores device state to how it was when Begin was called.
  125. //
  126. // OnLostDevice, OnResetDevice -
  127. // Call OnLostDevice() on this object before calling Reset() on the
  128. // device, so that this object can release any stateblocks and video
  129. // memory resources. After Reset(), the call OnResetDevice().
  130. ///////////////////////////////////////////////////////////////////////////
  131. typedef interface ID3DXSprite ID3DXSprite;
  132. typedef interface ID3DXSprite *LPD3DXSPRITE;
  133. // {E8691849-87B8-4929-9050-1B0542D5538C}
  134. DEFINE_GUID( IID_ID3DXSprite,
  135. 0xe8691849, 0x87b8, 0x4929, 0x90, 0x50, 0x1b, 0x5, 0x42, 0xd5, 0x53, 0x8c);
  136. #undef INTERFACE
  137. #define INTERFACE ID3DXSprite
  138. DECLARE_INTERFACE_(ID3DXSprite, IUnknown)
  139. {
  140. // IUnknown
  141. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  142. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  143. STDMETHOD_(ULONG, Release)(THIS) PURE;
  144. // ID3DXSprite
  145. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  146. STDMETHOD(Begin)(THIS) PURE;
  147. STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture,
  148. CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling,
  149. CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation,
  150. CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE;
  151. STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture,
  152. CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform,
  153. D3DCOLOR Color) PURE;
  154. STDMETHOD(End)(THIS) PURE;
  155. STDMETHOD(OnLostDevice)(THIS) PURE;
  156. STDMETHOD(OnResetDevice)(THIS) PURE;
  157. };
  158. #ifdef __cplusplus
  159. extern "C" {
  160. #endif //__cplusplus
  161. HRESULT WINAPI
  162. D3DXCreateSprite(
  163. LPDIRECT3DDEVICE8 pDevice,
  164. LPD3DXSPRITE* ppSprite);
  165. #ifdef __cplusplus
  166. }
  167. #endif //__cplusplus
  168. ///////////////////////////////////////////////////////////////////////////
  169. // ID3DXRenderToSurface:
  170. // ---------------------
  171. // This object abstracts rendering to surfaces. These surfaces do not
  172. // necessarily need to be render targets. If they are not, a compatible
  173. // render target is used, and the result copied into surface at end scene.
  174. //
  175. // BeginScene, EndScene -
  176. // Call BeginScene() and EndScene() at the beginning and ending of your
  177. // scene. These calls will setup and restore render targets, viewports,
  178. // etc..
  179. //
  180. // OnLostDevice, OnResetDevice -
  181. // Call OnLostDevice() on this object before calling Reset() on the
  182. // device, so that this object can release any stateblocks and video
  183. // memory resources. After Reset(), the call OnResetDevice().
  184. ///////////////////////////////////////////////////////////////////////////
  185. typedef struct _D3DXRTS_DESC
  186. {
  187. UINT Width;
  188. UINT Height;
  189. D3DFORMAT Format;
  190. BOOL DepthStencil;
  191. D3DFORMAT DepthStencilFormat;
  192. } D3DXRTS_DESC;
  193. typedef interface ID3DXRenderToSurface ID3DXRenderToSurface;
  194. typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE;
  195. // {69CC587C-E40C-458d-B5D3-B029E18EB60A}
  196. DEFINE_GUID( IID_ID3DXRenderToSurface,
  197. 0x69cc587c, 0xe40c, 0x458d, 0xb5, 0xd3, 0xb0, 0x29, 0xe1, 0x8e, 0xb6, 0xa);
  198. #undef INTERFACE
  199. #define INTERFACE ID3DXRenderToSurface
  200. DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown)
  201. {
  202. // IUnknown
  203. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  204. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  205. STDMETHOD_(ULONG, Release)(THIS) PURE;
  206. // ID3DXRenderToSurface
  207. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  208. STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE;
  209. STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE;
  210. STDMETHOD(EndScene)(THIS) PURE;
  211. STDMETHOD(OnLostDevice)(THIS) PURE;
  212. STDMETHOD(OnResetDevice)(THIS) PURE;
  213. };
  214. #ifdef __cplusplus
  215. extern "C" {
  216. #endif //__cplusplus
  217. HRESULT WINAPI
  218. D3DXCreateRenderToSurface(
  219. LPDIRECT3DDEVICE8 pDevice,
  220. UINT Width,
  221. UINT Height,
  222. D3DFORMAT Format,
  223. BOOL DepthStencil,
  224. D3DFORMAT DepthStencilFormat,
  225. LPD3DXRENDERTOSURFACE* ppRenderToSurface);
  226. #ifdef __cplusplus
  227. }
  228. #endif //__cplusplus
  229. ///////////////////////////////////////////////////////////////////////////
  230. // ID3DXRenderToEnvMap:
  231. // --------------------
  232. // This object abstracts rendering to environment maps. These surfaces
  233. // do not necessarily need to be render targets. If they are not, a
  234. // compatible render target is used, and the result copied into the
  235. // environment map at end scene.
  236. //
  237. // BeginCube, BeginSphere, BeginHemisphere, BeginParabolic -
  238. // This function initiates the rendering of the environment map. As
  239. // parameters, you pass the textures in which will get filled in with
  240. // the resulting environment map.
  241. //
  242. // Face -
  243. // Call this function to initiate the drawing of each face. For each
  244. // environment map, you will call this six times.. once for each face
  245. // in D3DCUBEMAP_FACES.
  246. //
  247. // End -
  248. // This will restore all render targets, and if needed compose all the
  249. // rendered faces into the environment map surfaces.
  250. //
  251. // OnLostDevice, OnResetDevice -
  252. // Call OnLostDevice() on this object before calling Reset() on the
  253. // device, so that this object can release any stateblocks and video
  254. // memory resources. After Reset(), the call OnResetDevice().
  255. ///////////////////////////////////////////////////////////////////////////
  256. typedef struct _D3DXRTE_DESC
  257. {
  258. UINT Size;
  259. D3DFORMAT Format;
  260. BOOL DepthStencil;
  261. D3DFORMAT DepthStencilFormat;
  262. } D3DXRTE_DESC;
  263. typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap;
  264. typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap;
  265. // {9F6779E5-60A9-4d8b-AEE4-32770F405DBA}
  266. DEFINE_GUID( IID_ID3DXRenderToEnvMap,
  267. 0x9f6779e5, 0x60a9, 0x4d8b, 0xae, 0xe4, 0x32, 0x77, 0xf, 0x40, 0x5d, 0xba);
  268. #undef INTERFACE
  269. #define INTERFACE ID3DXRenderToEnvMap
  270. DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown)
  271. {
  272. // IUnknown
  273. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  274. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  275. STDMETHOD_(ULONG, Release)(THIS) PURE;
  276. // ID3DXRenderToEnvMap
  277. STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE;
  278. STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE;
  279. STDMETHOD(BeginCube)(THIS_
  280. LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE;
  281. STDMETHOD(BeginSphere)(THIS_
  282. LPDIRECT3DTEXTURE8 pTex) PURE;
  283. STDMETHOD(BeginHemisphere)(THIS_
  284. LPDIRECT3DTEXTURE8 pTexZPos,
  285. LPDIRECT3DTEXTURE8 pTexZNeg) PURE;
  286. STDMETHOD(BeginParabolic)(THIS_
  287. LPDIRECT3DTEXTURE8 pTexZPos,
  288. LPDIRECT3DTEXTURE8 pTexZNeg) PURE;
  289. STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE;
  290. STDMETHOD(End)(THIS) PURE;
  291. STDMETHOD(OnLostDevice)(THIS) PURE;
  292. STDMETHOD(OnResetDevice)(THIS) PURE;
  293. };
  294. #ifdef __cplusplus
  295. extern "C" {
  296. #endif //__cplusplus
  297. HRESULT WINAPI
  298. D3DXCreateRenderToEnvMap(
  299. LPDIRECT3DDEVICE8 pDevice,
  300. UINT Size,
  301. D3DFORMAT Format,
  302. BOOL DepthStencil,
  303. D3DFORMAT DepthStencilFormat,
  304. LPD3DXRenderToEnvMap* ppRenderToEnvMap);
  305. #ifdef __cplusplus
  306. }
  307. #endif //__cplusplus
  308. ///////////////////////////////////////////////////////////////////////////
  309. // Shader assemblers:
  310. ///////////////////////////////////////////////////////////////////////////
  311. //-------------------------------------------------------------------------
  312. // D3DXASM flags:
  313. // --------------
  314. //
  315. // D3DXASM_DEBUG
  316. // Generate debug info.
  317. //
  318. // D3DXASM_SKIPVALIDATION
  319. // Do not validate the generated code against known capabilities and
  320. // constraints. This option is only recommended when assembling shaders
  321. // you KNOW will work. (ie. have assembled before without this option.)
  322. //-------------------------------------------------------------------------
  323. #define D3DXASM_DEBUG (1 << 0)
  324. #define D3DXASM_SKIPVALIDATION (1 << 1)
  325. #ifdef __cplusplus
  326. extern "C" {
  327. #endif //__cplusplus
  328. //-------------------------------------------------------------------------
  329. // D3DXAssembleShader:
  330. // -------------------
  331. // Assembles an ascii description of a vertex or pixel shader into
  332. // binary form.
  333. //
  334. // Parameters:
  335. // pSrcFile
  336. // Source file name
  337. // hSrcModule
  338. // Module handle. if NULL, current module will be used.
  339. // pSrcResource
  340. // Resource name in module
  341. // pSrcData
  342. // Pointer to source code
  343. // SrcDataLen
  344. // Size of source code, in bytes
  345. // Flags
  346. // D3DXASM_xxx flags
  347. // ppConstants
  348. // Returns an ID3DXBuffer object containing constant declarations.
  349. // ppCompiledShader
  350. // Returns an ID3DXBuffer object containing the object code.
  351. // ppCompilationErrors
  352. // Returns an ID3DXBuffer object containing ascii error messages
  353. //-------------------------------------------------------------------------
  354. HRESULT WINAPI
  355. D3DXAssembleShaderFromFileA(
  356. LPCSTR pSrcFile,
  357. DWORD Flags,
  358. LPD3DXBUFFER* ppConstants,
  359. LPD3DXBUFFER* ppCompiledShader,
  360. LPD3DXBUFFER* ppCompilationErrors);
  361. HRESULT WINAPI
  362. D3DXAssembleShaderFromFileW(
  363. LPCWSTR pSrcFile,
  364. DWORD Flags,
  365. LPD3DXBUFFER* ppConstants,
  366. LPD3DXBUFFER* ppCompiledShader,
  367. LPD3DXBUFFER* ppCompilationErrors);
  368. #ifdef UNICODE
  369. #define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW
  370. #else
  371. #define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA
  372. #endif
  373. HRESULT WINAPI
  374. D3DXAssembleShaderFromResourceA(
  375. HMODULE hSrcModule,
  376. LPCSTR pSrcResource,
  377. DWORD Flags,
  378. LPD3DXBUFFER* ppConstants,
  379. LPD3DXBUFFER* ppCompiledShader,
  380. LPD3DXBUFFER* ppCompilationErrors);
  381. HRESULT WINAPI
  382. D3DXAssembleShaderFromResourceW(
  383. HMODULE hSrcModule,
  384. LPCWSTR pSrcResource,
  385. DWORD Flags,
  386. LPD3DXBUFFER* ppConstants,
  387. LPD3DXBUFFER* ppCompiledShader,
  388. LPD3DXBUFFER* ppCompilationErrors);
  389. #ifdef UNICODE
  390. #define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW
  391. #else
  392. #define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA
  393. #endif
  394. HRESULT WINAPI
  395. D3DXAssembleShader(
  396. LPCVOID pSrcData,
  397. UINT SrcDataLen,
  398. DWORD Flags,
  399. LPD3DXBUFFER* ppConstants,
  400. LPD3DXBUFFER* ppCompiledShader,
  401. LPD3DXBUFFER* ppCompilationErrors);
  402. #ifdef __cplusplus
  403. }
  404. #endif //__cplusplus
  405. ///////////////////////////////////////////////////////////////////////////
  406. // Misc APIs:
  407. ///////////////////////////////////////////////////////////////////////////
  408. #ifdef __cplusplus
  409. extern "C" {
  410. #endif //__cplusplus
  411. //-------------------------------------------------------------------------
  412. // D3DXGetErrorString:
  413. // ------------------
  414. // Returns the error string for given an hresult. Interprets all D3DX and
  415. // D3D hresults.
  416. //
  417. // Parameters:
  418. // hr
  419. // The error code to be deciphered.
  420. // pBuffer
  421. // Pointer to the buffer to be filled in.
  422. // BufferLen
  423. // Count of characters in buffer. Any error message longer than this
  424. // length will be truncated to fit.
  425. //-------------------------------------------------------------------------
  426. HRESULT WINAPI
  427. D3DXGetErrorStringA(
  428. HRESULT hr,
  429. LPSTR pBuffer,
  430. UINT BufferLen);
  431. HRESULT WINAPI
  432. D3DXGetErrorStringW(
  433. HRESULT hr,
  434. LPWSTR pBuffer,
  435. UINT BufferLen);
  436. #ifdef UNICODE
  437. #define D3DXGetErrorString D3DXGetErrorStringW
  438. #else
  439. #define D3DXGetErrorString D3DXGetErrorStringA
  440. #endif
  441. #ifdef __cplusplus
  442. }
  443. #endif //__cplusplus
  444. #endif //__D3DX8CORE_H__