Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. (defn attrib-buffer-view
  2. [ptr stride num]
  3. (js/Float32Array. (.-buffer (aget js/Particles "HEAPU8")) ptr (* stride num)))
  4.  
  5. (defn update-attrib-buffer
  6. [gl attrib ptr stride num]
  7. (.bindBuffer gl glc/array-buffer
  8. (get-in (:scene @app) [:particles :attribs attrib :buffer]))
  9. (.bufferData gl glc/array-buffer
  10. (attrib-buffer-view ptr stride num)
  11. glc/dynamic-draw))
  12.  
  13. (defn update
  14. []
  15. (let [{:keys [gl psys psys-update psys-count particle-ptr scene mpos]} @app]
  16. (psys-update psys)
  17. (update-attrib-buffer gl :position particle-ptr 9 10000)
  18. (update-attrib-buffer gl :color (+ particle-ptr 24) 9 10000)
  19. (doto gl
  20. (gl/clear-color-and-depth-buffer (col/rgba 0 0 0.1) 1)
  21. (gl/draw-with-shader
  22. (-> (:particles scene)
  23. (assoc :num-vertices (psys-count psys))
  24. (assoc-in [:uniforms :model]
  25. (-> M44
  26. (g/rotate-x (* (mpos 1) 0.001))
  27. (g/rotate-y (* (mpos 0) 0.001))
  28. (g/scale 0.1))))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement