1 module directx.d3d8;
2 
3 version(Windows):
4 
5 import directx.win32;
6 import directx.com;
7 import directx.d3dcommon;
8 
9 extern (C++) interface IDirect3D8 : IUnknown {
10     HRESULT RegisterSoftwareDevice(void* pInitializeFunction);
11     UINT GetAdapterCount();
12     HRESULT GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier);
13     UINT GetAdapterModeCount(UINT Adapter);
14     HRESULT EnumAdapterModes(UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode);
15     HRESULT GetAdapterDisplayMode(UINT Adapter,D3DDISPLAYMODE* pMode);
16     HRESULT CheckDeviceType(UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed);
17     HRESULT CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat);
18     HRESULT CheckDeviceMultiSampleType(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType);
19     HRESULT CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat);
20     HRESULT GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps);
21     HMONITOR GetAdapterMonitor(UINT Adapter);
22     HRESULT CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8* ppReturnedDeviceInterface);
23 }
24 
25 extern (C++) interface IDirect3DDevice8 : IUnknown {
26     HRESULT TestCooperativeLevel();
27     UINT GetAvailableTextureMem();
28     HRESULT ResourceManagerDiscardBytes(DWORD Bytes);
29     HRESULT GetDirect3D(IDirect3D8* ppD3D8);
30     HRESULT GetDeviceCaps(D3DCAPS8* pCaps);
31     HRESULT GetDisplayMode(D3DDISPLAYMODE* pMode);
32     HRESULT GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *pParameters);
33     HRESULT SetCursorProperties(UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8 pCursorBitmap);
34     void SetCursorPosition(int X,int Y,DWORD Flags);
35     BOOL ShowCursor(BOOL bShow);
36     HRESULT CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8* pSwapChain);
37     HRESULT Reset(D3DPRESENT_PARAMETERS* pPresentationParameters);
38     HRESULT Present(const(RECT)* pSourceRect,const(RECT)* pDestRect,HWND hDestWindowOverride,const(RGNDATA)* pDirtyRegion);
39     HRESULT GetBackBuffer(UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8* ppBackBuffer);
40     HRESULT GetRasterStatus(D3DRASTER_STATUS* pRasterStatus);
41     void SetGammaRamp(DWORD Flags,const(D3DGAMMARAMP)* pRamp);
42     void GetGammaRamp(D3DGAMMARAMP* pRamp);
43     HRESULT CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8* ppTexture);
44     HRESULT CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8* ppVolumeTexture);
45     HRESULT CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8* ppCubeTexture);
46     HRESULT CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8* ppVertexBuffer);
47     HRESULT CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8* ppIndexBuffer);
48     HRESULT CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8* ppSurface);
49     HRESULT CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8* ppSurface);
50     HRESULT CreateImageSurface(UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8* ppSurface);
51     HRESULT CopyRects(IDirect3DSurface8 pSourceSurface,const(RECT)* pSourceRectsArray,UINT cRects,IDirect3DSurface8 pDestinationSurface,const(POINT)* pDestPointsArray);
52     HRESULT UpdateTexture(IDirect3DBaseTexture8 pSourceTexture,IDirect3DBaseTexture8 pDestinationTexture);
53     HRESULT GetFrontBuffer(IDirect3DSurface8 pDestSurface);
54     HRESULT SetRenderTarget(IDirect3DSurface8 pRenderTarget,IDirect3DSurface8 pNewZStencil);
55     HRESULT GetRenderTarget(IDirect3DSurface8* ppRenderTarget);
56     HRESULT GetDepthStencilSurface(IDirect3DSurface8* ppZStencilSurface);
57     HRESULT BeginScene();
58     HRESULT EndScene();
59     HRESULT Clear(DWORD Count,const(D3DRECT)* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil);
60     HRESULT SetTransform(D3DTRANSFORMSTATETYPE State,const(D3DMATRIX)* pMatrix);
61     HRESULT GetTransform(D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix);
62     HRESULT MultiplyTransform(D3DTRANSFORMSTATETYPE,const(D3DMATRIX)*);
63     HRESULT SetViewport(const(D3DVIEWPORT8)* pViewport);
64     HRESULT GetViewport(D3DVIEWPORT8* pViewport);
65     HRESULT SetMaterial(const(D3DMATERIAL8)* pMaterial);
66     HRESULT GetMaterial(D3DMATERIAL8* pMaterial);
67     HRESULT SetLight(DWORD Index,const(D3DLIGHT8)*);
68     HRESULT GetLight(DWORD Index,D3DLIGHT8*);
69     HRESULT LightEnable(DWORD Index,BOOL Enable);
70     HRESULT GetLightEnable(DWORD Index,BOOL* pEnable);
71     HRESULT SetClipPlane(DWORD Index,const(float)* pPlane);
72     HRESULT GetClipPlane(DWORD Index,float* pPlane);
73     HRESULT SetRenderState(D3DRENDERSTATETYPE State,DWORD Value);
74     HRESULT GetRenderState(D3DRENDERSTATETYPE State,DWORD* pValue);
75     HRESULT BeginStateBlock();
76     HRESULT EndStateBlock(DWORD* pToken);
77     HRESULT ApplyStateBlock(DWORD Token);
78     HRESULT CaptureStateBlock(DWORD Token);
79     HRESULT DeleteStateBlock(DWORD Token);
80     HRESULT CreateStateBlock(D3DSTATEBLOCKTYPE Type,DWORD* pToken);
81     HRESULT SetClipStatus(const(D3DCLIPSTATUS8)* pClipStatus);
82     HRESULT GetClipStatus(D3DCLIPSTATUS8* pClipStatus);
83     HRESULT GetTexture(DWORD Stage,IDirect3DBaseTexture8* ppTexture);
84     HRESULT SetTexture(DWORD Stage,IDirect3DBaseTexture8 pTexture);
85     HRESULT GetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue);
86     HRESULT SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
87     HRESULT ValidateDevice(DWORD* pNumPasses);
88     HRESULT GetInfo(DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize);
89     HRESULT SetPaletteEntries(UINT PaletteNumber,const(PALETTEENTRY)* pEntries);
90     HRESULT GetPaletteEntries(UINT PaletteNumber,PALETTEENTRY* pEntries);
91     HRESULT SetCurrentTexturePalette(UINT PaletteNumber);
92     HRESULT GetCurrentTexturePalette(UINT *PaletteNumber);
93     HRESULT DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount);
94     HRESULT DrawIndexedPrimitive(D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount);
95     HRESULT DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,const(void)* pVertexStreamZeroData,UINT VertexStreamZeroStride);
96     HRESULT DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,const(void)* pIndexData,D3DFORMAT IndexDataFormat,const(void)* pVertexStreamZeroData,UINT VertexStreamZeroStride);
97     HRESULT ProcessVertices(UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8 pDestBuffer,DWORD Flags);
98     HRESULT CreateVertexShader(const(DWORD)* pDeclaration,const(DWORD)* pFunction,DWORD* pHandle,DWORD Usage);
99     HRESULT SetVertexShader(DWORD Handle);
100     HRESULT GetVertexShader(DWORD* pHandle);
101     HRESULT DeleteVertexShader(DWORD Handle);
102     HRESULT SetVertexShaderConstant(DWORD Register,const(void)* pConstantData,DWORD ConstantCount);
103     HRESULT GetVertexShaderConstant(DWORD Register,void* pConstantData,DWORD ConstantCount);
104     HRESULT GetVertexShaderDeclaration(DWORD Handle,void* pData,DWORD* pSizeOfData);
105     HRESULT GetVertexShaderFunction(DWORD Handle,void* pData,DWORD* pSizeOfData);
106     HRESULT SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer8 pStreamData,UINT Stride);
107     HRESULT GetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer8* ppStreamData,UINT* pStride);
108     HRESULT SetIndices(IDirect3DIndexBuffer8 pIndexData,UINT BaseVertexIndex);
109     HRESULT GetIndices(IDirect3DIndexBuffer8* ppIndexData,UINT* pBaseVertexIndex);
110     HRESULT CreatePixelShader(const(DWORD)* pFunction,DWORD* pHandle);
111     HRESULT SetPixelShader(DWORD Handle);
112     HRESULT GetPixelShader(DWORD* pHandle);
113     HRESULT DeletePixelShader(DWORD Handle);
114     HRESULT SetPixelShaderConstant(DWORD Register,const(void)* pConstantData,DWORD ConstantCount);
115     HRESULT GetPixelShaderConstant(DWORD Register,void* pConstantData,DWORD ConstantCount);
116     HRESULT GetPixelShaderFunction(DWORD Handle,void* pData,DWORD* pSizeOfData);
117     HRESULT DrawRectPatch(UINT Handle,const(float)* pNumSegs,const(D3DRECTPATCH_INFO)* pRectPatchInfo);
118     HRESULT DrawTriPatch(UINT Handle,const(float)* pNumSegs,const(D3DTRIPATCH_INFO)* pTriPatchInfo);
119     HRESULT DeletePatch(UINT Handle);
120 }
121 
122 extern (C++) interface IDirect3DSwapChain8 : IUnknown {
123     HRESULT Present(const(RECT)* pSourceRect,const(RECT)* pDestRect,HWND hDestWindowOverride,const(RGNDATA)* pDirtyRegion);
124     HRESULT GetBackBuffer(UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8* ppBackBuffer);
125 }
126 
127 extern (C++) interface IDirect3DResource8 : IUnknown {
128     HRESULT GetDevice(IDirect3DDevice8* ppDevice);
129     HRESULT SetPrivateData(REFGUID refguid,const(void)* pData,DWORD SizeOfData,DWORD Flags);
130     HRESULT GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData);
131     HRESULT FreePrivateData(REFGUID refguid);
132     DWORD SetPriority(DWORD PriorityNew);
133     DWORD GetPriority();
134     void PreLoad();
135     D3DRESOURCETYPE GetType();
136 }
137 
138 extern (C++) interface IDirect3DBaseTexture8 : IDirect3DResource8 {
139     DWORD SetLOD(DWORD LODNew);
140     DWORD GetLOD();
141     DWORD GetLevelCount();
142 }
143 
144 extern (C++) interface IDirect3DTexture8 : IDirect3DBaseTexture8 {
145     HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc);
146     HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface8* ppSurfaceLevel);
147     HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,const(RECT)* pRect,DWORD Flags);
148     HRESULT UnlockRect(UINT Level);
149     HRESULT AddDirtyRect(const(RECT)* pDirtyRect);
150 }
151 
152 extern (C++) interface IDirect3DVolumeTexture8 : IDirect3DBaseTexture8 {
153     HRESULT GetLevelDesc(UINT Level,D3DVOLUME_DESC *pDesc);
154     HRESULT GetVolumeLevel(UINT Level,IDirect3DVolume8* ppVolumeLevel);
155     HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,const(D3DBOX)* pBox,DWORD Flags);
156     HRESULT UnlockBox(UINT Level);
157     HRESULT AddDirtyBox(const(D3DBOX)* pDirtyBox);
158 }
159 
160 extern (C++) interface IDirect3DCubeTexture8 : IDirect3DBaseTexture8 {
161     HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc);
162     HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8* ppCubeMapSurface);
163     HRESULT LockRect(D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,const(RECT)* pRect,DWORD Flags);
164     HRESULT UnlockRect(D3DCUBEMAP_FACES FaceType,UINT Level);
165     HRESULT AddDirtyRect(D3DCUBEMAP_FACES FaceType,const(RECT)* pDirtyRect);
166 }
167 
168 extern (C++) interface IDirect3DVertexBuffer8 : IDirect3DResource8 {}
169 extern (C++) interface IDirect3DIndexBuffer8  : IDirect3DResource8 {}
170 
171 extern (C++) interface IDirect3DSurface8 : IUnknown {
172     HRESULT GetDevice(IDirect3DDevice8* ppDevice);
173     HRESULT SetPrivateData(REFGUID refguid,const(void)* pData,DWORD SizeOfData,DWORD Flags);
174     HRESULT GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData);
175     HRESULT FreePrivateData(REFGUID refguid);
176     HRESULT GetContainer(REFIID riid,void** ppContainer);
177     HRESULT GetDesc(D3DSURFACE_DESC *pDesc);
178     HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,const(RECT)* pRect,DWORD Flags);
179     HRESULT UnlockRect();
180 }
181 
182 extern (C++) interface IDirect3DVolume8 : IUnknown {
183     HRESULT GetDevice(IDirect3DDevice8* ppDevice);
184     HRESULT SetPrivateData(REFGUID refguid,const(void)* pData,DWORD SizeOfData,DWORD Flags);
185     HRESULT GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData);
186     HRESULT FreePrivateData(REFGUID refguid);
187     HRESULT GetContainer(REFIID riid,void** ppContainer);
188     HRESULT GetDesc(D3DVOLUME_DESC *pDesc);
189     HRESULT LockBox(D3DLOCKED_BOX * pLockedVolume,const(D3DBOX)* pBox,DWORD Flags);
190     HRESULT UnlockBox();
191 }
192 
193 struct D3DVIEWPORT8 {
194     DWORD       X;
195     DWORD       Y;            /* Viewport Top left */
196     DWORD       Width;
197     DWORD       Height;       /* Viewport Dimensions */
198     float       MinZ;         /* Min/max of clip Volume */
199     float       MaxZ;
200 }
201 
202 struct D3DCLIPSTATUS8 {
203     DWORD ClipUnion;
204     DWORD ClipIntersection;
205 }
206 
207 struct D3DMATERIAL8 {
208     D3DCOLORVALUE   Diffuse;        /* Diffuse color RGBA */
209     D3DCOLORVALUE   Ambient;        /* Ambient color RGB */
210     D3DCOLORVALUE   Specular;       /* Specular 'shininess' */
211     D3DCOLORVALUE   Emissive;       /* Emissive color RGB */
212     float           Power;          /* Sharpness if specular highlight */
213 }
214 
215 struct D3DLIGHT8 {
216     D3DLIGHTTYPE    Type;            /* Type of light source */
217     D3DCOLORVALUE   Diffuse;         /* Diffuse color of light */
218     D3DCOLORVALUE   Specular;        /* Specular color of light */
219     D3DCOLORVALUE   Ambient;         /* Ambient color of light */
220     D3DVECTOR       Position;         /* Position in world space */
221     D3DVECTOR       Direction;        /* Direction in world space */
222     float           Range;            /* Cutoff range */
223     float           Falloff;          /* Falloff */
224     float           Attenuation0;     /* Constant attenuation */
225     float           Attenuation1;     /* Linear attenuation */
226     float           Attenuation2;     /* Quadratic attenuation */
227     float           Theta;            /* Inner angle of spotlight cone */
228     float           Phi;              /* Outer angle of spotlight cone */
229 }
230 
231 __gshared LPDIRECT3DCREATE8 Direct3DCreate8;
232 
233 extern (Windows) {
234     alias LPDIRECT3DCREATE8 = IDirect3D8 function(UINT SDKVersion);
235 }
236 
237 enum D3D_SDK_VERSION = 220;