Results 1 to 4 of 4

Thread: glReadPixels on Android

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    2

    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:

    Code :
    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:

    Code :
    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
    Code :
    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?

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    2

    Re: glReadPixels on Android

    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
    Code :
    #define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5
    and memory filled by glReadPixels contains valid data
    (for both RGBA8888 and L8A

    For PowerVR the return value of glCheckFramebufferStatus() is
    Code :
    #define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5
    for RGBA8888, and
    Code :
    #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.

  3. #3

    Re: glReadPixels on Android

    Can you paste your code here?

  4. #4
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: glReadPixels on Android

    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

Similar Threads

  1. glReadPixels too slow
    By e7fendy in forum OpenGL ES 2X - for programmable 3D graphics pipelines
    Replies: 1
    Last Post: 09-05-2011, 02:01 PM
  2. glReadPixels just returns 0s in Android.
    By as32b in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 07-18-2010, 11:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •