I used NeHe’s tutorial on creating normals and I used something like:
glNormal3f( 1.0f, 0.0f, 0.0f );
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 4.2f, 0.5f, -2.1f );
glTexCoord2f( 0.0f, 10.0f );glVertex3f( 4.2f, 0.5f, 1.0f );
glTexCoord2f( 0.0f, 0.0f );glVertex3f( 4.2f, 0.0f, 1.0f );
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 4.2f, 0.0f, -2.1f );
to create a normal facing in the positive x direction. My question the values that go into glNormals( ) parameters. Is it ok to use 1.0 for any sized polygon?
All normals if they are supposed to be used
by OpenGL HAVE to be at 1.0 (‘unit’) length. You can achive it in two ways:
1: tell OpenGL to normalize them before use
(glEnable(GL_NORMALIZE)
or 2: calculate them: length = sqrt(x^2 + y^2 + z^2);
if (length != 0) {
x /= length;
y /= length;
z /= length;
}
where x, y ,z are normal vector coordinates (stuff you put into glNormal3f(…))