The libdms Toolkit is a library of C++ classes for OpenGL programming, created for use in the DMS 424 - Programming Graphics 2 course at UB.
The main purpose of this library is pedagogical, not real-world utility or high performance. In particular, my goals are to:
Many other, roughly similar, toolkits exist, such as Performer, OpenSceneGraph, OpenSG, OpenRM, and Plib. However, these toolkits are much more complex (which they should be). The libdms library is kept very simple, so that beginning students should be able to learn how to use it easily, and so that they can study the source code and (hopefully) learn from it - something that's easier with a 2,000-lines-of-code library than a 40,000 line library.
A compressed tar file of the source code is here: libdms.tgz A zip file of the source code is here: libdms.zip
The libdms library consists of four general sections:
These include functions to check for any OpenGL errors, draw text strings, get timing information, and compute normal vectors.
See dms::Util for details.
These are the classes Vector2, Vector3, Vector4, and Color, representing 2, 3, and 4 dimensional points or vectors. The classes include several standard functions such as dot products, lengths, and math functions (addition, etc.).
The classes can be used for computations of object motions and geometry. They are also used by most of the other classes.
These classes - Light, Material, Texture2D, Transparency, and SimpleTransform - wrap various bits of fairly common OpenGL calls. Each class includes member variables to store the data required for the feature they implement (e.g. ambient/diffuse/specular color), and functions to set and get the values of these member variables.
There are also Image classes for storing the data used by textures.
These are the Camera and Object abstract classes, and their derived classes.
Camera represents a view of a scene. It consists of a projection (perspective or orthographic), and a camera position and orientation. There are two subclasses, for the different kinds of projection - PerspCamera and OrthoCamera.
Object represents any sort of object that can be drawn. It includes features to associate drawing state with an object, to assign an object drawing & update callback functions, and to create a simple, hierarchical scene graph.
All of the libdms classes and functions are declared in the
C++ namespace dms.
e.g., to create a Vector3 and use it with the drawString function, you would do:
#include <dms/Vector3.h> #include <dms/Util.h> dms::Vector3 position = dms::Vector3::Z_Axis * 5; dms::drawString("text", position);
Alternatively, you can use the C++ using command to eliminate the need for the "dms::" prefixes. e.g.:
#include <dms/Vector3.h> #include <dms/Util.h> using namespace dms; Vector3 position = Vector3::Z_Axis * 5; drawString("text", position);
All class names begin with a capital letter.
All function names begin with a lowercase letter.
The names of all functions to set a parameter (member variable)
in a class are the word "set" followed by the parameter
name. Object arguments are passed by reference.
All functions that fetch the value of a parameter have the same name as the parameter; the parameter value is the return value of the function (as opposed to returning it through an argument).
e.g., for the Material parameter ambient, we have the functions:
void Material::setAmbient(const Vector4& color); Vector4& Material::ambient(void);
The names of all constants that are #defined in the header
files begin with DMS_.
e.g., the constants for coordinate axes are DMS_X, DMS_Y, and DMS_Z.
The library is currently located in the directories ~dave/424/lib and ~dave/424/include, on the DMS Linux PCs. To compile a program with the library, you will need to add pointers to these directories to your Makefile.
Specifically, you should add -I/home/dms/dave/424/include to your C++ compile flags, and -L/home/dms/dave/424/lib -ldms -limage -ltiff to your link libraries. The -limage -ltiff part is needed for the Image (and Texture2D) classes (-ljpeg may also be needed on some systems, but usually the jpeg library is automatically included along with the tiff library).
The following is an example:
CFLAGS = -O CPPFLAGS = $(CFLAGS) -I/home/dms/dave/424/include LFLAGS = -O LIBS = -L/home/dms/dave/424/lib -ldms -lglut -lGLU -lGL -L/usr/X11R6/lib -lX11 -lm -limage -ltiff example0: example0.o c++ $(LFLAGS) -o example0 example0.o $(LIBS)
Note that there is an extra header file dms/dms.h, which is there for convenience. It #includes all of the other headers, so that you don't have to worry about remembering to include all the right class headers. Just use
in your source code.
Last updated 17 February 2003.