【问题标题】:Android Emulator and OpenGL ES3: EGL_BAD_CONFIGAndroid 模拟器和 OpenGL ES3:EGL_BAD_CONFIG
【发布时间】:2017-04-09 10:34:40
【问题描述】:

我在我的 Ubuntu 主机上运行 Android Virtual Device。 它使用的是 CPU/ABI Intel Atom (x86),我使用的是主机 GPU。 模拟器使用的是Kernel-based Virtual Machine

只要我使用 OpenGL ES2 上下文,它就可以很好地工作。 但是,如果我的应用尝试创建 OpenGL ES3 上下文,则使用...

const EGLint contextAttribs[] = {
    EGL_CONTEXT_CLIENT_VERSION, 3,
    EGL_NONE
};
context = eglCreateContext(display, config, NULL, contextAttribs);

...然后我收到 EGL_BAD_CONFIG 错误:

I/biplane ( 2839): EGL: vendor Android version 1.4 Android META-EGL
I/biplane ( 2839): EGL: client apis OpenGL_ES
I/biplane ( 2839): number of EGL configurations that match our preferred criteria: 1
I/biplane ( 2839): R8 G8 B8 A8 DEPTH24
E/EGL_emulation( 2839): tid 2852: eglCreateContext(919): error 0x3005 (EGL_BAD_CONFIG)

在硬件移动设备上请求 ES3,效果很好。 但是当从模拟器请求它时,它失败了。 从glxinfo可以看出,宿主机完全可以做OpenGL ES3.0、ES3.1和ES3.2:

$ glxinfo | grep ES3
    GL_ARB_ES2_compatibility, GL_ARB_ES3_1_compatibility, 
    GL_ARB_ES3_2_compatibility, GL_ARB_ES3_compatibility, 
    GL_NV_ES3_1_compatibility, GL_NV_bindless_multi_draw_indirect, 
    GL_ARB_ES2_compatibility, GL_ARB_ES3_1_compatibility, 
    GL_ARB_ES3_2_compatibility, GL_ARB_ES3_compatibility, 
    GL_NV_ES3_1_compatibility, GL_NV_bindless_multi_draw_indirect, 

有没有办法在 kvm 之上的 Android 虚拟设备上运行 OpenGL ES3 应用程序?

【问题讨论】:

标签: android android-emulator avd kvm opengl-es-3.0


【解决方案1】:

Android Studio 3.0 及更高版本支持在模拟器中运行 GLES3 应用。

在撰写本文时,此版本的预览版本可用。 见:https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html

启动模拟器后,您需要更改设置,然后重启模拟器,如下图所示。

另外,请确保您的应用请求 ES3 上下文,因为 Android 示例代码 gles3jni 不会这样做。

2018 年 6 月更新

在最新的 Android Studio 中,我无法再选择 OpenGL ES3.1,即使它是同一台 PC。

为了让它工作,我必须在 ~/.android/ 目录中添加一个文件。

cd ~/.android/
$ echo "GLESDynamicVersion = on" >> ~/.android/advancedFeatures.ini

【讨论】:

  • 现在在“高级”标签中
  • 我想给这个投票 100 次!使用“GLESDynamicVersion = on”创建文件“advancedFeatures.ini”为我完成了这项工作。虽然我只能选择 OpenGL ES 2.0,但设备在请求时正在创建 3.1 上下文!
【解决方案2】:

注意:

OpenGL SE应该在模拟器>设置>高级中打开

不在 ADB 页面中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-26
    • 1970-01-01
    • 2014-09-12
    相关资源
    最近更新 更多