开发者

Can I delete OpenGL vertex arrays after calling glDrawArrays?

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, G开发者_Go百科L_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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜