|
|
OpenGL Graphics
|
|
In our Supercomputer Applications course in the Computer Systems Lab at Jefferson, we have been using the text book OpenGL Programming Guide, 2nd Edition, by Mason Woo, Jackie Neider, and Tom Davis, Addison-Wesley Developers Press, 1997. It is the "Official Guide" to learning OpenGL version 1.1, includings examples in GLUT, the OpenGL Utility Toolkit. GLUT has many time saving routines allowing the user to create simple windows, handle keyboard and mouse interaction, access predefined shapes, and do many other cool things.
Originally designed for high powered Silicon Graphics workstations, there are versions or clones of OpenGL available for personal computer systems. At Jefferson, we are running Mesa, a free version of OpenGL that performs satisfactorily on our 133 Mhz Pentium systems running LINUX. We encourage you to introduce students to OpenGL, and suggest the following links for additional resources:
Drawing points in 2-D
|
This program creates a simple window using "glaux.h", a set of auxiliary
routines for OpenGL. The program sets the background of the window to
gray and then draws a yellow parabola, point by point.
Source Code |
Using Sub-windows and Text
|
This program creates a simple window using a different set of routines
from the OpenGL Utility
Tool Kit (GLUT), found in "glut.h". These routines actually create a
sub-window
within the main window, and with slight modifications a programmer
can create several sub windows. This program also demonstrates how to
display text on the screen using bit-mapped raster graphics.
Source Code |
Scaling Sub-windows, Mouse and Keyboard Routines
|
This program creates two sub-windows, and scales one of the images using
Orthographic Projection. It also demonstrates how to create mouse
routines that are active in the separate windows, as well as how to
use keyboard functions.
Source Code |
Shapes and Animation
|
This program creates several objects including a large yellow square, a
small red square, a parabola, and a wire-frame box using the "glaux.h"
libraries. It introduces
the concept of changing a point of refernce in the coordinate plane
by pushing or popping a transformation. It utilizes several other
OpenGL primatives including rotation, translation, and scaling. It
creates a "smooth" animation by using a technique known as double
buffering.
Source Code |
3-D Landscape #1 - Scalable surface
|
This program creates a simple 3-Dimensional surface using "glut.h" that can be manipulated
in space using the arrow keys. It uses Perspective rather than Orthographic
projection.
The program scales
high and low values in the height range, and adjusts the drawing
color accordingly. The curved surface is generated by a product
of sine functions, but with a new period and amplitude.
Source Code |
3-D Landscape #2 - Polynomial Equations
|
This program is a variation of the 3-D surface program but uses the
"glaux.h" rather than "glut.h". It graphs
a portion of a 3-D mathematical surface that was generated by polynomial
equations.
Source Code |
Animation and Lighting of Objects
|
This program draws several rotating spheres in 3-space. The red sphere
is the center of rotation with the yellow and green spheres acting
as planets. The blue sphere orbits the yellow sphere as if it were
a moon. This program uses advanced routines from "glut", the OpenGL
Utility Toolkit, rather than "glaux". The program includes examples
of depth buffering, surface properties, and lighting effects.
Source Code |
The following UNIX scripts will be helpful when compiling on the LINUX systems in Jefferson's CS Lab. The script includes paths to the various libraries including the header files for OpenGL and X-windows. The script will expect the user to provide the name of the source file, but without the extender. If the compilation is successful, it will create an executable file of that same name.