Microsoft DirectX 8.1 (Visual Basic)

Tutorial 3: Using Matrices

This tutorial introduces the concept of matrices and shows how to use them. The Vertices sample project rendered 2-D vertices to draw a triangle. However, in this tutorial you work with transformations of vertices in 3-D. Matrices are also used to set up cameras and viewports. For more information on working with transformation matrices, see Transforms.

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 3-D triangle. Typically, three different types of transformation are applied to a 3-D scene. Steps for creating each one of these typical transformations are listed below.

For more information on matrices and transformations, see Matrices.

Note  The path of the Matrices sample project is:

    (SDK root)\Samples\Multimedia\VBSamples\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 code in the Matrices sample project is nearly identical to the code in Vertices sample project. This tutorial focuses only on the code unique to matrices and does not cover initializing Direct3D, rendering, or shutting down. For information on these tasks, see Tutorial 1: Creating a Device.

This tutorial also uses custom vertices and a vertex buffer to display geometry. For more information on selecting a custom vertex type and implementing a vertex buffer, see Tutorial 2: Rendering Vertices.