The right way to draw normals in OpenGL?

Now I am writing a program in OpenGl. I give some complex three-dimensional shapes from files. After triple checking the code, I know that all values ​​are read correctly. The only thing that acts weird is the normals. I draw them like this:

glVertex3fv(vert1); glVertex3fv(vert2); glVertex3fv(vert3); glNormal3fv(norm1); glNormal3fv(norm2); glNormal3fv(norm3); 

Values ​​are read from GLFloats. Tell me the right way, or at least what I am doing wrong.

+4
source share
1 answer

When you call glVertex , it ends the vertex, so before that you need to set all the other states of the vertices. Before you finish it, you need to set the normal for the vertex.

It should look like this:

 glNormal3fv(norm1); glVertex3fv(vert1); glNormal3fv(norm2); glVertex3fv(vert2); glNormal3fv(norm3); glVertex3fv(vert3); 
+7
source

All Articles