顶点缓冲区对象(删除过程)opengl [英] Vertex Buffer Objects (Delete process) opengl

查看:426
本文介绍了顶点缓冲区对象(删除过程)opengl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该何时调用glDeleteBuffersARB?我应该在应用程序结束时这样做吗?我可以以某种方式自动化删除顶点缓冲对象的过程吗?例如smart_ptr。

When should i call glDeleteBuffersARB ? Should I do it when application ends? Can I somehow automatize the process of deletion vertex buffer object? For instance something like smart_ptr does.

推荐答案

从不。你不应该调用 glDeleteBuffersARB 。缓冲区对象已经是核心GL功能已经十多年了;如果您仍在使用ARB后缀扩展功能,请停止。如果您遵循使用它们的教程,请再次停止;

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.

现在,您应该何时使用 glDeleteBuffers 吗?你应该使用它,同时你将 delete 为一个普通的C ++对象。也就是说,当你与对象完成时使用它。当你没有更多的用途,并希望摆脱它。

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.


所以我可以创建类vbo与析构函数将删除vbo对象?然后创建对象作为smart_ptr以自动化一切?

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.

之前调用任何OpenGL函数是非法的OpenGL上下文被创建(并且变为当前)或者当GL上下文不是当前时(例如,在销毁GL上下文之后)。

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.

如果您使用 shared_ptr 来管理这些资源,理论上可能他们比实际的OpenGL上下文。那很糟。就个人而言,我更喜欢一个更加严格的管理计划,它将GL对象的生命周期与上下文的对象牢固地联系起来。

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.

这篇关于顶点缓冲区对象(删除过程)opengl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆