;; draw vao
;; where vao is expected to have
;; index 0: vectices - MANDATORY
;; index 1: normals - optional
;; index 2: uvw's - optional
;; index 3: colours - optional
(bind-func xtm_draw_vao
  (lambda (vao:VAO* shader m v p type update_data:i1 sz tex:Texture* blend:i1)
    (xtm_update_matrices shader m v p)
    (let ((vbo (get_vbo vao 0))
          (elmts (i64toi32 (elements vbo))))
      ;; (println vbo)
      (if update_data (update vbo))
      (if (= type GL_POINTS)
          (glPointSize sz)
          (glLineWidth 1.0))
      (if blend
          (begin (glEnable GL_BLEND)
                 (glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA)))
                 ;; (glBlendFunc GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR)))
      (if (not (null? tex)) (bind tex 1:i32))
      (shader_prepare_draw shader tex 0 (if (= type GL_POINTS) #t #f))
      (draw vao type 0 elmts 0)
      (if (not (null? tex)) (unbind tex 1:i32))
      (if blend (glDisable GL_BLEND))
      void)))