1

I want to use the function glBufferData to fill up some indices/vertices. But I have my arrays in a std::vector and the glBufferData only allows char*.

glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_indicesEBO), m_indicesEBO, GL_STATIC_DRAW);

How can I use std::vector here?

waas1919
  • 2,365
  • 7
  • 44
  • 76

2 Answers2

2

The answer, seen HERE is:

glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(m_indicesEBO), &m_indicesEBO.front(), GL_STATIC_DRAW);

Using the pointer to the beginning of the vector with .front()

Community
  • 1
  • 1
waas1919
  • 2,365
  • 7
  • 44
  • 76
1

You can do it this way, assuming m_indicesEBO is a std::vector.

glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indicesEBO.size() * sizeof(<data type>), &m_indicesEBO[0], GL_STATIC_DRAW);
FrostyZombi3
  • 619
  • 5
  • 13