C++ 如果我使用VAOs,是否需要调用GlenableVertexAttributeArray?

C++ 如果我使用VAOs,是否需要调用GlenableVertexAttributeArray?,c++,opengl,graphics,vbo,vao,C++,Opengl,Graphics,Vbo,Vao,我知道VAOs可以存储到VBO的绑定和索引VBO(包括GL_数组_BUFFER和GL_元素_数组_BUFFER),但现在我有一个问题: void render() { ..Set up textures, uniforms.. glBindVertexArray(vaoId)); // This also binds VBOs and indices VBOs automatically (if it was properly set up) glEnabl

我知道VAOs可以存储到VBO的绑定和索引VBO(包括
GL_数组_BUFFER
GL_元素_数组_BUFFER
),但现在我有一个问题:

void render()
{
    ..Set up textures, uniforms..

    glBindVertexArray(vaoId)); // This also binds VBOs and indices VBOs 
    automatically (if it was properly set up)

    glEnableVertexAttribArray(0); // Do I need this?
    glEnableVertexAttribArray(1); // Do I need this?
    glEnableVertexAttribArray(2); // Do I need this?

    glDrawElements(GL_TRIANGLES, indices_N, GL_UNSIGNED_BYTE, 0);

    .. cleanup..
}

即使已正确设置绑定VAO,是否仍需要调用
GlenableVertexAttributeArray

这不是必需的。您应该已经在VAO设置过程中调用了
GlenableVertexAttributeArray
,以便在VAO绑定时自动启用它们。

请参见,它应该为您解决问题。