Normals in Vertex Buffer Object

Hi folks,

I have a small problem with VBOs,

for example, if we want to render a simple BOX the VBO syntax requires something like

   GLfloat vertices[] = {1,1,1,  -1,1,1,  -1,-1,1,  1,-1,1,
                   1,-1,-1,  -1,-1,-1,  -1,1,-1,  1,1,-1};


GLfloat normals[] = {0.577, 0.577, 0.577, -0.577, 0.577, 0.577, -0.577, -0.577, 0.577, 0.577, -0.577, 0.577, 
                     0.577, -0.577, -0.577, -0.577, -0.577, -0.577, -0.577, 0.577, -0.577, 0.577, 0.577, -0.577};

GLfloat colors[] = {1,1,1,  1,1,0,  1,0,0,  1,0,1,
                    0,0,1,  0,0,0,  0,1,0,  0,1,1};

GLushort indices[] = {0, 1, 2, 0, 2, 3,
                       0, 3, 4, 0, 4, 7, 
                       0, 7, 6, 0, 6, 1, 
                       1, 6, 5, 1, 5, 2, 
                       5, 4, 3, 5, 3, 2, 
                       4, 5, 6, 4, 6, 7};

observe that, for each vertex there is a normal, i want to use an only normal for each facet (triangle). Is it possible?

Thanks in advance,

Yalmar

observe that, for each vertex there is a normal, i want to use an only normal for each facet (triangle).
You can use flat shading. That will only use the first normal passed for a particular triangle.

Thanks for answer my question Korval, do you have any example? or some reference where i can see how to use that.

Thanks again,

Vertices with different normal are different vertices… so a simple box requires 24, because for each of the 8 vertexposition 3 different normals exist. The index is for that type of primitive needless.

Sorry, I understand now,

glShadeModel(GL_FLAT);

simple, right?

Thanks Korval,

Isn’t it one normal per face?
Like one normal per 4 verts for quads and one normal per 3 verts for triangles?
I always thought it worked like this but this post has confused me.

It is always one normal per vertex.