Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesMust-See 3-D Engines


June 1996 / Features / Must-See 3-D Engines

An inside look at the most popular 3-D environments: OpenGL, QuickDraw 3D, and Direct3D.

By Tom Thompson

In the film Amadeus, the Emperor says to Mozart, "Too many notes." Developers trying to create 3-D applications could just as easily say, "Too many APIs." At last informal count, we knew of more than 50 (see http://www.cs.tu-berlin.de/ki/engines.html for excellent information on many of them). What's a developer to do?

We looked at the information about many of these 3-D engines and created a short list of three you should look at first: Silicon Graphics' OpenGL, Apple's zQuick Draw 3D, and Microsoft's Direct3D. Before committing your development efforts to any one of them, you sho uld know how they work and what their strengths are. One caveat: As we went to press, we had only preliminary information on Direct3D.

For cross-platform work, consider OpenGL (available on Unix, Windows NT and 95, and the Mac), especially if you're developing technical applications. Its client/server architecture enables desktop systems to off-load graphics processing to servers. QuickDraw 3D (QD3D) also has an advantage here, running on both Power Macs and Windows (NT and 95).

OpenGL, however, does not handle some high-level functions (e.g., file formats). QD3D and Direct3D both do, removing that particular headache from your development list. QD3D also has hardware abstraction, plus ready-made objects and built-in editing support.

Which one is for you? If you program for the Mac as well as Windows, you want to develop for QD3D. If you want to take f ull advantage of PC hardware (as a game might), both Direct3D and Apple's RAVE (Rendering Acceleration Virtual Engine, the device-independent interface that QD3D uses) offer solutions.

OpenGL

OpenGL is the only graphics engine we looked at that extends beyond the PC and Mac to many flavors of Unix. On a Unix system running the X Window System, a GLX extension library consisting of approximately a dozen calls initializes the windowing environment. The extension library then sets up a rendering context and makes a connection to the window's frame buffer. OpenGL implementations on other platforms use a similar interface library to handle these system-dependent details.

Compared to QD3D and Direct3D, OpenGL is not a high-level API. Its purpose is to draw objects. Such high-level tasks as object editing and file I/O are left up to the application (e.g., Silicon Graphics' Open Inventor). Instead, OpenGL provides a platform-independent interface to a low-level rendering engine. This interface consists of about 250 drawing commands that let the programmer describe objects and perform a set of operations to produce the final image. You can call OpenGL from a variety of languages, including C/C++, FORTRAN, Ada, and Java.

The most interesting feature about OpenGL is that it uses a client/server mechanism to handle graphics processing (see the sidebar "OpenGL's Command Structure" ). A graphics client (e.g., a 3-D application) uses the OpenGL interface and the host's OS to transmit such graphics primitives as vertex coordinates, colors, and texture coordinates to a graphics server process that runs the OpenGL rasterizer.

The rasterizer performs one or more graphics operations based on the current OpenGL graphics state and generates pixels. The pixel values undergo a final processing stage that includes texture-mapping, fogging, antialiasing, depth testing, and blending. This information goes to the client for display in the application window.

Normally, the client and server run on the same system. However, the advantage to the separation is that a low-cost desktop system can transmit OpenGL commands across a network to a high-performance system running the server process, which returns images to the desktop machine.

OpenGL supports both an immediate mode and a retained mode for graphics operations. In the immediate mode, an application sends graphics commands to OpenGL, which promptly executes them. This provides a quick response to any changes to an image, a critical feature for interactive graphics applications.

In the retained mode, sequences of graphics commands are stored in data structures known as display lists . Display lists have two important advantages. First, if you must display a complex object frequently, you only have to reference its display list. Second, they let object information be shipped quickly through a network. A disadvantage is that frequent modifications to an object require generating new object desc riptions.

A number of vendors provide 3-D applications and toolkits for use with OpenGL. Open Inventor is a 3-D toolkit that supplies a number of built-in graphics tools such as color and texture editors. It is available on workstations and Windows. It saves 3-D graphics in an Inventor file format that's a superset of the Virtual Reality Modeling Language (VRML), the industry-standard file format that describes 3-D objects on the Web.

Here's the lowdown: OpenGL lacks an object-oriented design like QD3D or Direct3D, but it's available on Unix, Windows (NT and 95), and the Mac. It is also a standard, managed by a group called the Architecture Review Board, whose members include Digital Equipment, Microsoft, and Evans & Sutherland.

OpenGL supports a wide range of graphics environments that cover the spectrum in terms of cost and performance. On the low end, it provides software-only rendering for desktop PCs. But it can also communicate directly with high-end workstations equipped with visua lization hardware that can draw 10 million polygons per second. With its industrial-strength graphics primitives, it is ideal for CAD and architectural design programs.

QuickDraw 3D

QD3D is a complete 3-D graphics environment (see the sidebar "QuickDraw 3D's Command Structure" ). The top level is an API that enables developers to create and manipulate 3-D objects and to read or write 3-D data to files. This API talks to an extensible graphics pipeline that processes drawing operations. The pipeline in turn talks to a thin hardware abstraction layer (HAL) that provides a device-independent API for game designers. (This HAL is known as QD3D RAVE. It shipped as a separate development kit for both Mac and Windows in March. For more information, see "Crave the RAVE" .)

QD3D supports an immediate mode and a retained mode. The immediate mode is identical to OpenGL's in that it's up to the application to supply drawing commands to the renderer. In the retained mode, the object-oriented-programming (OOP) structures maintain the scene's geometry for display and manipulation.

While the immediate mode offers fine-grained control for those applications that need it (e.g., animation, where all the objects change constantly), the retained mode lets you store the scene's geometry in an object database. The retained mode makes it easier to read and write objects, and it enables data structures to be cached for fast display or hardware acceleration. Programmers can opt to use one image mode exclusively, or both as the situation demands it.

Where QD3D differs radically from OpenGL is that it is an object-oriented graphics system. A new instance of an object can inherit characteristics from its class, including the geometry, size, orientation, color, texture-maps, and lighting, which makes for rapid construction of a scene's objects. This also simplifies the maintenance of each object's information for manipulation and display.

High-level API commands let you creat e, rotate, edit, illuminate, and apply transformations to objects. A widgets mechanism provides visual "handles" that allow you to edit or scale an object interactively. Thanks to QD3D's object-oriented design, you need no knowledge of the 3-D object's internal structure to perform these actions. Currently, you can use only C/C++ to make QD3D calls.

Also unlike OpenGL, QD3D lets you read and write 3-D images in a common 3-D metafile (3DMF) format. This format saves not only each object's geometry, but also its lighting and texture-maps. Also, 3DMF enables applications to copy and paste 3-D graphics or drag and drop them into other applications.

Apple provides the ANSI source code for the parser functions that read 3DMF files. You can find Unix, Windows, and Mac versions of the parser code at http://product.info.apple.com/qd3d/Parser.HTML . In March, Netscape, Silicon Graphics, and Apple jointly announced plans to develop a binary file format for Moving Worlds, a cross-platform specification for dynamic 3-D environments on the Web based on the 3DMF format.

QD3D is for those who want the OS to sweat 3-D's technical details. The API supplies a wide variety of basic objects (e.g., lines, spheres, and cones) that let you prototype a scene rapidly. It provides an interface that lets you visually edit these objects. Its architecture is extensible, so you can use third-party renderers or obtain access to hardware accelerators. You can also cut and paste graphics between applications or save the information into the cross-platform 3DMF format. Because of its acceptance as part of Moving Worlds, QD3D's 3DMF format is becoming a de facto standard. Finally, QD3D is available on both Macs and PCs.

Direct3D

Direct3D is Microsoft's 3-D API. It's a new addition to th e company's DirectX interactive-media technology family. At the time of this writing, it is scheduled to ship in the second quarter, for Windows 95 only. Microsoft tells us we can expect releases for Windows NT and the Power Mac by the end of the year. On the basis of preliminary specifications, we believe that Direct3D will provide an excellent environment for Windows 95 3-D developers--especially game developers. Its cross-platform capabilities, however, are currently nonexistent.

Although it is not cross-platform, Direct3D hides some of the differences in vendors' 3-D acceleration hardware (see the sidebar "Direct3D's Engine" ). It does this by using a HAL. The HAL interface lets programmers obtain information about the underlying hardware's characteristics, including device-specific and performance information. Because some systems might lack acceleration hardware, a Hardware Emulation Layer (HEL) emulates these features in software. The HEL ensures that all the Direct3D services are availa ble to an application on any system, possibly at reduced performance.

Like OpenGL and QD3D, Direct3D supports both immediate and retained modes of operation. Direct3D's retained mode resembles QD3D in that it offers developers an object-oriented high-level interface to applications for manipulating 3-D objects. After you load an object using one API call, you can rotate and scale it using other API calls. The retained mode provides API calls that read and write a file format that stores 3-D data. This data consists of predefined 3-D objects, meshes, textures, and animation sets. This file format lets applications exchange 3-D information and play back animation sequences in real time.

Direct3D's immediate mode is a thin API layer that deals with polygons and vertices. The immediate-mode API passes display lists composed of vertex data and graphics commands--known as execute buffers in Microsoft terminology--to the rendering engine for processing. This system provides a high-performance device-independent mechanism that lets programmers access a system's graphics hardware or tap into hardware accelerators. This mode doesn't offer any object or scene management engines; such functions are the application's responsibility.

The immediate mode is best suited for developers who have an application with its own rendering engine, yet wish to access a system's hardware-acceleration features. Currently, you use C/C++ to access Direct3D calls. Support for Visual Basic is planned.

Direct3D offers a variety of graphics objects. In the immediate mode, these objects include execute buffer, matrix (for transformations), light, texture, material (an object's surface properties), viewport (the screen region owned by the object), device (the hardware managing the screen), and interface. The retained mode provides additional objects based on the immediate-mode objects, including polygon face, mesh, frame (manages the position of all the objects in a scene and their orientation), shadow, and anima te (used to apply transformations to an object, such as scaling and position).

Direct3D is more like OpenGL in that it provides drawing primitives, but not such basic objects as spheres, cylinders, or cones, as QD3D does. It's not clear at this time whether such objects will be available in a separate library, or whether you will have to construct them from scratch. Also, information on the interactive editing of these objects is lacking.

Direct3D has been a long time coming, but it stands to exorcise all the hardware headaches that plague both 3-D programmers and game designers. It and the other DirectX technologies promise to clean up the PC's low-level act, possibly achieving real device independence for all software, not just 3-D applications. Like QD3D, it has an extensible architecture and can take advantage of systems with hardware accelerators. It also provides animation features that will be of use to game and multimedia programmers. However, Direct3D is available only on systems runnin g Windows 95, which limits its audience in the short term.

Three 3-D Choices

Your choice of API clearly depends on your needs. The easiest question is, "What platforms will the final application run on?" OpenGL runs on Unix, Mac, and PCs running Windows NT and Windows 95. QD3D has the next largest audience, running on Power Macs, Windows NT, and Windows 95. At present, Direct3D has the smallest audience, running only on Windows 95.

After that, the questions get more difficult and the answers become less black-and-white. OpenGL is particularly good at technical applications such as CAD and architectural drawing. QD3D is here today. It offers high-level access to 3-D acceleration hardware. It also provides nonuniform rational B-splines (NURBS) support, which makes it attractive for CAD work. Direct3D should boast such impressive features as a high degree of hardware abstraction, and its animation features will be of use to game and multimedia programmers.

Game designers pr obably have the hardest decision to make regarding a 3-D API, especially for the Christmas season. Direct3D's presence is limited at present. Combined with the fact that the Power Mac implementation will arrive too late in the year to be of value, those going the Direct3D route should anticipate a small market. Apple's QD3D RAVE has been available for several months on Power Macs and PCs. Thus, this API offers the developer a larger market.

While Apple's lead of several months in this area seems slim, remember that most of the QD3D components shipped last year and have been field-tested on the Mac. Although Microsoft released a beta version of Direct3D in October 1995, the specification has been under constant flux until recently. Direct3D thus starts out new when it ships. Practically, game programmers might opt for QD3D RAVE for this year, or write to the Reality Lab interface until the Direct3D situation settles.


Tom Thompson is a BYTE senior technical editor at large. You can reach him on the Internet at tom_thompson@bix.com .

Up to the Features section contentsGo to previous article: Go to next article: OpenGL's Command StructureSearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network