Clojure - java interop - How to pass a float array>
I need to call a java function from clojure, which takes a float array as a parameter. How would I do this in clojure?
I tried
(classname/function [0.1f 0.2f])
- but this doesn't work. Clearly the issue is with the parameter array. I can call other functions in the 开发者_StackOverflow中文版class with no problems, provide they don't take an array as a parameter.
Any suggestions?
Thank you
it looks like that function wants an array of GLfloats so the build in shortcut of float-array
may not give you what you need. the general array builder function is
(into-array type aseq)
so it may look something like:
(def my-array (into-array GLfloat [0.0 0.0 0.0]))
into array is longer winded though more general.
Try float-array
. From the documetation:
user=> (doc float-array)
-------------------------
clojure.core/float-array
([size-or-seq] [size init-val-or-seq])
Creates an array of floats
nil
user=> (float-array [1 2 3])
#<float[] [F@e1666>
user=>
精彩评论