Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Lighting problem

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    2

    Lighting problem

    Hi,

    I drew two yellow polygons parallel to the axis Z. Both are looking toward the positive X axis. The problem is: when the light is close to the polygon A, it becomes dark yellow. Otherwise, when the light is close to the polygon B, it becomes light yellow, as I expected. I tried to change the normal vector of the polygon A to (-1, 0, 0) and it seems to work,i.e., hen the light is close it, it becomes light yellow. I cannot figure out why the behavior is completely different for polygon A and B. What am I missing ?

    I attached a small program to show what I am talking about: the "r" key rotates the light and the arrows move the camera.

    Thanks
    Attached Files Attached Files

  2. #2
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    111
    Hello,


    You called:

    Code :
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    in your code. Last argument should be {0,0,0,1}, because light position is transformed by Modelview matrix.
    (set by glTranslate and glRotate before call to glLightfv)

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Location
    Rio de Janeiro, Brazil
    Posts
    2
    Thatīs it !

    Thanks a lot.

    Jobson

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •