anchor.diff:             "         color * color2;" ;mix(vec4(0.1, 0.0, 0.0, color.w), color2, color.w);"
              "}                                                                      "))
   
  -(let ((m-pos           nil)
  -      (m-num-particles 0)
  -      (m-point-size    1.0)
  -      (m-sprite-size   2.0)
  -      (m-vertex-shader nil)
  -      (m-pixel-shader  nil)
  -      (m-program       nil)
  -      (m-texture       0)
  -      (m-texture-data  (cffi:null-pointer))
  -      ;(m-pbo           nil)
  -      ;(m-vbo-color     nil)
  -      (m-base-color    #(0.0 0.0 0.0 0.0)))
  -  
  -  (defun particle-renderer-init ()
  -    (init-gl))
  -  
  -  (defun particle-renderer-release ()
  -    (cffi:foreign-free m-texture-data))
  -  
  -  (defun particle-renderer-set-positions (pos num-particles)
  -    (setf m-pos pos)
  -    (setf m-num-particles num-particles))
  -  
  -  (defun particle-renderer-set-base-color (color)
  -    (setf m-base-color (make-array 4))
  -    (dotimes (i 4)
  -      (setf (aref m-base-color i) (aref color i))))
  -  
  -  (defun particle-renderer-set-colors (color num-particles)
  -    (declare (ignore color num-particles))
  -    (not-implemented))
  -  
  -  (defun particle-renderer-set-pbo (pbo num-particles)
  -    (declare (ignore pbo num-particles))
  -    (not-implemented))
  -  
  -  (defun particle-renderer-display (mode)
  -    (ecase mode
  -      (:particle-points
  -        (gl:color 1.0 1.0 1.0)
  -        (gl:point-size m-point-size)
  -        (draw-points))
  -      (:particle-sprites
  -        (gl:enable :point-sprite)
  -        (gl:tex-env :point-sprite :coord-replace :true)
  -        (gl:enable :vertex-program-point-size-nv)
  -        (gl:point-size m-sprite-size)
  -        (gl:blend-func :src-alpha :one)
  -        (gl:enable :blend)
  -        (gl:depth-mask :false)
  -        
  -        (gl:use-program m-program)
  -        (gl:uniformi (gl:get-uniform-location m-program "splatTexture") 0)
  -        
  -        (gl:active-texture :texture0-arb)
  -        (gl:bind-texture :texture-2d m-texture)
  -        
  -        (gl:color 1.0 1.0 1.0)
  -        (gl:secondary-color (aref m-base-color 0) (aref m-base-color 1) (aref m-base-color 2))
  -        
  -        (draw-points)
  -        
  -        (gl:use-program 0)
  -        
  -        (gl:disable :point-sprite-arb)
  -        (gl:disable :blend)
  -        (gl:depth-mask :true))))
  -  
  -  (defun particle-renderer-set-point-size (size)
  -    (declare (ignore size))
  -    (not-implemented))
  -  
  -  (defun particle-renderer-set-sprite-size (size)
  -    (declare (ignore size))
  -    (not-implemented))
  -  
  -  (defun particle-renderer-reset-pbo ()
  -    (not-implemented))
  -  
  -  (defun init-gl ()
  +(let (;; for memory blocks
  +      m-new-pos m-old-pos m-vel
  +      ;; simulation parameters
  +      (m-num-bodies     2048)
  +      (m-delta-time     0.016)
  +      (m-damping        1.0)
  +      (m-p              256)
  +      (m-cluster-scale  1.56)
  +      (m-velocity-scale 2.64)
  +      ;; for rendering
  +      (m-point-size     1.0)
  +      (m-sprite-size    2.0)
  +      (m-base-color     #(1.0 0.6 0.3 1.0))
  +      ;; for shaders
  +      m-program m-vertex-shader m-pixel-shader
  +      ;; for texture
  +      (m-texture        0)
  +      (m-texture-data   (cffi:null-pointer)))
  +  
  +  (defun nbody-num-bodies ()
  +    m-num-bodies)
  +  
  +  (defun nbody-get-frame-rate ()
  +    (frame-rate-counter-get-frame-rate))
  +  
  +  (defun nbody-init ()
  +    (init-shaders)
  +    (create-texture 32)
  +    (init-cuda-context 0)
  +    (init-memory-blocks)
  +    (frame-rate-counter-init)
  +    (nbody-reset)
  +    (memcpy-host-to-device m-old-pos m-vel))
  +  
  +  (defun init-shaders ()
       ;; create shader objects
       (setf m-vertex-shader (gl:create-shader :vertex-shader))
       (setf m-pixel-shader (gl:create-shader :fragment-shader))
  
positive.code: ;;;
  
  (defmethod glut:display-window :before ((w nbody-window))
    (gl:enable :depth-test)
    (gl:clear-color 0 0 0 0)
    (nbody-demo-init))
  
  (defmethod glut:display-window :after ((w nbody-window))
    (nbody-demo-release))
  
  (defmethod glut:display ((w nbody-window))
    (with-slots (new-pos old-pos vel delta-time damping num-bodies p) w
      ;; update simulation
      (nbody-demo-update-simulation new-pos old-pos vel delta-time damping num-bodies p)
      (rotatef new-pos old-pos)
      ;; clear buffers
      (gl:clear :color-buffer :depth-buffer-bit)
      ;; view transform
      (gl:matrix-mode :modelview)
      (gl:load-identity)
      (gl:translate 0.0 0.0 -100.0)
      (gl:rotate 0.0 1.0 0.0 0.0)
      (gl:rotate 0.0 0.0 1.0 0.0)
      ;; display bodies
      (nbody-demo-display new-pos num-bodies)
      ;; swap buffers
      (glut:swap-buffers)
      ;; display frame rate
      (display-frame-rate num-bodies)))
  
  (defmethod glut:reshape ((w nbody-window) width height)
    ;; configure on projection mode
  
negative.code: 
    (defun get-elapsed-time ()
      (let (milliseconds)
        (stop-and-synchronize-timer)
        (cffi:with-foreign-object (pmilliseconds :float)
          (cu-event-elapsed-time pmilliseconds
                                 (cffi:mem-ref start-event 'cu-event)
                                 (cffi:mem-ref stop-event 'cu-event))
          (setf milliseconds (cffi:mem-ref pmilliseconds :float)))
        (start-timer)
        milliseconds)))
  
  (defmacro with-cuda-timer (&body body)
  