Search code examples
c++11opengl-3

Storing Vertex Array Objects in std::vector


i am writing a class for making easier the Vertex Array Object, i want to generate Vertex Array Objects in X number and store them in a std::vector.

How i can do that? I do not want to this in a loop, this is will be faster.

glGenVertexArrays(VAONumber, myVector); 

Solution

  • The std::vector class emulates an array, which means all its data is allocated in a contiguous chunk of memory, just like an array. That means you can get the whole array if you have a pointer to the very first element, i.e. &myVector[0].

    There's also a utility member function data to get this pointer.