[Previous Section] [Back to Table of Contents] [Next Section]

OpenGL Programming Guide (Addison-Wesley Publishing Company)


About This Guide

The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) It allows you to create interactive programs that produce color images of moving three-dimensional objects. With OpenGL, you can control computer-graphics technology to produce realistic pictures or ones that depart from reality in imaginative ways. This guide explains how to program with the OpenGL graphics system to deliver the visual effect you want.


What This Guide Contains

This guide has 14 chapters, one more than the ideal number. The first five chapters present basic information that you need to understand to be able to draw a properly colored and lit three-dimensional object on the screen.

The remaining chapters explain how to optimize or add sophisticated features to your three-dimensional scene. You might choose not to take advantage of many of these features until you're more comfortable with OpenGL. Particularly advanced topics are noted in the text where they occur.

In addition, there are several appendices that you will likely find useful.

Finally, an extensive Glossary defines the key terms used in this guide.


What's New in This Edition

To the question, "What's new in this edition?" the wiseacre answer is "About 100 pages." The more informative answer follows.


What You Should Know Before Reading This Guide

This guide assumes only that you know how to program in the C language and that you have some background in mathematics (geometry, trigonometry, linear algebra, calculus, and differential geometry). Even if you have little or no experience with computer-graphics technology, you should should be able to follow most of the discussions in this book. Of course, computer graphics is a huge subject, so you may want to enrich your learning experience with supplemental reading.

Once you begin programming with OpenGL, you might want to obtain the OpenGL Reference Manual by the OpenGL Architecture Review Board (Reading, MA: Addison-Wesley Developers Press, 1996), which is designed as a companion volume to this guide. The Reference Manual provides a technical view of how OpenGL operates on data that describes a geometric object or an image to produce an image on the screen. It also contains full descriptions of each set of related OpenGL commands - the parameters used by the commands, the default values for those parameters, and what the commands accomplish. Many OpenGL implementations have this same material on-line, in the form of man pages or other help documents, and it's probably more up-to-date. There is also a http version on the World Wide Web; consult Silicon Graphics OpenGL Web Site (http://www.sgi.com/software/opengl) for the latest pointer.

OpenGL is really a hardware-independent specification of a programming interface, and you use a particular implementation of it on a particular kind of hardware. This guide explains how to program with any OpenGL implementation. However, since implementations may vary slightly - in performance and in providing additional, optional features, for example - you might want to investigate whether supplementary documentation is available for the particular implementation you're using. In addition, you might have OpenGL-related utilities, toolkits, programming and debugging support, widgets, sample programs, and demos available to you with your system.


How to Obtain the Sample Code

This guide contains many sample programs to illustrate the use of particular OpenGL programming techniques. These programs make use of Mark Kilgard's OpenGL Utility Toolkit (GLUT). GLUT is documented in OpenGL Programming for the X Window System by Mark Kilgard (Reading, MA: Addison-Wesley Developers Press, 1996). The section "OpenGL-Related Libraries" in Chapter 1 and Appendix D gives more information about using GLUT. If you have access to the Internet, you can obtain the source code for both the sample programs and GLUT for free via anonymous ftp (file-transfer protocol).

For the source code examples found in this book, grab this file:

ftp://sgigate.sgi.com/pub/opengl/opengl1_1.tar.Z

The files you receive are compressed tar archives. To uncompress and extract the files, type

uncompress opengl1_1.tar
tar xf opengl1_1.tar

For Mark Kilgard's source code for an X Window System version of GLUT, you need to know what the most current version is. The filename will be glut-i.j.tar.Z, where i is the major revision number and j is the minor revision number of the most recent version. Check the directory for the right numbers, then grab this file:

ftp://sgigate.sgi.com/pub/opengl/xjournal/GLUT/glut-i.j.tar.Z

This file must also be uncompressed and extracted by using the tar command. The sample programs and GLUT library are created as subdirectories from wherever you are in the file directory structure.

Other ports of GLUT (for example, for Microsoft Windows NT) are springing up. A good place to start searching for the latest developments in GLUT and for OpenGL, in general, is Silicon Graphics' OpenGL Web Site:

http://www.sgi.com/software/opengl

Many implementations of OpenGL might also include the code samples as part of the system. This source code is probably the best source for your implementation, because it might have been optimized for your system. Read your machine-specific OpenGL documentation to see where the code samples can be found.


Errata

Although this book is ideal and perfect in every conceivable way, there is a a pointer to an errata list from the Silicon Graphics OpenGL Web Site:

http://www.sgi.com/software/opengl

The authors are quite certain there will be a little note there to reassure the reader of the pristeen quality of this book.


Style Conventions

These style conventions are used in this guide:

Code examples are set off from the text in a monospace font, and command summaries are shaded with gray boxes.

In a command summary, braces are used to identify choices among data types. In the following example, glCommand has four possible suffixes: s, i, f, and d, which stand for the data types GLshort, GLint, GLfloat, and GLdouble. In the function prototype for glCommand, TYPE is a wildcard that represents the data type indicated by the suffix.

void glCommand{sifd}(TYPEx1, TYPEy1, TYPEx2, TYPEy2);

[Previous Section] [Back to Table of Contents] [Next Section]

OpenGL Programming Guide (Addison-Wesley Publishing Company)