-1

我正在尝试使用单个 VAO 来表示包含多个网格的单个 VBO。现在我有:

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

更多来源:http: //pastebin.com/PDuk3fDu

我认为我的问题主要存在于代码段的最后一行。

我以为我可以在同一个 VBO 中填充两个不同的网格?如果我在设置缓冲源时只能设置看似一个的状态,这怎么可能?

我遇到了这个麻烦,因为我读到每个 VBO 都有一个 VAO 效率非常低,因为绑定是一件相对昂贵的事情。我还读到在同一个 VBO 中存储具有相似需求的网格是个好主意。

4

1 回答 1

0

不要将索引缓冲区与顶点数据(读取:属性)缓冲区 VBO 混合。

总之:

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.)
于 2015-07-13T20:32:54.553 回答