1 /***********************************************************************\
2 *                              d3dx10core.d                             *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                       Placed into public domain                       *
7 \***********************************************************************/
8 module win32.directx.d3dx10core;
9 
10 private import win32.windows;
11 
12 private import win32.directx.d3d10;
13 private import win32.directx.d3d10effect;
14 private import win32.directx.d3dx10math;
15 
16 const D3DX10_DLL_W = "d3dx10_36.dll";
17 const D3DX10_DLL_A = "d3dx10_36.dll";
18 
19 version(Unicode) {
20 	alias D3DX10_DLL_W D3DX10_DLL;
21 } else {
22 	alias D3DX10_DLL_A D3DX10_DLL;
23 }
24 
25 const D3DX10_SDK_VERSION = 36;
26 
27 extern(Windows) {
28 	HRESULT D3DX10CreateDevice(IDXGIAdapter pAdapter, D3D10_DRIVER_TYPE DriverType,
29 		HMODULE Software, UINT Flags, ID3D10Device* ppDevice);
30 	HRESULT D3DX10CreateDeviceAndSwapChain(IDXGIAdapter pAdapter, D3D10_DRIVER_TYPE DriverType,
31 		HMODULE Software, UINT Flags, DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, IDXGISwapChain* ppSwapChain,    
32 		ID3D10Device* ppDevice);
33 //TODO	HRESULT D3DX10GetFeatureLevel1(ID3D10Device pDevice, ID3D10Device1* ppDevice1);
34 
35 	debug(D3D10_DEBUG) {
36 		BOOL D3DX10DebugMute(BOOL Mute);
37 	}
38 
39 	HRESULT D3DX10CheckVersion(UINT D3DSdkVersion, UINT D3DX10SdkVersion);
40 	UINT D3DX10GetDriverLevel(ID3D10Device pDevice);
41 }
42 
43 enum D3DX10_SPRITE_FLAG {
44 	D3DX10_SPRITE_SORT_TEXTURE				= 0x01,
45 	D3DX10_SPRITE_SORT_DEPTH_BACK_TO_FRONT	= 0x02,
46 	D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK	= 0x04,
47 	D3DX10_SPRITE_SAVE_STATE				= 0x08,
48 	D3DX10_SPRITE_ADDREF_TEXTURES			= 0x10
49 }
50 
51 struct D3DX10_SPRITE {
52 	D3DXMATRIX					matWorld;
53 	D3DXVECTOR2					TexCoord;
54 	D3DXVECTOR2					TexSize;
55 	D3DXCOLOR					ColorModulate;
56 	ID3D10ShaderResourceView	pTexture;
57 	UINT						TextureIndex;
58 }
59 
60 extern(C) const GUID IID_ID3DX10Sprite = {0xba0b762d, 0x8d28, 0x43ec, [0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x06, 0x14]};
61 
62 interface ID3DX10Sprite : IUnknown {
63 	extern(Windows) :
64 	HRESULT Begin(UINT flags);
65 	HRESULT DrawSpritesBuffered(D3DX10_SPRITE* pSprites, UINT cSprites);
66 	HRESULT Flush();
67 	HRESULT DrawSpritesImmediate(D3DX10_SPRITE* pSprites, UINT cSprites, UINT cbSprite, UINT flags);
68 	HRESULT End();
69 	HRESULT GetViewTransform(D3DXMATRIX* pViewTransform);
70 	HRESULT SetViewTransform(D3DXMATRIX* pViewTransform);
71 	HRESULT GetProjectionTransform(D3DXMATRIX* pProjectionTransform);
72 	HRESULT SetProjectionTransform(D3DXMATRIX* pProjectionTransform);
73 	HRESULT GetDevice(ID3D10Device* ppDevice);
74 }
75 
76 extern(Windows) HRESULT D3DX10CreateSprite(ID3D10Device pDevice, UINT cDeviceBufferSize, ID3DX10Sprite* ppSprite);
77 
78 interface ID3DX10DataLoader {
79 /* TODO: fix vtbl[0] bug
80 	extern(Windows) :
81 	HRESULT Load();
82 	HRESULT Decompress(void** ppData, SIZE_T* pcBytes);
83 	HRESULT Destroy();
84 	*/
85 }
86 
87 interface ID3DX10DataProcessor {
88 /* TODO: fix vtbl[0] bug
89 	extern(Windows) :
90 	HRESULT Process(void* pData, SIZE_T cBytes);
91 	HRESULT CreateDeviceObject(void** ppDataObject);
92 	HRESULT Destroy();
93 	*/
94 }
95 
96 extern(C) const GUID IID_ID3DX10ThreadPump = {0xc93fecfa, 0x6967, 0x478a, [0xab, 0xbc, 0x40, 0x2d, 0x90, 0x62, 0x1f, 0xcb]};
97 
98 interface ID3DX10ThreadPump : IUnknown {
99 	extern(Windows) :
100 	HRESULT AddWorkItem(ID3DX10DataLoader pDataLoader, ID3DX10DataProcessor pDataProcessor, HRESULT *pHResult, void **ppDeviceObject);
101 	UINT GetWorkItemCount();
102 	HRESULT WaitForAllItems();
103 	HRESULT ProcessDeviceWorkItems(UINT iWorkItemCount);
104 	HRESULT PurgeAllItems();
105 	HRESULT GetQueueStatus(UINT* pIoQueue, UINT* pProcessQueue, UINT* pDeviceQueue);
106 }
107 
108 extern(Windows) HRESULT D3DX10CreateThreadPump(UINT cIoThreads, UINT cProcThreads,
109 	ID3DX10ThreadPump *ppThreadPump);
110 
111 struct D3DX10_FONT_DESCA {
112 	INT Height;
113 	UINT Width;
114 	UINT Weight;
115 	UINT MipLevels;
116 	BOOL Italic;
117 	BYTE CharSet;
118 	BYTE OutputPrecision;
119 	BYTE Quality;
120 	BYTE PitchAndFamily;
121 	CHAR[LF_FACESIZE] FaceName;
122 }
123 
124 struct D3DX10_FONT_DESCW {
125 	INT Height;
126 	UINT Width;
127 	UINT Weight;
128 	UINT MipLevels;
129 	BOOL Italic;
130 	BYTE CharSet;
131 	BYTE OutputPrecision;
132 	BYTE Quality;
133 	BYTE PitchAndFamily;
134 	WCHAR[LF_FACESIZE] FaceName;
135 }
136 
137 version(Unicode) {
138 	alias D3DX10_FONT_DESCW D3DX10_FONT_DESC;
139 } else {
140 	alias D3DX10_FONT_DESCA D3DX10_FONT_DESC;
141 }
142 
143 extern(C) const GUID IID_ID3DX10Font = {0xd79dbb70, 0x5f21, 0x4d36, [0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc]};
144 
145 interface ID3DX10Font : IUnknown {
146 	extern(Windows) :
147 	HRESULT GetDevice(ID3D10Device* ppDevice);
148 	HRESULT GetDescA(D3DX10_FONT_DESCA* pDesc);
149 	HRESULT GetDescW(D3DX10_FONT_DESCW* pDesc);
150 	BOOL GetTextMetricsA(TEXTMETRICA* pTextMetrics);
151 	BOOL GetTextMetricsW(TEXTMETRICW* pTextMetrics);
152 	HDC GetDC();
153 	HRESULT GetGlyphData(UINT Glyph, ID3D10ShaderResourceView* ppTexture, RECT* pBlackBox, POINT* pCellInc);
154 	HRESULT PreloadCharacters(UINT First, UINT Last);
155 	HRESULT PreloadGlyphs(UINT First, UINT Last);
156 	HRESULT PreloadTextA(LPCSTR pString, INT Count);
157 	HRESULT PreloadTextW(LPCWSTR pString, INT Count);
158 	INT DrawTextA(ID3DX10Sprite pSprite, LPCSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color);
159 	INT DrawTextW(ID3DX10Sprite pSprite, LPCWSTR pString, INT Count, LPRECT pRect, UINT Format, D3DXCOLOR Color);
160 	version(Unicode) {
161 		alias GetTextMetricsW GetTextMetrics;
162 		alias DrawTextW DrawText;
163 	} else {
164 		alias GetTextMetricsA GetTextMetrics;
165 		alias DrawTextA DrawText;
166 	}
167 }
168 
169 extern(Windows) {
170 	HRESULT D3DX10CreateFontA(ID3D10Device pDevice, INT Height, UINT Width, UINT Weight,
171 		UINT MipLevels, BOOL Italic, UINT CharSet, UINT OutputPrecision, UINT Quality,
172 		UINT PitchAndFamily, LPCSTR pFaceName, ID3DX10Font* ppFont);
173 	HRESULT D3DX10CreateFontW(ID3D10Device pDevice, INT Height, UINT Width, UINT Weight,
174 		UINT MipLevels, BOOL Italic, UINT CharSet, UINT OutputPrecision, UINT Quality,
175 		UINT PitchAndFamily, LPCWSTR pFaceName, ID3DX10Font* ppFont);
176 }
177 
178 version(Unicode) {
179 	alias D3DX10CreateFontW D3DX10CreateFont;
180 } else {
181 	alias D3DX10CreateFontA D3DX10CreateFont;
182 }
183 
184 extern(Windows) {
185 	HRESULT D3DX10CreateFontIndirectA(ID3D10Device pDevice, D3DX10_FONT_DESCA* pDesc, ID3DX10Font* ppFont);
186 	HRESULT D3DX10CreateFontIndirectW(ID3D10Device pDevice, D3DX10_FONT_DESCW* pDesc, ID3DX10Font* ppFont);
187 }
188 
189 version(Unicode) {
190 	alias D3DX10CreateFontIndirectW D3DX10CreateFontIndirect;
191 } else {
192 	alias D3DX10CreateFontIndirectA D3DX10CreateFontIndirect;
193 }
194 
195 extern(Windows) {
196 	HRESULT D3DX10UnsetAllDeviceObjects(ID3D10Device pDevice);
197 //TODO 	HRESULT D3DX10ReflectShader(void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection1 *ppReflector);
198 	HRESULT D3DX10DisassembleShader(void *pShader, SIZE_T BytecodeLength, BOOL EnableColorCode,
199 		LPCSTR pComments, ID3D10Blob* ppDisassembly);
200 	HRESULT D3DX10DisassembleEffect(ID3D10Effect pEffect, BOOL EnableColorCode, ID3D10Blob* ppDisassembly);
201 }
202 
203 const _FACD3D = 0x876;
204 
205 HRESULT MAKE_D3DHRESULT(T)(T code) {
206 	return MAKE_HRESULT(1, _FACD3D, code);
207 }
208 
209 HRESULT MAKE_D3DSTATUS(T)(T code) {
210 	return MAKE_HRESULT(0, _FACD3D, code);
211 }
212 
213 const D3DERR_INVALIDCALL = MAKE_D3DHRESULT(2156);
214 const D3DERR_WASSTILLDRAWING = MAKE_D3DHRESULT(540);