Advertisement
C0BRA

Untitled

May 18th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1.     delete [] pVerts; // Obj is loaded now, we don't need these anymore
  2.     delete [] pTexts;
  3.     delete [] pNorms;
  4.  
  5.     /*
  6.  
  7.     struct vert_t{ double x; double y; double z;};
  8.     struct norm_t{ double x; double y; double z;};
  9.     struct text_t{ double u; double v; double w;};
  10.     struct colr_t{ double r; double g; double b;};
  11.     struct vertex_t{ vert_t vert; norm_t norm; text_t text; }; // this is the openglpassed one
  12.  
  13.     */
  14.  
  15.  
  16.     glGenBuffers(1, &eid);
  17.     glBindBuffer(GL_ARRAY_BUFFER, eid);
  18.     glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_t) * faces * 3, pVertexes, GL_STATIC_DRAW); // Copy data to the GPU
  19.  
  20.     unsigned short* pIndices = new unsigned short[faces * 3];
  21.     for(unsigned int i = 0; i < faces * 3; i++)
  22.         pIndices[i] = i;
  23.  
  24.     glGenBuffers(1, &aid);
  25.     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, aid);
  26.     glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short) * faces * 3, pIndices, GL_STATIC_DRAW);
  27.    
  28.     delete [] pIndices;
  29.     delete [] pVertexes;
  30.  
  31.     FacesLoaded = faces;
  32.  
  33.     return true;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement