(bind-func generate_random_vao
(lambda (tris)
(let ((num (* 3 tris))
(verts:float* (alloc (* 4 num)))
(normals:float* (alloc (* 3 num)))
(uvws:float* (alloc (* 3 num)))
(colours:float* (alloc (* 4 num)))
(vbo_verts (VBO verts (* 4 num)))
(vbo_normals (VBO normals (* 3 num)))
(vbo_uvws (VBO uvws (* 3 num)))
(vbo_colours (VBO colours (* 4 num)))
(i 0) (j 0) (k 0))
;; random verts
(dotimes (i num)
(set! j (* i 4))
(set! k (* i 3))
(pset! verts (+ j 0) (- (* (random) 4.0) 2.0))
(pset! verts (+ j 1) (- (* (random) 4.0) 2.0))
(pset! verts (+ j 2) (- (* (random) 2.0) 1.0))
(pset! verts (+ j 3) 1.0))
;; generate normals
(generate_tri_normals verts (* 4 num) normals (* 3 num))
;; generate uvws
(generate_tri_uvws uvws (* 3 num))
;; white colour
(dotimes (i (* 4 num)) (pset! colours i 1.0))
(set_attribute testVAO vbo_verts 0 4)
(set_attribute testVAO vbo_normals 1 3)
(set_attribute testVAO vbo_uvws 2 3)
(set_attribute testVAO vbo_colours 3 4)
(update vbo_verts)
(update vbo_normals)
(update vbo_uvws)
(update vbo_colours)
void)))