glReadPixels problem


i have a little problem with glReadPixels. Maybe someone can help me.

i have an int variable could color.
then i render a pixel by setting the color with
when i want to read out the color with
(select is defined as GLubyte) other values for red,green and blue then rendered are appearing.



The colors that get to the framebuffer are not necessarily the same colors you set with glColor. If you’re for example running in 16-bit mode, the color values get rounded to some nearby value. If you want to guarantee similar results, like for picking, use stencil buffer instead of colors.


And note that glDrawBuffer and glReadBuffer can be set to different buffers.
Default for double buffering is GL_BACK for both, so if you readback after SwapBuffers, you don’t read the image you see but some (possibly undefined) stuff from the backbuffer.

Thanks a lot.

i´m now using the stencil buffer it works just fine.