Sample OpenGL SoftwareThis page is somewhat out-of-date. It uses examples from legacy (immediate mode) OpenGL. For examples using modern OpenGL with shader programs, please to the web page of OpenGL software supporting the planned second edition of the book.
The OpenGL programs below are intended to accompany the book 3D Computer Graphics: A mathematical approach with OpenGL, by Sam Buss, Cambridge University Press, 2003. However, they can be used independently as well. These are short C programs that illustrate the use of some of the basic features of OpenGL. There is also a ray tracing software package that accompanies the same book.
The programs are supplied with Visual C++ 6.0 project and workspace files; however, the source files should work with other compilers and on other systems as well. You will need to have OpenGL and GLUT installed (the header files to compile and the object libraries to run the programs).
For Unix/Linux users: Sample makefiles for compiling and linking SimpleDraw are provided here. For the other programs, make the obvious changes to the makefile by listing the .c source files on the compiler command line in the correct order. The makefiles have been tested under Solaris Unix only (if anyone gives me makefiles for other systems, I could post them too.) There are two makefiles: (a) a makefile which uses cc, and (b) a makefile which uses gcc and (c) A CMake configuration file, courtesy of Mick Beaver (email@example.com).
Visual Studio 2010 users: The projects above are Visual Studio C++ version 6.0, but should work with the new Visual Studio 2010 compiler too.
Visual Studio.NET users: The projects above are Visual Studio C++ version 6.0, but should work with the subsequent .NET compilers too. There is a potential problem with incompatibilities between the exit() function prototypes used by C and GLUT. These apparently can be avoided by being sure you do not #include the file stdlib.h after you #include the glut.h file. However, if you still get error messages about the exit() function prototype or from stdlib.h, you can also try using my modified version of glut.h that works with the more recent .NET compiler.
Obtaining GLUT. The programs above all depend on OpenGL and
If you are using Visual C++, you probably have OpenGL already installed, but it may not come with GLUT. The official page for downloading the latest version of GLUT for PC's is Nate Robin's page http://www.xmission.com/~nate/glut.html. You will get files glut32.dll and glut32.lib and glut.h. These should be installed on your Windows PC in the same directories as the other OpenGL files --- to find these directories do a "Seach" or "Find Files" for glu32.dll and glu32.lib and glu.h. It is also possible to install these files locally if you do not have the file access permissions to write to system directories.
You can also use GLUT with other compilers and operating systems (see the preface to the book).
More information on GLUT can be found at http://www.opengl.org/resources/libraries/glut/.
Visual Studio .NET users may wish to get my custom modified version of glut.h. (To let GLUT work Visual Studio.NET without needing to disable the "at exit" hack.)
Bug reports or other problems: firstname.lastname@example.org.