   Using STL vector made of my Vec3 class in Opengl array
  Hi everyone,I need a bit of help with using other data structures than standard arrays with OpenGL. So far, I've been able to use STL vector in OpenGL:std::vector<GLfloat> verts;and using it : &verts[0]   in an OpenGL function taking in pointer to an array.I would, however, like to use a stl vector made of my own Vec3 class. My Vec3 templated class has public member variables x,y and z.I realize that the vector would return my Vec3 class rather than the Vec3's member variables.So, I guess what I'm asking is whether it is somehow possible to have a vector return member variables of its elements when used with OpenGL?I would like to avoid copying everything to a new vector or and array before rendering.Thank you very much in advance.   
  Typically, the same method will work fine even when used with your own vector class with member fields x, y, and z.In order for this to work though, the in-memory representation of an object of your vector class must start with these three floats, arranged contiguously in memory. Technically it would be ok if there were something in memory after that, as you could compensate by using the 'stride' parameter, although ideally the size of the struct/class would be exactly 12 bytes.As far as I'm aware, this is exactly what you'll get with most compilers, so it shouldn't be a problem. If you do run into padding issues though, many compilers have compiler switches that you can use to enforce certain behaviors with respect to padding.So in short, yes, you can use a vector of your own vector class, and no, you don't have to copy the data into an array of floats in order to upload the data to OpenGL.   ;  Thank you very much, will try it right away. Will post back if I have any more questions.   ;  It works, thank you again, will have to read up more on data structures and memory allocations, but your answer helped me a lot!   