如果已经在缓冲区上调用glBufferData后再调用它,是否存在内存泄漏? [英] If you call glBufferData after already calling it on a buffer, is there a memory leak?

查看:172
本文介绍了如果已经在缓冲区上调用glBufferData后再调用它,是否存在内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我以为这是分配缓冲区的原因,如果您两次调用它,旧的缓冲区会被删除,还是内存泄漏?

Since I thought this was suppose to allocate the buffer, if you call it twice, does the old one get deleted, or is there a memory leak?

我试图确定最佳选择,以便根据需要频繁更改缓冲区的大小.是使用glBufferData的最佳选择吗?我认为是这样,只要没有泄漏.

I'm trying to decide to the best option for frequently changing the size of the buffer as necessary. Is the best option to use glBufferData? I think so, as long as there is no leak.

推荐答案

OGL文档说: "glBufferData创建并初始化一个新的数据存储.绑定到目标缓冲区的任何先前存在的数据存储都将被删除." 请参阅: http://www.opengl.org/sdk/docs/man/xhtml/glBufferData.xml

The OGL documentation says: "glBufferData creates and initializes a new data store. Any pre-existing data-store bound to the target buffer will be deleted." See: http://www.opengl.org/sdk/docs/man/xhtml/glBufferData.xml

因此,多次调用glBufferData时不会发生内存泄漏. 当然zero298是正确的,您必须调用glDeleteBuffer才能最终释放为目标分配的内存.

So there will be no memory leaks when invoking glBufferData multiple times. Of course zero298 was right and you have to call glDeleteBuffer to finally free the memory allocated for a target.

这篇关于如果已经在缓冲区上调用glBufferData后再调用它,是否存在内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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