PDA

View Full Version : Problem with glLightfv(GL_LIGHT0, ...);



Aquileo
02-26-2004, 03:45 AM
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.

Relic
02-27-2004, 01:28 AM
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.

Aquileo
02-27-2004, 03:50 AM
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

Relic
02-27-2004, 04:50 AM
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).]