2

Preamble:
I am making a project with VS 2013 and I tried to #include <d3dx11.h> and it was not found. I did a bit of searching and found this quote

D3DX is not considered the canonical API for using Direct3D in Windows 8 and therefore isn't included with the corresponding Windows SDK. Investigate alternate solutions for working with the Direct3D API.

from this page

I then did some more searching and found this SO question and I tried out the answer but it ended up just breaking all includes. So yes I have done some searching

Question:
How do you use d3dx11 in VS 2013?

Community
  • 1
  • 1
Noah Huppert
  • 4,028
  • 6
  • 36
  • 58
  • 1
    I think it was replaced with d3dmath, so you'd probably have to switch to that. Kind of annoying if you're used to the old way of doing things, especially since no 3rd party D3D11 tutorial has been updated to address the change (part of the reason I'm turned off from D3D in favor of OpenGL/CL). – NmdMystery Jan 16 '14 at 20:13
  • Ahh, ok. That kinda stinks. – Noah Huppert Jan 16 '14 at 20:18
  • Tell me about it :/ I'm not even sure what the improvements are over d3dx. – NmdMystery Jan 16 '14 at 20:20
  • @NmdMystery The "improvement" is that all old "legacy" code doesn't work. :) – Noah Huppert Jan 16 '14 at 20:28
  • @NmdMystery Do you know if there is some compatibility library to load it back in? – Noah Huppert Jan 16 '14 at 22:35
  • @NoahHuppert What functionality are you trying to use in D3DX? The vast majority of useful functionality is available in the open source [DirectX Toolkit](http://directxtk.codeplex.com/). – MooseBoys Jan 17 '14 at 00:47
  • @MooseBoys more like a possible path that someone made. Every single tutorial uses d3dx11 so something that uses that name would be nice. – Noah Huppert Jan 17 '14 at 02:18
  • @NoahHuppert 99% of the D3DX usage I've ever seen are for just two functions - `D3DXCreateTextureFromFile` and `D3DXCompileShaderFromFile`. Both of these functions should be replicated in the toolkit. – MooseBoys Jan 17 '14 at 19:03
  • @MooseBoys - Minor detail D3DXCompileShaderFromFile is replaced by using [D3DCompile directly](http://blogs.msdn.com/b/chuckw/archive/2012/05/07/hlsl-fxc-and-d3dcompile.aspx). – Chuck Walbourn Aug 09 '14 at 00:48

2 Answers2

1
  1. Download and install DirectX SDK

  2. In Visual Studio click on your project > Properties > VC++ Directories:

  3. Include Directories: click a little down-arrow > <Edit...> > ... > navigate to C:\Program Files (x86)\Microsoft DirectX SDK June 2010\Include > Select Folder

  4. Library Directories > same as above but select ...\Lib\x86 > OK

  5. In your code:

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib")
#pragma comment(lib, "dxgi.lib")

#include <d3d11.h>
#include <D3DX11.h>

jaho
  • 4,852
  • 6
  • 40
  • 66
  • With VS 2012/2013 you are using the Windows 8.x SDK so you have to use an include/lib path order where the DirectX SDK comes *after* the Windows 8.x SDK. Detailed instructions are on [MSDN](http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275%28v=vs.85%29.aspx) at the bottom of the page you referenced. Conversely if you are using the VS 2012/2013 "Windows XP" Platform Toolset, you are actually using the Windows 7.1A SDK so you have to put the DirectX SDK include/libs first. See [this](http://blogs.msdn.com/b/chuckw/archive/2012/11/26/visual-studio-2012-update-1.aspx) blog. – Chuck Walbourn Aug 09 '14 at 00:42
  • [This page on MSDN](https://msdn.microsoft.com/en-us/library/bb531344.aspx), "Breaking Changes in Visual C++", states the following, "To avoid run-time errors that are difficult to detect and diagnose, we recommend that you never statically link to binaries that were compiled by using different versions of the compiler. Also, when you upgrade an EXE or DLL project, make sure to upgrade the libraries that it links to." Do we need to worry about linking to these .lib files from VS2013, as they were built with an earlier compiler? – Tim Coolman Feb 02 '15 at 17:07
  • Absolutely, this applies to any libraries. – jaho Feb 02 '15 at 17:42
  • For D3DX11, you can avoid using the legacy DirectX SDK and use [Microsoft.DXSDK.D3DX](https://www.nuget.org/packages/Microsoft.DXSDK.D3DX) NuGet package. D3DX11 is still quite old and deprecated, so you should consider the [many replacements](https://walbourn.github.io/living-without-d3dx/) if possible. – Chuck Walbourn Mar 08 '21 at 08:48
0

You can use the legacy mode as jaho suggested, or adapt the new "Microsoft" way.

Be aware that replacement technologies for current uses of D3DX11 include DirectXTex and DirectXTK. D3DXMath is replaced by DirectXMath.

DirectXTex looks like a standalone Texture loading library, and actually it was still actively maintained by Microsoft. It contains all "LoadFromDDSFile()"-like functions.

  • DirectXTex is a great library for writing content processing tools, but it's overkill for loading a DDS file you control. [DDSTextureLoader / WICTextureLoader](http://blogs.msdn.com/b/chuckw/archive/2012/05/04/direct3d-11-textures-and-block-compression.aspx) are designed to cheaply load resources without the whole DirectXTex library. – Chuck Walbourn Aug 09 '14 at 00:47