ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >
Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Q: How
do I correctly set up and GLboolean aglSetDrawable (AGLContext context, AGLDrawable drawable);- where context is a valid context return from aglCreateContext .drawable is an AGLDrawable , which is defined in <AGL.h> as a CGrafPtr . This
AGLDrawable must be a CGrafPtr obtained from a valid window. Under
Mac OS 9 one can directly cast a WindowPtr to an AGLDrawable . Carbon
is more restrictive due to it's opaque data references. One must use
the function GetWindowPort to properly obtain a AGLDrawable from
an opaque WindowPtr or WindowRef .The following example code can be used, on Mac OS 9 without Carbon and on Mac OS 9 and Mac OS X with Carbon, to ensure the proper type is passed to the aglSetDrawable function:#if TARGET_API_MAC_CARBON aglSetDrawable (context, GetWindowPort (pWindow)); #else aglSetDrawable (context, (AGLDrawable) pWindow); #endif // TARGET_API_MAC_CARBON Q. What about DrawSprocket's front buffer? Isn't that really just a CGrafPtr ?A. Not really, DrawSprocket's front buffer is a non-standard CGrafPtr that causes
problems for OpenGL when trying to identify the correct display
device for rendering. This front buffer should never be used as an
AGLDrawable . Instead one should create a window on top of the
DrawSprocket blanking window and use this window to get your
AGLDrawable .Q. So I've done all this and my application is still crashing on the call to AGLSetDrawable . How can I fix this?A. If you're using pre-compiled headers such as <MacHeaders.h> , you will need to
instead use MacHeadersCarbon.h. Since the pre-compiled headers set
the compiler flags when they are pre-compiled not when you compile
your code, there is no way for these headers to know if you are
targeting Carbon or not. When not compiling for Carbon GetWindowPort
is defined in <MacWindows.h> as:#define GetWindowPort(w) ((CGrafPtr) (w))This results in a simple cast which does not work with Carbon's opaque data structures. To avoid this problem ensure you are using the correct pre-compiled headers for the environment you are building.
Updated: 4-October-2000 |
|