将“顶点缓冲对象"绑定到“顶点数组对象"后,我应该删除吗? [英] Should I delete `Vertex Buffer Object` after binding it to `Vertex Array Objects`?

查看:168
本文介绍了将“顶点缓冲对象"绑定到“顶点数组对象"后,我应该删除吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个VBO(顶点缓冲对象)和VAO(顶点数组对象),并执行了以下操作:

I created a VBO (Vertex Buffer Object) and VAO (Vertex Array Objects) and did this:

glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(...);
glVertexAttribPointer(...);
glEnableVertexAttribArray(0);
glBindVertexArray(0);

这样做之后,我能否删除vbo,然后假设一切都按顺序绘制,然后使用vao进行绘制?

Can I delete the vbo after I did this and then draw with the vao assuming everything is in order?

我知道缓冲区绑定到vao,所以我假设可以.

I know that the buffers bind to the vao so I am assuming I can.

问题是,如果我删除计算机(Intel图形)上的缓冲区,它可以很好地工作(一切都正确显示),但是在我的朋友计算机(AMD)上却没有任何显示.

The problem is, if I delete the buffer on my computer (Intel graphics) it works great (everything is displayed correctly), but on my friend computer (AMD) there is nothing displayed.

这可能是什么问题?

(顺便说一句,如果我不删除缓冲区,程序将在我的计算机和我的朋友的计算机上都可以工作)

(By the way, if I don't delete the buffers the program works both on my computer and on my friend's)

推荐答案

是的,根据OpenGL 4.5,在取消绑定VAO后合法删除 .

Yes, as per OpenGL 4.5, it is legal to delete it after you unbind the VAO.

2.6.1.2名称删除和对象删除

如果GL上下文当前正在使用该对象时删除了该对象,则其名称 立即被标记为未使用,并且某些类型的对象会自动 如5.1.2节所述,在当前上下文中不受绑定点的约束. 但是,只有在不再使用实际的基础对象时,才会删除该对象. 这种情况将在5.1.3节中详细讨论.

2.6.1.2 Name Deletion and Object Deletion

If an object is deleted while it is currently in use by a GL context, its name is immediately marked as unused, and some types of objects are automatically unbound from binding points in the current context, as described in section 5.1.2. However, the actual underlying object is not deleted until it is no longer in use. This situation is discussed in more detail in section 5.1.3.

删除缓冲区,纹理或渲染缓冲区对象后,该对象将不受任何约束 它在当前上下文中绑定到的绑定点,并与任何附件分离 绑定到当前上下文的容器对象的数量,如DeleteBuffers,DeleteTextures和DeleteRenderbuffers所述. [...] 未绑定容器的附件 对象,例如删除附加到顶点数组对象的缓冲区,该缓冲区不是 受限于上下文,不会受到影响,并继续作为参考 删除的对象,如下节所述.

When a buffer, texture, or renderbuffer object is deleted, it is unbound from any bind points it is bound to in the current context, and detached from any attachments of container objects that are bound to the current context, as described for DeleteBuffers, DeleteTextures, and DeleteRenderbuffers. [...] Attachments to unbound container objects, such as deletion of a buffer attached to a vertex array object which is not bound to the context, are not affected and continue to act as references on the deleted object, as described in the following section.

删除缓冲区,纹理,采样器,渲染缓冲区,查询或同步对象时,其 名称立即变为无效(例如,标记为未使用),但底层 对象将不再被删除,直到不再使用.

When a buffer, texture, sampler, renderbuffer, query, or sync object is deleted, its name immediately becomes invalid (e.g. is marked unused), but the underlying object will not be deleted until it is no longer in use.

如果满足以下任一条件,则正在使用缓冲区,纹理,采样器或渲染缓冲区对象:

A buffer, texture, sampler, or renderbuffer object is in use if any of the following conditions are satisfied:

  • 该对象已附加到任何容器对象
  • [...]

所以这是AMD驱动程序错误,或者情况不是您所描述的.

So either it's an AMD driver bug, or the situation is not as you describe.

这篇关于将“顶点缓冲对象"绑定到“顶点数组对象"后,我应该删除吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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