Ok new fun…
I made all of abies suggested changes and sure enough, I got vertex buffers to work!
My sample looks like this. Thing is a FloatBuffer and Faces is a ByteBuffer that worked with straight vetex arrays.
Init section:
gl.glGenBuffersARB(1, buffer);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, buffer[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, 15*4*4, thing, GL.GL_STATIC_DRAW_ARB);
gl.glGenBuffersARB(1, buffer2);
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, buffer2[0]);
gl.glBufferDataARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, 9*4, faces, GL.GL_STATIC_DRAW_ARB);
Draw section
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, buffer[0]);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);
However, my goal is INDEXED geometry…
Unfortuately, the normal way would be something like this:
Draw section
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, buffer[0]);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, buffer2[0]);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
//use indexing
gl.glDrawElements(GL.GL_TRIANGLES, 9, GL.GL_UNSIGNED_BYTE, 0); //last 0 is offset in element-array
Except that glDrawElements wants a buffer as the last arg. As I understand it there is only one glDrawElements in C, it’s just the meaning changes on the render context (it treats the arg as a pointer or an offset depending on the earlier binding…)
I did try null and an empty int[1] array, first no compile, second vm crash, as expected.
Making two methods in JOGL, one taking the buffer and the other accepting an int offset, map back to the one GL function I think is outside my current GlueGen hack ability, I looked around but thought I might post in the meantime. Any ideas?