0

I have a question regarding OpenGL glBufferData() method.Can I pass the vertex data in structures like std::vector ,std::list or it must be a classic ( [] )array of numbers?

Michael IV
  • 11,016
  • 12
  • 92
  • 223

2 Answers2

3

You have to pass a classic array to glBufferData() (the OpenGL API is defined in C). However, you can use std::vector<> by converting it to an array with &v[0] (also see Converting between C++ std::vector and C array without copying).

Community
  • 1
  • 1
Antti
  • 11,944
  • 2
  • 24
  • 29
  • Got you ,thanks for the answer.I mistakenly assumed other types could be used as well.Saw a code snippet with a custom data type name.But then found the typedef which eventually was array of floats .Thanks. – Michael IV Jan 14 '12 at 18:37
1

It basically needs an array. You should be able to use a std::vector, since it requires contiguous storage. Most others, including std::list, won't work. For std::list, it would need to be written to follow pointers, and know enough about the internals to be able to find the pointers -- but that's likely to vary between implementations, and may even change by passing different flags with the same implementation.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111