PDA

View Full Version : Only one light lit



06-16-2002, 12:35 PM
hi,

i'm using the following code to install eight lights (left, right, top ...):

for ( int i = 0; i < 8; i++){
glLightfv(GL_LIGHT0 + i, GL_AMBIENT, LightAmbient);
glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, 7.f);
glLightfv(GL_LIGHT0 + i, GL_POSITION, LightPosition[i]);
}

problem is that only light 0 functions correct. the other lights seem to shine with low intensity so that the scene is hardly lighten. the normals for the polygon are allright (from nehe) and even if i give every light the same position nothing changes. what might be the problem.
can anyone help me?

bye stephan

chowe6685
06-16-2002, 04:24 PM
have you enabled all the lights?

06-16-2002, 10:30 PM
Originally posted by chowe6685:
have you enabled all the lights?

Yeah, i enabled every light.

Bob
06-17-2002, 12:33 AM
By default, all lights are black except GL_LIGHT0 which is white. I think your other lights are still black, cause you don't set any diffuse or specular color (assuming that piece of code is all you do to the lights), so they default to RGBA=(0,0,0,1).

06-17-2002, 12:10 PM
I experimented a little bit more and found a solution. I set the ambientLight to {1,1,1,1} but more important was to change

glMaterialfv( GL_FRONT, GL_DIFFUSE , materialDiffuse );

to

glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE , materialDiffuse );

everything fine now

stephan