Is it safe to use a vertex array that’s on the stack when calling glVertexPointer() (and the other related functions)? It’s unclear to me when OpenGL actually copies the data from the passed in structure.
If isn’t safe, then how do you know when it’s safe to destroy/reuse the structure you passed to glVertexPointer()?
(Not using VBOs)
In the vertex array case the pointer will be dereferenced during the execution of
glDrawElements()and friends, assumingGL_VERTEX_ARRAYhas beenglEnableClientState()ed.As soon as
glDrawElements()returns OpenGL will have all the data it needs, so you’re free tofree().For VBOs you never pass in a real pointer, so it doesn’t really matter 🙂
So something like this should work: