LWJGL Forum

Programming => OpenGL => Topic started by: pdid on January 27, 2017, 00:06:29

Title: When is it safe to delete a OpenGL buffer?
Post by: pdid 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.
Title: Re: When is it safe to delete a OpenGL buffer?
Post by: Fred on February 01, 2017, 06:33:36
I have the exact same question, so if anyone could help us that would be great.
Title: Re: When is it safe to delete a OpenGL buffer?
Post by: spasi 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.