How to update the vertex array object when updating the vertex buffer object that it uses?

Updating VBO (especially its size) with glBufferData () can potentially change its physical memory address, but not its buffer name given by glGenBuffers (). The VBO is associated with the VAO by calling glVertexAttribPointer (), where information about the VBO (name of the buffer object? Memory address?) Is stored in the VAO. VAO becomes available for updating and drawing when it is bound through glBindVertexArray (). Does GL mean the VBO address at that moment? A VAO may or may not be bound when the VBO to which it refers is updated via glBufferData ().

Depending on when the name of the buffer object is translated to a physical memory address, I can imagine that a VAO can only be updated for a modified VBO by binding the VAO again after changing the VBO; or you may need to update VAO in more detail with another call to glVertexAttribPointer ().

So part of this question: what information about VBO is stored in VAO? If this is just the name of the buffer object, then after changing the contents of the VBO, it is not necessary to call glVertexAttribPointer ().

Perhaps such details are not part of the API specification, so the only safe practice is to update the VAO via glVertexAttribPointer () after each update of the associated VBO.

+4
source share
1 answer

, VBOs . , GL_ARRAY_BUFFER, , .

, glBufferData (...) ( , ), . , , ; ( ).


: ( )

GL_ARB_vertex_attrib_binding:

2.9.6 " "

-,       VERTEX_ATTRIB_BINDING , .        VERTEX_ATTRIB_RELATIVE_OFFSET        VERTEX_BINDING_OFFSET (        ) .

    bindingIndex = VERTEX_ATTRIB_BINDING[attribIndex];
    buffer = VERTEX_BINDING_BUFFER[bindingIndex];

    if (buffer->name != 0) {
        address = buffer->baseAddress + 
                  VERTEX_BINDING_OFFSET[bindingIndex] + 
                  VERTEX_ATTRIB_RELATIVE_OFFSET[attribIndex];
    }

/ OpenGL (4.3), , , , , . API , ( , GL_ARRAY_BUFFER ).

, (, glDrawArrays (...)).

+7

Source: https://habr.com/ru/post/1570932/


All Articles