I am using openGL and am currently passing it a vertex array. The problem is that I have to create many vertices, and add them in between one another (for order). This means that using a regular array is pretty annoying/inefficient.
I want to use a data structure from STL so that I can efficiently (and easily) put new vertices at any index. The problem is that openGL expects a regular array.
Does anyone know how to go about this? Is there an easy way to convert from an STL vector to an array?
I am using openGL 1.1
Thanks
You can use a pointer to the first address of the vector as an array pointer. STL vectors are guaranteed to keep their elements in contiguous memory. So you can just do something like:
&vertices[0]
where vertices
is your vector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With