Hello Guest

When is it safe to delete a OpenGL buffer?

  • 2 Replies
  • 1203 Views
*

Offline pdid

  • *
  • 22
When is it safe to delete a OpenGL buffer?
« on: January 27, 2017, 00:06:29 »
Currently I am deleting a element buffer after storing data in it and then using it to store data in a VAO attribute 'slot' (glVertexAttribPointer()). This leads to a JVM crash from the native code when I attempt to draw using the VAO. Do I need to take some other step, like waiting until the VAO is unbound, or until the VAO is deleted in order to solve this problem? To my understanding, when the method glVertexAttribPointer() is called, the data in the currently bound array buffer is copied to the VAO attribute 'slot', which would mean the VBO would be safe to delete, however it seems this is not the case. If anyone could explain what my issue is, that would help greatly. Thanks in advance.
« Last Edit: January 27, 2017, 00:55:09 by pdid »

Re: When is it safe to delete a OpenGL buffer?
« Reply #1 on: February 01, 2017, 06:33:36 »
I have the exact same question, so if anyone could help us that would be great.

*

Offline spasi

  • *****
  • 1988
    • WebHotelier
Re: When is it safe to delete a OpenGL buffer?
« Reply #2 on: February 01, 2017, 08:15:32 »
The glVertexAttribPointer() does not copy anything, it simply stores the data pointer. The buffer containing the data (whether a VBO or a client buffer) must remain live until rendering has finished.