调用 glDrawArrays 后可以删除 OpenGL 顶点数组吗?
我在每次渲染时动态生成顶点数组,然后我想删除这些数组。 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,它会立即复制,因此一旦完成调用,您就可以对数组执行任何您喜欢的操作。
另外,正如 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.是的,你可以在调用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.