#### Archived

This topic is now archived and is closed to further replies.

# glNormal with triangle strip, possible ?

This topic is 5983 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I would like to know if you could help me with a problem that I have with glNormal and GL_TRIANGLE_STRIP. I'm making a terrain. To do that, I use triangles strip. All works fine, but now, I would like to give values of normals to openGL. I've already calculated my normals and the probleme isn't there. I'm doing this :
  for (int z=0; z
When I execute this code, it generates a heightmap. But, I would like to know where to place the call for glNormal3f(). I know to do that if I use GL_TRIANGLES. I have to place it before the 3 glVertex call, but there, it's different. Have you an idea about how to do that ? I've posted this message in the GameDev OpenGL forum and A guy told me to do a call to glNormal3f() before each glVertex()... I'm okay to do this but, ...
5    6
*---*
|\  |
| \ |
|  \|
|3  |4
*---*
|\  |
| \ |
|  \|
|   |
*---*
1   2
`
(sorry, it's not very nice ) my code is making point1, point2, point3, point4 ... My normals are stored in an array. So, do you think I have to call glNormal3f() before my point1 with the value of the normal of face(1,2,3) and then glNormal3f() before my point2 with the value of the normal of face(2,3,4), etc ... ? Sorry for my very bad english. I hope that you can understand it Edited by - bestel on February 5, 2002 1:02:05 PM

##### Share on other sites
If you want the terrain look rounded and lit smoothly, you should take all the faces that the vertex is a part of and avergae the face normals together. Then call glNormal before every glVertex call.

##### Share on other sites
tsss. pourquoi les français s''excusent-ils toujours de mal parler la langue du secoueur de lance ? Euh de Shakespeare, pardon

If you use flat shading, you have to define the normal once per triangle, which in OpenGL means once before the last vertex of the triangle is rendered. For example in triangle strip, the normal have to be define before the 3rd vertex and then before every following vertex.

If you use smooth shading, you have to define the normal once per vertex, eg before every vertex.

Remember that in OpenGL, every vertex sent to GL machine (eg call to glVertex) causes the render. That is, to define colors, texture coords, normals, etc, you have to do every call (to glColor, glTexCoord, etc) BEFORE glVertex.

##### Share on other sites
I''m using smooth shading. So, if I have well understood, it means for example that I have to compute the average normal of all the yellow face and call the glNormal with this value before My glVertex() Call for the red point.

Is it true ?

##### Share on other sites

Yes that''s exactly that.

The normal is obtained by meaning all the normals of the neighbour triangles.

And of course for each triangle the normal has to be computed via a cross product.

##### Share on other sites
thank you

My last post was just there to be sure that I understood well

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631423
• Total Posts
3000003
×