I want to cache video frames coming from media codec with a separate thread and separate egl context and render with separate thread and separate egl context but I don't want to make them shared and also want to share those cached image textures data.
i have created the egl context using this code
public void eglInitPBuffer(int width, int height ,@Nullable EGLConfig config,@Nullable EGLContext sharedContext)
{
EGLDisplay dpy = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
int[] vers = new int[2];
EGL14.eglInitialize(dpy, vers, 0, vers, 1);
if (config == null)
{
int[] configAttr;
configAttr = new int[]{
EGL14.EGL_COLOR_BUFFER_TYPE,
EGL14.EGL_RGB_BUFFER,
EGL14.EGL_LEVEL, 0,
EGL14.EGL_RENDERABLE_TYPE,
EGL14.EGL_OPENGL_ES2_BIT,
EGL14.EGL_SURFACE_TYPE,
EGL14.EGL_PBUFFER_BIT,
EGL14.EGL_NONE
};
EGLConfig[] configs = new EGLConfig[1];
int[] numConfig = new int[1];
if (!EGL14.eglChooseConfig(dpy, configAttr, 0, configs, 0, configs.length, numConfig, 0)) {
Log.e("unable to find RGB8888"," EGLConfig");
return;
}
config = configs[0];
}
int[] surfAttr;
surfAttr = new int[]{
EGL14.EGL_WIDTH, width,
EGL14.EGL_HEIGHT, height,
EGL14.EGL_NONE
};
EGLSurface surf = EGL14.eglCreatePbufferSurface(dpy, config, surfAttr, 0);;
checkEglError("eglCreatePbufferSurface");
if (surf == null) {
throw new RuntimeException("surface was null");
}
eglSurface = surf;
eGLDisplay = dpy;
configMain = config;
createEglContext(sharedContext);
}