Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn update-spectrum [mesh]
- (s/>->> [:p] [:spectrum-data]
- #(if (and (:updated %2) (minim/playing? %1))
- (let
- [data (:data %2)
- l-data (:left data)
- r-data (:right data)
- vertices (persistent! (reduce (fn [c d] (conj! c (spec-x d (nth l-data d)) (spec-y d (nth r-data d)) 0)) (transient []) (range 360)))
- ]
- (update-vertex-buffer! mesh vb-type-position vertices)
- (s/ag!! :spectrum-data (fn [_] {:updated false}))
- (start-spectrum-data-gatherer %1)))))
- (defn update-vertex-buffer! [mesh|geom vb-type lazy-data]
- (let [data (apply concat lazy-data)
- ;_ (println "data =" lazy-data)
- vb (vertex-buffer?? mesh|geom vb-type)
- nio-buffer (.getData vb)]
- (if (> (count data) (.capacity nio-buffer))
- ; if the existing buffer length is shorter than data length, re-create the buffer
- (let
- [mesh (resolve-mesh mesh|geom)
- new-buffer (create-float-buffer data)]
- (vertex-buffer! mesh vb-type 3 new-buffer))
- ; if the existing buffer length is enough for data, re-use the buffer
- (do
- (.rewind nio-buffer)
- (.updateData vb (create-float-buffer data)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement