3D With QuickDraw 3D
Volume Number: 14
Issue Number: 7
Column Tag: Power Graphics
3D Programming With QuickDraw 3D
by Kas Thomas
Edited by the MacTech Editorial Staff
Getting up-to-speed quickly in 3D programming doesn't have
to be painful
Introduction
Have you noticed how the whole world has gone nutty over 3D graphics lately?
Computer-generated imagery was already coming on strong before the movie Titanic
hit, but now you can hardly open a magazine or turn on the TV without being
bombarded with raytraced logos. "Three-D" is no longer just the province of gamers
and VRML diehards; it's mainstream.
If you haven't considered tapping the power of 3D graphics in your own programming
(or maybe you ruled it out because it seemed like such a monumental undertaking),
now might be a good time to rethink the whole issue. As you may know, in 1995 Apple
unveiled a cutting-edge "enabling technology" for 3D programmers called QuickDraw
3D, which allows easy cross-platform access to a comprehensive library of highly
optimized 3D routines. You no longer have to be a Ph.D. mathematician to get 3D
graphics to happen. With the arrival of the latest G3 chipsets, the Mac platform is
fully capable of handling the formidable computational demands of 3D graphics.
There's no longer any reason to fear 3D. The way has been paved.
In this article, we'll take a look at Apple's extensive QuickDraw 3D API and how you
can use it to add that elusive third dimension to the already powerful 2D graphic
capabilities of the Mac. Along the way, we'll try to simplify (or at least demystify)
some of the seemingly arcane concepts of 3D graphics programming and show how (and
why) the QD3D way of doing things generally puts you ahead of the game.
To get the most out of this discussion, you should be comfortable with object
programming idioms (although the code will be plain, procedural C) as well as basic
3D concepts, like up, down, and sideways. It also wouldn't hurt for you to have your
own copy of the latest QuickDraw 3D software developer's kit (SDK), which is
available online at Apple's web site; you'll need it to compile the sample app developed
in this article. In keeping with the spirit of QuickDraw 3D, I'll try to hide as many of
the ugly details of low-level 3D programming from you as possible while
concentrating on how to get maximum onscreen magic to happen with minimum effort.
By the time you've finished reading this article, you should at least have an
appreciation for the power and scope of QuickDraw 3D, and you'll be in a position (if
you so desire) to bootstrap your way up through the rest of the vast, complex,
awe-inspiring QD3D API on your own.
What's So Great About QD3D?
Third-party 3D libraries are nothing new. What makes QuickDraw 3D unique is that
it represents the first time programmers have had support for 3D graphics at the core
operating system level. Mind you, we're talking about far more than just a fancy set of
draw routines here. QuickDraw 3D is breathtakingly broad in scope and was designed
from the ground up with developers in mind. Consider some of the design features of
QuickDraw 3D:
• Easy access to a comprehensive set of high- and low-level 3D geometries,
with support for 20 built-in primitives.
• A fully cross-platform API in which device dependencies are abstracted
out to well-isolated layers. (Porting your code to Windows doesn't require a
squad of Redmond-trained consultants.)
• Transparent access to graphics accelerators. (No changes to your code are
needed to take advantage of QD3D-compliant boards.)
• A flexible cross-platform 3D file format.
• An extensible, plug-in rendering architecture.
• Strong support for texture-mapping using 2D (e.g., PICT) imagery.
• Built-in pointing and picking support. (User selection of 3D objects is
easily handled.)
• A 3D pointing-device manager for input devices with more than two
degrees of freedom. (These guys think ahead, don't they?)
• A strongly object-oriented API, but 100% accessible in procedural C.