PDA

View Full Version : glReadPixels is failing...sometimes...on just one computer



ampersander7
04-28-2013, 03:27 PM
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?

Nowhere-01
04-28-2013, 03:53 PM
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.

ampersander7
04-28-2013, 08:20 PM
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.

Nowhere-01
04-29-2013, 01:40 AM
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.

AllForum
05-03-2013, 07:34 AM
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.