Vertex Buffer Arrays for Drawing a Cube

Started by TimmerCA, March 17, 2012, 06:13:09

Previous topic - Next topic

TimmerCA

Hi,

I'm trying to understand how to use glDrawElements to draw an object that has lots of shared vertices (like a cube) but that needs to use a different surface normal for each vertex depending on which face of the cube is being drawn.  It seems to me that it's not possible to re-use vertices in this way if each face has a complete different surface normal.  Or am I not understanding something here?

spasi

That is correct. You can reuse vertices only when all the components of the vertex format are identical. If there's a discontinuity in one of the components (whether it's the normal or tex-coord or whatever), you have to duplicate vertices. A cube by definition has different normals for each face, so there's no point using vertex indices.

TimmerCA

Quote from: spasi on March 17, 2012, 13:13:07
That is correct. You can reuse vertices only when all the components of the vertex format are identical. If there's a discontinuity in one of the components (whether it's the normal or tex-coord or whatever), you have to duplicate vertices. A cube by definition has different normals for each face, so there's no point using vertex indices.

Got it; thanks!