DirectX Core API Reference
This section provides detailed reference information for the core DirectX APIs, including device creation, resource management, and shader compilation.
ID3D11Device #
Represents the Direct3D device, which is the object that all Direct3D objects are created from. It provides methods for creating and managing resources, shaders, and states.
Methods
CreateDepthStencilState #
Creates a depth-stencil state object.
HRESULT CreateDepthStencilState(
[in] const D3D11_DEPTH_STENCIL_DESC *pDepthStencilDesc,
[out] ID3D11DepthStencilState **ppDepthStencilState
);
Parameters
Name | Type | Description |
---|---|---|
pDepthStencilDesc |
const D3D11_DEPTH_STENCIL_DESC* |
Pointer to a description of the depth-stencil state. |
ppDepthStencilState |
ID3D11DepthStencilState** |
Address of a pointer to the created depth-stencil state object. |
Return Value:
Returns
S_OK
on success or one of the following: E_OUTOFMEMORY
, E_INVALIDARG
Note: This method is used to configure depth testing and stencil buffer operations.
CreateVertexShader #
Creates a vertex shader object.
HRESULT CreateVertexShader(
[in] const void *pShaderBytecode,
[in] SIZE_T BytecodeLength,
[in] ID3D11ClassLinkage *pClassLinkage,
[out] ID3D11VertexShader **ppVertexShader
);
Parameters
Name | Type | Description |
---|---|---|
pShaderBytecode |
const void* |
Pointer to the compiled shader code. |
BytecodeLength |
SIZE_T |
Length of the compiled shader code. |
pClassLinkage |
ID3D11ClassLinkage* |
Optional pointer to a class linkage interface. |
ppVertexShader |
ID3D11VertexShader** |
Address of a pointer to the created vertex shader object. |
Return Value:
Returns
S_OK
on success or one of the following: E_OUTOFMEMORY
, E_INVALIDARG
ID3D11DeviceContext #
Represents a Direct3D device context, which is used to render to a render target.
Methods
Draw #
Draws from the current vertex buffer.
void Draw(
[in] UINT VertexCount,
[in] UINT StartVertexLocation
);
Parameters
Name | Type | Description |
---|---|---|
VertexCount |
UINT |
Number of vertices to draw. |
StartVertexLocation |
UINT |
The starting vertex for rendering. |
Note: This is a fundamental drawing command.
IASetVertexBuffers #
Binds an array of vertex buffers to the input-assembler stage.
void IASetVertexBuffers(
[in] UINT StartSlot,
[in] UINT NumBuffers,
[in] ID3D11Buffer *const *ppVertexBuffers,
[in] const UINT *pStrides,
[in] const UINT *pOffsets
);
Parameters
Name | Type | Description |
---|---|---|
StartSlot |
UINT |
The first vertex buffer to bind. |
NumBuffers |
UINT |
The total number of vertex buffers to bind. |
ppVertexBuffers |
ID3D11Buffer* const* |
Array of vertex buffer interfaces. |
pStrides |
const UINT* |
Array of strides (in bytes) for each vertex buffer. |
pOffsets |
const UINT* |
Array of offsets (in bytes) for each vertex buffer. |
D3DCompile #
Compiles a shader from source code or effects file.
HRESULT D3DCompile(
[in] LPCVOID pSrcData,
[in] SIZE_T SrcDataSize,
[in, optional] LPCSTR pSourceName,
[in, optional] const D3D_SHADER_MACRO pDefines,
[in, optional] ID3D11Include *pInclude,
[in] LPCSTR pEntrypoint,
[in] LPCSTR pTarget,
[in] UINT Flags1,
[in] UINT Flags2,
[out] ID3DBlob **ppCode,
[out, optional] ID3DBlob **ppErrorMsgs
);
Parameters
Name | Type | Description |
---|---|---|
pSrcData |
LPCVOID |
Pointer to the shader buffer. |
SrcDataSize |
SIZE_T |
Size of the shader buffer. |
pSourceName |
LPCSTR |
Name of the source file. |
pDefines |
const D3D_SHADER_MACRO* |
Optional defines. |
pInclude |
ID3D11Include* |
Optional include interface. |
pEntrypoint |
LPCSTR |
The shader's entry point. |
pTarget |
LPCSTR |
The shader model target. |
Flags1 |
UINT |
Shader compilation flags. |
Flags2 |
UINT |
More shader compilation flags. |
ppCode |
ID3DBlob** |
Pointer to the compiled shader code. |
ppErrorMsgs |
ID3DBlob** |
Pointer to error messages. |
Return Value:
Returns
S_OK
on success or a standard COM error code.
Note: Use this function to compile HLSL code into bytecode.
DXGI Adapter #
The DXGI Adapter interface represents a display adapter (graphics card).
Methods
EnumAdapters #
Enumerates the display adapters.
HRESULT EnumAdapters(
[in] UINT Adapter,
[out] IDXGIAdapter **ppAdapter
);
Parameters
Name | Type | Description |
---|---|---|
Adapter |
UINT |
The adapter number. |
ppAdapter |
IDXGIAdapter** |
Address of a pointer to the adapter interface. |
Return Value:
Returns
S_OK
on success or DXGI_ERROR_NOT_FOUND
if there are no more adapters.