I am testing some code with jruby and I use the opengl method
glGenTextures(GLsizei n, GLuint *textures) that I have previously
imported with java_import. The second parameter is a vector where the
generated textures will be stored.
I don’t know anything about the internals, but my guess is that the
to_java is a one way thing.
That is, to_java would create an object that Java would understand, but
there is no ability for that Java object’s modifications to be written
back to the original Ruby object.
Just a guess, though.
Maybe you could create the to_java object before the call, and then load
the results back after the call, something like this, if the Java object
is an array?:
java_array = [].to_java
glGenTextures(1, java_array, 0) @ruby_array = java_array.inject([]) { |ra, x| ra << x }
or if it’s a list:
java_list = java.util.ArrayList.new
glGenTextures(1, java_list, 0) @ruby_array = java_list.inject([]) { |ra, x| ra << x }
or if it’s a Vector, just replace ‘ArrayList’ with ‘Vector’.