I can't understand the glNormal3f, I know that it works for 'normalize' the 'normals' of the vertex... Or something like that, but I can't understand what is the 'normal' of the vertex. Can you explain me that function? I can't understand what 'normal' means in openGL...
-
6You should read more about geometry in OpenGL before asking a question like this. Normals are one of the most fundamental pieces. – jakev Oct 31 '12 at 00:26
-
Sorry, I'm just newbie to OpenGL, I was reading a bad book, now I'm searching a new one... – Spamdark Oct 31 '12 at 14:51
-
Please be sure to accept the answer that you found most helpful. Give any other helpful answers upvotes. – Code-Apprentice Oct 31 '12 at 19:53
-
Possible duplicate of [What is a normal in OpenGL?](http://stackoverflow.com/questions/5906993/what-is-a-normal-in-opengl) – Ciro Santilli OurBigBook.com Mar 18 '16 at 14:45
2 Answers
The "normal" of a vertex is the vector which is "perpendicular" to the vertex. In mathematics "normal" is a generalization of "perpendicular". For a polygon, this "normal vector" is perpendicular to the polygon and is the same for all of its vertices. One reason you might assign different normal vectors to each vertex of a polygon is if you are covering a curved surface with very small triangles. In this case, you don't want the normal vectors of the three vertices of the triangle to all be the same.
Now what is this normal vector used for? The typical application is used for coloring calculations when lighting is enabled in OpenGL. The normal vector can determine whether the light from a light source hits a surface and what angle a light ray makes with the surface. This can then be used to determine whether the surface is shadowed or contains a specular highlight, for instance.

- 81,660
- 23
- 145
- 268
-
1I think an important distinction you left out is that a polygon doesn't technically have a normal; only its vertices do. The normals of the vertices are interpolated across the fragments of the polygon during rendering. The method of interpolation depends on the shading model. – kevintodisco Oct 31 '12 at 02:18
-
@ktodisco Thanks for pointing that out. I approached my answer from a mathematical point of view more than from the details of OpenGL. – Code-Apprentice Oct 31 '12 at 19:50
A call to glNormal
will emit the normal vector to the last emitted vertex. A vertex normal is usually calculated as the normalized average of normals of the faces incident to the vertex. The normals of faces are vector so that they are perpendicular to the plane described by the face.
This function is deprecated and you really should pick up a good/tutorial or book.
See also Vertex Normal and the associated entries.
If you should not use glVertex*
and the associated glNormal*
functions, what should you use? Shaders and VBO's. Have a look at this question.
-
It's been a while since I've done any OpenGL programming. Can you please provide a link quoting the details about deprecating this function? In particular, I'm interested in what the new alternative is. – Code-Apprentice Oct 31 '12 at 00:32
-
@Code-Guru The fixed function pipeline is deprecated as of OpenGL 3.0 and removed in the OpenGL 3.1 Core Profile. I can dig up the relevant documents, if you want. http://www.opengl.org/wiki/Fixed_Function_Pipeline is a good starting point. – pmr Oct 31 '12 at 00:42
-
That would certainly be helpful and also a nice addition to your answer here. – Code-Apprentice Oct 31 '12 at 00:43
-
@Code-Guru: In essence everything used within, including glBegin/glEnd has been removed; also there are no longer standard vertex attributes. Only generalized vertex attributes (glVertexAttrib, glVertexAttribPointer) remain. There's no longer a built in matrix math system (it was never good for anything usefull anyway), i.e. no more glMatrixMode, glLoadIdentity, glMultMatrix, glLoadMatrix, and so on. There's no longer a glTexEnv, built in lighting, texture coordinate generation (and other fixed function stuff) – everything happens through shaders now. – datenwolf Oct 31 '12 at 06:49
-
So I was reading an old tutorial... Where can I find an updated or new book/videotutorials? I'd love to learn OpenGL! – Spamdark Oct 31 '12 at 14:48