我使用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搜索并获得以下信息:
答案 0 :(得分:0)
使用
new EglCore(EGL14.eglGetCurrentContext(), 0)
替换
new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);