Tutorial 1: Setting up DirectX 12 with Visual Studio

Before writing any graphics code we'll need to have the tools to do so. The first of these tools is a compiler that is preferably built into a nice IDE. The one I use and will be supplying project files for is Visual Studio 2015. There are several others available and some are free off the net. I'll leave that up to you to decide which one you prefer. I personally use Visual Studio 2015 Community because it is free and is an excellent IDE. You can download Visual Studio 2015 Community from the Visual Studio website. When you install Visual Studio 2015 make sure to choose custom and select all so that the Visual C++ components are all installed, otherwise it sets it up primarily for C# development.

The second tool you will need is the Windows 10 SDK. The Windows 10 SDK contains all of the DirectX 12 headers, libraries, DLLs, and so forth that you will need to write DirectX 12 applications. If you installed Visual Studio 2015 then the SDK was already installed with it. Otherwise you can download the Windows Standalone SDK for Windows 10 from Windows Dev Center (msdn) website. After downloading and installing the SDK you will have the files necessary to compile DirectX 12 programs. The documentation for the Windows 10 SDK is all on the Windows Dev Center website as well. You will find the Direct3D 12 Programming Guide there which has all the DirectX 12 documentation as well as some working samples that you can download and try out.

Once you have the IDE and the SDK installed you can now setup your IDE to work with the Windows 10 SDK so that you can write DirectX 12 applications. Please note that some IDEs will need to be installed first before installing the Windows 10 SDK.


Setting Up Visual Studio 2015

In Visual Studio 2015 I used the following steps:

First you need to create an empty Win32 project so select File -> New -> Project. In the New Project menu select Win32 under Templates -> Visual C++ -> Win32. Then select Win32 Project from the choices. Give the project a name (I called mine Engine) and a location and then click on "Ok". Click "Next" and you will be given another menu. Under "Additional options" put a check mark in the "Empty project" box and unclick the Security Development Lifecycle (SDL) checks. Click on "Finish" and you should now have an basic Win32 empty project setup.

Then on the top bar you will see the value "x86" in the Solution Platforms dropdown, select this and pick "x64" instead. This will set your project to 64bit instead of the default 32bit.

Now click "View" from the menu and select "Property Manager". Next click on the arrow to the left of your project name (mine was called Engine) in the property manager window on the left part of the screen. This will display the solution configurations you have. Select the "Debug | x64" folder and double click "Microsoft.Cpp.x64.user".

In the window that pops up select "VC++ Directories" from the menu on the left side. This will then display the directories that the project uses.

Now select "Include Directories" from the directory list and click on the down arrow that appears to the right. From the choices it pops up choose "Edit".

Click on the folder icon at the top (called New Line if you mouse over it) and click on the "..." that appears to the right side.

Navigate to the Windows 10 SDK include folder, different versions are named differently but on my system it was: C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\um

Next click on "Select Folder" and then click "Ok".

Now we also need to do the same thing to add the includes for the shared headers. Follow the same process and add: C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\shared

The libraries directory is also needed so now select "Library Directories" from the directory list and click on the down arrow that appears to the right. From the choices it pops up choose "Edit".

Click on the folder icon at the top (called New Line if you mouse over it) and click on the "..." that appears to the right side.

Navigate to the Windows 10 SDK library folder, different versions are named differently but on my system the 64 bit libraries were located here: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64

Next click on "Select Folder" and then click "Ok".

Finally click on the "Apply" button in the bottom right of the Property Pages window.

Now click "Ok" to close the window and your settings will be complete. From the menu click "View" and then "Solution Explorer" to return to your code. All DirectX projects should now compile fine and the error of "Cannot open include file: 'd3d12.h': No such file or directory" should disappear. Also note that these settings will automatically be applied to the Release | x64 solution configuration so you don't need to set them there. As well it should be persistent permanently for all new projects and will never need to be setup again.


Summary

Our DirectX 12 development environment should now be setup and ready for us to start writing DirectX 12 applications.


To Do Exercises

1. Go to the DirectX 12 Programming Guide on the Windows Dev Center (msdn) website. Download the Working Samples and look at HelloWorld sample set.

Back to Tutorial Index