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

ix0qys7i  于 2022-12-16  发布在  Android
关注(0)|答案(1)|浏览(221)

我使用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

我还在谷歌上搜索了一下,得到了以下信息:
1.您需要使用适合该手机的像素格式设置表面视图,最有可能的是PixelFormat.RGB565(link
1.我很确定你的界面与实际的显示界面格式不同。(link
但是,我没有办法解决这个问题,你有什么建议吗?

oxalkeyp

oxalkeyp1#

用途

new EglCore(EGL14.eglGetCurrentContext(), 0)

来代替

new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);

相关问题