glColor problem

HI,
I am relatively new to OpenGL…

I am facing one problem

when I use
glColor3f(1.0f,0.0f,0.0f);

The object looks 3D

But when i use color command like this
glColor3f(250.0f,0.0f,0.0f);

It does not look 3D at all…

can any body explain me the reason…

Thanks in advance
aus

The colors in the RGBA mode are specified in the range of 0 to 1 for each component, so…there’s no sense to use 250, i guess that the 250 should be clamped to 1.0 but it seems that opengl is messing up with such a higher value.

Bye

You must remember that the letter at the end of glColor3’x’ indecates value ranges.
Puting a higher value in glcolor3f which expects a float not an interger, so you get weird results.

glColor3i rgb values from 0 to 255.
glColor3f rgb values from 0.0 to 1.0

glColor3f(1.0, 0.0, 0.0) is the same as
glColor3i(255, 0, 0)

128i = 0.5f

Got it?

Originally posted by aus79er:
[b]HI,
I am relatively new to OpenGL…

I am facing one problem

when I use
glColor3f(1.0f,0.0f,0.0f);

The object looks 3D

But when i use color command like this
glColor3f(250.0f,0.0f,0.0f);

It does not look 3D at all…

can any body explain me the reason…

Thanks in advance
aus[/b]

[This message has been edited by nexusone (edited 09-27-2002).]

glColor3i rgb values from 0 to 255.
glColor3f rgb values from 0.0 to 1.0

glColor3f(1.0, 0.0, 0.0) is the same as
glColor3i(255, 0, 0)

No, they are not the same.

Integer types are mapped so that integer value 0 is mapped to 0.0, and largest representable value is mapped to 1.0. Since a GLint is requires to have at least 31 significant bits (excluding sign bit), the color range of glColori is at least [0, 2147483647], where 2147483647 is mapped to 1.0.

These glColor-calls will all result in the same colors, assuming the standard 8 bit char, 16 bit short and 32 bit int.

glColor3f(1, 0.5, 0);
glColor3b(127, 63, 0)
glColor3ub(255, 127, 0);
glColor3s(32767, 16383, 0);
glColor3us(65535, 32767, 0);
glColor3i(2147483647, 1073741823, 0);
glColor3ui(4294967295, 2147483647, 0);

Yes you are correct on the interger values, I was thinking of byte values when I posted it.

Originally posted by Bob:
[b] [quote]

glColor3f(1, 0.5, 0);
glColor3b(127, 63, 0)
glColor3ub(255, 127, 0);
glColor3s(32767, 16383, 0);
glColor3us(65535, 32767, 0);
glColor3i(2147483647, 1073741823, 0);
glColor3ui(4294967295, 2147483647, 0);

[/b][/QUOTE]

Thanks for your explaination…

aus