Ahh thanks, I found a page which explains everything.
Next Question:
How do the stride and offset parameters of glVertexPointer() and the like work? I’ve tried searching around and I can only find defines the byte offset between data etc. explanations which I don’t understand and C++ related explanations which uses sizeof() as a parameter which I don’t understand. Examples would be appriciated.
Say I have data packed as VCVCVC;
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(
GL_ARRAY_BUFFER,
(FloatBuffer) BufferUtils
.createFloatBuffer(18)
.put(new float[] { -0.5f, -0.5f, 0, 1f, 1f, 1f, -0.5f,
0.5f, 0f, 1f, 0f, 0f, 0.5f, -0.5f, 0f, 0f, 0f,
1f }).flip(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
.....
glVertexPointer(3, GL_FLOAT, 6 << 2, 0 << 2);
glColorPointer(3, GL_FLOAT, 6 << 2, 3 << 2);
That would translate to:
glVertexPointer(3, GL_FLOAT, 24, 0);
glColorPointer(3, GL_FLOAT, 24, 12);
That doesn’t really make sense to me. I only have 18 pieces of data in my buffer but I’m defining the stride as 24 and one of the offsets as 12. ???
Now lets consider I have the data packed as VVVCCC.
glVertexPointer(3, GL_FLOAT, 3 << 2, 0 << 2);
glColorPointer(3, GL_FLOAT, 3 << 2, 9 << 2);
Would I be correct in saying that the stride is [icode](pieces of data * proportional gap between data) << 2[/icode] and the offset is [icode]starting position of the data << 2[/icode]? Why do you left-shift everything by 2?
And finally, how is the below used?
[quote]public static void glVertexPointer(int size, int stride, java.nio.FloatBuffer pointer)
[/quote]
Is it used when the offset can be 0 i.e tightly packed non interleaved buffers? Everything I’ve seen so far binds the buffer and uses
[quote]public static void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset)
[/quote]
EDIT: Never mind I’m pretty sure that I’m correct in thinking that that function is used for VAOs. The difference between VBOs and VAOs is that the data for a VBO is placed on the GPU and you access it via a handle whereas with a VAO you have to keep creating the buffer. Am I correct?