Hi to all, sorry for my English and silly questions, simply I’m new in business. OK, here’s my problem. I’m drawing few objects using display lists and rotating them using mouse. The trouble is that I want light to remain in one point and not to rotate or move with drawn objects. Tell me what I’m doing wrong. I initialize GL, set viewport, set lights, load objects from file, calculate vertex normals, and prepare display lists (each object to a different list, no light calls during creating lists). Finally while drawing a frame I do not call glLightfv( GL_LIGHT0, GL_POSITION… at all, or call it before rotating and translating anything, but light moves anyway. Code looks like this:
{
glMatrixMode( GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glLoadIdentity();
glRotatef(XRotation+XDelta,0,1,0);
glRotatef(YRotation+YDelta,1,0,0);
glColor3f(0.6,0.6,0.6);
for (unsigned int i = 1; i <= Scene->ObjectCount; i++)
{
glCallList(i);
}
glPopMatrix();
glFlush();
SwapBuffers(hdc);
}
I’m using C++Builder 6. As you see it couldn’t be simpler. This is light preparation code:
{
glEnable(GL_DEPTH_TEST);
glFrontFace(GL_CCW);
glEnable(GL_NORMALIZE);
glEnable( GL_LIGHTING);
glLightfv( GL_LIGHT0, GL_AMBIENT, swiatlo_ambient);
glLightfv( GL_LIGHT0, GL_DIFFUSE, swiatlo_diffuse);
glLightfv( GL_LIGHT0, GL_POSITION, swiatlo_position);
glLightfv( GL_LIGHT0, GL_SPECULAR, swiatlo_specular);
glEnable( GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glMaterialfv(GL_FRONT,GL_SPECULAR,swiatlo_specular);
glMateriali(GL_FRONT,GL_SHININESS,128);
glClearColor( 0.0, 0.0, 0.0, 0.0);
}
Did I forgot something? Or am I just stupid? I just don’t want the light to move. When I draw a sphere using auxSolidSphere every thing is perfect, and when I draw a same sphere by display the light just cant stay in one point. Help.