I’ve been using the back-buffer picking technique from the Red Book for years. I draw a color value from a unique object ID into the back buffer and then use glReadPixels to get the single pixel from the mouse position from the back buffer to find the hit object .
I’ve recently run into three configurations where this doesn’t work properly. When I say it doesn’t work - my debugging is finding the values read are equal to those in the front buffer not the back buffer.
The cards giving me problems are the ATI FireGL v7100, ATI Mobility FireGL, and ATI Mobility M6. Works great on other Radeon cards and all NVIDIA cards.
I’ve confirmed the OpenGL context has a back buffer and all smooth and other effects are off during rendering and reading from the back buffer.
Does anybody have a clue how to fix this (without giving up pixel based selection) or have you heard of this problem before? Here is the code used:
glDrawBuffer( GL_BACK );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glDisable( GL_LIGHTING );
glDisable( GL_TEXTURE_2D );
glDisable( GL_MULTISAMPLE_ARB );
glDisable( GL_BLEND );
glShadeModel( GL_FLAT );
glEnable( GL_DEPTH_TEST );
DrawSelectionObjects();
glFlush();
glFinish(); // put here while tyring to debug problem
unsigned int pixelValue = 0;
glReadBuffer( GL_BACK );
glReadPixels( mouseX, flippedMouseY, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixelValue );
Thanks in advance! robo