Android Emulator and OpenGL ES3: EGL_BAD_CONFIG

烂漫一生 提交于 2021-01-02 08:02:37

问题


I am running an Android Virtual Device on my Ubuntu host. It is using the CPU/ABI Intel Atom (x86) and I am using the host GPU. The emulator is using a Kernel-based Virtual Machine.

This works splendidly as long as I use an OpenGL ES2 context. If my app attempts to create an OpenGL ES3 context however, using...

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

...then I get an EGL_BAD_CONFIG error:

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)

Requesting ES3 on a hardware mobile device, works well. But when requesting it from the emulator, it fails. The host machine is perfectly capable of doing OpenGL ES3.0, ES3.1 and ES3.2 as can be seen from glxinfo:

$ 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, 

Is there a way to run OpenGL ES3 apps on an Android Virtual Device on top of kvm?


回答1:


Running GLES3 apps in the emulator is supported in Android Studio 3.0 and higher.

At the time of writing, preview builds of this version are available. See: https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html

After launching the emulator, you need to change a setting, and restart the emulator as depicted below.

Also, make sure your app requests an ES3 context, because the Android sample code gles3jni does not do so.

UPDATE jun 2018

In the latest Android Studio, I can no longer select OpenGL ES3.1, even though it is the same PC.

To make it work, I had to add a file to ~/.android/ directory.

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



回答2:


Notice :

OpenGL SE should be opened in emulator > Setting > Advanced

Not in the ADB page.



来源:https://stackoverflow.com/questions/40797975/android-emulator-and-opengl-es3-egl-bad-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!