(bind-func draw
(let ((i 0))
(lambda (vao:VAO* draw_mode:i32 first_element:i32 count:i32 instances:i32)
;; (println 'draw: vao draw_mode first_element count)
(glBindVertexArray (id vao))
(gl_print_error "Error binding vertex array")
(dotimes (i 16)
(if (aref (attribs vao) i)
(begin ;; (println 'enable-attrib-list i)
(glEnableVertexAttribArray i))))
(gl_print_error "Error enablling attrib arrays in VAO!")
(if (> instances 0)
(glDrawArraysInstanced draw_mode first_element count instances)
(glDrawArrays draw_mode first_element count))
(gl_print_error "Error drawing VAO!")
(dotimes (i 16)
(if (aref (attribs vao) i)
(begin ;; (println 'disable-attrib-list i)
(glDisableVertexAttribArray i))))
(gl_print_error "Error disabling attrib arrays in VAO!")
;; (gl_print_error "Error drawing vertex array")
;; (println "done drawing vao")
(glBindVertexArray 0))))