调用 glDrawArrays 后可以删除 OpenGL 顶点数组吗?

发布于 2024-08-20 11:03:20 字数 347 浏览 8 评论 0原文

我在每次渲染时动态生成顶点数组,然后我想删除这些数组。 glDrawArrays 是否立即将顶点数组复制到服务器?因此,在调用glDrawArrays后删除顶点数组是否安全?

float * vp = GetVertices(); // Regenerated on each render
glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), vp);
glDrawArrays(GL_TRIANGLES, 0, nVertices);
delete[] vp; // Can I do this?

否则,我如何确定何时可以安全删除顶点数组?

I am generating the vertex arrays on the fly on each render and I want to delete the arrays afterwards. Does glDrawArrays immediately copy the vertex arrays to the server? Hence is it safe to delete the vertex arrays after calling glDrawArrays?

float * vp = GetVertices(); // Regenerated on each render
glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), vp);
glDrawArrays(GL_TRIANGLES, 0, nVertices);
delete[] vp; // Can I do this?

Otherwise, how can I determine when it is safe to delete the vertex arrays?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖凝香 2024-08-27 11:03:20

是的,它会立即复制,因此一旦完成调用,您就可以对数组执行任何您喜欢的操作。

另外,正如 dirkgently 指出的,您需要使用 delete[] vp 来删除数组。

Yes, it is copied immediately, so once you've done the call you can do whatever you like with the array.

Also, as dirkgently pointed out, you need to use delete[] vp to delete an array.

向地狱狂奔 2024-08-27 11:03:20

是的,你可以在调用glDrawArrays后删除顶点数组。但opengl不会将顶点数据存储在内存中。它只会使用顶点数组并在帧缓冲区上绘制。所以下次如果你想绘制相同的顶点,那么你必须再次向glDrawArrays提供顶点数组。

Yes, you can delete the vertex array after calling glDrawArrays. But opengl won't store vertex data in it's memory. It will just use the vertex array and draws on the frame buffer. So next time if you want draw the same vertex, then you have to provide the vertex array again to glDrawArrays.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文