glReadPixels is failing...sometimes...on just one computer

I’m using glReadPixels in my app for object picking and screen capture, and it works on all computers so far, except one. On the problem computer, glReadPixels only works intermittently. I have found that there are two conditions where glReadPixels will work correctly on this machine:

  1. If I run the app in a window. In full screen, the viewport is 1690 x 984. If I reduce this to about 1592 x 930, glReadPixels will work correctly. Larger than that, and it will fail, even in a window.

  2. If I place enough objects on the screen. I haven’t nailed down what the threshold is, but if I put enough objects on the screen, glReadPixels starts working.

I’m pretty baffled. Has anyone experienced a problem like this? Do the workarounds I’ve listed suggest to anyone where things might be going wrong?

ever tried running your application in debug mode? judging by amount of “random” behavior it might be useful. also, try gDebugger - OpenGL debugger. most probably you have a lot of OpenGL errors long before glReadPixels call.

Debug mode, yes, constantly. I haven’t even built a release version yet. But gDebugger…that’s sounds like a good idea. I’ll give that a try, thanks.

debug mode won’t be much help if you’re using dynamically allocated(new\delete) arrays instead of vector and string. it won’t give any consistent errors in case of out of bounds access and stuff like that. you will be just chasing phantom bugs.

Hello,

I also had a problem with glReadpixels : the depth buffer was invalid on parts of the view (http://www.opengl.org/discussion_boards/showthread.php/181183-Problem-with-glReadPixels-on-a-part-of-a-view-on-ATI-cards?p=1248827&viewfull=1#post1248827).
The problem was only on ATI cards with old drivers.
The only workaround that I have found in my case was to disable anti-aliasing ; with GL_*_SMOOTH or with MSAA there is a problem.