How do i use a GLSL vertex attribute array in Java?

I’ve started writing my own glsl shaders haven’t really had any problems until now. I’m tryng to use a vertex attribute array, which is pretty easy in c++. You just create an array and have a pointer point to it using:

glVertexAttribPointer()

The problem is that this method accepts a pointer to an array as one of it’s arguments… Java doesn’t use pointers. So how do I pass an array into my shader? I’m creating a shader that accepts multiple vertex attribute arrays that contain keyframe information for morphing my object.

TIA
Stephen.

[quote=“sgsrules,post:1,topic:31791”]
You create your pointer array in a Java NIO Buffer Object and then pass that in as your pointer argument.

To simulate offsets within the pointer array, you can use the position attribute of the nio buffers as well, jogl reads data from the buffer starting at its current position and going to its limit. Make sure that you rewind your buffers to reset the position for each call to any gl pointer function.

Already tried that, maybe i’m doing something wrong here’s some sample code:

float [] test = new float[]{0,4,204,21};
fbtest = ByteBuffer.allocateDirect(4*test.length).order(ByteOrder.nativeOrder()).asFloatBuffer();
fbtest.put(test);
fbtest.rewind();
gl.glVertexAttribPointer(1,fbtest.capacity(),GL.GL_FLOAT,GL.GL_FALSE,0,fbtest);

and i get:

Semantic Error: No applicable overload for a method with signature “glVertexAttribPointer(int, int, int, int, int, java.nio.FloatBuffer)” was found in type “javax.media.opengl.GL”. Perhaps you wanted the overloaded version “void glVertexAttribPointer(int $1, int $2, int $3, boolean $4, int $5, long $6);” instead?

arrrggh… it wasn’t the buffer i changed GL.GL_FALSE to false and it worked:
gl.glVertexAttribPointer(1,fbtest.capacity(),GL.GL_FLOAT,false,0,fbtest);

but now i’m getting:
javax.media.opengl.GLException: array vertex_buffer_object must be disabled to call this method

I’m using vbos to load my geometry, is there something i have to do to the vbo? Everything works fine if i call gl.glVertexAttribPointer() before loading my geometry.

Thanks again guys

Don’t you love it when you answer your own posts? I forgot to unbind the vbo:

gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);

everything works now thanks guys!