Would like to understand this about GL_LIGHT

This is a discussion on Would like to understand this about GL_LIGHT within the Game Programming forums, part of the General Programming Boards category; 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); ...

  1. #1
    Loom Weaver the dead tree's Avatar
    Join Date
    Apr 2004
    Posts
    140

    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
    Loom Weaver the dead tree's Avatar
    Join Date
    Apr 2004
    Posts
    140
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21