Trouble with light

I’m using this code for ambient light:


GLfloat light1_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
	GLfloat light1_diffuse[] = { 0.0, 1.0, 1.0, 1.0 }; 
	GLfloat light1_specular[] = { 1.0, 1.0, 1.0, 1.0 }; 
	GLfloat light1_position[] = { 20.0, 0.0, 0.0}; 
	GLfloat spot_direction[] = { 1.0, 0.0, 0.0 }; 
	glLightfv(GL_LIGHT1, GL_AMBIENT, light1_ambient); 
	glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse); 
	glLightfv(GL_LIGHT1, GL_SPECULAR, light1_specular);
	glLightfv(GL_LIGHT1, GL_POSITION, light1_position); 
	glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.5);
	glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.5);
	glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.2);
	glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 45.0); 
	glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction);
	glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 2.0);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT1);

but my scene is almost completely dark except when I do not put the line glEnable(GL_LIGHTING).What am I doing wrong?

Either you use glColor and forgot this :
glEnable(GL_COLOR_MATERIAL);

Or you scaled the scene without normalizing the normals. In this case just use :
glEnable(GL_NORMALIZE);

EDIT : try without attenuation, by commenting out these lines:
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.5);
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.5);
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.2);

Ok there is improvement but my scene now looks like this:
http://img143.imageshack.us/img143/401/mysceneaq9.th.jpg
Can you tell me why?

  1. please don’t link to a thumbnail ! Impossible to see anything.
  2. try with a white texture.
  3. use shaders to avoind clamping the color too early

Thanks!Problem solved.I checked the sphere normals again and corrected the problem.