gpt4 book ai didi

c++ - 将 `Vertex Buffer Object` 绑定(bind)到 `Vertex Array Objects` 后,我应该删除它吗?

转载 作者:可可西里 更新时间:2023-11-01 16:09:25 27 4
gpt4 key购买 nike

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

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

我可以在完成此操作后删除 vbo,然后假设一切正常,然后使用 vao 绘制吗?

我知道缓冲区绑定(bind)到 vao 所以我假设我可以。

问题是,如果我在我的计算机(Intel 图形)上删除缓冲区,它会工作得很好(一切都正确显示),但在我的 friend 计算机 (AMD) 上没有任何显示。

这可能是什么问题?

(顺便说一句,如果我不删除缓冲区,程序在我的电脑和我 friend 的电脑上都可以运行)

最佳答案

是的,根据 OpenGL 4.5,在您取消绑定(bind) VAO 后删除它是合法的

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.

5.1.2 Automatic Unbinding of Deleted Objects

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.

5.1.3 Deleted Object and Object Name Lifetimes

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:

  • the object is attached to any container object
  • [...]

所以要么是 AMD 驱动程序错误,要么情况与您描述的不一样。

关于c++ - 将 `Vertex Buffer Object` 绑定(bind)到 `Vertex Array Objects` 后,我应该删除它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41520764/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com