anchor.diff:      (assert (= (gl::get-buffer-parameter :array-buffer :buffer-size :int)
                  size))
       (let ((vb (make-vertex-buffer :index buff
  -                                  :nb-vertices (/ (length vertices) 3)
  -                                  :format (make-vertex-format :vertices vertices
  -                                                              :colors colors
  -                                                              :tex-coords tex-coords
  -                                                              :normals normals))))
  -      (vertex-buffer-update vb vertices 0)
  -      (let ((offset (* (vertex-buffer-nb-vertices vb) 3)))
  -        (when colors
  -          (vertex-buffer-update vb colors offset)
  -          (incf offset (* (vertex-buffer-nb-vertices vb) 4)))
  -        (when tex-coords
  -          (vertex-buffer-update vb tex-coords offset)
  -          (incf offset (* (vertex-buffer-nb-vertices vb) 2)))
  -        (when normals
  -          (vertex-buffer-update vb normals offset)
  -          (incf offset (* (vertex-buffer-nb-vertices vb) 3))))
  +                                  :nb-vertices nb-vertices
  +                                  :format format)))
         vb)))
   
   
  +(defun create-vertex-buffer (vertices &key colors tex-coords normals (usage :stream-draw))
  +  (let* ((fmt (make-vertex-format :vertices vertices :colors colors :tex-coords tex-coords
  +                                  :normals normals))
  +          (vb (create-empty-vertex-buffer (/ (length vertices) 3) :usage usage
  +                                          :format fmt)))
  +    (vertex-buffer-update-components vb 0 vertices :colors colors
  +                                      :tex-coords tex-coords :normals normals)
  +    vb))
  +
   (defun vertex-buffer-update (vb array &optional (offset 0))
  +  (assert (< (+ offset (length array)) (vertex-buffer-nb-vertices vb)))
     (gl:bind-buffer :array-buffer (vertex-buffer-index vb))
     (gl:with-mapped-buffer (p :array-buffer :write-only)
       (loop for i below (length array)
            do (setf (cffi:mem-aref p :float (+ offset i)) (float (aref array i) 0.0)))))
   
  +(defun vertex-buffer-update-components (vb offset vertices &key colors tex-coords normals)
  +  (assert (= (vertex-buffer-format vb)
  +             (make-vertex-format :vertices vertices
  +                                 :colors colors
  +                                 :tex-coords tex-coords
  +                                 :normals normals)))
  +  (vertex-buffer-update vb vertices offset)
  +  (incf offset (* (vertex-buffer-nb-vertices vb) 3))
  +  (when colors
  +    (vertex-buffer-update vb colors offset)
  +    (incf offset (* (vertex-buffer-nb-vertices vb) 4)))
  +  (when tex-coords
  +    (vertex-buffer-update vb tex-coords offset)
  +    (incf offset (* (vertex-buffer-nb-vertices vb) 2)))
  +  (when normals
  +    (vertex-buffer-update vb normals offset)
  +    (incf offset (* (vertex-buffer-nb-vertices vb) 3)))
  +  vb)
  +
  +
   (defun destroy-vertex-buffer (vb)
  -  (gl:delete-buffers (vertex-buffer-index vb)))
  -
  +  (gl:delete-buffers (list (vertex-buffer-index vb))))
  +
  +;;; Index Buffer
   (defstruct (index-buffer (:include buffer))
     nb-indices)
   
  
positive.code:                      (aref vertices (+ 2 (* i 3)))))))
  
  (defstruct display-list
    (index -1)
    primitive
    start end
    vb ib)
  
  (defun load-primitive (indices vertices &key (primitive :triangles)
                                               colors tex-coords normals
  
negative.code:              (gl:enable-client-state :index-array))
        (gl:disable-client-state :index-array)))
  
  (defun create-empty-index-buffer (nb-indices &key (usage :static-draw))
    (let ((buff (car (gl:gen-buffers 1))))
      (dformat "Creating index buffer: ~S~%" nb-indices)
      (dformat "Recommended # of indices: ~S~%" (gl:get-integer :max-elements-indices))
      (gl:bind-buffer :element-array-buffer buff)
      (%gl:buffer-data :element-array-buffer
                       (* nb-indices 2) ;; unsigned short
                       (cffi:null-pointer) ;; just allocating space
                       usage)
      (assert (= (gl::get-buffer-parameter :element-array-buffer :buffer-size :int)
                 (* nb-indices 2)))
      (let ((ib (make-index-buffer :index buff
                                   :nb-indices nb-indices)))
        ib)))
  
  (defun create-index-buffer (indices &key (usage :static-draw))
    (let ((ib (create-empty-index-buffer (length indices) :usage usage)))
      (index-buffer-update ib indices 0)
      ib))
  
  (defun index-buffer-update (ib array &optional (offset 0))
    (assert (< (+ offset (length array)) (index-buffer-nb-indices ib)))
    (gl:bind-buffer :element-array-buffer (index-buffer-index ib))
    (gl:with-mapped-buffer (p :element-array-buffer :write-only)
      (loop for i below (length array)
  