Shu*_*ang 5 android opengl-es android-ndk glsurfaceview opengl-es-2.0
我尝试通过以下代码分享2个GLSurfaceViews的EGL上下文:
createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
EGLContext shared = ...; // a cached egl context
int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
EGLContext context = egl.eglCreateContext(display, eglConfig, shared == null ? EGL10.EGL_NO_CONTEXT : shared,
attrib_list);
return context;
}
}
Run Code Online (Sandbox Code Playgroud)
该代码适用于大多数Android手机(操作系统> = 2.2),但在所有测试的平板电脑上都失败了.
01-12 18:33:35.381:E/AndroidRuntime(12171):致命异常:GLThread 11
01-12 18:33:35.381:E/AndroidRuntime(12171):java.lang.RuntimeException:eglMakeCurrent失败:EGL_BAD_ACCESS
01-12 18:33:35.381:E/AndroidRuntime(12171):在android.opengl.GLSurfaceView $ EglHelper.throwEglException(GLSurfaceView.java:1146)
由于我声明了LOCAL_LDLIBS:= - lGLESv2,因此EGL是2.0上下文.
为什么它在平板电脑上失败(xoom,galaxy,lg,sony等)
任何见解都表示赞赏.
以下几行很可能是 GLSurfaceView 中错误的原因。
public GL createSurface(SurfaceHolder holder) {
....
/*
* Before we can issue GL commands, we need to make sure
* the context is current and bound to a surface.
*/
if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
throwEglException("eglMakeCurrent");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6995 次 |
| 最近记录: |