reading single channel only


I am reading color data using glReadPixel. The color buffer has gray scale data so r=g=b for each pixel. When I read just one channel data for example, red channel only, the pixel values are inverted. If I read all rgb, it is OK. Why is this?

glReadPixels(…, GL_RED,…)–> inverted!
glReadPixels(…, GL_RGB,…)–> OK.

What do you have type set as? If it’s GL_FLOAT then it will return the component you want with no conversions as is. If it’s something other than GL_FLOAT, then it will multiply the component you specify by some function for conversion. Maybe it’s not using a conversion function that is good enough and is losing some bits somewhere or something. Check the man pages on glReadPixels for more detail of the conversion functions.