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 8 of 8

Thread: newbie light question

  1. #1
    Intern Newbie
    Join Date
    Dec 2005
    Posts
    35

    newbie light question

    Hi,
    I drawn my scene with a grid (white lines) and a square with a texture; I'm trying to change light position and I can see the difference only on the grid; why this? why I can't change difference light in my textured sqaure; thanks
    [CODE]
    const float spec[4]={.4f,.4f,.4f,1};
    const float shin = 1;
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR ,spec);
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS ,shin);

    GLfloat light_position[4] = {0,4,2,0};
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
    glLightfv(GL_LIGHT0, GL_AMBIENT,light_ambient);
    glLightfv(GL_LIGHT0, GL_AMBIENT,light_diffuse);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_NORMALIZE);glColorMaterial(GL_FRONT_AN D_BACK,GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_COLOR_MATERIAL);
    ............................
    [CODE]
    Mickey

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2006
    Posts
    1

    Re: newbie light question

    If u want to change light position u must update your light position every frame. for example:

    void Draw()
    {
    glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

    ...... // Some Draw code
    }

  3. #3
    Intern Newbie
    Join Date
    Dec 2005
    Posts
    35

    Re: newbie light question

    this is ok; in fact I can see effect of light changing, but only on white grid! I don't see effect on sqaure textured.Why this?
    Mickey

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    913

    Re: newbie light question

    What texture function you use on the textured grid? If it is GL_REPLACE, you will need to use GL_MODULATE instead.

  5. #5
    Intern Newbie
    Join Date
    Dec 2005
    Posts
    35

    Re: newbie light question

    It's seems don't change; change luminacne of some objects drawn with glVertex() and glColor but not texture....
    Mickey

  6. #6
    Guest

    Re: newbie light question


  7. #7
    Intern Newbie
    Join Date
    Dec 2005
    Posts
    35

    Re: newbie light question

    maybe I didin't to be clear; The grid are many lines white; the textures are on a square; then there's an arrow ( drawn with gevertex,glcolor..). I can see effect of change light position on the grid, on the arrow, but not on the texture ( i can change light pos very much, but the square textures appear in the same way). Is it normal?
    Thanks
    Mickey

  8. #8
    Advanced Member Frequent Contributor Mars_999's Avatar
    Join Date
    Mar 2001
    Location
    Sioux Falls, SD, USA
    Posts
    519

    Re: newbie light question

    post a Screenshot

    here is a site that can host
    http://imageshack.us/

    and BTW do you have your normals loaded?

Posting Permissions

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