Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm reading through the OpenGL docummentation for version 3.3 core. I'm having issues understanding proper buffer deletion.

ATM i have an object that loads itself into OpenGL memory in the constructor and only exposes a VAO with the attribute pointers and a bound element array ready for rendering. When it stops existing it deletes all the buffers and sets pointers to NULL.

How do i properly delete OpenGL data? I'm going to assume that the object doesn't stop existing while it's being rendered. Do i have to do something more than just delete the VAO and then delete the buffer objects? Does that leave anything out? Should i bind the VAO disable the attributes, unbind it and then delete it?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

In general, deleting an object in OpenGL involves nothing more than calling one of the glDelete* functions, where * is the type of object. OpenGL is smart enough to not break or otherwise implode when told to delete an object that may still be used by the renderer.

If you delete an object that is still attached to another object (a buffer object in a VAO or a texture attached to an FBO), then the actual deletion is deferred until all attachments are broken or the objects attached to them are themselves deleted. So if you delete a buffer object that a VAO uses, that VAO will still work, preserving the lifetime of the buffer object until it's no longer using it.

So ultimately, you don't have to care.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.