Introduction
Background
uisGL Primitives
Siggraph '96 Educators Program
Availability
Author
References
Acknowledgements
UisGL is a toolkit of portable C++ classes to support computer
graphic education. Although it is designed to work with OpenGL
for rendering, custom or other rendering APIs can be used. The
uisGL primitives relieve students from implementing low level
details associated with vectors, matrices, and 3D data structures.
This allows students to create impressive images early in the
semester using existing software and slowly replace each component
with their own software as the semester progresses. This 'plug
and play' approach not only provides motivation early in the semester
but it allows for deep understanding of the algorithms by the
end of the semester.
Computer science students are expected to understand and write
software that performs all three steps of the graphics pipeline.
However, it may take all semester to develop the software in an
introductory course. Only at the end of the semester will students
have the satisfaction of seeing the fruits of their labor. A better
solution would be to allow students to create pictures from the
first day while they investigate how the pictures
are created during the rest of the semester. One strategy is to
provide all of the software to students at the beginning of the
semester (Schweitzer and Northrop, 1991). Unfortunately, this
approach does not require students to truly understand the software
because they did not develop it themselves.
A better strategy is to provide software at the beginning of the
semester and require students to develop their own
software. This approach was taken by Clevenger et al. (1991).
However, their work was not adopted by many educators because
it is developed in Ada, a programming language not as popular
as C++. A similar approach was taken at The Ohio State University
(Carlson, 1990). A limitation of the Ohio State software is that
it does not take advantage of object-oriented programming. This
is why some students find the data structure to be somewhat overwhelming
to learn (Carlson, 1990). In addition, neither of these approaches
use OpenGL to perform rendering.
Three primitives used in most graphics algorithms are vertices,
vectors, and matrices. Each primitive has certain operations that
are commonly performed. For example, vectors involve dot products
and cross products. Homogenous matrices are multiplied with each
other as well as vertices to transform a point in 3D space.
Several uisGL classes are provided with overloaded operators.
This makes the C++ code read like pseudo code used in a classroom.
High-level code allows students to focus on concepts rather than
syntax and implementation of the language. The multiplication
operator is overloaded to return the dot product of two vectors.
The vertical bar is overloaded to return the cross product of
two vectors. Subtraction between two verticies yields a vector.
For example, the following code calculates a normal unit vector
from three verticies on a face: P1, P2, and P3.
V1 = P2 - P1; // calc first vectorV2 = P3 - P1; // calc second vectorN = V1 | V2; // calc normal to faceN.normalize(); // make a unit vector
Matrices are not only used to perform affine transformations
but also for view manipulation and perspective projection. Each
of the common matrices can be initialized with data using member
functions of the matrix class. Students must insert the appropriate
values and multiply matrices to obtain the desired results. The
following code initializes a scaling and translation matrix and
then concatenates them. Although many APIs provide a stack to
efficiently perform concatenation, having students directly control
individual matrices reinforces the concept of affine transformations.
uisMatrix Mat, S, T;S.setScaling(2, 2, 2);T.setTranslation(10, 0, 0);Mat = S * T;
A complex data structure is necessary to model 3D graphic objects.
UisGL provides a common data structure used in graphics textbooks
that represents objects as a collection of faces composed of a
counterclockwise series of vertices. Providing a well designed
data structure relieves students from the drudgery of implementing
their own. Students must still be aware of the underlying data
structure and use it correctly in the rendering algorithms. Member
functions are used to extract face and vertex information as needed.
Attributes such as color are also available through member functions.
Default values can be initialized for common primitives with the
constructor. The data structure can also be read from a standard
text file using the overloaded input operator. The data format
is quite common and many ftp sites have appropriate data files.
This feature also allows students and instructors to create their
own graphic objects.
The following code defines an object as a standard cube and retrieves
information to render the second face.
uisObject Cube(UIS_CUBE);uisFace F;uisVertex P1, P2, P3, P4;F = Cube.getFace[2];P1 = F.getVertex[1];P2 = F.getVertex[2];P3 = F.getVertex[3];P4 = F.getVertex[4];// render a polygon with P1, P2, P3, P4
I presented a paper at the SIGGRAPH '96 Educators Program that
describes my use of uisGL in an Introduction to Computer Graphics
course. The paper, A Middle-Out Approach
to Teaching Computer Graphics with uisGL is an HTML document
that has several useful links to other products such os OpenGL
and GLUT.
UisGL is portable C++ code that should work on any system with
C++. However, at this time I can only vouch for a UNIX implementation
on Sun Solaris. I plan to confirm that it works on Windows and
LINUX as well but feel free to volunteer if you want to blaze
the trial for me on either of these platforms!
Documentation is available for students and instructors. Student
manuals explain how to use uisGL. Instructor materials include
instructions for obtaining the software, installing it, and recommendations
for integrating the material into a curriculum. Sample programs
are included in all documentation.
Please send me an e-mail message if you want to obtain a copy
of the software.
Scott Grissom
Grand Valley State University
Computer Science Department
grissom@gvsu.edu
W.E. Carlson, "An Environment for a Graduate Curriculum
in Computer Graphics," ACM SIGCSE Bulletin ,
22(2), June 1990, pp. 15-20.
J. Clevenger, R. Chaddock, R. Bendig, "TUGS - A Tool for
Teaching Computer Graphics," Computer Graphics,
25 (3), July 1991, pp.158-164.
S. Cunningham, "The Computer Graphics Course in the Computer
Science Curriculum," Teaching Computer Graphics: An
Interdisciplinary Approach , 1987 ACM SIGGRAPH Educator's
Workshop Course Notes.
J. D. Foley, A. van Dam, S. K. Feiner, J. F. Hughes and R. L.
Phillips, Introduction to Computer Graphics , Addison-Wesley:
New York, 1994.
S. Grissom, J. Bresenham, B. Kubitz, G.S. Owens & D. Schweitzer,
"Approaches to Teaching Computer Graphics," ACM
SIGCSE Bulletin , 27(1), March 1995, pp382-283.
S. B. Grissom, "uisGL: A C++ Library to Support Graphics
Education," Computer Graphics, 30 (3), August 1996.
M.J. Kilgard, The OpenGL Utility Toolkit (GLUT) Programming
Interface, Silicon Graphics, Inc., 1995.
J. Neider, T. Davis and M. Woo, OpenGL Programming Guide
, Addison-Wesley: New York, 1993.
M. Ohlson, "The Role and Position of Graphics in Computer
Science Education," ACM SIGCSE Bulletin , 18
(1), February 1986, pp. 232-237.
S. Owens, "Considerations in Teaching A Two Quarter Computer
Graphics Sequence," Computer Graphics , 25 (3),
July 1991, pp. 147-150.
S. Owens, M. M. Larrondo-Petrie and C. Laxer, "Computer Graphics
Curriculum: Time for a Change?," Computer Graphics
, 28 (3), August 1994, pp. 183-185.
N. Schaller, "Graphics Education for Computer Science - Panel
Report," Computer Graphics , 27 (1), Jan. 1993,
pp. 6-10.
D. Schweitzer and L. Northrop, "Getting to the 'Graphics'
in a Graphics Exercise," Computer Graphics,
25 (3), July 1991, 151-175.
This work is supported by the Learning Technologies in Higher Education Program at the University of Illinois. I also appreciate the patience and effort of my students who provided valuable feedback during the development of uisGL.