Tutorial 3: Using Matrices

This tutorial introduces the concept of matrices and shows how to use them. The Vertices sample project rendered 2D vertices to draw a triangle. However, in this tutorial you will be working with transformations of vertices in 3D. Matrices are also used to set up cameras and viewports.

Before the Matrices sample project renders geometry, it calls the SetupMatrices application-defined function to create and set the matrix transformations that are used to render the 3D triangle. Typically, three types of transformation are set for a 3D scene. Steps for creating each one of these typical transformations are listed below.

Steps

The path of the Matrices sample project is:

(SDK root)\Samples\C++\Direct3D\Tutorials\Tut03_Matrices

The order in which these transformation matrices are created does not affect the layout of the objects in a scene. However, Direct3D applies the matrices to the scene in the following order:

  1. World
  2. View
  3. Projection

The sample code in the Matrices project is nearly identical to the sample code in the Vertices project. The>Using Matrices tutorial focuses only on the code unique to matrices and does not cover initializing Direct3D, handling Windows messages, rendering, or shutting down.