Global lighting?

How can I set the light so that it is global and not in one position? eg like sunlight…

This is dependent on the w field in the light position vector (x, y, z, w).
When w = 0, you get a directional light, with x, y, z, describing the light’s direction. When w = 1, you get a positional light, with x, y, z, describing the position of the light.
For sunlight a directional light is what you would use:

GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);

where the light points in the direction of the (1.0, 1.0, 1.0) vector.

If you want every object in your scene to have the same color, this is called ambient light.

GLfloat light_ambient = {1.0, 1.0, 1.0, 1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);

I am not sure which you meant by your post, either one could be used for your problem. It depends on the effect you want.

Hope I helped.

[This message has been edited by thebamaman (edited 01-03-2002).]

yeah, you helped a lot.
It was the directional light I was looking for… one more question about that… does the light direction vector need to be normalized?

Originally posted by Jax:
does the light direction vector need to be normalized?

No, I don’t think that would have any effect, but I could be wrong. It might help, but I’m not sure.

[This message has been edited by thebamaman (edited 01-04-2002).]