CS405 Lab 2: Fundamental OpenGL Functions

Highlights of this lab:

This lab is an introduction to Fundamental OpenGL Functions


After the lab lecture, you have one week to:

On-line OpenGL Manual

Seminar Notes

A. What is OpenGL?

B. Why is OpenGL used?

C. What are the basic steps to use OpenGL in a Windows Program?

D. What is a DC?

E. What is an RC?

F. Brief Introduction to Pixel Format Data Structure

G. Basic Rendering Function

For the first part of the following discussion it may be useful to try out the OpenGL Shapes Demoinstructions.


Goals of this assignment:

For starters:

It is good to get a feeling for where you can put points on the scene.

The following instructions are meant to get you started (based on the program you completed last week). Modify the OpenGLView.cpp code:

  1. In the SetupViewingTransform function, comment out the glRotatef code.
  2. Also in the SetupViewingTranform function, change the glTranslate to read: ::glTranslatef( 0.0f, 0.0f, -10.0f );
  3. Comment out (or delete) all of the existing RenderScene and RenderStockScene code.
  4. Now, you can use a line loop to draw the outline of the space that you can work in (add this code to the RenderScene or RenderStockScene function):
     glColor3f(1.0f, 0.0f, 0.0f); //draw in red
    Note: these values may vary slightly depending on the machine you are using.
  5. The approximate range of values is:

Note: you will be looking directly down the z axis. The positive z axis is pointing towards you.

Marking scheme and details of assignment:

(17 marks total)

Samples of previous work.


  1. A version of the MFC OpenGL project from last week with the changes suggested in the marking scheme above. You may modify the SDL project if you wish.
  2. OPTIONAL: A screenshot of your final picture for advance marking and to be included in an anonymous picture gallery.
  3. BONUS: Announced at the end of lab lecture.

Hints and Tips

You can find sample code at: http://www.sgi.com/products/software/opengl/examples/redbook/. If you get this error when you compile the sample code:

error C2381: 'exit' : redefinition; __declspec(noreturn) differs
try removing:
#include <stdlib.h>

Pay particular attention to:

You might want to look up glPointSize in the Online OpenGL Manual

Some Definitions

Taken from page 46 and 47 and 64 of Fosner's book, OpenGL Programming for Windows 95 and Windows NT