This book is not just about OpenGL—more specifically, it’s about OpenGL on Microsoft Windows. Let us look briefly at the current state of the art in OpenGL and graphics implementation, and sketch out a picture of likely developments in the near future.
OpenGL is essentially a software interface to 3D hardware. Although what we call a “generic” or “software-only” implementation is available for both Windows NT and Windows 95, 3D hardware for the PC is just beginning to come of age. Naturally, it makes sense for OpenGL to make use of 3D hardware (which is faster than 3D software) when it is available.
At the time this book was written, the 3D graphics acceleration market was immature. Prices of OpenGL-specific accelerator boards for the PC are beginning to come down, but the real driving force behind this market is PC-based games. Video games require the fastest hardware available and/or the most efficient coding. PCs make good gaming machines for a number of reasons. With the right peripherals, you get a high-quality color monitor that can produce higher resolution graphics than any TV set. You get sound, and even wave table synthesis for realistic instrument sounds. In addition to a joystick and a button or two, you also have a mouse and a whole keyboard, opening up new options for game input. Add to this the massive storage capabilities of CD-ROMs, plus the ability to store (and, let’s admit it, copy) game programs on hard disks or floppies. Put it all together, and you have a very expensive yet supremely capable gaming machine.
Few people can justify buying a PC just to play games (unless, of course, they are educational games). But hey, let’s face it—if you already have a PC for your home-based business or for telecommuting, you might as well have a little fun with it, right? When Microsoft Windows grew more dominant than DOS for business and productivity applications, many people installed Windows for just that purpose. Nonetheless, until the last year or so, game developers avoided Windows and kept right on writing games for DOS.
The reason for this can be summed up in one word: performance. Windows did make life easier for the applications developer because all graphics commands acquired similar identities regardless of the underlying graphics hardware. Want to draw a rectangle? Just call the rectangle function! You don’t need to know how to convert row and column coordinates to a memory address, and there’s no fussing with algorithms. All you needed for your graphics hardware was a Windows driver that would translate GDI calls into hardware instructions.
Unfortunately, this approach added many layers of code between the programmer’s graphics instructions and the hardware that actually produced the graphics on the screen. This generated a graphics phenomenon commonly referred to as S-L-O-W. No sane games developer would consider writing Windows-hosted video games, and for a good long while, the most stunning examples of Windows-based games were Solitaire and Reversi.
Hardware vendors seeking to capitalize on the emerging markets in desktop publishing and Windows-based word processing started to bring out PC graphics cards that had hardware acceleration of many common Windows-based drawing commands. A flood of 2D accelerated graphics cards filled the market with speedy Windows-based workstations, which promised to make Windows-based games more practical. Developers have a hard time resisting a sexy new graphical environment that just plain looks cool in comparison to DOS’s text-mode interface. Slowly, card games, strategy games, and even a few video games began to emerge into the marketplace.
By the time nearly everyone recognized that Windows ruled the desktop, most of the best games (particularly action games and vehicle simulators) were still being written for DOS. Developers simply could not achieve the frame rates and lightning-fast bitmap transfers under Windows that were possible under DOS.
Microsoft’s first attempt to help game developers along was called the WinG API. It was really little more than just a few new functions that enabled very fast bitblts. The WinG API was a substantial improvement, but it still wasn’t enough to woo the major players in the games market.
The release of Windows 95 proved to be a major turning point in this chronology. Microsoft desperately wanted to establish Windows 95 as the 32-bit successor to DOS for home and corporate users. History would have it that Windows NT actually got the major mind-share of corporate America, and that Windows 95 found a cozy place at home. But even before this became obvious, Microsoft wanted to make Windows 95 a premium gaming platform. For that, Microsoft would need to spruce up the multimedia capabilities of Windows 95 in a very big way.
To give game developers more direct access to hardware, Microsoft devised a set of APIs now known as DirectX. This includes Direct Draw for fast screen updates, Direct Sound for fast sound and MIDI streaming, Direct Play for networked multiplayer games, and Direct Input for better responsiveness to joysticks and other I/O devices. A new driver model rests atop a very thin hardware abstraction layer and gives Windows game developers unprecedented access to hardware—and thus unprecedented speed.
The latest component added to the Direct X family is Direct 3D. Today’s video games are no longer flat, two-dimensional space games. They are highly complex flight simulators, and dungeon adventure games with texture-mapped monsters, walls, and corridors. Direct 3D is tightly integrated with Direct Draw and 3D accelerated hardware. If a feature does not exist in hardware, it is emulated in software. This lets developers code and test their applications and later seamlessly take advantage of extra performance benefits provided by new hardware down the road.
What does all this have to do with OpenGL? Quite simply, what’s good for the goose is good for the gander! Within one to two years of the printing of this book, 3D accelerated graphics hardware will be practically ubiquitous. There are many historical parallels that support this prediction. For example, when CD-ROMs where first introduced they didn’t play music CDs. Then someone had the bright idea that adding this capability would differentiate them from the rest of the market. Who wouldn’t want to listen to music while at their workstation? Now, of course, you can’t buy a new CD-ROM that doesn’t play standard musical CDs.