glReadPixels on Android

Hi Everyone, I am reading texture data on different Android devices with the goal of saving it to disk (to deal with onStart/onStop cycles)

The way I do it is like this:


glGenFramebuffersOES(1, &uiFBOId);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, uiFBOId);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, (*i)->uiGLId, 0);
glReadPixels(0,0,(*i)->iSrcSizeX,(*i)->iSrcSizeY, GL_RGBA, GL_UNSIGNED_BYTE, map);

or like this:


glGenFramebuffersOES(1, &uiFBOId);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, uiFBOId);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, (*i)->uiGLId, 0);
glReadPixels(0,0,(*i)->iSrcSizeX,(*i)->iSrcSizeY, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, map);

I check glFramebufferTexture2DOES status by calling

glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)

I know it has been mentioned that you can’t do this approach with L8A8 type textures, but what I am seeing is that:

Both RGBA and L8A8 work on Motorola Xoom, Acer A500
Neither RGBA and L8A8 work on Samsung Galaxy Nexus (phone)

Thoughts?

Here are some more details on what I have found…

Xoom and Acer both use Tegra2 chips, while Galaxy Nexus uses PowerVR.

For Tegra2’s the return value of glCheckFramebufferStatus() is

#define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5

and memory filled by glReadPixels contains valid data
(for both RGBA8888 and L8A8)

For PowerVR the return value of glCheckFramebufferStatus() is

#define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5

for RGBA8888, and

#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES                0x8CD6

for L8A8
however, in both cases the memory filled by glReadPixels contains only zeroes (which is, needless to say, incorrect)

I guess I’m just wondering why in the case of PowerVR a successful GL_FRAMEBUFFER status still gives a buffer full of zeros.

Can you paste your code here?

Beginning with Ice Cream Sandwich (API level 14), there is now a better way to copy frames rendered by OpenGL ES into an Android Bitmap which can be used with Android’s Canvas API. Use the getBitmap() method of the TextureView class. See:

http://developer.android.com/reference/ … eView.html

Regards, Clay

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.