Thread: Would like to understand this about GL_LIGHT

  1. #1

    Would like to understand this about GL_LIGHT

    Code:
     // GL lights initialization:
    glLightfv(GL_LIGHT2, GL_AMBIENT, LightAmbient);
     
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
    glLightf(GL_LIGHT1, GL_SPOT_CUTOFF,90.0f);
    glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, LightSpotDirection);
    glLightf(GL_LIGHT1,GL_SPOT_EXPONENT,0.4f);
    glEnable(GL_LIGHT1); 
    glEnable(GL_LIGHT2);
    Notice I used GL_LIGHT2 only for the ambient light.
    Right now it is working the way I want, but if I simply change it to GL_LIGHT1, the ambient light gets way, way darker.

    Any ideas why this happens?

  2. #2
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    because of this line
    Code:
    glLightf(GL_LIGHT1,GL_SPOT_EXPONENT,0.4f);
    I am pretty sure at least.

  3. #3
    Uhm, I tried testing with all lights set to 1, and the darkness only occurs when I enable GL_SPOT_CUTOFF. Then I tried changing the spot exponent value, but nothing seemed to change, even if it is set to 0.01f.
    But anyway, shouldn´t the ambient light be completely independent from any diffuse lights? At least I was sure so

Popular pages Recent additions subscribe to a feed