MSDN

Microsoft Developer Network

Direct3D 11 API Reference

This section provides comprehensive documentation for the Direct3D 11 API, a powerful graphics API for Windows that enables hardware-accelerated rendering of 2D and 3D graphics.

Core Concepts

Direct3D 11 introduces several key concepts that streamline graphics development and improve performance. Understanding these concepts is fundamental to effectively using the API.

  • Device and Device Context: The ID3D11Device object represents the graphics adapter, and the ID3D11DeviceContext is used to issue rendering commands.
  • Resources: Data used by the GPU, such as textures, buffers, and shaders.
  • Views: Define how resources are accessed by the pipeline (e.g., shader resource views, render target views).
  • Pipeline Stages: The various stages of the graphics pipeline where data is processed.

Key Objects

Here are some of the fundamental objects you'll encounter when working with Direct3D 11.

ID3D11Device

Represents the graphics adapter and provides methods for creating Direct3D objects.

Methods:

  • CreateBuffer: Creates a buffer object.
  • CreateTexture2D: Creates a 2D texture object.
  • CreateVertexShader: Creates a vertex shader.
  • CreatePixelShader: Creates a pixel shader.
  • CreateRenderTargetView: Creates a render target view.
  • CreateDepthStencilView: Creates a depth-stencil view.
  • CreateShaderResourceView: Creates a shader resource view.

ID3D11DeviceContext

Used to issue commands to the graphics pipeline.

Methods:

  • VSSetShader: Sets the vertex shader.
  • PSSetShader: Sets the pixel shader.
  • IASetInputLayout: Sets the input layout.
  • IASetPrimitiveTopology: Sets the primitive topology.
  • DrawIndexed: Draws indexed primitives.
  • OMSetRenderTargets: Sets the output merger render targets.

ID3D11Texture2D

Represents a 2D texture resource.

Properties:

  • Width
  • Height
  • MipLevels
  • ArraySize
  • Format
  • Usage
  • BindFlags

ID3D11ShaderResourceView

A view that allows a shader to access a resource.

ID3D11RenderTargetView

A view that allows a resource to be used as a render target.

ID3D11DepthStencilView

A view that allows a resource to be used as a depth-stencil buffer.

ID3D11Buffer

A generic buffer object, used for vertex data, index data, constant data, etc.

ID3D11VertexShader

Represents a compiled vertex shader.

ID3D11PixelShader

Represents a compiled pixel shader.

Functions

Key functions for creating and managing Direct3D 11 resources and rendering.

Function Name Description
D3D11CreateDevice Creates a Direct3D 11 device.
D3D11CreateDeviceAndSwapChain Creates a Direct3D 11 device and a swap chain.
ID3D11Device::CreateInputLayout Creates an input layout object.
ID3D11DeviceContext::Draw Draws non-indexed primitives.

Structures

Commonly used structures for configuring Direct3D 11 objects and operations.

  • D3D11_TEXTURE2D_DESC: Describes a 2D texture.
  • D3D11_VIEWPORT: Defines a viewport.
  • D3D11_BUFFER_DESC: Describes a buffer.
  • D3D11_INPUT_ELEMENT_DESC: Describes an element in the input layout.

Enumerations

Key enumerations used throughout the Direct3D 11 API.

  • D3D11_BIND_FLAG: Flags for binding resources to pipeline stages.
  • D3D11_USAGE: Resource usage types.
  • D3D11_CPU_ACCESS_FLAG: CPU access flags for resources.
  • DXGI_FORMAT: Pixel formats.

Error Codes

Common HRESULT error codes encountered when using Direct3D 11.

  • S_OK: Operation successful.
  • E_INVALIDARG: Invalid argument.
  • DXGI_ERROR_DEVICE_REMOVED: The graphics device has been removed.