PDA

View Full Version : glColor problem



aus79er
09-27-2002, 03:34 PM
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

What3v3r
09-27-2002, 03:54 PM
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

nexusone
09-27-2002, 04:03 PM
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?

http://www.opengl.org/discussion_boards/ubb/smile.gif



Originally posted by aus79er:
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



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

Bob
09-28-2002, 12:32 AM
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);

nexusone
09-28-2002, 04:07 AM
Yes you are correct on the interger values, I was thinking of byte values when I posted it.



Originally posted by Bob:



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);

aus79er
09-28-2002, 09:08 AM
Thanks for your explaination....

aus