glNormal?

I’m having some trouble understanging what the glNormal command does between glBegin and glEnd. I understand what a normal to a plane is and everything but i just don’t see how this book is useing normals to create a better looking sphere. How do normals take a bunch of triangles (making up a 20 sided object) and create a sphere. Anyhelp gere would be great thanx

The normals are used in shading calculations, not in the construction of the underlying geometry. And with smooth shading your choppy looking 20 sided object will look more closely like a sphere.

-Paul

but there were 2 sets of code:

glBegin(GL_TRIANGLES);
for (i = 0; i < 20; i++) {

glVertexfv(…)
glVertexfv(…)
glVertexfv(…)

}

glEnd();

where that created 20 sided 3d object

and :

glBegin(GL_TRIANGLES);
for (i = 0; i < 20; i++) {

glNormal3fv(…);
glVertexfv(…);
glNormal3fv(…);
glVertexfv(…);
glNormal3fv(…);
glVertexfv(…);

}

and this one takes that 20 sided object and makes it into a more sphericle object. I’m just asking if there is any real reason why this works with glNormal?

glEnd();

glNormal does not make the object itself more spherical, it makes it look more spherical.

With glNormal you set tha normal for the current vertex, that will enter the ogl pipeline with the following glVertex instruction.
Since the ‘brightness’ of the face color depends by the angle between the normal and the vector from light to face, you can get some different results changing the normals.
Flat shading (uniform color for all the face) is obtained specifing normals perpendicular to the face plane. This is used with object like cubes, ecc.
Smooth shading (a different color for all the vertices of the face, that is filled with interpolated values) is a way to approx curved surfaces with a relatively small amount of polys. With falt shading this does not works because the edges are between different colors, resulting in a discontinuous color. The trick is to assign the same color to vertices shared between different faces. If face 1,5,7 & 8 have a common vertex at 1.0,2.0,1.0 you assign at this vertex (each time you create a face that shares this vertex) a normal that is the average of all the normals you would use for flat shading of these faces…

Now I can’t understand what I wrote… hope you’ll understand!
Bye
tFz

By calling glNormal just before each glvertex call you can assign a smooth shading to the 3d object.
To do this, glNormal (before each vertex) is the result of the average of the normals of each face that share that particular vertex.

Averagin the normal of all faces sharing a specific vertex is a simple way to appproximate the vertex normal. Most of the time it will give you a satifying result, even though it might not be exact. Just as a sidenote.