Newsgroups: comp.lang.lisp.mcl
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!tank.news.pipex.net!pipex!howland.reston.ans.net!vixen.cso.uiuc.edu!uchinews!kropp-duster.cs.uchicago.edu!user
From: t-mcdougal@uchicago.edu (Thomas McDougal)
Subject: Re: flicker-free drawing
X-Nntp-Posting-Host: kropp-duster.cs.uchicago.edu
Message-ID: <t-mcdougal-2803961547330001@kropp-duster.cs.uchicago.edu>
Sender: news@midway.uchicago.edu (News Administrator)
Organization: University of Chicago -- Academic Computing Services
References: <v01540b00ad726cc32be2@[161.142.8.120]>
Date: Thu, 28 Mar 1996 21:47:33 GMT
Lines: 61

> I have also been suggested to look at gWorld - the learning curse seems a
> bit steep compraed to bitmaps. 

It's really not so bad if you use the Oodles-of-Utils gworld-view.
Here's some sample code to get you started (sorry for the
paucity of comments).

--- cut here ---
;;; gworld-play.lisp
;;; by Tom McDougal <t-mcdougal@uchicago.edu>
;;;
;;;   Try some simple stuff with gworlds.

(oou-dependencies :GWorld-view)
(require "QUICKDRAW")

(defparameter *size* #@(200 200))
(defvar *testgw*)
(defvar *testw*)

(setq *testgw* (make-instance 'GWorld-view
                :view-size *size*))
(GWorld-alloc *testgw*)

(setq *testw*  (make-instance 'window :view-size *size*
                               :window-title "GWorld window"))

(with-focused-view *testgw*
  (#_eraseRect (pref (wptr *testgw*) :GrafPort.portRect))
  (with-fore-color *blue-color*
    (#_moveTo 20 20)
    (#_lineTo 100 20)))

;;; Copy the contents of the GWorld to the window.
(multiple-value-bind (topLeft botRight) (focused-corners *testgw*)
  (rlet ((win-rect :Rect :topLeft topLeft :botRight botRight)
         (gw-rect  :Rect :topLeft #@(0 0) :botRight *size*))
    (with-locked-Gworld-view *testgw*
      (with-macptrs ((gw-portBits (view-portBits *testgw*))
                     (win-portBits (pref (wptr *testw*) :GrafPort.portBits)))
        (with-focused-view *testw*
          (#_CopyBits gw-portBits win-portBits gw-rect win-rect 
           #$srcCopy (%null-ptr)))))))


;;; try some animation
(rlet ((r :rect :topleft #@(0 0) :botright #@(50 50)))
  (with-locked-Gworld-view *testgw*
    (with-macptrs ((gworld-rect (pref (wptr *testgw*) :GrafPort.portRect))
                   (win-rect (pref (wptr *testw*) :grafPort.portRect))
                   (gw-portBits (view-portBits *testgw*))
                   (win-portBits (pref (wptr *testw*) :GrafPort.portBits)))
      (without-interrupts 
       (dotimes (i 50)
         (with-focused-view *testgw*
           (#_offsetRect r 1 1)
           (#_eraseRect gworld-rect)
           (#_frameRect r))
         (with-focused-view *testw*
           (#_CopyBits gw-portBits win-portBits gworld-rect win-rect 
            #$srcCopy (%null-ptr))))))))
