View Full Version : Parameter in glColor3f 1, 0, 0 by Example...
Why the parameters are to 1 and not to 255 in that case?
glColor3f 1, 0, 0
glColor3f 255, 0, 0 ?
10-01-2001, 04:29 AM
I think that us purely for compatibility.
It's a float (or double)
the color ranges from 0.0 to 1.0
The reason probably is for future colors that get's added hardware wise.
If we work in 16bit colors, or 32-bit
the 1.0f will not be a problem,
but when you use 255 for the color, then there is extra conversion to be done.
RGBA coloring int 32bit. Leaving 1 byte per color. Now if we had to convert it to 16 bit,
we would have to do a ((color)/255)*newratio
This would cause some extra calcualtions.
Even though you could probably wright the code not to have one div. I'm not sure if openGL put's the cpu into FPU mode, but if it does, the caculation is faster floating point wise.
So then rather than doing that whole conversion formual, you just specify a float between 0.0 and 1.0.
Ok, this information is not completely accurate. I know very little on openGL,
and would like to see someone elses comment on this maybe a bit more of an indepth explanation.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.