OpenGL: Windows NT Gets 3-D Graphics Library

Dale Rogerson
Technical Writer, Developer Network Technology Group

Until recently, fast, high-quality, 3-D graphics like those produced for the movie Jurassic Park could only be built on an expensive platform such as Silicon Graphics' IRIS workstation. This meant that the quality of graphical animation that could be produced on less expensive, Windows-based PCs suffered greatly by comparison.

However, Windows NT version 3.5 and the Win32 API now include OpenGL, a 3-D graphics library that will someday enable every PC to be a high-end, three-dimensional graphics platform.

The inclusion of OpenGL with Windows NT opens up a number of possibilities for the developer community. One result will be a huge expansion in the number of programmers who have the opportunity to develop 3-D applications or to enhance their applications by adding 3-D graphics. Also, more high-end graphics applications will be ported to the PC. In addition, OpenGL will eventually be added to Windows 95, which will dramatically increase the installed base of OpenGL users, further encouraging development of OpenGL applications for a greatly expanded market.

(For a preview of OpenGL, take a look at the new OpenGL screen savers included with Windows NT version 3.5: 3-D Flying Objects and 3-D Pipes.)

Okay, so what is OpenGL?

OpenGL is a very portable software interface for rendering 3-D graphics. It includes approximately 120 commands to draw graphics primitives such as points, lines, and polygons. However, unlike the Windows GDI (graphics device interface), OpenGL primitives are drawn in three dimensions. OpenGL also includes support for shading, texture mapping, anti-aliasing, lighting, and animation. Commands for producing and manipulating higher-level 3-D objects, such as cubes, pyramids, spheres, and the Boeing 777, are not included but can be built from the existing primitives.

OpenGL does not manage windows, read input, or write files. Windows NT, Windows, or some other operating system does the job of managing the windows. An application gives OpenGL a piece of a window or bitmap on which to render.

Silicon Graphics Inc. (commonly known as SGI) originally developed GL, a 3-D graphics language, for its 3-D graphics machine, the IRIS. The process of porting it to another system proved extremely difficult, however. So SGI decided to change GL to make it easier to port to different hardware, operating systems, and windowing systems. The result was OpenGL.

While SGI still maintains IRIS GL, all new work and enhancements are being made to OpenGL. The enhancements and changes to OpenGL are decided by the Architecture Review Board (ARB), whose founding members are Digital Equipment Corporation, IBM, Intel, Microsoft, and SGI.

Benefits for graphics workstation users

OpenGL runs best on high-end 3-D graphics workstations, such as the SGI boxes used for Jurassic Park. Of course, OpenGL running on a Pentium PC with an enhanced VGA card isn't going to come close to the performance of the same application running on an SGI Crimson box. However, the Crimson box will set you back close to $50,000.

So if you don't have $50,000 to drop, the addition of OpenGL to Windows NT provides a number of benefits. For the graphics workstation community, it is low-cost, scalable, and portable. It means that Windows NT can now serve as a low-cost platform for developing and running high-end graphics applications, including CAD/CAM (computer-aided design/computer-aided manufacturing), and thus can replace more expensive graphics workstations. This means a standard Pentium-based PC can become the basis for a graphics workstation.

Windows NT runs on small, portable laptops and large, multiple-processor file servers. You can easily try out 3-D applications or application development on your existing desktop computer and upgrade when you need the extra power. It also runs on the 386, 486, Pentium, MIPS, Alpha AXP, and PowerPC processors.

In addition, Windows NT can easily run standard Windows-based applications. The same system that runs your advanced graphics applications can run word processors, spreadsheets, and other applications for Windows. No need for multiple computers, expensive proprietary applications, or troublesome emulators.

And for developers

Including OpenGL in Windows NT provides a number of benefits for developers:

• Windows NT now provides a way to add 3-D effects to applications. You won't need to buy a third-party library, because OpenGL is included with the system. Applications that traditionally haven't used 3-D graphics can now include 3-D graphics enhancements.

• OpenGL simplifies development of 3-D applications. The number of 3-D drawing and rendering applications should increase, because programmers no longer have to develop their own 3-D graphics libraries.

• It creates the potential for new, exciting 3-D games for Windows. Instead of having to look down on the game board, you can now view the action from the edge of the board.

• It provides a standard 3-D graphics library for the Windows environment.

• It sets a standard that hardware manufacturers can use to create high-performance video cards. Graphics card manufacturers can improve OpenGL performance by performing many OpenGL operations in hardware. In the near future, real-time 3-D graphics will be available on the desktop for a reasonable price.

"Making OpenGL available across our operating system platforms will move 3-D from the esoteric to the mainstream," said Gilman Wong of Microsoft's OpenGL development team. "What I mean by that statement is that 3-D is mostly used in very specific markets, such as games, CAD, maybe high-end graphics design, and the occasional business chart. Providing an industry-proven API like OpenGL will greatly reduce the engineering effort of incorporating 3-D. This in turn will hopefully stimulate and foster its use in a greater variety of applications."

Portability

Due to the ease of porting an OpenGL program from one system to another, it shouldn't take long for OpenGL applications originally developed for SGI, DEC, or IBM systems to appear running under Windows NT.

Win32 applications can run with only a recompile on a variety of platforms, including those with one or more Intel, MIPS, Alpha, or PowerPC processors, and OpenGL applications written for Windows will inherit the built-in portability of the Win32 API.

When OpenGL is ported to Windows 95, it will dramatically increase the installed base of OpenGL users. Companies currently developing applications for the high-end graphics workstation market will suddenly have a much larger possible market for their products. It will also be easier to sell a software package that doesn't require a special dedicated computer system, reducing the expense considerably.

Hardware manufacturers are making enhancements, too

To improve the performance of OpenGL on the PC platform, several video card manufacturers are developing cards and drivers that implement many OpenGL commands in hardware instead of software.

While a properly written OpenGL program will be able to run on a system with or without a hardware accelerator, OpenGL was designed with hardware accelerators in mind. The hardware accelerator will give the program better performance and possibly more capabilities.

The performance of these cards varies depending on how much you pay. They vary in price from several hundred to tens of thousands of dollars. It will soon be possible to get the performance of an SGI Crimson on your desktop at a fraction of the price.

Moving from GDI to OpenGL

Incorporating OpenGL is not as simple as just extending GDI to perform 3-D drawing: GDI users are going to find little that is familiar with OpenGL. For example, drawing a line with OpenGL is completely different from drawing a line with GDI. In fact, OpenGL uses a rendering context and only indirectly uses a device context. Current brushes, colors, fonts, and other objects selected into the device context have no effect on OpenGL rendering. Even the GDI mapping modes have no effect on OpenGL.

Still, though their GDI expertise is not directly applicable to an OpenGL world, GDI experts should be happy that a proven industry-standard graphics interface was chosen.

GDI mavens won't have much trouble learning the basics of OpenGL. In many cases, OpenGL and GDI differ more in syntax than in paradigm. The hard part for a converted GDI programmer is going to be learning 3-D graphics programming. OpenGL is a library for rendering 3-D images; it is not designed to hide developers from the intricacies of 3-D programming. A beginning OpenGL 3-D graphics programmer should read a 3-D textbook before getting too involved with OpenGL. In addition, several books have already been written about OpenGL. (See "OpenGL resources" in the "Additional Information" section at the end of this article.)

Program managers can also rejoice. They can add 3-D graphics to their programs by hiring OpenGL programmers. These OpenGL programmers need to know little or nothing about Windows, because once the display context is set up there is no additional GDI work needed.

Moving toward 3-D Windows

The addition of OpenGL makes the Windows NT platform more attractive to scientific and technical computer users. It shouldn't be long before desktop applications start taking advantage of the rendering capabilities of OpenGL.

The Developer Network Development Library is your best place to get started learning about and using OpenGL. The OpenGL Programmer's Reference appears in the January release of the Development Library as part of the product documentation for the Win32 Software Development Kit. In addition, you'll find various technical articles about OpenGL under Technical Articles/Windows (32-bit)/GDI in the Development Library.

Dale Rogerson is a really swell guy, good-looking, and a snazzy dresser, too. He lives in Corpus Christi, Texas with his pet orangutan, and commutes each day to Redmond, Washington in his Cobra gunship.

Additional Information

Open GL Resources

General graphics textbooks

Computer Graphics: Principles and Practice, James D. Foley, Andries van Dam, Steven K. Feiner, and John F. Hughes, Second Edition, Addison-Wesley, 1990. (This is THE book on computer graphics.)

Computer Graphics, F.S. Hill Jr., Macmillan Publishing Company, 1990.

OpenGL information from the ARB

The OpenGL Architecture Review Board (ARB) has published two books that are a must for all OpenGL programmers: OpenGL Programming Guide and OpenGL Reference Manual.

Another source of information is a Usenet newsgroup: comp.graphics.opengl. This newsgroup publishes an informative frequently-asked-questions (FAQ) list. Also, OpenGL programs for a variety of platforms written by the OpenGL community-at-large can be downloaded from sgi.com via anonymous ftp. Look in the \OpenGL\Contrib directory.

Articles on the Windows NT implementation of OpenGL

"Windows NT OpenGL: Getting Started" by Dennis Crain in the Development Library explains the functions added to Win32 to support OpenGL.

The Microsoft Systems Journal has published two very good articles on beginning OpenGL programming for Windows:

• "Advanced 3-D Graphics for Windows NT 3.5: Introducing the OpenGL Interface, Part I," by Jeff Prosise, Microsoft Systems Journal, Vol. 9 No. 10, October 1994.

• "Advanced 3-D Graphics for Windows NT 3.5: The OpenGL Interface, Part II," by Jeff Prosise, Microsoft Systems Journal, Vol. 9 No. 11, November 1994.

Both articles can be found in the Development Library.