You can choose whether to have a light source that's treated as though it's located infinitely far away from the scene or one that's nearer to the scene.
The first type is referred to as a directional light source; the effect of an infinite location is that the rays of light can be considered parallel by the time they reach an object. An example of a real-world directional light source is the sun.
The second type is called a positional light source, since its exact position within the scene determines the effect it has on a scene and, specifically, the direction from which the light rays come. A desk lamp is an example of a positional light source. Example:
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; // direction light
or
GLfloat light_position[] = { 1.0, 1.0, 1.0, 1.0 }; // positional light
glLightfv(GL_LIGHT0, GL_POSITION, light_position); // Set position
You supply a vector of four values (x, y, z, w) for the GL_POSITION parameter.
If the w value is nonzero, the light is positional, and the (x, y, z) values
specify the location of the light in homogeneous object coordinates.
This location is transformed by the modelview matrix and stored
in eye coordinates.
By default, a positional light radiates in all directions, but
you can restrict it to producing a cone of illumination by defining the light
as a spotlight.