anchor.diff:  ;;;
   
   (defun main ()
  -  (glut:display-window (make-instance 'nbody-window)))
  +  (setf glut:*run-main-loop-after-display* nil)
  +  (let ((window (make-instance 'nbody-window)))
  +    (glut:display-window window) ; GLUT window must be created before initializing nbody-demo
  +    (with-nbody-demo (demo 2048 *gpu*)
  +      (with-frame-rate-counter (counter)
  +        (setf (slot-value window 'nbody-demo) demo
  +              (slot-value window 'counter)    counter)
  +        (glut:main-loop)))))
   
   (defun not-implemented ()
     (error "not implemented."))
  
positive.code:       (set (aref new-pos index) position)
        (set (aref vel index) velocity))))
  
  (defun integrate-nbody-system (new-pos old-pos vel delta-time damping num-bodies p)
    (let ((grid-dim (list (ceiling (/ num-bodies p)) 1 1))
          (block-dim (list p 1 1)))
      (integrate-bodies new-pos old-pos vel delta-time damping num-bodies
                        :grid-dim grid-dim
                        :block-dim block-dim)))
  
  
  ;;;
  ;;; cl-glut window subclass
  ;;;
  
  (defclass nbody-window (glut:window) ()
    (:default-initargs :width 640 :height 480 :pos-x 100 :pos-y 100
                       :mode '(:double :rgb) :title "nbody"))
  
  
negative.code: ;;; Frame rate counter
  ;;;
  
  (defstruct (frame-rate-counter :conc-name)
    timer
    (fps-count 0)
    (fps-limit 5)
    (fps       0))
  
  (defmacro with-frame-rate-counter ((var) &body body)
    `(let (,var)
       (unwind-protect
            (progn (setf ,var (init-frame-rate-counter))
                   ,@body)
         (release-frame-rate-counter ,var))))
  
  (defun init-frame-rate-counter ()
    (let ((counter (make-frame-rate-counter)))
      (setf (timer counter) (create-timer))
      (start-timer (timer counter))
      counter))
  
  (defun release-frame-rate-counter (counter)
    (destroy-timer (timer counter)))
  
  (defun get-frame-rate (counter)
    (fps counter))
  
  (defun measure-frame-rate (counter)
    (symbol-macrolet ((timer     (timer counter))
                      (fps-count (fps-count counter))
                      (fps-limit (fps-limit counter))
                      (fps       (fps counter)))
      (incf fps-count)
      (when (>= fps-count fps-limit)
        (let ((milliseconds (/ (get-elapsed-time timer) fps-count)))
  