2

我使用createOffscreenSurface来自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;
}

它在某些设备上运行良好,但在其他设备上却不行。错误消息是:

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

我也google了一下,得到了以下信息:

  1. 您需要为该手机设置适当的像素格式的表面视图,这很可能是 PixelFormat.RGB565 (链接)

  2. 我很确定您的表面与实际显示表面的格式不同。(链接

但是,我没有解决它的想法。有什么建议么 ?

4

1 回答 1

0

利用

new EglCore(EGL14.eglGetCurrentContext(), 0) 

取代

new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);
于 2015-10-15T03:47:25.023 回答