[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sample GWorld Code?
- To: "pierce" <vitro!pierce@uu.psi.com>, info-mcl@cambridge.apple.com
- Subject: Re: Sample GWorld Code?
- From: Michael Travers <mt@media-lab.media.mit.edu>
- Date: Thu, 15 Aug 91 01:15:41 EDT
- In-reply-to: Your message of 14 Aug 91 10:27:33 +0800. <9108141450.AA22738@uu.psi.com>
Here's a simple example use of GWorlds to generate offscreen pixmaps.
If this crashes, you probably need to install the patch that Alan
mentioned.
;;; Body should consist of low-level Quickdraw calls, which will be
;;; done on the pixmap.
;;; Bugs: doesn't deallocate gworld.
(defmacro make-pixmap ((w h) &body body)
`(rlet ((cgrafptr :pointer) (gdhandle :pointer))
(#_GetGWorld cgrafptr gdhandle)
(let* ((gworld (make-gworld ,w ,h))
(pixmap (#_GetGWorldPixMap gworld)))
(unwind-protect
(progn
(#_SetGworld gworld (ccl:%null-ptr))
(#_LockPixels pixmap)
(#_EraseRect (ccl:rref gworld cgrafport.portrect))
,@body))
(#_UnLockPixels pixmap)
(#_SetGWorld (ccl:%get-ptr cgrafptr) (ccl:%get-ptr gdhandle))
pixmap)))
(defun make-gworld (w h)
(rlet ((bounds-rect :rect :top 0 :left 0 :right w :bottom h)
(gworldp :pointer))
(unless (zerop (#_NewGWorld gworldp 0 bounds-rect (ccl:%null-ptr) (ccl:%null-ptr) 0))
(error "Failed to make gworld"))
(ccl:%get-ptr gworldp)))