diff -ruN /tmp/cl-opengl/glut/callbacks.lisp cl-opengl/glut/callbacks.lisp
--- /tmp/cl-opengl/glut/callbacks.lisp	2009-06-26 22:09:17.000000000 +0100
+++ cl-opengl/glut/callbacks.lisp	2009-06-24 19:26:35.000000000 +0100
@@ -137,21 +137,29 @@
   (poll-interval :int))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutMouseWheelFunc" mouse-wheel-func) :void
   ;; void (*func)(int button, int pressed, int x, int y)
   (callback-pointer :pointer))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutCloseFunc" close-func) :void
   ;; void (*func)(void)
   (callback-pointer :pointer))
 
+#+darwin
+(defcfun ("glutWMCloseFunc" close-func) :void
+  ;; void (*func)(void)
+  (callback-pointer :pointer))
+
 ;; freeglut ext
 (defcfun ("glutWMCloseFunc" wm-close-func) :void
   ;; void (*func)(void)
   (callback-pointer :pointer))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutMenuDestroyFunc" menu-destroy-func) :void
   ;; void (*func)(void)
   (callback-pointer :pointer))
diff -ruN /tmp/cl-opengl/glut/fonts.lisp cl-opengl/glut/fonts.lisp
--- /tmp/cl-opengl/glut/fonts.lisp	2009-06-26 22:09:17.000000000 +0100
+++ cl-opengl/glut/fonts.lisp	2009-06-24 19:24:36.000000000 +0100
@@ -107,19 +107,23 @@
   (string :string))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutBitmapHeight" bitmap-height) :int
   (font :pointer))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutStrokeHeight" stroke-height) %gl:float
   (font :pointer))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutBitmapString" bitmap-string) :void
   (font :pointer)
   (string :string))
 
 ;; freeglut ext
+#-darwin
 (defcfun ("glutStrokeString" stroke-string) :void
   (font :pointer)
   (string :string))
\ No newline at end of file
diff -ruN /tmp/cl-opengl/glut/geometry.lisp cl-opengl/glut/geometry.lisp
--- /tmp/cl-opengl/glut/geometry.lisp	2009-06-26 22:09:16.000000000 +0100
+++ cl-opengl/glut/geometry.lisp	2009-06-24 19:24:36.000000000 +0100
@@ -92,33 +92,39 @@
 
 ;;; The following are freeglut extensions:
 
-(defcfun ("glutWireRhombicDodecahedron" wire-rhombic-dodecahedron) :void)
-(defcfun ("glutSolidRhombicDodecahedron" solid-rhombic-dodecahedron) :void)
+#-darwin (defcfun ("glutWireRhombicDodecahedron" wire-rhombic-dodecahedron) :void)
+#-darwin (defcfun ("glutSolidRhombicDodecahedron" solid-rhombic-dodecahedron) :void)
 
+#-darwin
 (defcfun ("glutWireSierpinskiSponge" %glutWireSierpinskiSponge) :void
   (num-levels :int)
   (offset-seq :pointer) ; GLdouble offset[3]
   (scale %gl:double))
 
+#-darwin
 (defun wire-sierpinski-sponge (num-levels offset-seq scale)
   (gl::with-opengl-sequence (offset '%gl:double offset-seq)
     (%glutWireSierpinskiSponge num-levels offset scale)))
 
+#-darwin
 (defcfun ("glutSolidSierpinskiSponge" %glutSolidSierpinskiSponge) :void
   (num-levels :int)
   (offset-seq :pointer) ; GLdouble offset[3]
   (scale %gl:double))
 
+#-darwin
 (defun solid-sierpinski-sponge (num-levels offset-seq scale)
   (gl::with-opengl-sequence (offset '%gl:double offset-seq)
     (%glutSolidSierpinskiSponge num-levels offset scale)))
 
+#-darwin
 (defcfun ("glutWireCylinder" wire-cylinder) :void
   (radius %gl:double)
   (height %gl:double)
   (slices %gl:int)
   (stacks %gl:int))
 
+#-darwin
 (defcfun ("glutSolidCylinder" solid-cylinder) :void
   (radius %gl:double)
   (height %gl:double)
diff -ruN /tmp/cl-opengl/glut/init.lisp cl-opengl/glut/init.lisp
--- /tmp/cl-opengl/glut/init.lisp	2009-06-26 22:09:17.000000000 +0100
+++ cl-opengl/glut/init.lisp	2009-06-24 19:24:36.000000000 +0100
@@ -43,16 +43,23 @@
   #-(and sbcl (or x86 x86-64))
   `(progn ,@body))
 
+
+(defparameter *glut-initialized-p* nil)
+
+
 (defun init (&optional (program-name (lisp-implementation-type)))
   (without-fp-traps
     ;; freeglut will exit() if we try to call initGlut() when
     ;; things are already initialized.
-    (unless (getp :init-state)
+    (unless
+        #-darwin (getp :init-state)
+        #+darwin *glut-initialized-p*
       (with-foreign-objects ((argcp :int) (argv :pointer))
         (setf (mem-ref argcp :int) 1)
         (with-foreign-string (str program-name)
           (setf (mem-ref argv :pointer) str)
-          (%glutInit argcp argv)))
+          (%glutInit argcp argv)
+          (setf *glut-initialized-p* t)))
       ;; By default, we choose the saner option to return from the event
       ;; loop on window close instead of exit()ing.
       (set-action-on-window-close :action-continue-execution)
diff -ruN /tmp/cl-opengl/glut/interface.lisp cl-opengl/glut/interface.lisp
--- /tmp/cl-opengl/glut/interface.lisp	2009-06-26 22:09:17.000000000 +0100
+++ cl-opengl/glut/interface.lisp	2009-06-26 22:06:29.000000000 +0100
@@ -159,6 +159,7 @@
                 (when-current-window-exists
                  (,name current-window ,@(mapcar #'car (cdr args))))))))
 
+
 (define-glut-events
   ;; (idle             (window))
   (keyboard         (window (key ascii-to-char) (x :int) (y :int)))
@@ -188,10 +189,11 @@
   ;;                           (z :int)))
   (mouse-wheel      (window (button mouse-button) (pressed mouse-button-state)
                             (x :int) (y :int)))
-  (close            (window))
-  ;; (wm-close         (window)) ; synonym for CLOSE
+  (close            (window))           ; close-func does not exist on darwin
+;  (wm-close         (window))    
   (menu-destroy     (window)))
 
+
 ;;; These two functions should not be called directly and are called
 ;;; by ENABLE-EVENT and DISABLE-EVENT. See below.
 
@@ -318,7 +320,8 @@
       (let ((event (find-event-or-lose event-name)))
         ;; We don't actually disable the CLOSE event since we need it
         ;; for bookkeeping. See the CLOSE methods below.
-        (unless (or (eq event-name :idle) (eq event-name :close))
+        (unless (or (eq event-name :idle)
+                    (eq event-name :close))
           (with-window window
             (unregister-callback event)))
         (setf (events window) (delete event (events window)))
@@ -330,7 +333,10 @@
   (when-current-window-exists
     (if (game-mode current-window)
         (leave-game-mode)
-        (destroy-window (id current-window)))))
+        #-darwin
+        (destroy-window (id current-window))
+        #+darwin
+        (close current-window))))
 
 (defmethod close :around ((w base-window))
   (when (member :close (events w) :key #'event-name)
@@ -338,7 +344,29 @@
   (setf (aref *id->window* (id w)) nil)
   (setq *windows-with-idle-event* (delete w *windows-with-idle-event*))
   (when (null *windows-with-idle-event*)
-    (unregister-callback (find-event-or-lose :idle))))
+    (unregister-callback (find-event-or-lose :idle))
+    ;; We want to leave the glut event loop if all glut windows are closed,
+    ;; even when :action-continue-execution is set
+    #+darwin
+    (leave-main-loop)
+    )
+  ;; The following is possibly a naive solution, but it seems that freeglut
+  ;; takes care of this while darwin glut does not, so we have to do it here
+  #+darwin
+  (progn (destroy-window (id w))
+         (ecase *window-close-action*
+           (:action-exit
+            #+sbcl (sb-ext:quit)
+            #+ccl (ccl:quit)
+            #-(or sbcl ccl) nil
+            )
+           (:action-glutmainloop-returns
+            (leave-main-loop))
+           (:action-continue-execution
+            nil)))
+  )
+  
+           
 
 (defmethod close ((w base-window))
   (values))
@@ -417,10 +445,17 @@
 ;;; loops in the initial thread on multithreaded Lisps, or in this case,
 ;;; OpenMCL."
 
+
 ;; #-openmcl
 ;; (defun run-event-loop ()
 ;;   (glut:main-loop))
 
+;;; The following does not seem to work in current CCL (1.3) as the initial
+;;; thread does various housekeeping tasks and can not be simply hijacked
+;;; in the manner demonstrated below. Someone familiar with CCL might look
+;;; into how CCL does this with its own event loop that hooks into cocoa
+;;; and duplicate the functionality.
+
 ;; #+openmcl
 ;; (defun run-event-loop ()
 ;;   (flet ((start ()
diff -ruN /tmp/cl-opengl/glut/library.lisp cl-opengl/glut/library.lisp
--- /tmp/cl-opengl/glut/library.lisp	2009-06-26 22:09:16.000000000 +0100
+++ cl-opengl/glut/library.lisp	2009-06-24 19:24:36.000000000 +0100
@@ -33,7 +33,7 @@
 (in-package :cl-glut)
 
 (define-foreign-library glut
-  (:darwin (:or "libglut.dylib" "libglut.3.dylib"))
+  (:darwin (:framework "GLUT"))
   (:windows "freeglut.dll")
   (:unix (:or "libglut.so" "libglut.so.3")))
 
diff -ruN /tmp/cl-opengl/glut/main.lisp cl-opengl/glut/main.lisp
--- /tmp/cl-opengl/glut/main.lisp	2009-06-26 22:09:17.000000000 +0100
+++ cl-opengl/glut/main.lisp	2009-06-26 22:07:10.000000000 +0100
@@ -33,12 +33,25 @@
 (in-package #:cl-glut)
 
 (defcfun ("glutMainLoop" %glutMainLoop) :void)
+#+darwin (defcfun ("glutCheckLoop" check-loop) :void)
 
+#-darwin
 (defun main-loop ()
   (without-fp-traps
     (%glutMainLoop))
   (init))
 
-(defcfun ("glutMainLoopEvent" main-loop-event) :void)
+#+darwin
+(let ((darwin-run-main-loop-p t))
+  (defun main-loop ()
+    (without-fp-traps
+      (loop :while darwin-run-main-loop-p :do (check-loop)))
+    (init)
+    (setf darwin-run-main-loop-p t))
 
-(defcfun ("glutLeaveMainLoop" leave-main-loop) :void)
\ No newline at end of file
+  (defun leave-main-loop ()
+    (setf darwin-run-main-loop-p nil)))
+  
+
+#-darwin (defcfun ("glutMainLoopEvent" main-loop-event) :void)
+#-darwin (defcfun ("glutLeaveMainLoop" leave-main-loop) :void)
\ No newline at end of file
diff -ruN /tmp/cl-opengl/glut/misc.lisp cl-opengl/glut/misc.lisp
--- /tmp/cl-opengl/glut/misc.lisp	2009-06-26 22:09:17.000000000 +0100
+++ cl-opengl/glut/misc.lisp	2009-06-24 19:24:36.000000000 +0100
@@ -73,7 +73,8 @@
 (defcfun ("glutGameModeString" game-mode-string) :void
   (string :string))
 
-(defcfun ("glutEnterGameMode" enter-game-mode) :int)
+#-darwin (defcfun ("glutEnterGameMode" enter-game-mode) :int)
+#+darwin (defcfun ("glutEnterGameMode" enter-game-mode) :void)
 (defcfun ("glutLeaveGameMode" leave-game-mode) :void)
 
 (defcenum (game-mode-param %gl:enum)
diff -ruN /tmp/cl-opengl/glut/state.lisp cl-opengl/glut/state.lisp
--- /tmp/cl-opengl/glut/state.lisp	2009-06-26 22:09:16.000000000 +0100
+++ cl-opengl/glut/state.lisp	2009-06-24 19:24:36.000000000 +0100
@@ -41,6 +41,11 @@
 
 ;;; Setting Options
 
+
+(defparameter *window-close-action*
+  nil)
+
+
 ;; freeglut ext
 (defcenum (options %gl:enum)
   (:init-window-x #x01F4)
@@ -54,10 +59,15 @@
   (:window-cursor #x007A))
 
 ;;; freeglut ext
+#-darwin
 (defcfun ("glutSetOption" set-option) :void
   (option options)
   (value :int))
 
+#+darwin
+(defun set-option (val1 val2)
+  (declare (ignore val1 val2)))
+
 ;;; Also provide some utility functions around glutSetOption().
 
 ;; freeglut ext
@@ -100,9 +110,13 @@
   (set-option :init-display-mode
               (foreign-bitfield-value 'display-mode options)))
 
+
 (defun set-action-on-window-close (action)
   (set-option :action-on-window-close
-              (foreign-enum-value 'window-close-behaviour action)))
+              (foreign-enum-value 'window-close-behaviour action))
+  (setf *window-close-action*
+        action))
+
 
 (defun set-rendering-context (option)
   (set-option :rendering-context
@@ -155,8 +169,8 @@
   (:action-on-window-close #x01F9)      ; freeglut ext
   :window-border-width                  ; freeglut ext
   :window-header-height                 ; freeglut ext
-  :version                              ; freeglut ext
-  :rendering-context                    ; freeglut ext
+  :version                              ; freeglut ext  
+#-darwin  :rendering-context                    ; freeglut ext
   :direct-rendering)
 
 (defcfun ("glutGet" get) :int
