3D Graphics Programming with QuickDraw 3D
In general, QuickDraw3D does not duplicate existing methods of creating, handling user actions in, or manipulating drawing destinations. For example, QuickDraw3D does not provide any means of creating a Macintosh window, handling events in the window, or modifying the size or location of the window. A QuickDraw3D draw context, which provides a link between your application and the Macintosh window, simply contains the minimum amount of information it needs to draw into the window. You must use the Window Manager for all other operations on a Macintosh window.
A draw context is of type TQ3DrawContextObject
, which is a subtype of shared object. You need to create an instance of a specific type of draw context object and then attach it to a view, usually by calling Q3View_SetDrawContext
. QuickDraw3D currently supports these types of draw contexts:
All draw contexts share a set of basic properties, which are maintained in a structure of type TQ3DrawContextData
.
typedef struct TQ3DrawContextData { TQ3DrawContextClearImageMethod clearImageMethod; TQ3ColorARGB clearImageColor; TQ3Area pane; TQ3Boolean paneState; TQ3Bitmap mask; TQ3Boolean maskState; TQ3Boolean doubleBufferState; } TQ3DrawContextData;These properties define the manner in which a window (or region of memory) is cleared, the size of the destination drawing pane, the drawing mask, and the state of the double buffering. These basic properties are designed to be independent of any particular window system. You can rely on the capabilities provided by these properties across window systems, whether or not the drawing destination supports them.
Not all the basic properties maintained in the TQ3DrawContextData
data structure are supported by all draw contexts. For example, it makes no sense to use double buffering when drawing into a pixmap.<8bat>u
In addition to these basic properties that are common to all draw contexts, each specific type of draw context defines context-specific properties. For example, the Macintosh draw context maintains information about the window into which QuickDraw3D is to draw, the optional use of a two-dimensional graphics library (QuickDraw or QuickDraw GX), and so forth. The following sections describe the specific draw context types.
CWindowPtr
) which defines the area into which QuickDraw3D will draw images of rendered models. In addition, you can attach to a Macintosh draw context either a QuickDraw color graphics port (of type CGrafPort
) or gxViewPort
). Using this optional two-dimensional graphics library, you can achieve special effects such as clipping, dithering, and geometrical transforms of the image. At most one 2D graphics library can be associated with a Macintosh draw context at one time, and you are responsible for initializing the graphics library and performing any other required set-up.QuickDraw3D cannot use a two-dimensional graphics library unless the draw context is configured for double buffering and the active buffer is set to the back buffer. QuickDraw and QuickDraw GX effects are applied when the front buffer is updated from the back buffer. Figure 12-1 illustrates the three possibilities for drawing in a Macintosh draw context. You can use QuickDraw to set a clip region (middle possibility) and QuickDraw GX to set a clip shape (right possibility).
Figure 12-1 Using a two-dimensional graphics library in a Macintosh draw context
See the chapter "Geometric Objects" for information on the structure of pixmaps.<8bat>u
To draw an image into an offscreen graphics world (pointed to by a variable of type GWorldPtr
), for instance, you need to (1) create the offscreen graphics world using standard QuickDraw routines, (2) call LockPixels
to lock the pixels in memory, and (3) create a pixmap draw context in which the address of the pixmap is the pointer returned by the GetPixBaseAddr
function. You need to lock the pixmap in memory because QuickDraw3D routines may move or purge memory.
See the book Inside Macintosh: Imaging With QuickDraw for complete information about offscreen graphics worlds.<8bat>u
You can update a window without rendering to it by rendering to an offscreen graphics world and then copying the data to the window.
Let us know what you think of these prototype pages.
Generated with Harlequin WebMaker