您是否将索引数据附加到 VAO(顶点数组对象)?
Do you attach index data to VAO (Vertex Array Objects)?
我知道对于 VAO,提供所有属性数据是理想的,例如顶点法线、顶点位置、顶点颜色、纹理坐标等,但是在使用 drawElements
绘制的情况下索引数据呢?而不是 drawArrays
?
到目前为止,我创建了一个 VAO 并提供了上面的数据,但不确定如何将索引缓冲区数据附加到 VAO(如果推荐或可能的话)
顶点数组对象中没有存储任何缓冲区的数据。顶点数组对象只是收集如何 "use" 不同缓冲区数据的信息。
它知道数据格式、类型、跨步偏移和缓冲区名称等信息,但它不知道 "mirror" 存储在缓冲区对象中的数据。
命名元素缓冲区对象的名称是顶点数组对象状态向量的一个状态。
这意味着顶点数组对象中没有存储数据。索引存储在元素缓冲区中,但索引缓冲区的名称(整数对象编号)在顶点数组对象中被引用。
必须在绑定顶点数组对象(glBindVertexArray
) 之后绑定GL_ELEMENT_ARRAY_BUFFER
。 GL_ELEMENT_ARRAY_BUFFER
对象存储在顶点数组对象状态向量中。
如果顶点数组对象已解除绑定并再次绑定,则 GL_ELEMENT_ARRAY_BUFFER
已知并再次绑定。但是,如果在绑定顶点数组对象时元素数组缓冲区显式解除绑定,则会将其从状态向量中移除。
参见OpenGL ES 3.0.5 Specification - 2.11 Vertex Array Objects, page 44:
A vertex array object is created by binding a name returned by GenVertexArrays
with the command
void BindVertexArray( uint array );
array is the vertex array object name. The resulting vertex array object is a new state vector, comprising all the state and with the same initial values listed in table 6.2.
BindVertexArray
may also be used to bind an existing vertex array object.
If the bind is successful no change is made to the state of the bound vertex array object, and any previous binding is broken.
Tables 6.2, Vertex Array Object State
VERTEX_ATTRIB_ARRAY_ENABLED
, VERTEX_ATTRIB_ARRAY_SIZE
, VERTEX_ATTRIB_ARRAY_STRIDE
, VERTEX_ATTRIB_ARRAY_TYPE
, VERTEX_ATTRIB_ARRAY_NORMALIZED
, VERTEX_ATTRIB_ARRAY_INTEGER
, VERTEX_ATTRIB_ARRAY_DIVISOR
, VERTEX_ATTRIB_ARRAY_POINTER
, ELEMENT_ARRAY_BUFFER_BINDING
, VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
.
I'm curious whether index buffer object data or uniforms would be somehow stored inside of VAOs?
Uniforms are stored to the default uniform block which belongs to the program object.
uniform存储在属于程序对象的默认uniform块中,与顶点数组对象没有关系。
我知道对于 VAO,提供所有属性数据是理想的,例如顶点法线、顶点位置、顶点颜色、纹理坐标等,但是在使用 drawElements
绘制的情况下索引数据呢?而不是 drawArrays
?
到目前为止,我创建了一个 VAO 并提供了上面的数据,但不确定如何将索引缓冲区数据附加到 VAO(如果推荐或可能的话)
顶点数组对象中没有存储任何缓冲区的数据。顶点数组对象只是收集如何 "use" 不同缓冲区数据的信息。 它知道数据格式、类型、跨步偏移和缓冲区名称等信息,但它不知道 "mirror" 存储在缓冲区对象中的数据。
命名元素缓冲区对象的名称是顶点数组对象状态向量的一个状态。
这意味着顶点数组对象中没有存储数据。索引存储在元素缓冲区中,但索引缓冲区的名称(整数对象编号)在顶点数组对象中被引用。
必须在绑定顶点数组对象(glBindVertexArray
) 之后绑定GL_ELEMENT_ARRAY_BUFFER
。 GL_ELEMENT_ARRAY_BUFFER
对象存储在顶点数组对象状态向量中。
如果顶点数组对象已解除绑定并再次绑定,则 GL_ELEMENT_ARRAY_BUFFER
已知并再次绑定。但是,如果在绑定顶点数组对象时元素数组缓冲区显式解除绑定,则会将其从状态向量中移除。
参见OpenGL ES 3.0.5 Specification - 2.11 Vertex Array Objects, page 44:
A vertex array object is created by binding a name returned by
GenVertexArrays
with the commandvoid BindVertexArray( uint array );
array is the vertex array object name. The resulting vertex array object is a new state vector, comprising all the state and with the same initial values listed in table 6.2.
BindVertexArray
may also be used to bind an existing vertex array object. If the bind is successful no change is made to the state of the bound vertex array object, and any previous binding is broken.Tables 6.2, Vertex Array Object State
VERTEX_ATTRIB_ARRAY_ENABLED
,VERTEX_ATTRIB_ARRAY_SIZE
,VERTEX_ATTRIB_ARRAY_STRIDE
,VERTEX_ATTRIB_ARRAY_TYPE
,VERTEX_ATTRIB_ARRAY_NORMALIZED
,VERTEX_ATTRIB_ARRAY_INTEGER
,VERTEX_ATTRIB_ARRAY_DIVISOR
,VERTEX_ATTRIB_ARRAY_POINTER
,ELEMENT_ARRAY_BUFFER_BINDING
,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
.
I'm curious whether index buffer object data or uniforms would be somehow stored inside of VAOs? Uniforms are stored to the default uniform block which belongs to the program object.
uniform存储在属于程序对象的默认uniform块中,与顶点数组对象没有关系。