LWJGL Forum

Programming => OpenGL => Topic started by: TimmerCA on March 17, 2012, 06:13:09

Title: Vertex Buffer Arrays for Drawing a Cube
Post by: TimmerCA 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?
Title: Re: Vertex Buffer Arrays for Drawing a Cube
Post by: 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.
Title: Re: Vertex Buffer Arrays for Drawing a Cube
Post by: TimmerCA on March 17, 2012, 16:19:32
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!