glLightModel

I have a problem with the function :
glLightModel.
How does it work, expecially with the pname GL_LIGHT_MODEL_LOCAL_VIEWER?
I have a room in 3D and I move through it, but the lights don’t work well.
Can anyone help me? Thanks!

I think local viewer should be set to TRUE. Hard to diagnose what you mean by ‘not working well’.

AFAIK local viewer only affects the placement of specular highlights… It’s a little slower to have it on.

Thanks for the answer
…more in details…
In my virtual room when I move along the -x axis I have the right wall and the wall in front of me good lighted but the left wall remains in the shadow. Viceversa when I move along the x axis.
I have only one light that is positioned in the point of the eye and it is direct along the axis of my direction.
The light is moved with the point of view.
I have already set to TRUE the LOCAL_VIEWER.
Could you tell me somthing to do?
Thanks

Could it be that the wall is back-facing?
check out the face normal, and the material for the back face.
Another thing: do you mean that the left wall remains in shadow when you look in its direction (ie: you rotate the camera to the left)?

Thank Paolom,
I have four walls with the normal parallel to the x and y axes and turn into the room.
I put my point of view in the middle of the room and, however I move the point of view, one of the three wall that I see remains in shadow.
I have the Material set to back and front faces.
(I don’t use the SPOT_CUTOFF)

mmh… can’t figure out
I think it’s time to see some code

Hi paolom,

//I create a room with a lot of objects

//…
void init()
{
glClearColor (1.0f, 1.0f, 1.0f, 1.0f);
glShadeModel (GL_SMOOTH);

glEnable (GL_DEPTH_TEST);
glEnable (GL_NORMALIZE);

GLfloat mat_specular[] = {0.1f, 0.1f, 0.1f, 1.0f};
GLfloat mat_shininess[] = {50.0f};
GLfloat mat_ambient[] = {1.0, 1.0, 1.0, 1.0};

glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);

//…(omissis)

}
/* DISPLAY */

void display(void)
{
GLfloat ambientLight0[] = {0.2f, 0.2f, 0.2f, 0.0f};
GLfloat diffuseLight0[] = {0.6f, 0.6f, 0.6f, 0.0f};
GLfloat specularLight0[] = {1.0f, 1.0f, 1.0f, 1.0f};

GLfloat positionLight0[] = {px, py, pz, 1.0f};
GLfloat directionLight0[] = {gx, gy, gz};

GLfloat lm_ambient[] = {0.3, 0.3, 0.3, 1.0};

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity ();

glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lm_ambient);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);

glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight0);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight0);

glLightfv(GL_LIGHT0, GL_POSITION, positionLight0);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, directionLight0);

glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);

// I move my point of view with the keybord
// at the same time the position and the // direction of the Light0 must change

gluLookAt (px, py, pz ,gx, gy, gz, 0.0, 0.0, 1.0);

displayObjects();

glFlush();
}

/* RESHAPE */

void reshape (int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(65.0, (4/3), 20.0, 2000.0);
glMatrixMode (GL_MODELVIEW);
}

//…

What do I have to do?