I've seen multiple takes on this topic and its starting to confuse me. I really hope someone can give me a definitive answer! :)
I guess to be blunt: does the Android emulator support OpenGL ES 2.0? I've seen some people say "Yes, but you have to change a few settings." and I've also seen "No, it doesn't support it, period." Here's what I've done to try and correct the problem, including some error messages that I got.
First, I modified the AndroidManifest.xml to contain the following code:
<uses-feature
android:glEsVersion="0x00020000" />
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
Then, when I want to instantiate my GLSurfaceView, I use this sequence of code to instantiate it:
super(context);
setEGLContextClientVersion(2);
setRenderer(new MyRenderer());
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
Then, everywhere I looked said that you must go into the AVD Manager, select the emulator, go to "Hardware", add "GPU emulation" and set the boolean to "yes". However, here is what I see when I look at mine:
What's peculiar is that I have another emulator in my AVD Manager of which I do have the "Hardware" table:
And just to show you exactly what I'm doing, here's some code that does some stuff I want to do in OpenGL ES 2.0 (I mainly got this from Android's own tutorials):
int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);
program = GLES20.glCreateProgram();
GLES20.glAttachShader(program, vertexShader);
GLES20.glAttachShader(program, fragmentShader);
GLES20.glLinkProgram(program);
I don't want to change my code back to work with OpenGL ES 1.0 because that will require a lot of headaches and if I can avoid it, I will.
Finally, when I try running my program, the program closes with the window: "Unfortunately, has stopped." This is what LogCat told me:
12-05 06:16:27.165: E/AndroidRuntime(936): FATAL EXCEPTION: GLThread 81
12-05 06:16:27.165: E/AndroidRuntime(936): java.lang.IllegalArgumentException: No config chosen
12-05 06:16:27.165: E/AndroidRuntime(936): at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:874)
12-05 06:16:27.165: E/AndroidRuntime(936): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1024)
12-05 06:16:27.165: E/AndroidRuntime(936): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1401)
12-05 06:16:27.165: E/AndroidRuntime(936): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
I will say I am not an expert on this at all and this is my first experience with OpenGL. If anybody has any ideas of what I can do to fix this, I would be forever grateful. :) Thank you!
Got the same problem. Original Buggy Code:
Solved by :
a.) Replacing this code line
with
b.) Setting
-gpu on
via Eclipse --> Run as ---> Target ---> Additional Emulator Command Line OptionsAdding a little more to the above discussion:
There were two different Exception messages I came across while working with the above piece of code
and
A more detailed case study narrated at http://on-android-opengl2.blogspot.in/2013/05/android-opengl-es-20-emulator.html
I just fixed the problem without adding any new lines to my source code. In the avd-manager i set "Use Host GPU" for my emulator device. Works now perfectly fine on my Geforce GTX 570.
API Level on emulator device is 16, and min-SDK in Manifest is 15.
I can say Yes on your question. Android emulator supports OpenGL ES 2.0. I created an app with cocos2d-x v.2 (which uses OpenGL ES 2.0). I had same FATAL EXCEPTION: GLThread 81 error with same stack. I solved this issue by adding
before setting renderer setRenderer:
Now I can run my app on Android emulator.
See my question and answer at https://stackoverflow.com/a/13719983/307547. My post on this link contains screenshot with AVD settings:
http://www.cocos2d-x.org/boards/6/topics/12563?r=19274#message-19274