Can I remove OpenGL vertex arrays after calling glDrawArrays?

I create vertex arrays on the fly on each render, and I want to delete arrays afterwards. Can I glDrawArrayscopy vertex arrays to the server? Therefore, is it safe to delete vertex arrays after a call 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 vertex arrays?

+3
source share
2 answers

Yes, this is copied immediately, so as soon as you make the call, you can do whatever you want with an array.

Also, as stated in dirkgently, you need to use delete[] vpto delete the array.

+8

, glDrawArrays. opengl . . , , , glDrawArrays.

+2

Source: https://habr.com/ru/post/1731668/


All Articles