cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

rob_bateman
Journeyman III

glReadPixels doesn't work on ATI cards?

I'm at a loss as to how to read the pixels from the backbuffer on ATI cards. Any pointers? I've tried everything, but just can't get glReadPixels to return any meaningful data on ATI cards at all. Help!?!?

0 Likes
5 Replies
nou
Exemplar

post your source code. butfor example

glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, frame);

should read data from color framebuffer.

0 Likes

 

glReadPixels(0, 0, view_width, view_height, GL_DEPTH_COMPONENT, GL_FLOAT, depth_pixels);

CHECK_GL_ERROR();

glReadPixels(0, 0, view_width, view_height, GL_RGBA, GL_UNSIGNED_BYTE, colours);

CHECK_GL_ERROR();

Both report no errors, both work on Nvidia and Intel cards. On ATI however all depth values are 1, and all colours are the clear colour. If I set the read buffer to GL_FRONT, then it works. If I set it to the GL_BACK I get *nothing*. I've tried doing this from an FBO as well, and get exactly the same results. This just affects ATI cards and I'm perplexed????



 

0 Likes

OK, have a workaround. If I render into an FBO, I can then use glCopyTexSubImage2D to copy the region I want to read to an unused mipmap level, and then finally I can I use glGetTexImage to read the pixel data back. Ugh. What a PITA. 

0 Likes

which hardware/os are you using ? as well, which pixelformat are you using ?

we have many apps (including thousands of our own tests) using ReadPixels without any issue, so your report is surprising. usually, we can see issues because of pixel ownership (reading a pixel in back/front buffer not owned by the window), but that does not seem your case.

from your description, it could be that nothing got actually rendered in your back buffer. what happens if you do a swapbuffer after your readpixels which failed ?

Pierre B.

0 Likes

Are you reading pixels after swapbuffers? I only know of copy and exchange buffer swap modes but it seems possible that the contents of the back buffer are undefined after a swap. The fact that clear values are returned is suspicious, have you tried an explicit glfinish before readpixels?

0 Likes