Some sample OpenGL source code is provided here as additional and more complete examples of what is covered in the lectures. In most cases they are single files that you can compile with:
gcc simple.c -o simple -I/usr/X11R6/include/ -L/usr/X11R6/lib -lX11 -lXi -lXmu -lglut -lGL -lGLU
or on the Macintosh (OS X):
cc simple.c -o simple -framework GLUT -framework OpenGL -lobjc
(Substitute "simple" for the program name).
Here is a Makefile to complie all the sample code for Linux (contributed by Brendon Taylor)
File Description simple.c This program draws a white rectangle on a black background.
text.c Illustates the use of GLUT to draw stroke and raster text. In addiditon shows how callbacks are used by GLUT to respond to redraw events, mouse clicks and keyboard events.
displayList.c A simple example showing how to use display lists (Lecture7). Also shows how to use
glutIdleFunc
to perform animation.Simple set of functions to illustrate the use of tessellation using GLU. Needed for viewports.c below.
viewports.c Shows how to draw to multiple viewports. Requires the tessellation functions above.
timer.c Uses the
glutTimerFunc
callback to make a simple timer.gasket.c Draws the Sierpinski gasket using the random point method.
3dPrims.c Simple 3D program that draws glut shapes in wireframe mode. Use the right mouse button menu to select a new shape to draw.
spirograph.c
[new version!]Draws spiral patterns in 2D with simple parameter animation and mouse control. Press the space bar to display a menu of keyboard and mouse options. In particular try the "a" and "e" keys. Run in the background while you're programming to increase productivity.
solar.tar.gz Solar system model that demonstrates the use of compound transformations in OpenGL, also OpenGL lighting and depth buffering. This is a gzip'ed tar file – unpack the file and look at the README to see how to compile. LoadObj.tgz Program to load a model of an island and display it in using simple lighting. You can use this for assignment 2 if you can't get the fractal subdivision algorithm working.