Games for Windows and the DirectX SDK blog

Technical tips, tricks, and news about game development for Microsoft platforms including desktop, Xbox, and UWP

Project maintained by walbourn Hosted on GitHub Pages — Theme by mattgraham
Home | Posts by Tag | Posts by Month


codeplex, direct3d, winphone

Originally posted to Chuck Walbourn's Blog on MSDN,

The DirectXTex library does an excellent job of providing all the ‘texture content processing’ functionality from the venerable D3DX library (see “Where is the DirectX SDK?”), and DirectXMath (or the older XNAMath) takes over for D3DXMath. Shawn Hargreaves and I have been putting together another utility library, dubbed “DirectX Tool Kit” or “DirectXTK”, to address some additional runtime needs for Direct3D 11 applications.

DirectXTK includes the following components:

  • SpriteBatch - a 2D sprite rendering class (a C++ version of the SpriteBatch used for XNA Game Studio)
  • SpriteFont - a bitmap based text rendering (a C++ version of the SpriteFont used for XNA Game Studio)
  • Effects - a collection of ready-to-use common shaders (C++ versions of the BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, and SkinnedEffect used for XNA Game Studio)
  • PrimtiveBatch - simple and efficient way to draw user primitives which replicates the simplicity of the Direct3D 9 era DrawUP APIs
  • GeometricPrimitives - geometry helpers for common shapes (Cube, Sphere, GeoSphere, Cylinder, Torus, Teapot, Tetrahedron, Octahedron, Dodecahedron, and Isosahedron)
  • Model - draws simple meshes loaded from .CMO or .SDKMESH files
  • CommonStates - Factory for common combinations of rendering states as Direct3D 11 state objects (C++ versions modelled after the 'public fields' of BlendState, DepthStencilState, RasterizerState, and SampleState classes used for XNA Game Studio)
  • VertexTypes -  collection of commonly used vertex buffer data structures with a input layout descriptions (C++ versions of VertexPositionColor, VertexPositionTexture, VertexPositionColorTexture, and VertexPositionNormalTexture structures used for XNA Game Studio)
  • It also includes DDSTextureLoader,  WICTextureLoader, and ScreenGrab from the DirectXTex package.
  • SimpleMath - a wrapper for DirectXMath that makes it easier to write basic math operations without as many restrictions as the SIMD-friendly base library
  • And the MakeSpriteFont utility for generating .spritefont files (based on the Bitmap Font Maker Tool for XNA Game Studio)

Platforms: The code is designed to build with the Windows 8.x SDK using Visual Studio 2010, 2012, or 2013 and works on Windows Vista, Windows 7, Windows 8.x Win32 desktop, Windows Store apps, Windows phone 8.1, and Xbox One.

The README.TXT in the ZIP package contains additional information, and see Shawn’s posts here and here with some code snippets for usage.

Porting Notes

Here’s a handy table of equivalents for D3DX (see Living without D3DX for a complete listing):

ID3DX10Sprite SpriteBatch
ID3DX10Font SpriteFont, SpriteBatch
ID3DX10Mesh Model, ModelMesh, ModelMeshPart
D3DXCreateBox D3DXCreateCylinder D3DXCreateSphere D3DXCreateTeapot D3DXCreateTorus GeometricPrimitive
D3DX11CreateShaderResourceViewFromFile CreateXXXTextureFromFile
D3DX11CreateShaderResourceViewFromResource D3DX11CreateShaderResourceViewFromMemory CreateXXXTextureFromMemory
D3DX11CreateTextureFromFile CreateXXXTextureFromFile
D3DX11CreateTextureFromResource D3DX11CreateTextureFromMemory CreateXXXTextureFromMemory
D3DX11SaveTextureToFile SaveXXXTextureToFile

Where XXX is “DDS” for working with .DDS files, or “WIC” for working with WIC-supported bitmap image formats such as .BMP, .JPG, .PNG, etc. Note that .TGA is supported by legacy D3DX and by DirectXTex, but not by DirectXTK.


Update: DirectXTK is now hosted on GitHub.The latest version of the library, documentation, notes on future work, release history, and other information is now available there. The library now includes PrimitiveBatch, ModelGamePad, Keyboard/Mouse, SimpleMath, and DirectXTK for Audio as well.

Windows phone 8: DirectXTK supports Windows phone 8 apps using the Windows phone SDK 8.0. See ShawnHar’s post. It also supports Windows phone 8.1 using VS 2013 Update 2 or later.

DirectX 12: If you are already an expert in using DirectX 11 and would like to use DirectX 12 instead, see DirectX Tool Kit for DirectX 12

vcpkg: The vcpkg C++ Package Manager has a directxtk port available.

Related: DirectXMesh