Hi.
I want to use glReadPixels to selected an object on the screen.
My drawObjects function draw my objects with a red variant depending of their id. So I want to catch the color in the backbuffer to be able to know on which object I have clicked. I know that this is a common method but I have not be able to make it work. Here is a portion of code, the problem is that “pixels_data” always stay at 1, wherever I click.
GLfloat pixels_data;
glDisable(GL_TEXTURE_2D);
drawObjects_SelectionMode();
glReadBuffer(GL_BACK);
glReadPixels(mouse_pos.x,mouse_pos.y,1,1,GL_RED,GL_FLOAT,&pixels_data);
glEnable(GL_TEXTURE_2D);
Any comments,sugestion,idea ???