I’m trying to implement selection mechanism using unique colors.
If I try to get color info for a single pixel everything works just fine and I always get correct color.
…
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
…
But if I try to get color info for a rectangular group of pixels I don’t get correct colors
…
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glReadPixels(x, viewport[3] - y, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
…
According to the gotten results, it seems that some of the pixels are missed somehow…
Additional information…
For example if a blue QUAD is drawn so that it is spread all over the viewport and if I read pixels with
…
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glReadPixels(viewport[0],viewport[1],viewport[2],viewport[3], GL_RGB, GL_UNSIGNED_BYTE, pixels);
…
I’ll get that color of some pixels is (0,0,255) and color of the other pixels is (255,255,255).
Shouldn’t it be (0,0,255) for all pixels? That’s why I said it seems that some pixels are missed…