Results 1 to 4 of 4

Thread: Problem with glLightfv(GL_LIGHT0, ...);

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Alicante
    Posts
    22

    Problem with glLightfv(GL_LIGHT0, ...);

    Hello.

    I'm trying to do four TTrackBar, one for each light's value. The first and second work fine, but the third and fourth don't work fine.

    My code is:

    float tipoLuz[4];

    tipoLuz[0] = ...;
    tipoLuz[1] = ...;
    ....

    GLfloat col_luz[] = {tipoLuz[0], tipoLuz[1], tipoLuz[2], tipoLuz[3]};

    glLightfv(GL_LIGHT0,GL_POSITION,pos_luz);
    glLightfv(GL_LIGHT0, GL_AMBIENT, col_luz);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, col_luz);
    glLightfv(GL_LIGHT0, GL_SPECULAR, col_luz);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    Anybody knows why?

    Thank you very much.
    Josemi.

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Problem with glLightfv(GL_LIGHT0, ...);

    You're saying the sliders for position and ambient work but for diffuse and specular they don't?
    Check the glMaterial colors and shininess you use to draw the object. E.g. you won't see an effect if those have black for those.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2003
    Location
    Alicante
    Posts
    22

    Re: Problem with glLightfv(GL_LIGHT0, ...);

    Relic, with the sliders I change the value of tipoLuz[0], tipoLuz[1], tipoLuz[2], tipoLuz[3].
    Then I use ones for position, ambient, diffuse and specular.
    When I move the first and second slider I see change, but with the third and fourth I don't see change on my model.

    Thank you again
    Josemi

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Problem with glLightfv(GL_LIGHT0, ...);

    I see, third and fourth slider are blue and alpha then.
    So if your _material_ is something like red or green, adjusting blue in the light will not have much effect. check what your glMaterial colors are for GL_FRONT and GL_BACK. Try to used white for the diffuse and specular material and dark grey for ambient to see any effect of light color changes.
    The alpha value in the lighting is purely derived from the diffuse part. All other alphas have no effect. You can find the complete lighting formula in the OpenGL specs.
    You won't see a change in alpha values if you don't draw your object with alpha blending enabled and the glBlendFunc set to something like (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).

    If that's still not it, go through your code step by step and look if you really change the values with the sliders.

    Makes sense?

    [This message has been edited by Relic (edited 02-27-2004).]

Similar Threads

  1. Replies: 1
    Last Post: 09-23-2016, 02:24 PM
  2. Size of glMaterialfv and glLightfv array
    By ramy1989 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-03-2012, 01:42 PM
  3. Shading problem? (pyglet-problem?, my problem?)
    By H2OBrain in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-03-2009, 08:31 AM
  4. OGLES 1.1 - glLightfv & GL_POSITION
    By bonfo in forum OpenGL ES
    Replies: 2
    Last Post: 10-29-2007, 02:07 AM
  5. Replies: 4
    Last Post: 09-27-2004, 06:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean