问题
OpenGL 4.4、C++11
通过将顶点属性设置为 element_array_buffer 和 array_buffer,我是否有权在 element_array_buffer 中为每个属性使用从 0 开始的索引?
数据布局
VAO
Buffer(array_buffer)
PositionFloat * n
TextureFloat * n
NormalFloat * n
Buffer(element_array_buffer)
PositionIndex * 1
TextureIndex * 1
NormalIndex * 1
数据使用
//gen
glBindVertexArray(VAO);
glBindBuffer(array_buffer, vbo);
glBufferData(array_buffer, size(vertices), data(vertices), access(vertices));
glVertexAttribPointer(POSITIONS, 3, float, offset(0));
glVertexAttribPointer(UVS, 2, float, offset(positions));
glVertexAttribPointer(NORMALS, 3, float, offset(normals));
glBindBuffer(element_array_buffer, ebo);
glBufferData(element_array_buffer, size(elements), data(elements), access(elements));
...?! /*Cannot set element attributes!
If I could, I would set a strided, offset attribPointer for each attribute,
so that if 0 appears in the NORMALS attribute, it will look up the first normal,
and not the first element in the buffer. */
问题
我编写索引以便可以使用 0/0/0 引用第一个顶点、UV 和法线。是否可以将其映射到 element_array_buffer 并照此使用?或者我的解决方案是将 nPositions 添加到我的纹理索引,并将 nPositions+nTextures 添加到我的正常索引?