NEWS: This project is now hosted on GitHub https://github.com/Microsoft/DirectXTK. This site is being maintained for now, but please move to using GitHub https://github.com/Microsoft/DirectXTK/wiki/Adding-the-DirectX-Tool-Kit particularly as the CodePlex copy of the tutorials are a little dated.

After creating a new project in the The basic game loop, the next step is to add the DirectX Tool Kit to the project so we can make use of it in our code.

NuGet package manager

The easiest way to achieve this is to use the NuGet package manager built into VS 2013.
  1. From the drop-down menu, select Project / Manage NuGet Packages...
  2. Select "Online/All" in the left-hand tree view
  3. In the text search field on the top-right type "DirectX Tool Kit" and hit enter to search for the packages
  4. Select the package with the id directxtk_desktop_2013
  5. Select "Install"
  6. Select "Close"

nuget.png

https://www.nuget.org/packages/directxtk_desktop_2013/

You can check for updates to the NuGet package by selecting "Updates/All" in the left-hand tree view. If there are updates, select the "DirectX Tool Kit" package, and click on "Update".

Project-to-project references

Another option rather than using NuGet is to use Visual Studio's project-to-project references. This approach is a little more setup, but it does ensure that you are building the full DirectX Tool Kit library as part of your solution, and allows you to make changes directly to the tool kit if desired as well.
  1. Extract the DirectXTK.zip file into a directory relative to the new project you created. For this tutorial, we will assume the "DirectXTK" folder is in the same folder as your new project's Visual Studio Solution (.sln) file.
  2. Right-click on your solution in the Solution Explorer, and select Add / Existing Project...
  3. Browse into the "DirectXTK" folder and select "DirectXTK_Desktop_2013.vcxproj", click "Open"
  4. If Visual Studio presents a "Security Warning", select "OK". Optional: Uncheck "Ask me for every project in this solution" first.
  5. Right-click on your project in the Solution Explorer, and select Add / References...
  6. Select "Add New Reference..."
  7. Check "DirectXTK_Desktop_2013" and select "OK"
  8. Click on "Configuration Properties" in the left-hand tree view, then C/C++ / General
  9. Select "All Configurations" and "All Platforms"
  10. Edit Additional Include Directories to the relative path to the "DirectXTK\Inc" folder. With our original assumption, you can use "$(SolutionDir)\DirectXTK\Inc".
  11. Select "OK"

AddReference.png

AdditionalIncludes.png

For more information see DirectXTK under Adding to a VS solution.

http://blogs.msdn.com/b/vcblog/archive/2010/05/03/flexible-project-to-project-references.aspx

Adding the headers

Now that we have the DirectX Tool Kit usable in your project, the next step is to include the library headers into your project.

General advice for C++ projects is that you should only add the headers you actually use to your project, but to simplify the tutorial we will go ahead and add them all to your new project's pch.h header:

//
// pch.h
// Header for standard system include files.
//

#pragma once

...

#include "CommonStates.h"
#include "DDSTextureLoader.h"
#include "DirectXHelpers.h"
#include "Effects.h"
#include "GamePad.h"
#include "GeometricPrimitive.h"
#include "Model.h"
#include "PrimitiveBatch.h"
#include "ScreenGrab.h"
#include "SimpleMath.h"
#include "SpriteBatch.h"
#include "SpriteFont.h"
#include "VertexTypes.h"
#include "WICTextureLoader.h"

Then finish off the setup by adding a C++ namespace using statement to your Game.cpp file to make it a bit easier to use the SimpleMath types:

//
// Game.cpp -
//

#include "pch.h"
#include "Game.h"

using namespace DirectX;
using namespace DirectX::SimpleMath;

using Microsoft::WRL::ComPtr;

...

Next lessons: Sprites and textures, Game controller input, Using the SimpleMath library, Adding the DirectX Tool Kit for Audio

Further reading

https://www.nuget.org/

Last edited Jul 28, 2015 at 6:51 PM by walbourn, version 20