Advertisement
Benjamin_Loison

void Gl_object::initializeRender()

Aug 5th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. void Gl_object::initializeRender()
  2. {
  3.     //initializeTexture();
  4.     //Init vertices + texCoord
  5.  
  6.     //float *vertices = m_vertices.data();
  7.     //float *texCoord = m_texCoord.data();
  8.  
  9.     //m_vertice = sizeof(vertices);
  10.     //m_tex = sizeof(texCoord);
  11.  
  12.     m_vertice = m_vertices.size() * sizeof(glm::vec3);
  13.     m_tex = m_texCoord.size() * sizeof(glm::vec2);
  14.  
  15.  
  16.     //Init shader
  17.     if(m_transparency)
  18.     {
  19.         shader = Shader("Extensions/AltisCraft/Shaders/shader4.vs", "Extensions/AltisCraft/Shaders/shader4.fs");
  20.         shader2 = Shader("Extensions/AltisCraft/Shaders/shader5.vs", "Extensions/AltisCraft/Shaders/shader5.fs");
  21.     }
  22.     else
  23.         shader = Shader("Extensions/AltisCraft/Shaders/shader3.vs", "Extensions/AltisCraft/Shaders/shader3.fs");
  24.  
  25.     //Init first VBO with vertice and texture coordinates
  26.     glGenVertexArrays(1, &m_VAO);
  27.     glGenBuffers(1, &m_VBO);
  28.     glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
  29.     glBufferData(GL_ARRAY_BUFFER, m_vertice + m_tex, 0, GL_STATIC_DRAW);
  30.     glBufferSubData(GL_ARRAY_BUFFER, 0, m_tex, &m_vertices[0]);
  31.     glBufferSubData(GL_ARRAY_BUFFER, m_vertice, m_tex, &m_texCoord[0]);
  32.     glBindBuffer(GL_ARRAY_BUFFER, 0);
  33.  
  34.     glGenBuffers(1, &m_translationVBO);
  35.  
  36.     m_indice = m_indices.size() * sizeof(unsigned int);
  37.     glGenBuffers(1, &m_IBO);
  38.     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IBO);
  39.     glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indice, &m_indices[0], GL_STATIC_DRAW);
  40.     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement