View Full Version : glNormalPointer with face normals?
10-01-2003, 07:29 AM
Is it a fact that glNormalPointer, etc, only work with vertex normals? Is there any way to tell OpenGL to use face normals?
10-01-2003, 08:03 AM
Opengl doenst have facenormals, only vertex ones. when you send one normal first, and then 3 verices its just that the same normal is used on all vertices ( statemachine.. until you chang ethe state it will become the same).. so just replikate the normal 3 times.
then you have shading which can be flat or smooth where flat just use the first vertex normal of the triangle, but that works even if you send one normal per vertex.
10-01-2003, 09:16 AM
Both of you are assuming I'm using immediate mode. I'm not. I'm using glDrawElements. Hence glNormalPointer(). The problem is that I have my face indices setup, but OpenGL is indexing my normals array as though it is an array of normals for each vertex -- which it's not. It's an array of normals for each face.
So I'm wondering, is there a way to tell it to iterate through the array as though it was an array of face normals vs. vertex normals?
10-01-2003, 09:58 AM
Each vertex you send to opengl always has one normal. You can't have some with a normal and some without. When the shading model is GL_FLAT OpenGL uses the normal in the first vertex of each primitive for shading calculations.
If you need correct flat shading you either need to remove vertex sharng completely and just have three unique vertices for every triangle or be really careful with the order of your triangle indices so the first vertex always contains the correct normal. The last suggestion might not be possible in practice.
10-01-2003, 10:09 AM
Yeah, I tried it with GL_FLAT and it still seems to be using my normal array as though it was for each vertex. I guess I could just triplicate my face normals, or I could take the plunge and calculate vertex normals... problem is this isn't as easy as this is a morphing object. Ohwell...
Just make sure each vertex in the geometry has the same normal as other vertices in the same face...this can easily be done with or without immediate mode.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.