Video Game Programming
Lab 2 : Drawing a Square to the Screen


Applications in Windows use an event loop structure. What this means is that the program keeps going through a certain set of functions and keeps redrawing the window until it recieves user input. When input is recieved, windows programs package the input in the form of a message and send them to the appropriate file to be translated and then perform the appropriate operation. What we need to do as game programmers is to develop an interface that encapsulates the standard windows functions so that we no longer need to deal with the simple windows functions. A basic application program is provided for you on the website at These functions encapsulate the standard Windows functions, WinMain() and WinProc(), and redirect user input directly to your program, thus cutting out the middleman.

Topics Covered :
  • Introduction to Windows Programming - The Event Loop
  • Introduction to the DirectX API
  • Vertices and Vertex Buffers
  • Transformations using DirectX
  • World, View and Projection Transforms
  • Viewports

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 square centered at the origin. DirectX reduces every shape to a polygon before blitting to screen, so a square is represented by two triangles. You must make the shape rotate slowly clockwise. In addition you need to set the lighting flag to true and add one omnidirectional point light source to your scene.
Extra Credit: Add Textures to your scene using a bitmap (as shown in the example).

Knowledge of the C++ language

Chapters 1-9 "Real Time Rendering in DirectX"

  • Window opens
  • Program quits on closing window
  • Appropriate filling of vertex buffer
  • Square is displayed
  • Rotations
  • Lighting
  • Textures (extra credit)
  • 10%
  • 10%
  • 20%
  • 15%
  • 15%
  • 20%
  • 10%

Lab 2

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