Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn attrib-buffer-view
- [ptr stride num]
- (js/Float32Array. (.-buffer (aget js/Particles "HEAPU8")) ptr (* stride num)))
- (defn update-attrib-buffer
- [gl attrib ptr stride num]
- (.bindBuffer gl glc/array-buffer
- (get-in (:scene @app) [:particles :attribs attrib :buffer]))
- (.bufferData gl glc/array-buffer
- (attrib-buffer-view ptr stride num)
- glc/dynamic-draw))
- (defn update
- []
- (let [{:keys [gl psys psys-update psys-count particle-ptr scene mpos]} @app]
- (psys-update psys)
- (update-attrib-buffer gl :position particle-ptr 9 10000)
- (update-attrib-buffer gl :color (+ particle-ptr 24) 9 10000)
- (doto gl
- (gl/clear-color-and-depth-buffer (col/rgba 0 0 0.1) 1)
- (gl/draw-with-shader
- (-> (:particles scene)
- (assoc :num-vertices (psys-count psys))
- (assoc-in [:uniforms :model]
- (-> M44
- (g/rotate-x (* (mpos 1) 0.001))
- (g/rotate-y (* (mpos 0) 0.001))
- (g/scale 0.1))))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement