View Full Version : Normals and GL_TRIANGLE_STRIP
04-20-2006, 07: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!
04-20-2006, 07:46 PM
If you want per face normals you can't use a triangle strip, you'll have to use GL_TRIANGLES.
04-20-2006, 08: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!
04-21-2006, 12:06 AM
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.
04-21-2006, 08: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!
04-21-2006, 10: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.
Or you can use 3 times the same normal for each vertex of a polygon.
04-22-2006, 07: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.
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.