PDA

View Full Version : Normals and GL_TRIANGLE_STRIP



ToddAtWSU
04-20-2006, 06:05 PM
I know how to calculate a normal for polygons. Like if I did glBegin( GL_TRIANGLES ) I would do a glNormal followed by 3 glVertex calls and you repeat this process for each triangle. But I need to draw my triangles as strips so how do I calculate the normals for this since when I add a 4th and each additional pixel after that, I would need a new normal to be calculated? Is this possible? If my question does not make sense, please tell me what confuses you so I can clear up the confusion. Thanks for your help!

Humus
04-20-2006, 06:46 PM
If you want per face normals you can't use a triangle strip, you'll have to use GL_TRIANGLES.

ToddAtWSU
04-20-2006, 07:24 PM
I want normals for lighting and shading. I was reading through some examples in the Superbible and it talked about using normals on a per/polygon basis. Can I do lighting and shading with a normal per/vertex basis? I am plan to do more reading tonight on lighting and shading but any more help would be great. Thanks!

jtipton
04-20-2006, 11:06 PM
You can perform lighting on a per-vertex basis. The normals will be interpolated across the polygon if smooth shading is enabled. Flat shading will eliminate the normal interpolation.

ToddAtWSU
04-21-2006, 07:48 AM
So I need to just calculate the normals at the vertices then? And everytime I do a glVertex, right before it do a glNormal? Thanks again!

Matt Zamborsky
04-21-2006, 09:06 AM
Originally posted by jtipton:
You can perform lighting on a per-vertex basis. The normals will be interpolated across the polygon if smooth shading is enabled. Flat shading will eliminate the normal interpolation. Normals won't be interpolated across the polygon, only the resulting color, which will be computed per vertex(Normal dot ligtvector). What you mean is per pixel lighting, for this kind of lighting, shaders or some extensions are needed.

jide
04-21-2006, 11:26 AM
Or you can use 3 times the same normal for each vertex of a polygon.

jtipton
04-22-2006, 06:58 AM
Sorry about the typo from my previous post. My recommendation stays the same however. Per-pixel lighting is not what Todd is looking for.

Marc
05-08-2006, 09:22 AM
OpenGL is a state machine, which means, that any variable stays the same until you modify it. That means, that you could set the normal one time and then draw thousands of quads/triangles/whatever all with the same normal when you never call glNormal again.
On the opposite side you also could change the normal for a triangle three times, so that every vertex has it's own normal vector.
At triangle strips you can only apply one normal to one vertex, which means, that up to three triangles share one normal for their common vertex.
For spheres it's no problem, but a cube can't be rendered this way.