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.