Problem with lighting on cylinder OPEN GL C

Here is my code but I am not getting any lighting on my cylinder. I am new to OpenGL so very confused with this stuff. I am wondering if my error is in (white, black) using the light.

void draw_cylinder(GLfloat radius,
                   GLfloat height,
                   GLubyte R,
                   GLubyte G,
                   GLubyte B, double xx,double yy,double zz)
{
    GLfloat x              = 0;
    GLfloat y              = 0;
    GLfloat angle          = 0.0;
    GLfloat angle_stepsize = 0.1;
    float white[] = {1,1,1,1};
    float black[] = {0,0,0,1};
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,shiny);
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,white);
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,black);
    glPushMatrix();
    glTranslatef(xx,yy,zz);
    glRotatef(90, 0, 0.0, 0.0);;
    /** Draw the tube */
    glColor3ub(R-40,G-40,B-40);
    glBegin(GL_QUAD_STRIP);
    angle = 0;
        while( angle < 2*PI ) {
            x = radius * cos(angle);
            y = radius * sin(angle);
            glVertex3f(x, y , height);
            glVertex3f(x, y , 0.0);
            angle = angle + angle_stepsize;
        }
        glVertex3f(radius, 0.0, height);
        glVertex3f(radius, 0.0, 0.0);
    glEnd();
    glPopMatrix();;
}


Read more here: https://stackoverflow.com/questions/64417839/problem-with-lighting-on-cylinder-open-gl-c

Content Attribution

This content was originally published by Jameson Marzak at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: