PDA

View Full Version : Interleaved VBO noob question



Riskz
04-09-2009, 11:37 AM
I got VBO to work with a different array for vertex positions, normals, texture cordinates and an index array.
Now I'm trying to use an interleaved VBO with the position, normals and texture coords and the separated index array.
I've read something about using blocks of 32 bytes to store all the vertex atributes in the array, so (tell me if I'm wrong) I store the attributes this way:
"PPPNNNTT" (where P stands for position, N for normals and T for tex coords)

If they are all floats of 4bytes, then summed up I have 32 bytes.

But I don't know well how to use gl**Pointer() to specify where each attribute is.
I'm doing something like this:

...
glVertexPointer(3, GL_FLOAT, 20, 0);
glNormalPointer(GL_FLOAT, 20,12);
glTexCoordPointer(2, GL_FLOAT, 24, 24);
...
But I think the last two arguments of the functions don't expect bytes, can anyone help me out with this?
Thanks

ephtracy
04-09-2009, 05:36 PM
in this way :


int size = 32;
glVertexPointer( 3, GL_FLOAT, size, (char *)NULL + 0 );
glNormalPointer( GL_FLOAT, size, (char *)NULL + 12 );
glTexCoordPointer( 2, GL_FLOAT, size, (char *)NULL + 24 );

Riskz
04-09-2009, 05:40 PM
Thanks man =)