I'm learning how to use VBOs and I'm following up on the tutorial at the bottom of this page.

So I went ahead and created a structure Vertex to hold vertex data.(coordinates and normals).

struct Vertex  {
  GLfloat  x,  y,  z;
  GLfloat nx, ny, nz;
  GLfloat   r, g,  b;
  GLfloat padding[7];

For the moment I'm trying to draw a cube.So I created an array with 8 vertices. My question is how do I set the normals?

When I used immediate rendering, I would just do a glNormal3f and proceeded to draw the vertices for that face. Now that the normals are defined on a per-vertex basis, and a vertex practically belongs to 3 faces, I'm somewhat confused as what I should do here.

Have I taken a wrong approach on making that structure, or I am missing something else.

I would also like to note that I want to make something more generic, so I don't want it to be limited to just drawing cubes.


  • \$\begingroup\$ why don't you try using average of the normals of the faces which contain that vertex? \$\endgroup\$
    – Ali1S232
    Commented Jun 3, 2011 at 16:31

2 Answers 2


As you note, every vertex can only have one normal. That means that, depending on the lighting appearance you want, you may need to duplicate vertices. Specifically, if you want the edges of the cube to have a sharp boundary, then you will need to have separate vertices for each side. Make new vertices at the exact same position and use each duplicate for a different face.

If however you want to keep the vertices shared between multiple faces and have the lighting smoothed out over the edge, then you should set the normal of the vertex to the average of the normals of its faces.


The answer for your "cube" problem is probably that you're probably going to need more than 8 vertices. Make 4 for each face and set the normals for them to be the normal of the surface.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .