Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!udel!rochester!rit!cci632!ph From: ph@cci632.UUCP (Pete Hoch) Newsgroups: comp.sys.mac.programmer Subject: Re: Offscreen Worlds...help, please? Summary: Only set gWorld to offscreen when drawing to offscreen. Message-ID: <39461@cci632.UUCP> Date: 23 Aug 90 21:15:33 GMT References: <3990@husc6.harvard.edu> Organization: Computer Consoles Inc. an STC Company, Rochester, NY Lines: 58 In article <3990@husc6.harvard.edu>, fry@brauer.harvard.edu (David Fry) writes: David is having trouble with offscreen gWorlds and keeping the right graphics device active. I hacked up his code below. > Any ideas? > David Fry > Harvard University > fry@math.harvard.edu > main() > { [ variable definitions and basic initilization. ] > GetGWorld(&savePtr,&saveDev); [ call to NewWindow and NewGWorld. ] > SetGWorld(offGWorld,NULL); /* <---- the offender */ No it isn't > if ( !LockPixels(offGWorld->portPixMap) ) { > SetGWorld(savePtr,saveDev); > ExitToShell(); > } > SetRect(&bounds,0,0,300,300); > PaintOval(&bounds); > UnlockPixels(offGWorld->portPixMap); > SetPort(theWindow); ^^^^^^^ Here is the problem. SetPort is not enough. You must first use SetGworld so that the graphics device is set back to a screen device and not an offscreen device as it is now. try this instead. SetGWorld( theWindow, saveDev); > LockPixels(offGWorld->portPixMap); > CopyBits( *(offGWorld->portPixMap), &theWindow->portBits, > &offGWorld->portRect,&theWindow->portRect,srcCopy,NULL); Without setting the device to the screen the copybits call will fail. > UnlockPixels(offGWorld->portPixMap); [ remainder of program unimportant. ] Pete Hoch