Hello Guest

Vertex Buffer Arrays for Drawing a Cube

  • 2 Replies
  • 5839 Views
Vertex Buffer Arrays for Drawing a Cube
« on: March 17, 2012, 06:13:09 »
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?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Vertex Buffer Arrays for Drawing a Cube
« Reply #1 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.

Re: Vertex Buffer Arrays for Drawing a Cube
« Reply #2 on: March 17, 2012, 16:19:32 »
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!