Advertisement
Benjamin_Loison

void Gl_object::initializeTranslations(vector<glm::vec3> tra

Aug 8th, 2018
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. void Gl_object::initializeTranslations(vector<glm::vec3> translations)
  2. {
  3.     initializeTexture();
  4.     m_size = translations.size();
  5.  
  6.     //Init second VBO with translations
  7.     glBindBuffer(GL_ARRAY_BUFFER, m_translationVBO);
  8.     glBufferData(GL_ARRAY_BUFFER, m_size * sizeof(glm::vec3), &translations[0], GL_STATIC_DRAW);
  9.     glBindBuffer(GL_ARRAY_BUFFER, 0);
  10.  
  11.     //Send vertex attrib to VAO
  12.     glBindVertexArray(m_VAO);
  13.     glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
  14.     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
  15.     glEnableVertexAttribArray(0);
  16.     glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, ((char*)NULL + (m_vertice)));
  17.     glEnableVertexAttribArray(1);
  18.     glBindBuffer(GL_ARRAY_BUFFER, 0);
  19.     glBindBuffer(GL_ARRAY_BUFFER, m_translationVBO);
  20.     glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0);
  21.     glEnableVertexAttribArray(2);
  22.     glBindBuffer(GL_ARRAY_BUFFER, 0);
  23.     glVertexAttribDivisor(2, 1);
  24.     debug("GLObject initRender");
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement