1

I'm trying to to use GLSL for OpenGL ES 3.0 with OpenGL ES Context 2.0 on Android Emulator Nexus 6 API 24. I declare in my vertex shader and fragment shader with

"#version 300 es"

But I got error: "unsupported shader version". After searching around, I think that maybe changing to OpenGL ES Context 3.0 would solve my problem. Therefore, I edit my GLES3JNIView.java (from this sample: https://github.com/googlesamples/android-ndk/tree/master/gles3jni/app/src/main/java/com/android/gles3jni).

Change the context from 2 to 3 with

setEGLContextClientVersion(3);

and edit the manifest:

< uses-feature android:glEsVersion="0x00030000" android:required="true" />

But I ran into another problem, when I run the app, it crashes on launching. I found these in the logcat:

02-14 17:29:04.879 5546-5546/? I/art: Not late-enabling -Xcheck:jni (already on)
02-14 17:29:04.879 5546-5546/? W/art: Unexpected CPU variant for X86 using defaults: x86
02-14 17:29:05.215 5546-5568/com.android.gl2jni I/OpenGLRenderer: Initialized EGL, version 1.4
02-14 17:29:05.215 5546-5568/com.android.gl2jni D/OpenGLRenderer: Swap behavior 1
02-14 17:29:05.313 5546-5568/com.android.gl2jni E/EGL_emulation: tid 5568: eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)
02-14 17:29:05.313 5546-5568/com.android.gl2jni W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa917dca0, error=EGL_BAD_MATCH
                                                                  
[ 02-14 17:29:05.430  5546: 5565 D/         ]
                                                                  HostConnection::get() New Host Connection established 0xacd1d780, tid 5565
02-14 17:29:05.435 5546-5565/com.android.gl2jni E/AndroidRuntime: FATAL EXCEPTION: GLThread 157
                                                                  Process: com.android.gl2jni, PID: 5546
                                                                  java.lang.IllegalArgumentException: eglChooseConfig failed
                                                                      at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:865)
                                                                      at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1036)
                                                                      at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1416)
                                                                      at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)

What am I doing wrong?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Toan Tran
  • 476
  • 6
  • 28

1 Answers1

2

OpenGL ES 3.0 isn't supported on the Android emulator.

See:

https://developer.android.com/ndk/guides/stable_apis.html

Specifically:

Note: The Android emulator does not support OpenGL ES 3.0 hardware emulation. Running and testing code that uses this API requires a real device with hardware that can support OpenGL ES 3.0

solidpixel
  • 10,688
  • 1
  • 20
  • 33
  • Thanks for your reply. Btw, I also found this in the given link: Note: The Android emulator does not support OpenGL ES 2.0 hardware emulation. Running and testing code that uses this API requires a real device with hardware that can support OpenGL ES 2.0. However, the example that i use could create OpenGL ES 2.0 Context and declare the OpenGL ES 2.0 in the manifest.xml with no problem. Is this some kind of mistake in the given link or it just doesn't work with GLSL for OpenGL ES 2.0? – Toan Tran Feb 14 '17 at 15:51