PDA

View Full Version : lighting problem in movement



edwong
12-08-2003, 03:40 PM
hi,

for some reason, my lighting which will show below is moving when the world object is moving. for example, if i press the up arrow key to move up in my environemnt, the light moves also wrt to the object.

here is what i did in init()

// lighting resources
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 60.0 };
GLfloat light_position[] = { -10.0, 5.0, 1.0, 1.0 };
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_SMOOTH);

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position); // this defines position
glEnable(GL_LIGHT0);
// Turn on a light with defaults set
glEnable(GL_LIGHTING);
// Turn on lighting
glEnable(GL_COLOR_MATERIAL);

and i never change it.

any help is appreciated

thank you

jwatte
12-08-2003, 07:27 PM
Is the beginner board so deserted that there are no questions answered there? Should the boards be collapsed?

Your problem is that you don't re-specify the light when your modelview and/or orientation of your object changes.