我試圖使用多個EGL上下文來加載我的主線程之外的紋理.在我的eglCreateContext調用之後,我收到了一個EGL_BAD_CONTEXT錯誤.
在我的android.opengl.Renderer裡面
public void onSurfaceCreated (javax.microedition.khronos.opengles.GL10 gl, EGLConfig config) {
// ...
EGLContext sharedContext = egl.getCurrentContext();
EGLDisplay display = eglGetCurrentDisplay();
eglCreateContext(display, config, sharedContext, new int[] { EGL_CONTEXT_CLIENT_VERSION, 2 } );
}
EGL_BAD_CONTEXT引導我閱讀文檔here
EGL_BAD_CONTEXT is generated if share_context is not an EGL rendering context of the same client API type as the newly created context and is not EGL_NO_CONTEXT.
這就是我在EGL_CONTEXT_CLIENT_VERSION參數中添加的原因,但它似乎沒有起作用.
我所看到的是,即使我收到此錯誤,上下文似乎也是半有效的.我可以在另一個線程上使用它
egl.eglMakeCurrent(display, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, context);
在此之後,在該線程上建立紋理不會導緻錯誤.但我确實看到紋理名稱沒有共享,每個線程似乎從0本身算起來.
我的下一個假設是我需要在上下文之間分享表面.但是,如果我從原始上下文中通過相同的表面進入我的eglMakeCurrent,但我完全失敗了
E/AndroidRuntime(3210): java.lang.IllegalArgumentException
E/AndroidRuntime(3210): at com.google.android.gles_jni.EGLImpl._eglCreateContext(Native Method)
E/AndroidRuntime(3210): at com.google.android.gles_jni.EGLImpl.eglCreateContext(EGLImpl.java:54)
我覺得好像我幾乎在那裡,有人知道缺少什麼嗎?