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

DirectXTex

codeplex, conference, dds

Originally posted to Chuck Walbourn's Blog on MSDN,

As part of my Gamefest 2011 presentation Modern Texture Content Pipelines (link), I demonstrated the “DirectXTex” library which is a shared source implementation of DDS file I/O (including the “DX10” header extension), texture content processing operations (resize, format conversion, mip-map-generation), software block compression (BC1 - BC7), height-map to normal-map conversion, and a simple .TGA file reader and writer.

The attached package includes:

  • The DirectXTex library
  • Texconv, a sample using DirectXTex that is a command-line tool replacement for the DirectX SDK Texture Conversion Tool (Extended)
  • DDSView, a simple DDS viewer sample using DirectXTex
  • DDSTextureLoader, a light-weight DDS loader for DirectX 11 applications
  • WICTextureLoader, a WIC-based image loader for creating simple 2D textures with auto-gen mipmaps for DirectX 11 applications
  • ScreenGrab, a light-weight screen shot saver for DirectX 11 applications
  • A copy of XNAMath 2.04, which is required to build the DirectXTex library with VS 2010

See the ReadMe file in the package for more details.

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.

Note: DDSTextureLoader, WICTextureLoader, and ScreenGrab are also provided in the DirectX Tool Kit for DX11 / DX12

Porting Notes

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

D3DX11ComputeNormalMap

ComputeNormalMap

D3DX11CreateShaderResourceViewFromFile

LoadFromXXXFile, CreateShaderResourceView

-or-

CreateXXXTextureFromFile

D3DX11CreateShaderResourceViewFromResource
D3DX11CreateShaderResourceViewFromMemory

LoadFromXXXMemory, CreateShaderResourceView

-or-

CreateXXXTextureFromMemory

D3DX11CreateTextureFromFile

LoadFromXXXFile, CreateTexture

-or-

CreateXXXTextureFromFile

D3DX11CreateTextureFromResource
D3DX11CreateTextureFromMemory

LoadFromXXXMemory, CreateTexture

-or-

CreateXXXTextureFromMemory

D3DX11FilterTexture

GenerateMipMaps, GenerateMipMaps3D

D3DX11GetImageInfoFromFile

GetMetadataFromXXXFile

D3DX11GetImageInfoFromResource
D3DX11GetImageInfoFromMemory

GetMetadataFromXXXMemory

D3DX11LoadTextureFromTexture

Resize, Convert, Compress, Decompress, and/or CopyRectangle

D3DX11SaveTextureToFile

CaptureTexture, SaveToXXXFile

-or-

SaveXXXTextureToFile

D3DX11SaveTextureToMemory

CaptureTexture, SaveToXXXMemory

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

UPDATE: DirectXTex now also supports .HDR files. See this post. The XXX above would be “HDR”.

Note

There is another version of the Texconv sample with the DirectXTex library that uses DirectXMath with DXGI 1.2 support available on the Windows SDK Samples Code Gallery. It can be built using either Visual Studio 2012 or VS 2010 with the new Windows SDK. There is also a Windows Store app (a.k.a. Metro style app) version of the DDSTextureLoader there as well. The Windows SDK Samples Code Gallery version of DirectXTex can be made to run on Windows Vista and Windows 7 by adding _WIN32_WINNT=0x0600 to the Preprocessor Definitions.

Update: DirectXTex is now hosted on CodePlexGitHub. The latest version of the library, documentation, notes on future work, release history, and other information is now available there.

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

Related: DirectX Tool Kit for DX11, DirectXMesh, DirectX Tool Kit for DX12