How to set up your DirectX Windows Store app to display a view

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

To develop a Windows Store app with DirectX, you must understand how to hook DirectX up to the windowing infrastructure that is provided by the Windows Runtime and exposed as the CoreApplicationView and CoreWindow types. Here we step you through the process of creating a CoreWindow object and connecting a DirectX swap chain to it.

What you need to know

Technologies

Prerequisites

  • C++ programming knowledge
  • Familiarity with DirectX and DirectX terminology
  • Some knowledge of the Windows Runtime framework
  • A basic knowledge of COM/COM+

Remarks

In this topic, you will follow the code used to create a basic view provider. Existing Windows graphics frameworks, such as XAML, contain their own implementation of a view provider and core event handlers that cannot be replaced or modified. When writing code for DirectX directly, you must include code that connects the graphics device resources to the window for your application, and connect up the core windowing events yourself. There are two ways to accomplish that:

  • Use and modify the Direct3D templates in Visual Studio 2013.
  • Create a DirectX view provider from scratch.

While we recommend you use the Visual Studio 2013 Direct3D templates, it is also important to understand how the code provided in those templates works so you can effectively modify or extend that functionality, or if you do not wish to use those templates.

Also, note that if you want to use DirectX in your game or graphics app, you must use native C++ for development. This means that you need to be familiar with references and basic memory management techniques. You should also have a basic grasp of design patterns such as the factory and singleton patterns. Also, if you're unfamiliar with DirectX graphics programming, take some time to read through the high-level DirectX 11 documentation to understand some of the terminology we use in this topic, such as view, render target, and swap chain.

The setup takes three steps:

  • Create and initialize an app view using the Windows Runtime, and obtain a CoreWindow instance
  • Set up your event dispatch behaviors on that CoreWindow instance
  • Connect the DirectX swap chain to the CoreWindow instance, handle display change events, and then perform a draw operation.

We want to get you quickly to a place where you can begin to output DirectX graphics and have basic events connected to that output.

Steps

Topic Description

Step 1: Create and initialize a view

In this step, you create and initialize the CoreApplicationView that configures the basic settings for a display window, and you obtain the CoreWindow object that controls the input events on that view.

Step 2: Set up the event handlers

To continue with setting up DirectX to display a view, let's connect handlers to events. This step builds on the code you already created for the basic flow of your DirectX app using C++ and the Windows Runtime APIs, in Step1: Create and initialize a view.

Step 3: Connect the DirectX swap chain to the UI

To finish setting up DirectX to display a view, it's time to bring DirectX into the view provider you created for your Windows Store app using DirectX with C++. InStep1: Create and initialize a view, you created the view provider and the factory that creates it. Then, in Step 2: Set up the event handlers, you prepared the necessary events to handle PLM, display, and window changes. Now, let's add the graphics resources that draw and manage the view, and which update in response to the events received by the app's CoreWindow.

Complete code for a DirectX Windows Store app framework

This topic provides the complete code sample used in the tutorial How to set up your DirectX Windows Store app to display a view.

 

Complete code for a DirectX Windows Store app

Creating a DirectX game

Developing games