Vertex Buffer Objects (Delete process) opengl

蓝咒 提交于 2019-12-06 07:39:52

Never. You should never call glDeleteBuffersARB. Buffer objects have been core GL functionality for upwards of a decade now; if you're still using the ARB-suffixed extensions functions, STOP. If you're follow a tutorial that uses them, again STOP; it's clearly too old to be useful.

Now, when should you use glDeleteBuffers? You should use it at the same time you would delete for a regular C++ object. That is, use it when you are finished with the object. When you have no more use for it and want to get rid of it.

so can I create class for vbo with destructor which will delete vbo object? And then create objects as smart_ptr to automatize everything?

You could, but it's not going to buy you all that much. Also, you run the very real risk of waiting to delete the object until it's too late.

It is illegal to call any OpenGL function before the OpenGL context is created (and made current) or whenever a GL context is not current (for example, after you've destroyed the GL context). Attempts to do so are not good.

If you use shared_ptr to manage these resources, it becomes theoretically possible for them to outlive the actual OpenGL context. That's bad. Personally, I would prefer a more rigid management scheme, one that firmly ties the lifetime of the GL objects to that of the context.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!