I\'ve written a model loader in C++ an OpenGL. I\'ve used std::vectors to store my vertex data, but now I want to pass it to glBufferData(), howeve
This should do the trick:
&vertices[0]
Some prefer &vertices.front(), but that's more typing and I'm bone lazy.
To be even lazier, you could overload glBufferData thus:
template
inline void glBufferData(GLenum target, const vector& v, GLenum usage) {
glBufferData(target, v.size() * sizeof(T), &v[0], usage);
}
Then you can write:
glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
and also avoid bugs (your struct is bigger than 3 * sizeof(float)).