[plt-scheme] MrEd+Allegro on MacOS

From: alex mitchell (cnmmai at nus.edu.sg)
Date: Fri Feb 29 02:29:10 EST 2008

Hi Jon (and the list),

The postings about the Tetris game reminded me of the problems I was having
on MacOS with the Allegro Scheme bindings. A while back I was building a
simplified version of Logo, using Allegro for the turtle graphics. It was
working well under Windows, but on MacOS the MrEd UI elements would stop
responding, or only give intermittent, laggy responces, once the Allegro
window appeared. 

Here's a simple example of the problem, which I've tried (unsuccessfully) to
solve using a separate thread for the game loop. In this example, there's an
Allegro window showing the sample "Hello world" program, and a MrEd window
with a single button, which closes the Allegro window. The MrEd button
sometimes responds to mouse clicks, but sometimes doesn't, and after closing
the program, DrScheme doesn't respond properly, and needs a "force quit" to

Anyone have any ideas how to solve this problem? Any help would be greatly


(require (prefix image- (planet "image.ss" ("kazzmir" "allegro.plt" 2 3))))
(require (prefix mouse- (planet "mouse.ss" ("kazzmir" "allegro.plt" 2 3))))
(require (planet "util.ss" ("kazzmir" "allegro.plt" 2 3)))
(require (planet "keyboard.ss" ("kazzmir" "allegro.plt" 2 3)))

(require (lib "async-channel.ss"))

; asynchronous channel to communicate between threads
(define mychannel (make-async-channel))

; create a mred window
(define f (instantiate frame% ("test" #f 100 50)))
(define b1 (instantiate button% () (label "Exit")
             (parent f)
             (callback (lambda (button event) (doexit)))))
(send f show #t)

; exit
(define (doexit)
  (async-channel-put mychannel #t))

; game loop
(thread (lambda ()
(easy-init 640 480 16)
  (lambda ()
    (let ((v (async-channel-try-get mychannel)))
     (lambda (buffer)
        (image-print buffer 50 50 (image-color 255 255 255) -1 "Hello
  (frames-per-second 30))

Posted on the users mailing list.