Reputation: 1623
Right now I am writing a program in OpenGl. I'm rendering some-what complex 3D figures from files. After triple checking the code, I know that all the values are being read right. The only thing thats acting weird is the normals. I'm drawing them like this:
glVertex3fv(vert1);
glVertex3fv(vert2);
glVertex3fv(vert3);
glNormal3fv(norm1);
glNormal3fv(norm2);
glNormal3fv(norm3);
The values are being read from GLFloats. Tell me the right way, or at least what I'm doing wrong.
Upvotes: 4
Views: 1384
Reputation: 35933
When you call glVertex
, that finishes a vertex, so you need to set all the other vertex state before that. You need to set the normal for a vertex before finishing it.
It should look like this:
glNormal3fv(norm1);
glVertex3fv(vert1);
glNormal3fv(norm2);
glVertex3fv(vert2);
glNormal3fv(norm3);
glVertex3fv(vert3);
Upvotes: 7