Values go from 0 to 255.
So what will happen when you divide by 256?
255.0/256.0 = 0.99609375
which is NOT WHITE.
And if you want to convert 0.0 to 1.0
to the 0 to 255, mult by 255.
How to make colour to a quad other than RGB.
There is a *range of 256 *values.
The highest *value is 255 because we count 0.
You divide by the highest *value (255) of the *range (256 values) to normalize it.
1 = 0/255
2 = 1/255
3 = 2/255
...
256 = 255/255
If you can't wrap your mind around this now, then have something to drink, bust out a pen and paper, start reading some discrete mathematics books. You'll eventually get it.
The highest *value is 255 because we count 0.
You divide by the highest *value (255) of the *range (256 values) to normalize it.
1 = 0/255
2 = 1/255
3 = 2/255
...
256 = 255/255
If you can't wrap your mind around this now, then have something to drink, bust out a pen and paper, start reading some discrete mathematics books. You'll eventually get it.
Quote:Original post by Decrius
Hmm yes, but it must be divided by 256 somehow, else it will never be right, will it?
Take 127, considered to be grey. 127 / 255 != 0.5
Right, because 127 isn't the center of the range (0,255). 127.5/255 = 0.5
I think what the op is asking is how to color each vertex individually. You stated that you wrote glColor3d *before* glBegin(). If you call glBegin and then call glColor3d for each vertex, each vertex can have a different color. Example:
This will give you a quad with red, green, blue and white corners, blending together in the middle. HTH
Jeremiah
glBegin(GL_QUADS)glColor3f(1, 0, 0);glVertex3f(...);glColor3f(0, 1, 0);glVertex3f(...);glColor3f(0, 0, 1);glVertex3f(...);glColor3f(1, 1, 1);glVertex3f(...);glEnd();
This will give you a quad with red, green, blue and white corners, blending together in the middle. HTH
Jeremiah
Nah, use glColor4ub or better yet glColor4ubv. The hardware works with 32 bit at a time.
Do this :
Why on earth is the OP using glColor3d?
Do this :
uint color=0xFFFFFFFF;glColor4ubv((GLubyte *)&color);
Why on earth is the OP using glColor3d?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement