Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
This is the Getting Started tutorial for DirectX Tool Kit which introduces the reader to programming Direct3D 11 in C++.
If you are looking to use DirectX 12 and are already familiar with Direct3D 11, the place to start is the DirectX Tool Kit for DirectX 12 tutorials. Keep in mind that DirectX 12 is an expert API which builds on knowing the ins & outs of DirectX 11, and is an unforgiving API to developers new to Direct3D or graphics in general. 15
This tutorial assumes the reader is familiar with the basics of C++ programming using Microsoft Visual C++, including writing code, building applications, and basic debugging. Coding conventions here will make use of C++11 language features such as
auto, simple lambdas (aka anonymous functions), and the standard smart-pointer
std::make_unique<T>(), but will generally be otherwise 'core' C++.
This tutorial does not assume prior experience with Direct3D, but the reader should be familiar with the basic graphics concepts for DirectX or OpenGL. That said, you can get a long way using DirectX Tool Kit without much in the way of graphics experience.
Note that Direct3D 11 and DirectX Tool Kit are not Windows Runtime (aka "WinRT") components, so we do not make use of the C++/CX language extensions or the
One thing that many C++ developers, particularly game developers, may not be all that familiar with is "C++ Exception Handling". This is distinct from "Structured Exception Handling" (SEH) which some developers have seen in the past, and can leave an unfavorable impression of C++ EH. On both ARM and x64 native platforms, C++ EH is very efficient, although the x86 32-bit implementation does have some quirks. In any case, DirectX Tool Kit uses C++ Exception Handling for most error conditions, just as the Standard Template Library (STL) does and the standard behavior of the operator
For debugging exceptions thrown by the DirectX Tool Kit, you should enable the checkbox next to
std::exception in the Visual Studio Exception Settings dialog (Debug -> Windows -> Exception Settings). It's not on by default. Then select the "C++ Exceptions" line, click the PLUS button, and type
DirectX::com_exception to add that one. If working with the Direct3D VS Game templates you should do this once more typing
For some more detail on how the Visual Studio debugger deals with exceptions, read this blog post.
In Visual Studio 2015/2017, the exception debugging options changed compared to VS 2013; see this blog post.
These tutorials are written with game development in mind as the target application since games are an excellent fit for the 'immersive DirectX app' model. Keep in mind, however, that the majority of the functionality in the DirectX Tool Kit is applicable to DirectX graphics programming in general for both game and non-game applications.
For learning purposes, these instructions are going to focus on the following setup:
- Visual Studio 2015 Update 3 or Visual Studio 2017 (15.7 update or 15.8 update) Community, Professional, Premium, or Ultimate
- Windows 7 Service Pack 1, Windows 8.1, or Windows 10
We will be using a Win32 desktop application project template in order to support developers using Windows 7, but all these techniques and APIs apply to Universal Windows Platform apps and Xbox One as well.
There is no need to install the legacy DirectX SDK to use DirectX Tool Kit. The DirectX SDK is deprecated and you should not use it. The only time you would need to install the legacy DirectX SDK for this tutorial series is if you are using Windows 7 for the audio portions. See Microsoft Docs, DirectX SDK Samples Catalog, and DirectX SDK Tools Catalog.
Visual Studio 2015
Be sure to install Visual C++ which requires using the Custom install as it's not part of the Typical install. See the Visual C++ Team Blog for details.
Visual Studio 2017
When using the new lightweight installer be sure to select the appropriate workloads. Here are the recommended options to select:
- Workload: Game development with C++
- Workload: Desktop development with C++
- Workload: Universal Windows Platform development
- Optional component: C++ Universal Windows Platform tools
Note that Xbox One XDK developers also need to include the optional component Windows 8.1 SDK and UCRT SDK
- Basic drawing: SimpleTriangle
- Basic texturing: SimpleTexture
- Basic lighting: SimpleLighting
- DirectCompute: SimpleCompute
- Tessellation: SimpleBezier
- Instancing: SimpleInstancing
- Multisample Antialiasing: SimpleMSAA
- Sprites and textures
- More tricks with sprites
- Drawing text
- Simple rendering
- 3D shapes
- Rendering a model
- Using skinned models
- Using advanced shaders
- Creating custom shaders with DGSL
- Writing custom shaders
- Using HDR rendering
- Using the SimpleMath library
- Basic game math
- Collision detection
- Mixing SimpleMath and DirectXMath
- Adding the DirectX Tool Kit for Audio
- Adding audio to your project
- Creating and playing sounds
- Using positional audio