-1

I'm trying to use a single VAO to represent a single VBO that contains multiple meshes. Right now I have:

    glVertexArrayElementBuffer ( vertexArray, buffer );
    glVertexArrayVertexBuffer ( vertexArray, positionLocation, buffer, 0, 3 * sizeof ( float ) );
    glVertexArrayVertexBuffer ( vertexArray, normalLocation, buffer, (objectVertexBytes + objectIndexBytes), 3 * sizeof ( float ) ); // Issue 2

More of the source here: http://pastebin.com/PDuk3fDu

I think my problem resides mainly in the last line of the snippet.

I thought I could stuff two dissimilar meshes in the same VBO? How is that possible if I can only set the state for seemingly one when setting up the buffer sources?

I'm going through this trouble because I read that having a single VAO for each VBO is horribly inefficient due to the fact that binding is a relatively expensive thing to do. I also read that storing meshes with similar needs in the same VBO is a good idea.

Stradigos
  • 814
  • 1
  • 13
  • 29

1 Answers1

0

Don't mix your index buffer with your vertex data (read: attribute) buffer VBO's.

In summary:

VBO 1
Mesh 1 indices + Mesh 2 indices

(Of course you could separate out Mesh 1 and Mesh 2 here if you'd like)

VBO 2
Mesh 1 Attributes (Vertex, Normal, etc.)
Mesh 2 Attributes (Vertex, Normal, etc.)
Stradigos
  • 814
  • 1
  • 13
  • 29