Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!swrinde!cs.utexas.edu!husc6!brauer!fry From: fry@brauer.harvard.edu (David Fry) Newsgroups: comp.sys.mac.programmer Subject: Offscreen Worlds...help, please? Message-ID: <3990@husc6.harvard.edu> Date: 23 Aug 90 10:54:49 GMT Sender: news@husc6.harvard.edu Reply-To: fry@brauer.harvard.edu (David Fry) Organization: Harvard Math Department Lines: 105 I'm having tremendous trouble getting offscreen worlds to work in even the least little way on my Mac IIfx (8-megs RAM, System 6.0.5, 32bitQD 1.2 in the System Folder...makes no difference if I remove it, all other INITs off, 8-bit graphics). As an example, this program opens a small window, and draws a circle in it. Ideally, the circle would be drawn in an offscreen world and CopyBits-ed onto the window. The code to do that is commented out. However, just by including a SetGWorld() call to my offscreen GWorld, the PaintOval call later in the program causes the Mac to crash. Macsbug shows that most of my program has been converted to $FFFF's. (Did it try to draw the oval in code space??) If the SetGWorld call is commented out as well, the program works. So simply allocating and deallocating the GWorlds doesn't crash the system. Any ideas? David Fry Harvard University fry@math.harvard.edu ------------------------------------------------------------- #include "color.h" #include "colortoolbox.h" #include "GraphDevMgr.h" #define NULL 0L main() { WindowPtr theWindow; Rect bounds; GWorldPtr offGWorld; short error; CGrafPtr savePtr; GDHandle saveDev; InitGraf(&thePort); InitWindows(); InitCursor(); FlushEvents(everyEvent,0); GetGWorld(&savePtr,&saveDev); SetRect(&bounds,0,0,300,300); OffsetRect(&bounds,5,40); theWindow = NewWindow(NULL,&bounds,"\ptest of gworlds", TRUE,documentProc,-1L,FALSE,NULL); SetPort(theWindow); SetRect(&bounds,0,0,300,300); error = NewGWorld(&offGWorld,1,&bounds,NULL,NULL,0L); if ( error != noErr ) { DebugStr("\pAn Error!"); SetGWorld(savePtr,saveDev); ExitToShell(); } SetGWorld(offGWorld,NULL); /* <---- the offender */ /* Ultimately, the circle should be drawn on the offGWorld and then CopyBits onto theWindow. If I don't call SetGWorld directly above things are okay. But calling it here, causes the PaintOval below to fail. */ /* if ( !LockPixels(offGWorld->portPixMap) ) { DebugStr("\p pixels purged"); SetGWorld(savePtr,saveDev); ExitToShell(); } SetRect(&bounds,0,0,300,300); PaintOval(&bounds); UnlockPixels(offGWorld->portPixMap); */ SetPort(theWindow); SetRect(&bounds,0,0,300,300); PaintOval(&bounds); /* LockPixels(offGWorld->portPixMap); CopyBits( *(offGWorld->portPixMap), &theWindow->portBits, &offGWorld->portRect,&theWindow->portRect,srcCopy,NULL); UnlockPixels(offGWorld->portPixMap); */ while ( !Button() ) {} DisposeGWorld(offGWorld); DisposeWindow(theWindow); FlushEvents(everyEvent,0); SetGWorld(savePtr,saveDev); }