Reputation: 13
I am currently writing an OpenGL program that creates a vertex buffer, uses it exactly once to draw a batch of triangles.
How long do I have to keep it around. Right now I just keep it until the next drawing batch gets started but I'm not sure if this is safe. The documentation in glDeleteBuffers is a bit unclear.
From the looks of it, unlike shaders, it implies that the buffer is deleted immediately. Does this also happen when the buffer is currently used for rendering or does it delay the actual deletion.
So, what's the safest way to do this without accumulating too many buffers?
Upvotes: 1
Views: 263
Reputation: 162164
You can unbind and delete the buffer object right after the glDraw…
call. It's a specified OpenGL requirement, that after a implementation keeps track of all internal references for as long as required and then cleans up internally. This holds not only for glDelete…
but to every OpenGL call that modifies data.
Upvotes: 3