[Resolved] glNormal3f for a quarter cylinder

Hello,

First, sorry for my English, I’m a French student.

I’m drawing a quarter cylinder and I want it to be correctly lighted.
I simplify the code to make is more readable.

This think works:



glBegin(GL_QUAD_STRIP);
for (i=-90; i<=0; i+=precision)
{
    float angle_radians = i  * M_PI / (float)180;
    float x = rayon * (float)cos(angle_radians);
    float z = rayon * (float)sin(angle_radians);
    glNormal3f( 1., 0., 1. );
    glVertex3f(x,0,z);
    glVertex3f(x,hauteur,z);
}
glEnd();


But I want the light rendering being normal to little rectangles drawn. What follows does not work, it’s lighten as a grid:



glBegin(GL_QUAD_STRIP);
for (i=-90; i<=0; i+=precision)
{
    float angle_radians = i  * M_PI / (float)180;
    float x = rayon * (float)cos(angle_radians);
    float z = rayon * (float)sin(angle_radians);
    //glNormal3f( 1., 0., 1. );
    glNormal3f(cos(i),0,sin(i));
    glVertex3f(x,0,z);
    glVertex3f(x,hauteur,z);
}
glEnd();


By the way, if you know a glut function that draw a part of cylinder, I’m interested!

Maybe You want per-fragment lighting?
http://www.lighthouse3d.com/opengl/glsl/index.php?dirlightpix

Edit: (just noticed a bug)
You do:


    float x = rayon * (float)cos(angle_radians);
    float z = rayon * (float)sin(angle_radians);
(...)
    glNormal3f(cos(i),0,sin(i)); // <---

I think i should be replaced with angle_radians

so that was that! i => angle_radians works well. So much time spent!

I still have a difference between that and little rectangles that I draw next (I’m drawing a room will round corners) but it’s ok.