glVertexPointer NIO problem

Hi,

I am using the glVertexPointer with JOGL which in turn uses the new NIO feature in JDK 1.4 (as opposed to float[] in gl4java) to setup the vertex array. Occasionally (>50%) I will get EXCEPTION_ACCESS_VIOLATION error in the native code when executing net.java.games.jogl.impl.windows.WindowsGLImpl.glArrayElement(Native Method)

Since I am new to NIO, is there anything I should look out for? I am porting my project from gl4java so the original code works fine.

Thanks and appreciate for any suggestions.
Aaron

The first thing to check would be the number of elements you’re passing in to drawArrays/drawElements to see if you’re going past the end of the array. But if you’ve switched straight from an existing app this is probably ok.

In terms of NIO specific, its very easy to forget to call .clear and .rewind before you fill it with data again, and end up putting data in places you don’t expect.

Short of that, hows about seeing some code?

You may want to look at the VertexArrayRange and VertexBufferObject demos in the jogl-demos project on java.net; unlike these demos you should use the SIZEOF_FLOAT and SIZEOF_INT constants in net.java.games.jogl.util.BufferUtils if necessary.

Here’s my code to set the array:
where the varray is a set of {x,y,z} and tarray is a set of {s,t}

public void setVertexArrayPtr(float[] varray) {
FloatBuffer f = net.java.games.jogl.util.BufferUtils.newFloatBuffer(varray.length);
f.put(varray);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, f);
}
public void setTextureArrayPtr(float[] tarray) {
FloatBuffer f = net.java.games.jogl.util.BufferUtils.newFloatBuffer(tarray.length);
f.put(tarray);
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, f);
}

Am I calling it correctly?
Aaron