# Colors: glColor3f(0.3, 0.3, 0.3 )???

Hi to everybody,
How do I know what his color is?

I know that (1.0,0.0,0.0) is red,
(0.0,0.1,0.0) green
(0.0,0.0,0.1) blue

So how do I can come up with glColor3f(0.0, 1.0, 0.5);
glColor3f(0.5, 0.5, 0.5); or glColor3f(0.3, 0.3, 0.3 )???

Thanks.

(0.0,0.1,0.0) green
(0.0,0.0,0.1) blue

That’s true, but they are a dark green and blue. 0.0, 1.0, 0.0 would be a full intentsity green, 0.0, 0.0, 1.0 a full blue.

0.0, 1.0, 0.5 == Sort of a green blue, full green component, and blue at half

0.5, 0.5, 0.5 == 1/2 intensity gray

0.3, 0.3, 0.3 == about a 30% gray, darker than the 50% gray above.

If you don’t know anything about color mixing, you should play with some paint program that lets you define your colors. Most paint programs use unsigned bytes for each color component rather than a float, though. In those cases you just have to realize that 0.0-1.0 for float colors is the same as 0-255 for unsigned byte colors.

If you have a paint program (let’s say Paint Shop Pro) just select a color and somewhere in the pick color dialog you’ll se RGB values.
To use these values in OpenGL, you must calculate them with formula: 1/255 * value (0 -255)

Or use glColor3ub(255,255,255);

Originally posted by M/\dm/
:
Or use glColor3ub(255,255,255);

I’m just starting out here Is glColor3ub() slower in any way? I mean is there any casting involved? Can I use something similar for coordinates?

Thanks.

I think the glColor3ub(…) takes our values and divides them by 255. I don’t think it deals with them in that format. So it’s a few extra steps, but nothing that will be noticable. Of course i could be wrong and OpenGL deals with color values in integers…in which case, the glColor3f(…) would be slower. But i think the first senario is more plausible. For coordinates being integers instead of floats, it woudl be glVertex3i(…) or for double it would be glVertex3d(…) and so on. Most opengl calls let you decide on the type of data that goes in by the suffixes to the function names. They couldnt’ make overloaded functions because that doesn’t exist in C.

• Halcyon

My personal take on this kind of thing is that you should use whatever data format your application will be happiest with.

Who am I to assume that I can (a) second guess the client drivers as to what they’d prefer, and (b) implement a more efficient data conversion than whatever the drivers are doing?

They’re providing a driver that implements the OpenGL interface - part of that contract is that they’re happy to do all necessary data conversions as long as you tell them what format you’re passing them data in.