CS 371
Computer Graphics
Spring 2005


5 Simple Ray Tracing Part II

5.1 Light Sources

5.2 The GraphicsWindow Library

OpenGL uses an event-driven programming model. Eventually we will adopt this approach. For now, it is easier to assume that there are windows that we can create and draw to without worrying about handling user events.

The GraphicsWindow library (libCS371.a) provides windows which can be displayed on the screen, and the pixels of which can be individually set.

5.2.1 Use

See the program GraphicsWindowTest.cc for an example of using these windows.

5.2.2 Compiling a GraphicsWindow Program by Brute Force

The compiled code for the GraphicsWindow library is located in /usr/cs-local/lib/cs371lib/ and is called libCS3y1.a. To use libCS371.a with your own programs, you need to tell the compiler the name of the library and where it can be found. Library xyz is traditionally given the name libxyz.a in the file system. The option -lxyz to g++ command instructs the compiler to look for a file called libxyz.a. The option -Ldirectoryname (e.g., -L/usr/cs-local/lib/cs371lib to g++ tells the compiler to look in the specified directory for libraries.

Because the GraphicsWindow library uses XWindows as well as a C++ library and a math library, you will also have to tell the compiler which of these libraries it will need, and where it can find them. To do this, add -L/usr/X11R6/lib -lX11 -lm -lc to the g++ command. To tell the compiler where the header file GraphicsWindow.h resides, add -I/usr/cs-local/include/cs371include. To tell it where the include files needed for XWindows reside, add -I/usr/cs-local/include/cs371include.

In summary, to compile, for example, the program GraphicsWindowTest.cc, you would give the following commands:

g++ -c GraphicsWindowTest.cc -I/usr/cs-local/include/cs371include \backslash
-I/usr/X11R6/include
g++ -o GraphicsWindowTest GraphicsWindowTest.o -L/usr/cs-local/lib/cs371lib \backslash
-L/usr/X11R6/lib -lCS371 -lX11 -lm -lc
The backslash at the end of a command line allows you to continue a long command after hitting Enter. Of course you can just continue typing; I only used it to improve readability of this document.

Suggestion: Copy the file GraphicsWindowTest.cc into your own directory and try this!

5.2.3 Compiling a GraphicsWindow Program with gmake

Or... Copy both GraphicsWindowTest.cc and Makefile from the sampleCode directory, and enter the command
gmake GraphicsWindowTest
Wasn't that better? See Lecture 4 for more about gmake.
lenhart@cs.williams.edu