Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top