# A little bit confused on how to set normals in this case

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;
};


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.

Thanks.

• why don't you try using average of the normals of the faces which contain that vertex? – Ali1S232 Jun 3 '11 at 16:31