Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Question on VAO/VBOs

  1. #1

    Question Question on VAO/VBOs

    Since the VAO needs to be completely setup during initialization, what is the best way to feed new vertex data to the GPU? Is it better to recreate the VAO and VBO or to simply pass new vertex and texture data to the VBO?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    A VAO does not hold any data. You simply update your VBO once the VAO is bound. The VAO remains completely untouched by updates to the VBO's data store.

  3. #3
    Correct. If I have a function named fillVertexArray(), would all I need to do is bind the VBO, call glBufferData() and then unbind? Or is there a step missing?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    When using vertex array objects you have to be certain that

    a) you either update the buffer which is bound by the currently bound VAO
    b) or you update the buffer while no VAO is bound at all, thus not altering the bindings of the currently bound VAO
    c) or you you switch VAOs before updating the buffer you want

    Action a) is preferable. Why? Because binding and unbinding costs time and if you can determine that a buffer needs to be updated shortly before you render from the currently bound buffer (and thus VAO), you don't need to switch either of them.

  5. #5
    Quote Originally Posted by thokra View Post
    When using vertex array objects you have to be certain that

    a) you either update the buffer which is bound by the currently bound VAO
    b) or you update the buffer while no VAO is bound at all, thus not altering the bindings of the currently bound VAO
    c) or you you switch VAOs before updating the buffer you want

    Action a) is preferable. Why? Because binding and unbinding costs time and if you can determine that a buffer needs to be updated shortly before you render from the currently bound buffer (and thus VAO), you don't need to switch either of them.
    A) should work because right now I only have one VAO and one VBO. I wanted to reuse them for each object getting drawn but wasn't sure if that was the best practice. If I can simply update the buffer only as needed then great!

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    IMHO, that is the way to go. The fewer unnecessary changes the better. However, buffer sizes should probably not exceed a few MB. Test various sizes until you reach max performance.

  7. #7
    And just to make sure I have the correct understanding... in my data update function should I be using glBufferData() or look into the glMapBuffer() calls? I thought all I needed was a glBufferData() but that doesn't seem to carry over to the actual rendering. I must be missing something...

  8. #8
    Intern Contributor
    Join Date
    Jun 2009
    Posts
    85
    How about glBufferSubData..??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •