Compiling Direct X 11 code on windows 8 - directx-11

I've been trying to run the examples from the book 'Introduction to 3D Game Programming with Direct X 11' by Frank Luna however, no matter what I try I can't seem to get any of the projects to compile.
I've installed the june 2010 SDK as per instructions found here: http://d3dcoder.net/WordPress/
However I'm not sure I've done the rest of the tasks correctly.
Has anyone had any luck trying to run these? I'd like to learn Direct X but without the proper way to compile them I'm pretty much dead in the water.

The include/lib path order for using the legacy DirectX SDK with VS 2012 or later is inverted from the traditional order used for VS 2010. You need to modify your project's VC++ Directories to account for this.
For x86/Win32 configurations:
$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86
$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x86
For x64 native configurations:
$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86
$(IncludePath);$(DXSDK_DIR)Include
$(LibraryPath);$(DXSDK_DIR)Lib\x64
This is covered in detail on MSDN.
You should also read the notes I have about that book on my blog. His DirectX 11 book was published just prior to the deprecation of the legacy DirectX SDK, so it's a bit out-of-date on the margins although the core API stuff is fine.
See also Where is the DirectX SDK (2013 Edition)?, DirectX SDK Tools Catalog, Living without D3DX,
DirectX SDKs of a certain age, DirectX SDK Samples Catalog, and The Zombie DirectX SDK

Related

DirectML, Windows Insider Preview and DX SDK Debacle

So, I've got Windows 10.0.18358.1 installed, latest Visual Studio (17, not bothering with 19 as of yet), updated (Insider) Windows SDK which should include the DX12 SDK.
And, yet, I have no DXSDK_DIR environment variable set.
I can see all of the DX and D3D headers and libs in the windows kits folder, but their distribution doesn't really correspond to a typical include/bin/lib structure.
Suggestions on how to correct this? I'd settle for copy of anyone's set output
that has this working.
(DirectML tag is because that is the feature that I require, and the source of all of this insanity.)
The DXSDK_DIR variable was only used by the legacy DirectX SDK and the 'beta DirectX 12 SDK' test vehicle, it's not used by the Windows 10 SDK as the standard WindowsSDKDir already includes the required headers & libraries.
If you are building with the Visual Studio build system, you don't have any special setup to use the DirectX 12 headers as they are all in the path already. Likely, your project is set to use the 10.0.17763 Windows 10 SDK by default, so to use the Windows 10 Insider SDK, you'll need to modify the project settings <WindowsTargetPlatformVersion> element to reference the newer 10.0.18xxx version.
If you are using some more manual build system, then you should use the include paths for the Windows 10 SDK side-by-side structure:
%WindowsSdkDir% is typically "C:\Program Files (x86)\Windows Kits\10\"
%WindowsSDKVersion% is something like "10.0.17763.0\"
%arch% is "arm", "arm64", "x64", or "x86'
INCLUDE=%WindowsSdkDir%include\%WindowsSDKVersion%shared;
%WindowsSdkDir%include\%WindowsSDKVersion%um;
%WindowsSdkDir%include\%WindowsSDKVersion%winrt;
%WindowsSdkDir%include\%WindowsSDKVersion%cppwinrt
LIB=%WindowsSdkDir%lib\%WindowsSDKVersion%um\%arch%
See Microsoft Docs and this blog post
The Windows 10 SDK does not include utilities which are instead shared source. For D3DX12, you can obtain the latest header from here
You may also want to look at DirectX Tool Kit for DX12, DirectXTex, and DirectXMesh
For historic and usability reasons, DirectXMath is part of the Windows 10 SDK, but you can also get the latest version from GitHub. The recent Windows 10 SDKs also include the HLSL compiler/D3DCompile API including both the older FXC.EXE and the new Shader Model 6 DXC.EXE.
You may also find the Visual Studio templates on directx-vs-templates useful.
I would suggest reverting to the previous build and flagging the issue in the Feedback Hub. Also, if you haven't already, run chkdsk before and after install, just in case.

cbuffer unexpected token DX11 examples

On loading up a direct x 11 SDK project example, after linking all Libs./includes ETC that I was given an error from; I came across the following within an fx file.
VS version : VS ultimate 2013
Example name : 'DepthOfFeild10.1'
SDK : 'Microsoft DirectX SDK (February 2010)'
fx file name : 'DepthOfField10.1.fx'
error : Error 1 error X3000: syntax error: unexpected token 'cb0'
Perhaps I'm missing a lib/tool/set-up procedure ?
(Running Debug, X64)
Advice appreciated.
First of all, if you are trying to use VS 2013 and the legacy DirectX SDK together, be sure to read MSDN.
You need to use a different include/lib/executable path order with VS 2012 and later than the default VS 2010 projects that come with the legacy DirectX SDK February 2010 and June 2010 releases.
Many of the legacy DirectX SDK samples have been updated to remove the need to use the legacy DirectX SDK at all since VS 2013 and the Windows 8.1 SDK are generally sufficient. These are published to GitHub. See DirectX SDK Samples Catalog. DepthOfField10.1, however, is not one of these because it's an AMD sample. You can find AMD's version of it in their archive.
Start with the DirectX SDK (June 2010) version of DepthOfField10.1 (install it from the sample browser).
Open the DepthOfField10.1_2010.sln file and let it Upgrade the VC++ Tools and Libraries to v120.
Edit the Project Properties -> VC++ Directories:
For all configurations and the Win32 Platform, set it to:
Executable Directories: $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86
Include Directories: $(IncludePath);$(DXSDK_DIR)Include
Library Directories: $(LibraryPath);$(DXSDK_DIR)Lib\x86
For all configurations and the x64 Platform, set it to:
Executable Directories: $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86;
Include Directories: $(IncludePath);$(DXSDK_DIR)Include
Library Directories: $(LibraryPath);$(DXSDK_DIR)Lib\x64
If you were using VS 2015, then you also need to add the blog version of DXERR and remove the legacy DirectX SDK version of dxerr.lib from the project. A quick hack of DXUT is needed to resolve the ASCII/UNICODE differences. This is needed because VS 2015 includes some C99 related standard library changes that fail to link with the old version of strsafe.h used to build the legacy DirectX SDK.
Once this is done, it builds and runs as is.
Note: Most of the Direct3D 10 samples in the legacy DirectX SDK make use of the old Effects (FX) system. There's a Direct3D 11 version of Effects available, but the HLSL compiler support for Effects is officially deprecated. See Effects for Direct3D 11.
If the problem is happening in our own projects, then likely you have mis-configured the FXC command-line for building that .fx file.

intelliSense: cant open source file "d3dx11.h"

Visual Studio 2010 shows error on a DirectX program, which is taken from a books source code.I am very new to DirectX programming. There is not any Microsoft DirectX SDK folder in my computers programs files(i'm using win 8.1). When i try to reinstall DirectX setup has determined that a newer or equivalent version of DirectX has been installed already. I dont khow what is the matter please help me.
If you want to use D3DX, you need to install the June 2010 DirectX SDK. This is the last SDK that supported D3DX. This page also has some good info on what you need to write DirectX applications.

What differences are there learning direct3d11 using the windows sdk as compared to the directx sdk?

One can use direct3d11 through either the windows 8 sdk or the directx sdk? As a learner it isn't clear what effects this choice has. What differences does it make whether one learns directx 11 using windows sdk or directx sdk?
directx sdk ( last was june 2010, three years ago ) is deprecated. Windows 8 kits contains an up to date version of the direct x headers and library.
Basic API and documentation are mostly the same, but recent changes are missing. D3DX is deprecated, maths move to directxmath.h and shader compilation move to d3dcompiler.h
Pix is not working anymore with recent windows, so you have to stick with VSGD shipped with visual 2012, but the PiX replacement is far from really useful in the state it is :( So a better tool is nsight for nvidia, and gpuperfstudio for AMD.
That's it.
For Direct3D 11, the best way to go is to use VS 2012 or VS 2013 with the integrated Windows 8.x SDK and avoid the complexities of using the legacy DirectX SDK (June 2010) at all until you determine you actually really need it (the one compelling case would be XAudio2.7 on Windows Vista or Windows 7 rather than using XAudio 2.8 on Windows 8 or later).
For Windows Store apps on Windows 8.x, there a lot of official tutorials and samples on MSDN and the MSDN Code Gallery for you to learn about Direct3D 11.
For Win32 desktop apps on Windows 7 or Windows 8.x, I've posted a lot of unofficial samples harvested from the legacy DirectX SDK that build just fine with the Windows 8.x SDK. See this blog post for an inventory and links to MSDN Code Gallery.
Many older tutorials and books do indeed assume you are using the now deprecated D3DX library, but for Direct3D 11 there are a lot of options that avoid it as covered here. Some recent books embrace these newer libraries as well.
BTW, I'm assuming from your question that you are asking about programming Direct3D 11 with C++ since that's what the DirectX SDK and the Windows 8.x SDK support. If you are looking for C#, then I suggest looking at SharpDX or SlimDX.

What options do I have in terms of porting my XNA game to Mac?

I've been reading a lot into this and MonoMac/Mono seemed to be the best if not one of the only ways to go about it. I do have a MacBook Pro and it seems Xamarin bought Mono and wants something like $800 for a business edition to be able to load in Visual Studio projects. I only downloaded the free version so when I tried to load in my VS project on my Mac into Xamarin it said it didn't recognize it and that's when I discovered it seemed I needed a business edition.
A lot of what my search found was stuff that was 1-2 years old and even older. Things seemed to have changed a bit since then and with the Xamarin integrating Mono sort of thing. I've been working on an XNA 4.0 game for PC for over 7 months now and I'd like to have a Mac version. Apparently games like Magicka have figured it out and were made in XNA. I plan to release on Steam so I suppose I need to find a way to try and make it work with Steam if that's possible too. I don't really use my MacBook that often and I don't have Steam on it so I'm not really sure how to go about this.
I guess it comes down to this. I don't understand the current situation of MonoMac and Xamarin and did they aquire Mono? Do I need that expensive business edition? Are there alternatives? How does this tie in to being able to release a Mac version on Steam?
Most of the information I can find is a few years ago now and a lot has changed it seems.
MonoGame is a re-implementation of the XNA API for various platforms, including Mac.
It depends on Mono to provide a C# runtime across different platforms. And on platform specific versions of Mono (such as MonoMac, MonoTouch, etc, from Xamarin) to provide the API bindings and other features specific to those platforms.
You don't so much "load" an existing Visual Studio project as create a new project - either in Visual Studio (if the tools are available and you've bought them - but I don't think this is the case for Mac) or MonoDevelop or Xamarin studio.
To your new project, you would add your existing source files and add a reference to the MonoGame library for that platform. That MonoGame library will provide versions of the classes in the Microsoft.Xna.Framework namespace that work on that platform. Your code gets compiled against these alternate classes, creating a new binary specific for that platform.
(MonoGame will probably have more in-depth documentation of the process on their website, including how to deal with game content.)
Put simply: Use MonoGame. It is an alternate version of the XNA library, not a conversion tool.

Resources