Created
April 30, 2016 22:24
-
-
Save postspectacular/d0d86076e1f9e1f3864a836b73b55556 to your computer and use it in GitHub Desktop.
Wrapping & calling compiled C fns from Clojurescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; initialize particle system and | |
;; create C function wrappers | |
(let [psys (.ccall js/Particles "initParticleSystem" "*" | |
#js ["number" "number" "number" "number"] | |
#js [10000 1000 0.0 -0.01 0.125]) | |
psys-update (.cwrap js/Particles "updateParticleSystem" "*" | |
#js ["number"]) | |
psys-count (.cwrap js/Particles "getNumParticles" "number" | |
#js ["number"]) | |
particle-ptr (.ccall js/Particles "getParticlesPointer" "*" | |
#js ["number"] #js [psys])] | |
;; store in app state atom for future use | |
(swap! app merge | |
{:psys psys | |
:psys-update psys-update | |
:psys-count psys-count | |
:psys-get psys-get | |
:particle-ptr particle-ptr})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment