AnsweredAssumed Answered

glReadPixels does different work in ATI card.

Question asked by manny85 on Aug 16, 2012
Latest reply on Aug 21, 2012 by Andrey2007AMD

I have implemented opengl picking using FBO and glReadPixels.

(I referred tutorial site :

It works fine in NVIDIA card(GTX580). But it works strangely in ATI card(HD 7970).



[Problem 1]

It works strangely when internalFormat is 'GL_RGB32UI'. The code like below.

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32UI, WindowWidth, WindowHeight, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, NULL);

This is a part of initialization of FBO texture of tutorial I mentioned.


It also works ATI when glReadPixels get only 1 pixel. The code like below.

glReadPixels(x, y, 1, 1, GL_RGB_INTEGER, GL_UNSIGNED_INT, &Pixel);


But I want to get any range of pixels. The code like below.

glReadPixels(x, y, w, h, GL_RGB_INTEGER, GL_UNSIGNED_INT, pPixel);


But It works strangely. Anyway I fixed this like below.

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, WindowWidth, WindowHeight, 0, GL_RGBA_INTEGER, GL_INT, NULL);

glReadPixels(x, y, w, h, GL_RGBA_INTEGER, GL_INT, pPixel);

Also fixed fragment shader : uvec3 -> ivec4



Unfortunatly, it is not the end. there is serious problem I couldn't fix.

[Problem 2]

My application pick polygons of mesh. The problem occur when the mesh has a number of polygons(eg. over 3 million polygons). My Application picked rectangle range has a lot of holes and sometimes it doesn't pick nothing.

I guess glReadpixels doesn't work normally. Writing to FBO texture is no matter according to some tests I have done. The problem is not occur in NVIDIA GTX580.

Does anybody know why this problem happend and how to fix it? Any comment would be helpful for me.