title: OpenGL Interleaved Index Array
body: <p>I'm writing a class in C++ that will handle drawing 3D models (ie triangles meshes) and I'm wondering how best to organize my data buffers.</p>
  
  <p>Here's what I know so far:</p>
  
  <ul>
  <li><p>Using <b>interleaved arrays</b> speeds up the code. It makes use of spatial locality and increases cache hits. You can implement this by organizing vertices into <code>struct</code>s where each <code>struct</code> holds the position/normal/texcoord/etc. information for that vertex.</p></li>
  <li><p>Using <b>indexed arrays</b> decreases memory consumption by storing each distinct vertex/normal/texcoord/etc. only once and then defining faces by references into those arrays, rather than redundantly specifying all of the information for each face. You can <em>also</em> implement this with a <code>struct</code> of indices into lists of vertex attributes.</p></li>
  </ul>
  
  <p><b>My question:</b> How should I best make use of both of these? Is it possible to do both? I've heard for both that you should always use them when you can, but haven't found anything concerning using both at once, or one over the other.</p>
  
  <p><b>My initial solution:</b> I was going to implement a struct that had indices into the data arrays and pass an array of these structs, as well as the data arrays, as VBOs, essentially combining the two.</p>
  
  <p>Am I on the right track? Is there a better way to do this? What should/shouldn't I do? Is there anything I seem to be unaware of that would impact this decision?</p>