OpenGL and JRuby issue with methods and passing arrays

Hey guys, Im attaching a simple OpenGL helloworld program for JRuby. If
you run it and you have the JOGL stuff in your classpath, then it will
simply open up and make a cube spin (hooray! spinning cube!). My issue
is there’s one line that’s commented out in the file:

#gl.glLightfv( GL::GL_LIGHT0, GL::GL_AMB IENT, color)

– if i uncomment this I get errored (btw GL_AMB IENT is supposed to be
one word, but it tells me I’m posting spam on this forum because it
contains the string “amb ien”). I’m not new to Java or to Ruby,
but quite new to Jruby. It seems that no matter what java function I
call, if it takes an array I’m screwed. Any tips? I’ve tried having the
‘color’ var set to [0.5,0.5,0.5], and then again I tried to do
java.lang.reflect.Array.newInstance(java.lang.Double::TYPE, 3) and fill
the array that way. The long-and-short of it is, I don’t even know what
the error is failing me on because the trace stack is like 90 lines long
and none of them are my source files. Help, please? Has anyone else had
a problem passing arrays to java functions?

Nevermind!! I figured it out, I needed to use “java.nio.FloatBuffer”
Problem solved!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs