Skip to content

DirectXTK

Chuck Walbourn edited this page Mar 31, 2026 · 151 revisions

Headers

Public headers are in the Inc folder of the distribution package.

Namespace

All the functions in the library are in the DirectX C++ namespace.

using namespace DirectX;

The Xbox One exclusive application XBoxDDSTextureLoader functions are in the Xbox C++ namespace.

Modules

Tools

  • MakeSpriteFont - builds .spritefont data files for use with SpriteFont class
  • XWBTool - builds .xwb XACT-style wave banks for use with WaveBank class

Building

This code is designed to build with Visual Studio 2022 or later. It requires the Windows SDK (19041) or later for functionality such as the DirectXMath library and the DXGI 1.2 headers.

These components are designed to work without requiring any content from the DirectX SDK. For details, see Where is the DirectX SDK?, Where is the DirectX SDK (2021 Edition)?, and The Zombie DirectX SDK.

HLSL shaders

The required Direct3D shaders are built as headers in Src\Shader\Compiled\*.inc and included into the DirectXTK static library. They are automatically built by the Visual Studio project if they are not present, and cleared by a Clean. They can also be manually rebuilt using the CompileShaders.cmd script (i.e. ...\DirectXTK\Src\Shaders)

Dependencies

The DirectX Tool Kit library assumes your binary is linking with the following system libraries:

  • d3d11.lib: Provides the Direct3D device creation function D3D11CreateDevice
  • dxgi.lib: Provides the DXGI factory creation function CreateDXGIFactory1 / CreateDXGIFactory2
  • dxguid.lib: Provides COM GUID values for IID_ID3D11Device, WKPDID_D3DDebugObjectName, etc.
  • windowscodecs.lib or uuid.lib: Provides COM GUID values for WIC usage such as CLSID_WICImagingFactory, CLSID_WICImagingFactory1, CLSID_WICImagingFactory2, etc.
  • For Win32 desktop applications, ole32.lib: Provides CoCreateInstance. For other platforms, this export is in the umbrella library (WindowsApps.lib, onecore.lib, etc.).

DirectX Tool Kit for Audio

For Windows configurations of the AudioEngine class, you'll need to use xaudio2.lib.

For XAudio2Redist, the Microsoft.XAudio2.Redist NuGet package provides the xaudio2_9redist.lib.

GamePad

For "Windows 10" and "Windows 11" configurations of the GamePad class that use Windows.Gaming.Input, you need runtimeobject.lib for Win32 desktop apps. For UWP apps, this is already handled with the umbrella lib windowsapp.lib.

For "Windows 8.1" configurations of the GamePad class using XInput 1.4, you'll need xinput.lib.

For the "Gaming.Desktop.x64" platform configuration in the Microsoft GDK, the GamePad class uses GameInput 'v0' and links to gameinput.lib.

Content pipeline

To use the Visual Studio graphics assets tools in the build system, be sure to add them to your project.

Note: When adding .spritefont, .sdkmesh, or .xwb files to your Universal Windows Platform (UWP) or Xbox One project, you need to manually set the file properties to "Content: Yes" for all configurations to have these files included in your AppX package. .dds files, other image file formats, and .wav files are automatically detected as a media file and are included as content by default.

Error handling

DirectXTK makes use of C++ exception handling which should be enabled by the application via the /EHsc compiler switch. In Visual Studio, this is set in the project settings under "C++ / Code Generation" with Enable C++ Exceptions set to "Yes (/EHsc)" for all configurations.

Visual Studio Express editions have limited exception handling debugging support, so consider using VS Community or Pro+ instead.

Smart-pointers and reference counting

DirectXTK encourages and makes use of a number of smart-pointers to simplify resource lifetime tracking.

Additional information

Integration

Implementation

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Xbox One

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2026
  • Visual Studio 2022 (17.12 or later)
  • clang/LLVM v12 - v20
  • MinGW 12.2, 13.2
  • CMake 3.21

Related Projects

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXTex

DirectXMath

Win2D

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

Clone this wiki locally