如何在调用eglCreatePbufferSurface时修复0x3009(EGL_BAD_MATCH)问题?

时间:2015-10-08 04:41:26

标签: android egl grafika

我使用grafika中的createOffscreenSurface

/**
 * 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;
}

它在某些设备上运行正常,但在其他设备上却没有。错误消息是:

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

我也用Google搜索并获得以下信息:

  1.   

    您需要使用该手机的相应像素格式设置曲面视图,这很可能是PixelFormat.RGB565(link

  2.   

    我非常确定您的表面与实际显示表面的格式不同。 (link

  3. 但是,我没有想法来解决它。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

使用

new EglCore(EGL14.eglGetCurrentContext(), 0) 

替换

new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);