Problem in lighting

Started by
0 comments, last by tomalter 21 years ago
i created a cylinder using quadrics. i tried to use lighting but i could not creat any light my cylinder always appears to be a 2D object . its only rotations that give some feel that i have create a cylinder a 3D object. please tell me what could be my mistake i have done the following GLfloat LightAmbient[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[] = { 1.0f, -1.0f, 2.0f, 1.0f }; GLvoid InitGL(GLsizei Width, GLsizei Height) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0); // Enables Clearing Of The Depth Buffer glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); / glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); glEnable(GL_LIGHT1); / glBlendFunc(GL_SRC_ALPHA,GL_ONE); glColor4f(0.5f, 0.2f, 1.0f, 0.5); quadratic=gluNewQuadric(); gluQuadricNormals(quadratic, GLU_FLAT); / gluQuadricTexture(quadratic, GL_TRUE); }
Advertisement
are you making sure to call glEnable(GL_LIGHTING) as well?

This topic is closed to new replies.

Advertisement