This topic is now archived and is closed to further replies.


Light Moving around object?

Recommended Posts

tmwsiy    122
Ok, I have been trying for a good week now to try to fix this light issue so please help if you can... I am trying to rotate an object, with the camera/lighting fixed in place, so that the object is always lit up. I set my lighting stuff up in the init() function: glShadeModel(GL_SMOOTH); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //Lighting, Coloring and so forth... glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180.0f); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); // Turn on automatic normalization for normal vectors glEnable(GL_NORMALIZE); glMaterialfv(GL_FRONT, GL_AMBIENT, bevel_mat_ambient); glMaterialfv(GL_FRONT, GL_SHININESS, bevel_mat_shininess); glMaterialfv(GL_FRONT, GL_SPECULAR, bevel_mat_specular); glMaterialfv(GL_FRONT, GL_DIFFUSE, bevel_mat_diffuse); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); The only glRotate I have is in the display function around the object I want to rotate. glPushMatrix(); //Color glColor3f(0.2f,0.5f,0.8f); //Rotation due to mouse.. glRotated(xangle,0.0,1.0,0.0); glRotated(yangle,1.0,0.0,0.0); //drawing routine displayObj(); glPopMatrix(); But when I run this you can see on the glutSolidSphere, for instance, that the light is moving around the object, because as I rotate it the "light spot" on the sphere changes position. . But I thought since the light is in init() and I have a glLoadIdentity() before it that this would not be the case??? Totally confused... ~tmwsiy

Share this post

Link to post
Share on other sites