Hallo, I’m a newbe with JOGL, started this week.
Now I have a question about BufferUtils.bufferOffset.
I have a float-array:
3 Colors, 3 Vertex, 3 Colors, 3 Vertex and so.
Can’t I put this array in a OpenGL Buffer, created with glGenBuffersARB() and use BufferUtils.bufferOffset like this:
gl.glVertexPointer(
3, GL.GL_FLOAT, 3 * Float.SIZE,
BufferUtils.bufferOffset(3 * Float.SIZE));
gl.glColorPointer(
3, GL.GL_FLOAT, 3 * Float.SIZE,
BufferUtils.bufferOffset(0));
glDrawArrays(…)
to draw a primitive object ?
That looks correct as far as I can tell. Note that you have to bind the buffer in order to use the bufferOffset API. Take a look at the source code for the VertexBufferObject demo in the jogl-demos workspace for an example.