(defn
set-array-buffer
[game
program
buffer
attrib-name
data
{:keys [size type iter normalize stride offset divisor], :as opts}]
(let
[attrib-location
(gl game getAttribLocation program attrib-name)
previous-buffer
(gl
game
#?(:clj getInteger :cljs getParameter)
(gl game ARRAY_BUFFER_BINDING))
total-size
(* size iter)]
(gl game bindBuffer (gl game ARRAY_BUFFER) buffer)
(gl
game
bufferData
(gl game ARRAY_BUFFER)
data
(gl game STATIC_DRAW))
(dotimes
[i iter]
(let
[loc (+ attrib-location i)]
(gl game enableVertexAttribArray loc)
(gl
game
vertexAttribPointer
loc
size
type
normalize
(* total-size float-size)
(* i size float-size))
(gl game vertexAttribDivisor loc divisor)))
(gl game bindBuffer (gl game ARRAY_BUFFER) previous-buffer)
(/ (#?(:clj count :cljs .-length) data) total-size)))