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