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 3 of 3

Thread: Unbinding things after you use them

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    12

    Unbinding things after you use them

    Right, now I unbind targets with glBindBuffer(GL_ARRAY_BUFFER, 0); after I finish using each VBO. Similarly, I reset the "active program" using glUseProgram(0); after I finish using them. Is there any benefits or drawbacks to this?

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    More GL calls can eat some performance and there is no direct advantage of:
    Code :
    glUseProgram( foo );
    glUseProgram( 0 );
    glUseProgram( bar );
    glUseProgram( 0 );
    // next frame
    glUseProgram( foo );
    ...

    over just:

    Code :
    glUseProgram( foo );
    glUseProgram( bar );
    // next frame
    glUseProgram( foo );
    ...

    You only might catch errors in your program more easily if for example you draw something without setting the correct VAOs or shaderprograms if you also unset all of them, so you will try to draw with program 0 and VAO 0 instead of the one that just happens to be active (and might work for a while making the bug even harder to find later on). But apart from that 'cleaning up' might not help you much if you do that each frame.

  3. #3
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    12
    Thanks, noted!

Posting Permissions

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