LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: When is it safe to delete a OpenGL buffer?  (Read 537 times)

pdid

  • Newbie
  • *
  • Offline Offline
  • Posts: 21
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.
Logged

Fred

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
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.
Logged

spasi

  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1835
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.
Logged