Video Game Programming
Lab 3 : Rotating Cube

As powerful as it is, DirectX only has the ability to draw one type of primitive -> a triangle. This is not much of a limitation, since any polygonal structure can be represented as a set of triangles. In lab 1, you drew a square using two triangles. In this lab, you will output a cube to screen. A cube has six faces, and therefore can be represented by twelve triangles. Doing this the brute force way, you would need 12 x 3 = 48 vertices just to draw a cube. However, there is a more efficient way to draw structures that share vertices. Fill in the vertex buffer as you normally would -> with 8 vertices for the cube. Now, youll need to make use of the index buffer. Using the index buffer you can assign any set of vertices to a triangle face. So the first face would be vertices 1,2 and 3; the second would be 2,3,and 4, and so on.....

Topics Covered :
  • Vertices and Vertex Buffers
  • Transformations using DirectX
  • World, View and Projection Transforms
  • The Vertex Buffer
  • The index buffer

Your assignment is to write a program that will open up in fullscreen mode. It should quit when the user closes the window. The program should display a cube centered at the origin. The cube should rotate slowly around at least two axes.

  • Completion of lab 2
  • Knowledge of the C++ language

Chapters 1-9 "Real Time Rendering in DirectX"

  • Cube appears
  • Cube rotates slowly
  • Vertex buffer appropriately filled
  • Index buffer appropriately filled
  • 30%
  • 20%
  • 25%
  • 25%

Lab 3

This lab is being distributed as a zip file. You must unzip all files to the same directory.

This lab requires DirectX 9.0a End-User Runtime

Address questions regarding this lab to Prasan Samtani at