title: How do I use a pointer as an offset?
body: <p>This issue originally came up in a <a href="https://stackoverflow.com/questions/1645309/help-me-evaluate-this-casting">related question</a> of mine where I was having trouble reading some bit of code.  The answer turned out to be that this line </p>
  
  <pre><code>&amp;((GLushort *)0)[3 * mesh.sBoneBatches.pnBatchOffset[batchNum]] 
  </code></pre>
  
  <p>evaluates to be a pointer.  And it's used in </p>
  
  <pre><code>glDrawElements(GL_TRIANGLES, i32Tris * 3, GL_UNSIGNED_SHORT, &amp;((unsigned short*)0)[3 * mesh.sBoneBatches.pnBatchOffset[batchNum]]);
  </code></pre>
  
  <p>where it is <strong>interpreted as an offset</strong> to draw a subset of vertex indices.  </p>
  
  <p>My code currently requires me to do by hand some of what openGL is doing in the glDrawElements, and I can't figure out how to use the pointer as an offset.  glDrawElements uses an array of indices (named vertexIndices in my code), so I tried something like this:</p>
  
  <pre><code>vertexIndices[&amp;((GLushort *)0)[3 * mesh.sBoneBatches.pnBatchOffset[batchNum]]]
  </code></pre>
  
  <p>but that obviously failed.</p>
  
  <p><strong><em>EDIT 1:</em></strong>
     I just tried this and it compiles... still not sure if it's correct though. <code>vertexIndices + (uint) &amp;((GLushort *)0)[3 * mesh.sBoneBatches.pnBatchOffset[batchNum]]</code></p>