Windows API Reference

Direct3D 11 Functions

This section details the core functions used for interacting with Direct3D 11. These functions enable the creation, configuration, and rendering of graphics resources.

D3D11CreateDevice HRESULT D3D11CreateDevice( _In_opt_ IDXGIAdapter* Adapter, _In_ D3D_DRIVER_TYPE DriverType, _In_opt_ HMODULE Software, _In_ UINT Flags, _In_reads_opt_(D3D11_SDK_VERSION) const D3D11_FEATURE_LEVEL* FeatureLevels, _In_ UINT FeatureLevels, _In_ UINT SDKVersion, _Out_opt_ ID3D11Device** ppDevice, _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, _Out_opt_ ID3D11DeviceContext** ppImmediateContext );
Creates a Direct3D 11 device and its immediate device context.
Parameters:
  • Adapter: Pointer to the video memory adapter.
  • DriverType: Specifies the driver type.
  • Software: Handle to a DLL that implements a software rasterizer.
  • Flags: Flags for creating the device.
  • FeatureLevels: An array of feature levels that are supported by the device.
  • SDKVersion: The SDK version for the runtime.
  • ppDevice: Pointer to the created Direct3D device.
  • pFeatureLevel: Pointer to a D3D_FEATURE_LEVEL variable that receives the feature level.
  • ppImmediateContext: Pointer to the device's immediate device context.
Return Value:
  • S_OK if the method succeeds.
  • E_INVALIDARG if invalid parameters are used.
ID3D11Device::CreateBuffer HRESULT CreateBuffer( _In_ const D3D11_BUFFER_DESC* pDesc, _In_opt_ const D3D11_SUBRESOURCE_DATA* pInitialData, _Out_opt_ ID3D11Buffer** ppBuffer );
Creates a buffer resource. Buffers are used for storing vertex data, index data, constant data, and unordered data.
Parameters:
  • pDesc: Pointer to a D3D11_BUFFER_DESC structure that describes the buffer.
  • pInitialData: Pointer to initialized data for the buffer.
  • ppBuffer: Pointer to a buffer interface.
Return Value:
  • S_OK if the method succeeds.
  • D3DERR_INVALIDCALL if the method fails.
ID3D11DeviceContext::IASetPrimitiveTopology void IASetPrimitiveTopology( _In_ D3D_PRIMITIVE_TOPOLOGY Topology );
Sets the type of primitives to render.
Parameters:
  • Topology: A D3D_PRIMITIVE_TOPOLOGY-typed value that specifies the type of primitives.
ID3D11DeviceContext::Draw void Draw( _In_ UINT VertexCount, _In_ UINT StartVertexLocation );
Draws a non-indexed primitive or series of primitives.
Parameters:
  • VertexCount: The number of vertices to render.
  • StartVertexLocation: The starting vertex for the draw operation.
ID3D11Device::CreateVertexShader HRESULT CreateVertexShader( _In_reads_bytes_(BytecodeLength) const void* pShaderBytecode, _In_ SIZE_T BytecodeLength, _In_opt_ ID3D11ClassLinkage* pClassLinkage, _Out_opt_ ID3D11VertexShader** ppVertexShader );
Creates a vertex shader.
Parameters:
  • pShaderBytecode: Pointer to the compiled shader code.
  • BytecodeLength: Size of the compiled shader code.
  • pClassLinkage: Pointer to a shader linkage interface.
  • ppVertexShader: Pointer to the created vertex shader.
Return Value:
  • S_OK if the method succeeds.
  • D3DERR_INVALIDCALL if the method fails.
ID3D11DeviceContext::VSSetShader void VSSetShader( _In_opt_ ID3D11VertexShader* pVertexShader, _In_opt_ ID3D11ClassInstance* const* ppClassInstances, _In_ UINT NumClassInstances );
Sets a vertex shader to the device.
Parameters:
  • pVertexShader: Pointer to the vertex shader to bind to the device.
  • ppClassInstances: An array of pointers to class instances.
  • NumClassInstances: The number of class instances in the array.