Direct3D11 for those in a Post D3DX world

DirectX 11 for those using Visual Studio 2012 As most tutorials on D3D11 are created in VS2010, they don't work when you pass them into VS2012, even more so when you are using the latest tool chain (v110). This is meant as a supplement, alongside some of the differences between tutorials I have seen.

CreateDeviceAndSwapChain(...)

is useful when you don't want to enable MSAA,

if you want MSAA, use CreateDevice(...), query what the graphics card supports, then get the ID3D11Device's DXGIFactory using these three successive query calls:

d3dDevice->QueryInterface(__uuidof(IDXGIDevice),(void**)&dxgiDevice);
dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter);
dxgiAdapter->GetParent(__uuidof(IDXGIFactory),(void**)&dxgiFactory);

and then

dxgiFactory->CreateSwapChain(...)

In the Windows 8 SDK D3DX is completely deprecated, even if you are using DX11 and not DX11.1. This includes all texture loading methods and the Effects SDK. If you want to use it, MS released the DirectX Tool Kit. As D3DX included the DXTrace(), you have to use the more general Win32 error checking method called FormatMessage(), like so:

I normally wrap it in a macro instead of in a function and have it display a MessageBox instead of returning the error string, but whatever works for you.

Effects are closer to OpenGL shader programs, but if you don't use it, you only need to pass around the ID3D11DeviceContext instead of the effect, allowing you to do more with the same number of parameters.

Wrapping com object release and then null the pointer as a macro is a good idea, as you will probably be calling the following all too much:

someComPtr->Release(); someComPtr = nullptr;

By the way, using nullptr still works with checking if something is NULL or null. C++11 is out, freaking use it if you are going to use this version of DX11.

The shader loading example in MSDN is entirely in .Net, so for those that haven't needed to load a file as a byte array (FX.exe outputs .cso's at build time by default in VS2012, so you might as well use them) and don't want to use C++.Net, the following code works just as well:

which you then feed into

d3dDevice->CreatePixelShader(&FileData[0],FileData.size(),0,&shader);

There you have it! one shader, ready to bind to the pipeline! Remember that you need to create an ID3D11InputLayout from the same vertex shader byte array and bind that too, otherwise you won't get anything on screen, but most tutorials already cover that, if they aren't written using the Effects SDK

That's it for now, this might get more content as I work on Spear.