Open GL Super Bible

Previous Table of Contents Next

Part I
Introduction To OpenGL

Part I of this book introduces you to 3D graphics and programming with OpenGL. We start with a brief discussion of OpenGL, its background, purpose, and how it works. Then, before getting into any code, we’ll talk generally about 3D graphics on computers, including how and why we “think” we see 3D, and how an object’s position and orientation in 3D space is specified. You’ll get the fundamental background and terminology you need to get the best out of this book.

In Chapter 3 you’ll start writing your first OpenGL programs. You’ll learn about the various libraries and headers that are needed, and how OpenGL functions and data types are called and named. Initially we’ll cover the AUX library, a toolkit for learning OpenGL independently of any particular platform. Then we’ll “wiggle” our way into writing programs that use OpenGL under Windows 95 and Windows NT, in Chapter 4. We’ll cover the extensions to the Windows GDI (graphical device interface) to support OpenGL under Windows and describe how they must be used.

In Chapter 5 you’ll get some essential information on OpenGL’s handling and reporting of error conditions. We’ll tell you how you can ask the AUX library to identify itself and who makes it, and how to give performance “hints” to the library. With this knowledge in hand, you’ll be ready to tackle the meatier issues of OpenGL in Part II, where the examples will get a lot better!

Chapter 1
What Is OpenGL?

OpenGL is strictly defined as “a software interface to graphics hardware.” In essence, it is a 3D graphics and modeling library that is extremely portable and very fast. Using OpenGL, you can create elegant and beautiful 3D graphics with nearly the visual quality of a ray-tracer. The greatest advantage to using OpenGL is that it is orders of magnitude faster than a ray-tracer. It uses algorithms carefully developed and optimized by Silicon Graphics, Inc. (SGI), an acknowledged world leader in computer graphics and animation.

OpenGL is intended for use with computer hardware that is designed and optimized for the display and manipulation of 3D graphics. Software-only, “generic” implementations of OpenGL are also possible, and the Microsoft Windows NT and Windows 95 implementations fall into this category. Soon this may not strictly be the case, because more and more PC graphics hardware vendors are adding 3D acceleration to their products. Although this is mostly driven by the market for 3D games, it closely parallels the evolution of 2D Windows-based graphics accelerators that optimize operations such as line drawing and bitmap filling and manipulation. Just as today no one would consider using an ordinary VGA card to run Windows on a new machine, soon 3D accelerated graphics cards will become commonplace.

The Windows Graphics APIs
First there was GDI (Graphics Device Interface), which made it possible to write hardware-independent graphics—but at the cost of speed. Then graphics card makers began writing optimized GDI drivers to considerably speed up GDI. Then Microsoft introduced WinG to lure game developers. WinG consisted of little more than a few functions that got bitmaps to the display much faster, but it was still too slow. Microsoft next created the Direct Draw API for really low-level access to the hardware. This became rolled in with a whole set of DirectX APIs for writing directly to hardware, making games easier to write and improving their performance. Finally, 3DDI (a part of DirectX) gives high-performance 3D games a much needed shot in the arm. In Chapter 24 we talk more about the evolution and relationship of Windows and 3D graphics acceleration.

OpenGL is used for a variety of purposes, from CAD engineering and architectural applications to computer-generated dinosaurs in blockbuster movies. The introduction of an industry standard 3D API to a mass-market operating system such as Microsoft Windows has some exciting repercussions. With hardware acceleration and fast PC microprocessors becoming commonplace, 3D graphics will soon be typical components of consumer and business applications, not just of games and scientific applications.

Who remembers when spreadsheets had only 2D graphics and charting capabilities? If you think adding 3D to ordinary applications is extravagant, take a look at the bottom line of the companies that first exploited this idea. Quattro Pro, one of the first to simplify 3D charting, nearly captured the entire spreadsheet market. Today it takes far more than flat, two-dimensional pie charts to guarantee long-term success for spreadsheet applications.

This isn’t to say that everyone will be using OpenGL to do pie and bar charts for business applications. Nevertheless, appearances count for a lot. The success or failure of products with otherwise roughly equivalent features often depends on “sex appeal.” And you can add a lot of sex appeal with good 3D graphics!

About OpenGL

Let’s take a look at OpenGL’s origins, who’s “in charge” of OpenGL, and where OpenGL is going. We’ll also examine the principles of OpenGL implementation.

A History of OpenGL

OpenGL is a relatively new industry standard that in only a few years has gained an enormous following. The forerunner of OpenGL was GL from Silicon Graphics. “IRIS GL” was the 3D programming API for that company’s high-end IRIS graphics workstations. These computers were more than just general-purpose computers; they had specialized hardware optimized for the display of sophisticated graphics. This hardware provided ultrafast matrix transformations (a prerequisite for 3D graphics), hardware support for depth buffering, and other features. When SGI tried porting IRIS GL to other hardware platforms, however, problems occurred.

OpenGL is the result of SGI’s efforts to improve IRIS GL’s portability. The new language would offer the power of GL but would be “Open,” allowing for easier adaptability to other hardware platforms and operating systems. (SGI still maintains IRIS GL, but no enhancements or features other than bug fixes are being made.)

On July 1, 1992, Version 1.0 of the OpenGL specification was introduced. Just five days later, at the very first Win32 developers conference, SGI demonstrated OpenGL running on their IRIS Indigo hardware. Video clips from films such as Terminator Two: Judgment Day, and medical imaging applications were popular attractions in the vendor exhibit hall. Already, SGI and Microsoft were working together to bring OpenGL to a future version of Windows NT.

Previous Table of Contents Next