VBO Pointer stride and offset

Started by gopgop, June 07, 2013, 13:43:30

Previous topic - Next topic

gopgop

What would be the stride and offset that I were to put in these if I have 3 COLOR,3*4*6 VETREX?
as in this

THIS REPEATS
{
  //COLOR
  put(1f)put(1f)put(1f);

  //VETREX
  then this 4*6 times
  put(1f)put(1f)put(1f);
  put(....
}



What would be my pointer offsets?
          glVertexPointer(3, GL_FLOAT, 6 << 2, 3);
          glColorPointer(3, GL_FLOAT,stride 6 << 2, offset 0);

quew8

I suggest you work it out for yourself, you won't always be able to ask: http://lwjgl.org/wiki/index.php?title=Using_Vertex_Buffer_Objects_(VBO)#Rendering. That's a good place to start. There are more than enough tutorials online so I doubt anyone here will teach it to you but if you have a specific problem then we are more than happy to help.

gopgop

I tried.. I cant get the hang of it. They dont explain it so well in the tutorial you sent me...

quew8

I wrote the tutorial  ;D.
Frankly I'm not sure what you mean by "3*4*6 VERTEX". The important bits of info are:
1) The number of elements in the data - example: 3 Vertex (x, y, z), 4 Colour (r, g, b, a) -
2) The number of bytes in each element - example: all elements are floats so 4 bytes per element (4 bytes in a float) -
3) The order the bits of info are arranged - example: vertex then colour.

The stride is then the total number of elements times by the number of bytes per element. The stride is the same for all pointers. In the example above it would be ( 3 + 4 ) * 4 = 28

The offset is the total number of elements BEFORE these elements times by the number of bytes. In example, vertex offset is 0 since there are no elements before the vertex ones, colour offset is ( 3 ) * 4 = 12 since there are 3 vertex elements before the colour ones.

I know I said I wouldn't teach it to you but I had time whilst something was unzipping. You're lucky boy.

gopgop

Yay thanks! I got it to work based on what you said :D