Omni light?

How can I create a omni light? And I don’t want it to put a new color on my objects, is this possible?
It’s kinda hard to get a ball look like a ball without a light… :stuck_out_tongue:

Hi there!

Since, I am not a native english speaker (as everybody figured out already ), I am not really sure If I got it (sorry).

Ever tried a light that only emits a ambient color?

Just a thought,


No, I haven’t but that’s what I would like to know how to do…

/me are not from an english speaking country either. :slight_smile:

i want to know that also?!!
how did they do that?!!!

OK, here is something that should work :

GLfloat AmbientColor[4]={0.2,0.2,0.2,1}; // Ambient - Grey
GLfloat DiffuseColor[4]={0.2,0,0,1}; // Diffuse - Red
GLfloat SpecularColor[4]={0.0,0.2,0.2,1}; // Specular - Cyan
GLfloat Position[4]={0,0,100,1}; // Light Position at (0,0,100);
Note : the 4th coordinates is !=0 for a positional light
(when you give its actual position !) and 0 for a directional light
(ie : for the sun. A light that is far, far away is directional).

GLfloat Direction[3]={0,0,0}; // Light Direction
Note : the direction is used only when you specify a value which
is not 180 for GL_SPOT_CUTOFF. If you do that, you do not have uniform
lighting anymore. But here, we want an omni light so the direction
is not important…

GLfloat SpotExponent=0;
Note : this specifies how focused is your light beam. But for an
omni light, there is no beam !

GLfloat SpotCutOff=180; // See above //
GLfloat m_ConstantAttenuation=1;
GLfloat m_LinearAttenuation=0;
GLfloat m_QuadraticAttenuation=0;
Note : this means we do not attenuate the light according to
its distance from the light source */


/Now, if you do not want to assign material to your objects but
want the objects to use what you specify with glColor, you have
to use the following :


/* This means that the Ambient and Diffuse material will use the
values specified by glColor. Otherwise, you have to use glMaterial.
Note that there are plenty of different parameters so you should
have a look at glColorMaterial function in your docs. */


/* This enable the Color Material mode we specified above */

I hope I did not forget anything.

It was a real pain for me to understand OpenGL lights when I started so I really know what you are feeling.

Nevertheless, after some practice on simple things, you should be able to do whatever you want with the lights.

Have fun and do not hesitate to contact me if this code does not work.

Best regards.


From what I get from your post, CyBBe, you’re looking for a directional light… That will light up the whole scence, kinda like (as Eric said) sunlight. A positional light is like a lightbulb. The farther an object is from it, the dimmer it is. A directional light should be quite a bit faster than a positional one… Hopefully this is understandable…