Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Chapter 2 - Basic QuickDraw / Basic QuickDraw Reference
Routines / Initializing QuickDraw


Use the InitGraf procedure to initialize QuickDraw.

PROCEDURE InitGraf (globalPtr: Ptr);
A pointer to the global variable thePort, which from Pascal can be passed as @thePort.
Use the InitGraf procedure before initializing any other Toolbox managers, such as the Menu Manager and Window Manager. The InitGraf procedure initializes the global variables listed in Table 2-1 (as well as some private global variables for QuickDraw's own internal use). The InitGraf procedure also initializes Color QuickDraw on computers with Color QuickDraw capabilities.
Table 2-1 QuickDraw global variables (Continued)
VariableTypeInitial setting
whitePatternAll-white pattern
blackPatternAll-black pattern
grayPattern50% gray pattern
ltGrayPattern25% gray pattern
dkGrayPattern75% gray pattern
arrowCursorStandard arrow cursor
screenBitsBitMapEntire main screen

The QuickDraw global variables are stored in reverse order, from high to low memory as listed in Table 2-1, and require the number of bytes specified by the global constant grafSize. Most development systems preallocate space for these global variables immediately below the location pointed to by register A5. Since thePort is 4 bytes, you would pass the globalPtr parameter as follows:

PEA   -4(A5)
The InitGraf procedure stores this pointer to thePort in the location pointed to by A5.

This value is used as a base address when accessing the other QuickDraw global variables, which are accessed using negative offsets (the offsets have the same names as the Pascal global variables). For example:

MOVE.L   (A5),A0           ;point to first QuickDraw global
MOVE.L   randSeed(A0),A1   ;get global variable randSeed
The InitGraf procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.

Listing 2-1 on page 2-14 illustrates the use of InitGraf.

To initialize the cursor, call the InitCursor procedure, which is described in the chapter "Cursor Utilities."

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996