Search code examples
androidopengl-esandroid-ndkadb

adb screencap output is different than on the device


I have a graphical glitch related to blending in my OpenGL application using Android NDK.

The strange thing is that when I take a screenshot through adb screencap command, the problem completely disappears and the result looks okay.

My question is: Is there a way to know what is happening behind the scenes of making screenshots? Is there eglChooseConfig called with some specific values for the entire frame for example? Or maybe is there some specific initial GL state forced?

Some background:

My device is using Qualcomm Adreno 320.

The glich occurs when I call glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) for some of the geometry.

I have also found that setting glColorMask(1, 1, 1, 0) results in a black screen on my device (and only on this device), whereas taking a screenshot results in a complete, correct game frame.

The application outputs no glitches on several other Android devices, and other applications work well, even ones that use blending extensively.


Solution

  • The problem disappeared once I commented out EGL_ALPHA_SIZE setting:

    const EGLint attribs[] = {
        EGL_BLUE_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_RED_SIZE, 8,
        //EGL_ALPHA_SIZE, 8,
        EGL_NONE
    };
    

    It looks like with alpha set to 8 bits, eglChooseConfig returned a problematic configuration object.

    Funnily enough, the "correct" EGLConfig specifies 0 bits for EGL_ALPHA_SIZE, so at first I would expect it to not work at all. Other devices don't really care about the value and they are doing well provided only RGB channels' depths.

    I have learned a lesson: if there are graphical glitches on your device, always check all possible EGL configurations!

    So my conclusion is: yes, probably there is a custom EGLConfig set inside adb screencap.