2

I use the createOffscreenSurface from grafika:

/**
 * Creates an off-screen surface.
 */
public void createOffscreenSurface(int width, int height) {
    if (mEGLSurface != EGL14.EGL_NO_SURFACE) {
        throw new IllegalStateException("surface already created");
    }
    mEGLSurface = mEglCore.createOffscreenSurface(width, height);
    mWidth = width;
    mHeight = height;
}

/**
 * Creates an EGL surface associated with an offscreen buffer.
 */
public EGLSurface createOffscreenSurface(int width, int height) {
    int[] surfaceAttribs = {
            EGL14.EGL_WIDTH, width,
            EGL14.EGL_HEIGHT, height,
            EGL14.EGL_NONE
    };
    EGLSurface eglSurface = EGL14.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig,
            surfaceAttribs, 0);
    checkEglError("eglCreatePbufferSurface");
    if (eglSurface == null) {
        throw new RuntimeException("surface was null");
    }
    return eglSurface;
}

It works fine on some devices, but doesn't on other devices. The error msg is:

java.lang.RuntimeException: eglCreatePbufferSurface: EGL error: 0x3009

I also googled and got the following information:

  1. You need to setup the surface view with the appropriate pixel format for that phone, which is most likely PixelFormat.RGB565 (link)

  2. I'm pretty certain your surface is a different format to the actual display surface. (link)

However, i don't have ideas to fix it. Any suggestions ?

Community
  • 1
  • 1
Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71
  • On the devices where it fails, do the Grafika activities that use pbuffers work? If so, what's different about the way you're using it? – fadden Oct 08 '15 at 20:09
  • Fails here: `EGLSurface eglSurface = EGL14.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, surfaceAttribs, 0);` I use the `OffscreenSurface` to do the screenshot. – Jerikc XIONG Oct 09 '15 at 02:45
  • See the solution here: [http://stackoverflow.com/questions/40697339/error-egl-bad-match-in-android-studio-emulator/41948265#41948265](http://stackoverflow.com/questions/40697339/error-egl-bad-match-in-android-studio-emulator/41948265#41948265) – Uddhav P. Gautam Jan 31 '17 at 01:27

1 Answers1

0

Use

new EglCore(EGL14.eglGetCurrentContext(), 0) 

to replace

new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71