Walkthrough: Port a simple Direct3D 9 app to DirectX 11 and Universal Windows Platform (UWP)

This porting exercise shows how to bring a simple rendering framework from Direct3D 9 to Direct3D 11 and Universal Windows Platform (UWP).

Topic Description

Initialize Direct3D 11

Shows how to convert Direct3D 9 initialization code to Direct3D 11, including how to get handles to the Direct3D device and the device context and how to use DXGI to set up a swap chain.

Convert the rendering framework

Shows how to convert a simple rendering framework from Direct3D 9 to Direct3D 11, including how to port geometry buffers, how to compile and load HLSL shader programs, and how to implement the rendering chain in Direct3D 11.

Port the game loop

Shows how to implement a window for a UWP game and how to bring over the game loop, including how to build an IFrameworkView to control a full-screen CoreWindow.

 

This topic walks through two code paths that perform the same basic graphics task: display a rotating vertex-shaded cube. In both cases, the code covers the following process:

  1. Creating a Direct3D device and a swap chain.
  2. Creating a vertex buffer, and an index buffer, to represent a colorful cube mesh.
  3. Creating a vertex shader that transforms vertices to screen space, a pixel shader that blends color values, compiling the shaders, and loading the shaders as Direct3D resources.
  4. Implementing the rendering chain and presenting the drawn cube to the screen.
  5. Creating a window, starting a main loop, and taking care of window message processing.

Upon completing this walkthrough, you should be familiar with the following basic differences between Direct3D 9 and Direct3D 11:

  • The separation of device, device context, and graphics infrastructure.
  • The process of compiling shaders, and loading shader bytecode at runtime.
  • How to configure per-vertex data for the Input Assembler (IA) stage.
  • How to use an IFrameworkView to create a CoreWindow view.

Note that this walkthrough uses CoreWindow for simplicity, and does not cover XAML interop.

Prerequisites

You should Prepare your dev environment for UWP DirectX game development. You don't need a template yet, but you'll need Microsoft Visual Studio 2015 to load the code samples for this walkthrough.

Visit Porting concepts and considerations to gain a better understanding of the DirectX 11 and UWP programming concepts shown in this walkthrough.

Direct3D

Microsoft Store