Counter Strike : Global Offensive Source Code
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.

444 lines
14 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: d3dx10core.h
  6. // Content: D3DX10 core types and functions
  7. //
  8. ///////////////////////////////////////////////////////////////////////////
  9. #include "d3dx10.h"
  10. #ifndef __D3DX10CORE_H__
  11. #define __D3DX10CORE_H__
  12. // Current name of the DLL shipped in the same SDK as this header.
  13. #define D3DX10_DLL_W L"d3dx10_43.dll"
  14. #define D3DX10_DLL_A "d3dx10_43.dll"
  15. #ifdef UNICODE
  16. #define D3DX10_DLL D3DX10_DLL_W
  17. #else
  18. #define D3DX10_DLL D3DX10_DLL_A
  19. #endif
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif //__cplusplus
  23. ///////////////////////////////////////////////////////////////////////////
  24. // D3DX10_SDK_VERSION:
  25. // -----------------
  26. // This identifier is passed to D3DX10CheckVersion in order to ensure that an
  27. // application was built against the correct header files and lib files.
  28. // This number is incremented whenever a header (or other) change would
  29. // require applications to be rebuilt. If the version doesn't match,
  30. // D3DX10CreateVersion will return FALSE. (The number itself has no meaning.)
  31. ///////////////////////////////////////////////////////////////////////////
  32. #define D3DX10_SDK_VERSION 43
  33. ///////////////////////////////////////////////////////////////////////////
  34. // D3DX10CreateDevice
  35. // D3DX10CreateDeviceAndSwapChain
  36. // D3DX10GetFeatureLevel1
  37. ///////////////////////////////////////////////////////////////////////////
  38. HRESULT WINAPI D3DX10CreateDevice(IDXGIAdapter *pAdapter,
  39. D3D10_DRIVER_TYPE DriverType,
  40. HMODULE Software,
  41. UINT Flags,
  42. ID3D10Device **ppDevice);
  43. HRESULT WINAPI D3DX10CreateDeviceAndSwapChain(IDXGIAdapter *pAdapter,
  44. D3D10_DRIVER_TYPE DriverType,
  45. HMODULE Software,
  46. UINT Flags,
  47. DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
  48. IDXGISwapChain **ppSwapChain,
  49. ID3D10Device **ppDevice);
  50. typedef interface ID3D10Device1 ID3D10Device1;
  51. HRESULT WINAPI D3DX10GetFeatureLevel1(ID3D10Device *pDevice, ID3D10Device1 **ppDevice1);
  52. #ifdef D3D_DIAG_DLL
  53. BOOL WINAPI D3DX10DebugMute(BOOL Mute);
  54. #endif
  55. HRESULT WINAPI D3DX10CheckVersion(UINT D3DSdkVersion, UINT D3DX10SdkVersion);
  56. #ifdef __cplusplus
  57. }
  58. #endif //__cplusplus
  59. //////////////////////////////////////////////////////////////////////////////
  60. // D3DX10_SPRITE flags:
  61. // -----------------
  62. // D3DX10_SPRITE_SAVE_STATE
  63. // Specifies device state should be saved and restored in Begin/End.
  64. // D3DX10SPRITE_SORT_TEXTURE
  65. // Sprites are sorted by texture prior to drawing. This is recommended when
  66. // drawing non-overlapping sprites of uniform depth. For example, drawing
  67. // screen-aligned text with ID3DX10Font.
  68. // D3DX10SPRITE_SORT_DEPTH_FRONT_TO_BACK
  69. // Sprites are sorted by depth front-to-back prior to drawing. This is
  70. // recommended when drawing opaque sprites of varying depths.
  71. // D3DX10SPRITE_SORT_DEPTH_BACK_TO_FRONT
  72. // Sprites are sorted by depth back-to-front prior to drawing. This is
  73. // recommended when drawing transparent sprites of varying depths.
  74. // D3DX10SPRITE_ADDREF_TEXTURES
  75. // AddRef/Release all textures passed in to DrawSpritesBuffered
  76. //////////////////////////////////////////////////////////////////////////////
  77. typedef enum _D3DX10_SPRITE_FLAG
  78. {
  79. D3DX10_SPRITE_SORT_TEXTURE = 0x01,
  80. D3DX10_SPRITE_SORT_DEPTH_BACK_TO_FRONT = 0x02,
  81. D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK = 0x04,
  82. D3DX10_SPRITE_SAVE_STATE = 0x08,
  83. D3DX10_SPRITE_ADDREF_TEXTURES = 0x10,
  84. } D3DX10_SPRITE_FLAG;
  85. typedef struct _D3DX10_SPRITE
  86. {
  87. D3DXMATRIX matWorld;
  88. D3DXVECTOR2 TexCoord;
  89. D3DXVECTOR2 TexSize;
  90. D3DXCOLOR ColorModulate;
  91. ID3D10ShaderResourceView *pTexture;
  92. UINT TextureIndex;
  93. } D3DX10_SPRITE;
  94. //////////////////////////////////////////////////////////////////////////////
  95. // ID3DX10Sprite:
  96. // ------------
  97. // This object intends to provide an easy way to drawing sprites using D3D.
  98. //
  99. // Begin -
  100. // Prepares device for drawing sprites.
  101. //
  102. // Draw -
  103. // Draws a sprite
  104. //
  105. // Flush -
  106. // Forces all batched sprites to submitted to the device.
  107. //
  108. // End -
  109. // Restores device state to how it was when Begin was called.
  110. //
  111. //////////////////////////////////////////////////////////////////////////////
  112. typedef interface ID3DX10Sprite ID3DX10Sprite;
  113. typedef interface ID3DX10Sprite *LPD3DX10SPRITE;
  114. // {BA0B762D-8D28-43ec-B9DC-2F84443B0614}
  115. DEFINE_GUID(IID_ID3DX10Sprite,
  116. 0xba0b762d, 0x8d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14);
  117. #undef INTERFACE
  118. #define INTERFACE ID3DX10Sprite
  119. DECLARE_INTERFACE_(ID3DX10Sprite, IUnknown)
  120. {
  121. // IUnknown
  122. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  123. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  124. STDMETHOD_(ULONG, Release)(THIS) PURE;
  125. // ID3DX10Sprite
  126. STDMETHOD(Begin)(THIS_ UINT flags) PURE;
  127. STDMETHOD(DrawSpritesBuffered)(THIS_ D3DX10_SPRITE *pSprites, UINT cSprites) PURE;
  128. STDMETHOD(Flush)(THIS) PURE;
  129. STDMETHOD(DrawSpritesImmediate)(THIS_ D3DX10_SPRITE *pSprites, UINT cSprites, UINT cbSprite, UINT flags) PURE;
  130. STDMETHOD(End)(THIS) PURE;
  131. STDMETHOD(GetViewTransform)(THIS_ D3DXMATRIX *pViewTransform) PURE;
  132. STDMETHOD(SetViewTransform)(THIS_ D3DXMATRIX *pViewTransform) PURE;
  133. STDMETHOD(GetProjectionTransform)(THIS_ D3DXMATRIX *pProjectionTransform) PURE;
  134. STDMETHOD(SetProjectionTransform)(THIS_ D3DXMATRIX *pProjectionTransform) PURE;
  135. STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE;
  136. };
  137. #ifdef __cplusplus
  138. extern "C" {
  139. #endif //__cplusplus
  140. HRESULT WINAPI
  141. D3DX10CreateSprite(
  142. ID3D10Device* pDevice,
  143. UINT cDeviceBufferSize,
  144. LPD3DX10SPRITE* ppSprite);
  145. #ifdef __cplusplus
  146. }
  147. #endif //__cplusplus
  148. //////////////////////////////////////////////////////////////////////////////
  149. // ID3DX10ThreadPump:
  150. //////////////////////////////////////////////////////////////////////////////
  151. #undef INTERFACE
  152. #define INTERFACE ID3DX10DataLoader
  153. DECLARE_INTERFACE(ID3DX10DataLoader)
  154. {
  155. STDMETHOD(Load)(THIS) PURE;
  156. STDMETHOD(Decompress)(THIS_ void **ppData, SIZE_T *pcBytes) PURE;
  157. STDMETHOD(Destroy)(THIS) PURE;
  158. };
  159. #undef INTERFACE
  160. #define INTERFACE ID3DX10DataProcessor
  161. DECLARE_INTERFACE(ID3DX10DataProcessor)
  162. {
  163. STDMETHOD(Process)(THIS_ void *pData, SIZE_T cBytes) PURE;
  164. STDMETHOD(CreateDeviceObject)(THIS_ void **ppDataObject) PURE;
  165. STDMETHOD(Destroy)(THIS) PURE;
  166. };
  167. // {C93FECFA-6967-478a-ABBC-402D90621FCB}
  168. DEFINE_GUID(IID_ID3DX10ThreadPump,
  169. 0xc93fecfa, 0x6967, 0x478a, 0xab, 0xbc, 0x40, 0x2d, 0x90, 0x62, 0x1f, 0xcb);
  170. #undef INTERFACE
  171. #define INTERFACE ID3DX10ThreadPump
  172. DECLARE_INTERFACE_(ID3DX10ThreadPump, IUnknown)
  173. {
  174. // IUnknown
  175. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  176. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  177. STDMETHOD_(ULONG, Release)(THIS) PURE;
  178. // ID3DX10ThreadPump
  179. STDMETHOD(AddWorkItem)(THIS_ ID3DX10DataLoader *pDataLoader, ID3DX10DataProcessor *pDataProcessor, HRESULT *pHResult, void **ppDeviceObject) PURE;
  180. STDMETHOD_(UINT, GetWorkItemCount)(THIS) PURE;
  181. STDMETHOD(WaitForAllItems)(THIS) PURE;
  182. STDMETHOD(ProcessDeviceWorkItems)(THIS_ UINT iWorkItemCount);
  183. STDMETHOD(PurgeAllItems)(THIS) PURE;
  184. STDMETHOD(GetQueueStatus)(THIS_ UINT *pIoQueue, UINT *pProcessQueue, UINT *pDeviceQueue) PURE;
  185. };
  186. HRESULT WINAPI D3DX10CreateThreadPump(UINT cIoThreads, UINT cProcThreads, ID3DX10ThreadPump **ppThreadPump);
  187. //////////////////////////////////////////////////////////////////////////////
  188. // ID3DX10Font:
  189. // ----------
  190. // Font objects contain the textures and resources needed to render a specific
  191. // font on a specific device.
  192. //
  193. // GetGlyphData -
  194. // Returns glyph cache data, for a given glyph.
  195. //
  196. // PreloadCharacters/PreloadGlyphs/PreloadText -
  197. // Preloads glyphs into the glyph cache textures.
  198. //
  199. // DrawText -
  200. // Draws formatted text on a D3D device. Some parameters are
  201. // surprisingly similar to those of GDI's DrawText function. See GDI
  202. // documentation for a detailed description of these parameters.
  203. // If pSprite is NULL, an internal sprite object will be used.
  204. //
  205. //////////////////////////////////////////////////////////////////////////////
  206. typedef struct _D3DX10_FONT_DESCA
  207. {
  208. INT Height;
  209. UINT Width;
  210. UINT Weight;
  211. UINT MipLevels;
  212. BOOL Italic;
  213. BYTE CharSet;
  214. BYTE OutputPrecision;
  215. BYTE Quality;
  216. BYTE PitchAndFamily;
  217. CHAR FaceName[LF_FACESIZE];
  218. } D3DX10_FONT_DESCA, *LPD3DX10_FONT_DESCA;
  219. typedef struct _D3DX10_FONT_DESCW
  220. {
  221. INT Height;
  222. UINT Width;
  223. UINT Weight;
  224. UINT MipLevels;
  225. BOOL Italic;
  226. BYTE CharSet;
  227. BYTE OutputPrecision;
  228. BYTE Quality;
  229. BYTE PitchAndFamily;
  230. WCHAR FaceName[LF_FACESIZE];
  231. } D3DX10_FONT_DESCW, *LPD3DX10_FONT_DESCW;
  232. #ifdef UNICODE
  233. typedef D3DX10_FONT_DESCW D3DX10_FONT_DESC;
  234. typedef LPD3DX10_FONT_DESCW LPD3DX10_FONT_DESC;
  235. #else
  236. typedef D3DX10_FONT_DESCA D3DX10_FONT_DESC;
  237. typedef LPD3DX10_FONT_DESCA LPD3DX10_FONT_DESC;
  238. #endif
  239. typedef interface ID3DX10Font ID3DX10Font;
  240. typedef interface ID3DX10Font *LPD3DX10FONT;
  241. // {D79DBB70-5F21-4d36-BBC2-FF525C213CDC}
  242. DEFINE_GUID(IID_ID3DX10Font,
  243. 0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc);
  244. #undef INTERFACE
  245. #define INTERFACE ID3DX10Font
  246. DECLARE_INTERFACE_(ID3DX10Font, IUnknown)
  247. {
  248. // IUnknown
  249. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  250. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  251. STDMETHOD_(ULONG, Release)(THIS) PURE;
  252. // ID3DX10Font
  253. STDMETHOD(GetDevice)(THIS_ ID3D10Device** ppDevice) PURE;
  254. STDMETHOD(GetDescA)(THIS_ D3DX10_FONT_DESCA *pDesc) PURE;
  255. STDMETHOD(GetDescW)(THIS_ D3DX10_FONT_DESCW *pDesc) PURE;
  256. STDMETHOD_(BOOL, GetTextMetricsA)(THIS_ TEXTMETRICA *pTextMetrics) PURE;
  257. STDMETHOD_(BOOL, GetTextMetricsW)(THIS_ TEXTMETRICW *pTextMetrics) PURE;
  258. STDMETHOD_(HDC, GetDC)(THIS) PURE;
  259. STDMETHOD(GetGlyphData)(THIS_ UINT Glyph, ID3D10ShaderResourceView** ppTexture, RECT *pBlackBox, POINT *pCellInc) PURE;
  260. STDMETHOD(PreloadCharacters)(THIS_ UINT First, UINT Last) PURE;
  261. STDMETHOD(PreloadGlyphs)(THIS_ UINT First, UINT Last) PURE;
  262. STDMETHOD(PreloadTextA)(THIS_ LPCSTR pString, INT Count) PURE;
  263. STDMETHOD(PreloadTextW)(THIS_ LPCWSTR pString, INT Count) PURE;
  264. STDMETHOD_(INT, DrawTextA)(THIS_ LPD3DX10SPRITE pSprite, LPCSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color) PURE;
  265. STDMETHOD_(INT, DrawTextW)(THIS_ LPD3DX10SPRITE pSprite, LPCWSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color) PURE;
  266. #ifdef __cplusplus
  267. #ifdef UNICODE
  268. HRESULT WINAPI_INLINE GetDesc(D3DX10_FONT_DESCW *pDesc) { return GetDescW(pDesc); }
  269. HRESULT WINAPI_INLINE PreloadText(LPCWSTR pString, INT Count) { return PreloadTextW(pString, Count); }
  270. #else
  271. HRESULT WINAPI_INLINE GetDesc(D3DX10_FONT_DESCA *pDesc) { return GetDescA(pDesc); }
  272. HRESULT WINAPI_INLINE PreloadText(LPCSTR pString, INT Count) { return PreloadTextA(pString, Count); }
  273. #endif
  274. #endif //__cplusplus
  275. };
  276. #ifndef GetTextMetrics
  277. #ifdef UNICODE
  278. #define GetTextMetrics GetTextMetricsW
  279. #else
  280. #define GetTextMetrics GetTextMetricsA
  281. #endif
  282. #endif
  283. #ifndef DrawText
  284. #ifdef UNICODE
  285. #define DrawText DrawTextW
  286. #else
  287. #define DrawText DrawTextA
  288. #endif
  289. #endif
  290. #ifdef __cplusplus
  291. extern "C" {
  292. #endif //__cplusplus
  293. HRESULT WINAPI
  294. D3DX10CreateFontA(
  295. ID3D10Device* pDevice,
  296. INT Height,
  297. UINT Width,
  298. UINT Weight,
  299. UINT MipLevels,
  300. BOOL Italic,
  301. UINT CharSet,
  302. UINT OutputPrecision,
  303. UINT Quality,
  304. UINT PitchAndFamily,
  305. LPCSTR pFaceName,
  306. LPD3DX10FONT* ppFont);
  307. HRESULT WINAPI
  308. D3DX10CreateFontW(
  309. ID3D10Device* pDevice,
  310. INT Height,
  311. UINT Width,
  312. UINT Weight,
  313. UINT MipLevels,
  314. BOOL Italic,
  315. UINT CharSet,
  316. UINT OutputPrecision,
  317. UINT Quality,
  318. UINT PitchAndFamily,
  319. LPCWSTR pFaceName,
  320. LPD3DX10FONT* ppFont);
  321. #ifdef UNICODE
  322. #define D3DX10CreateFont D3DX10CreateFontW
  323. #else
  324. #define D3DX10CreateFont D3DX10CreateFontA
  325. #endif
  326. HRESULT WINAPI
  327. D3DX10CreateFontIndirectA(
  328. ID3D10Device* pDevice,
  329. CONST D3DX10_FONT_DESCA* pDesc,
  330. LPD3DX10FONT* ppFont);
  331. HRESULT WINAPI
  332. D3DX10CreateFontIndirectW(
  333. ID3D10Device* pDevice,
  334. CONST D3DX10_FONT_DESCW* pDesc,
  335. LPD3DX10FONT* ppFont);
  336. #ifdef UNICODE
  337. #define D3DX10CreateFontIndirect D3DX10CreateFontIndirectW
  338. #else
  339. #define D3DX10CreateFontIndirect D3DX10CreateFontIndirectA
  340. #endif
  341. HRESULT WINAPI D3DX10UnsetAllDeviceObjects(ID3D10Device *pDevice);
  342. #ifdef __cplusplus
  343. }
  344. #endif //__cplusplus
  345. ///////////////////////////////////////////////////////////////////////////
  346. #define _FACD3D 0x876
  347. #define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code )
  348. #define MAKE_D3DSTATUS( code ) MAKE_HRESULT( 0, _FACD3D, code )
  349. #define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156)
  350. #define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540)
  351. #endif //__D3DX10CORE_H__