DirectX 11 (D3D11) API Reference
Welcome to the DirectX 11 API documentation. This page provides an overview of the core interfaces, usage patterns, and code snippets to help you get started with D3D11 development.
Key Interfaces
- ID3D11Device ā Represents the virtual adapter for creating resources.
- ID3D11DeviceContext ā Issues rendering commands.
- ID3D11Buffer ā Describes vertex, index, or constant buffers.
- ID3D11ShaderResourceView ā Provides read access to resources from shaders.
- ID3D11RenderTargetView ā Allows rendering output to textures.
Sample: Creating a Device and Swap Chain
#include <d3d11.h>
#pragma comment(lib, "d3d11.lib")
IDXGISwapChain* swapChain = nullptr;
ID3D11Device* device = nullptr;
ID3D11DeviceContext* context = nullptr;
DXGI_SWAP_CHAIN_DESC scDesc = {};
scDesc.BufferCount = 1;
scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scDesc.BufferDesc.Width = 1280;
scDesc.BufferDesc.Height = 720;
scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scDesc.OutputWindow = hWnd; // handle to your window
scDesc.SampleDesc.Count = 1;
scDesc.Windowed = TRUE;
HRESULT hr = D3D11CreateDeviceAndSwapChain(
nullptr,
D3D_DRIVER_TYPE_HARDWARE,
nullptr,
0,
nullptr,
0,
D3D11_SDK_VERSION,
&scDesc,
&swapChain,
&device,
nullptr,
&context
);
if (FAILED(hr)) { /* handle error */ }
Comments