Category : mouse-picking

I want to do mouse picking based on colors. Here is my code: bool Geometry::IsObjectClicked(int x, int y, float color[4]) { glFlush(); glFinish(); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); struct { GLubyte red, green, blue; } pixel; glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixel); float clickedColor[3]; clickedColor[0] = (float)((float)pixel.red / 255); clickedColor[1] = (float)((float)pixel.green / 255); clickedColor[2] = (float)((float)pixel.blue ..

Read more