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:
You need to setup the surface view with the appropriate pixel format for that phone, which is most likely PixelFormat.RGB565 (link)
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 ?
Use
new EglCore(EGL14.eglGetCurrentContext(), 0)
to replace
new EglCore(newSharedContext, EglCore.FLAG_RECORDABLE);