OpenGL: Inaccurate Color?

I am trying to follow the directions on this page:
http://www.opengl.org/resources/faq/technical/color.htm
regarding rendering primitives with unique color

I checked the number of bits for each color and the result was 8 for each.
When called:

 glColor3ui(0x80000000, 0, 0xFF000000);

      

and reading the pixel with glReadPixels () I get the color: 0xFFFE007F


which matches R=0x7F, G=0, B=0xFE


The bottom two bits of red and blue are wrong.

Why is this? I am using a brand new nVidia card on a Dell laptop with the most up to date drivers.

+1


source to share


2 answers


It turned out that the FAQ is common.

glColor documentation that: " Unsigned integer color components, if specified, map linearly to floating point values, so that the largest displayed value displays 1.0 (full intensity) and 0 maps to 0.0 (zero intensity)."
This actually suggests that in order to get the full white intensity I have to call:

glColor3ui(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);

      

but not



glColor3ui(0xFF000000, 0xFF000000, 0xFF000000);

      

as frequently asked questions.
And that explains why 0xFF000000 maps to 254.

I have filed a bug report for people presumably maintaining the FAQ

+3


source


Did you do that too?

In either event, you'll need to ensure that any state that could
affect the final color has been disabled. The following code will
accomplish this:

glDisable (GL_BLEND); glDisable (GL_DITHER);
glDisable (GL_FOG); glDisable (GL_LIGHTING);
glDisable (GL_TEXTURE_1D); glDisable (GL_TEXTURE_2D);
glDisable (GL_TEXTURE_3D); glShadeModel (GL_FLAT); 

      



Also check if the glReadPixels buffer is 24/32 bit.

+1


source







All Articles