DirectX 11 API Reference
DirectX 11 provides a high‑performance, low‑level graphics API for Windows desktop applications. It enables developers to harness the power of modern GPUs for rendering, compute, and multimedia tasks.
Key Features
- Hardware‑tessellation
- Multithreaded rendering
- Shader Model 5.0
- Compute shaders
- Instancing and advanced blending
Installation & Setup
▾
To develop with DirectX 11, install the Windows 10 SDK and use Visual Studio 2019 or later.
# Install Windows SDK
winget install Microsoft.WindowsSDK
# Create a new project in Visual Studio
File → New → Project → Desktop Development → DirectX App (C++)
Sample Code: Initializing a Device
▾
#include <d3d11.h>
#pragma comment(lib, "d3d11.lib")
HRESULT InitDevice(HWND hWnd, ID3D11Device** ppDevice, ID3D11DeviceContext** ppContext)
{
DXGI_SWAP_CHAIN_DESC scDesc = {};
scDesc.BufferCount = 1;
scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scDesc.OutputWindow = hWnd;
scDesc.SampleDesc.Count = 1;
scDesc.Windowed = TRUE;
return D3D11CreateDeviceAndSwapChain(
nullptr, D3D_DRIVER_TYPE_HARDWARE,
nullptr, 0, nullptr, 0,
D3D11_SDK_VERSION,
&scDesc, nullptr, ppDevice,
nullptr, ppContext);
}
This function creates a Direct3D 11 device and immediate context for the given window handle.