CSC418/2504 Fall 2007: Getting Started

Demo Program

To get started, we have created a simple demo for you. This will show you how to use the very basic commands of OpenGL to open a window and draw some basic shapes. It will also provide you with a template Makefile for compilation and linking of your programs.

This simple demo program opens a window, and animates a two squares connected by a hinge. To run this demo, first get copies of the C++/OpenGL source code and the Makefile from the following tar file: monkey.tar . Then place these files into your own graphics directory and check the compilation instructions below.

Compilation

To compile programs easily we have set up a simple makefile for you. Go to your graphics directory that contains the demo program and makefile, and then type the command: make . This command searches the current directory for the file called Makefile which contains instructions for compilation and linking with the appropriate libraries.

You will find this Makefile useful when compiling programs for your assignments. For example, inside the Makefile you will have to make several small changes to include the name of the current program you are running. For example, change all occurrences of monkey to the name of the file you wish to compile. You can also change the Makefile to include code from several files by listing the the C++ source files (i.e., the files ending in ".cpp") on the line CPPSRCS =  . The name of the executable file is determined by the name you use in the Makefile on the line PROGRAM = monkey

When you run the demo program a graphics window will appear. The size of the window is determined by parameters (xmax and ymax) to the initialization routine. Each pixel is indexed by an integer pair denoting the (x, y) pixel coordinates with (0,0) in the top left hand corner and (xmax,ymax) in the bottom right.

Compatibility

All of your assignments must run on CDF Linux. However, you are welcome to develop on other platforms (and then port to CDF for the final submission). This sample code is designed to work on Linux or Solaris machines, but should be portable to other Unix platforms. If you are running your own machine, it almost certainly has OpenGL installed; if not, you can search for an rpm or go to http://www.opengl.org/ (see their getting started FAQ. If you develop on a different platform, be sure you know how to compile and test your code on CDF, well before the deadline.

For Windows users: For the most part, you shouldn't have much trouble moving your code to CDF, if you program on Windows. We have put together a sample Visual C++ project for the sample code that you may use: windows_starter.zip. You'll need to put these files in the same folder as the skeleton code and add the skeleton code to the project.

One common error when porting is due to a difference in scoping rules; MSVC is somewhat lax about scoping rules for for loops, and will allow:

for(int i =0; i < N; i++)
{
   foo(i);
}
foo(i);
whereas gcc will not allow the reference to i outside the for loop.