8 February 2012

Setting up DirectX SDK in Visual Studio 2010

Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. The DirectX software development kit (SDK) consists of runtime libraries in redistributable binary form, along with accompanying documentation and headers for use in coding. Originally, the runtimes were only installed by games or explicitly by the user. Direct3D 9Ex, Direct3D 10, and Direct3D 11 are only available for Windows Vista and Windows 7 because each of these new versions was built to depend upon the new Windows Display Driver Model that was introduced for Windows Vista. The new Vista/WDDM graphics architecture includes a new video memory manager supporting virtualization of graphics hardware for various applications and services like the Desktop Window Manager.

Download and install the latest DirectX SDK binary from microsoft's website - http://msdn.microsoft.com/en-us/directx/aa937788.

After installation of SDK, you can run DxDiag.exe to check your current DirectX settings or for any existing problems.

Setting up the include and library directories on Visual Studio -
1. You can add the include settings and library settings of the directx sdk present in your program files folder individually for every project. This is advisable if you are working on a serious project. But if you are lazy to do so, you can add it to the global settings so that it is incorporated in all your projects.
2. Open the "Property Manager" from the View menu.

3. Expand the project/configuration tree and select the "Microsoft.Cpp.X.user" user file. Right click and select "Properties".

4. Add the DirectX SDK include directory to the "VC++ Directories">"Include Directories" -
   $(DXSDK_DIR)Include
   Add the DirectX SDK library directory to the "VC++ Directories">Library Directories" -
   $(DXSDK_DIR)Lib\x86

5. Now, open your DirectX project and add the DirectX linker settings to it.
   Expand the "Linker" section and select "Input" and under "Additional Dependencies" add the necessary lib files -
  d3d11.lib
  d3dx11.lib
  dxerr.lib

Now you are ready to start coding with DirectX.

You can download sample files from here and include them in an empty project to see how a DirectX code looks like. This is a simple code which just displays a blank DirectX screen.