• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps setEGLContextClientVersion(2) causes a crash

I am trying to make an OpenGL ES2 application. As a start, I just copied the demo BasicGLSurfaceView from the API level 11 samples.

After it crashed no matter what I changed, I made a very stripped version which basically just creates the surface. After many testing and finally trying out the debugger, it seems like calling setEGLContextClientVersion() with 2 causes an exception in GLThread:

PHP:
Thread [<1> main] (Running)    
Thread [<8> Binder Thread #2] (Running)    
Thread [<7> Binder Thread #1] (Running)    
Thread [<9> GLThread 10] (Suspended (exception IllegalArgumentException))    
    GLSurfaceView$GLThread.run() line: 1122
This is my first try at an Android application, so I have no idea what this means. Tried to find what GLThread is, but it isn't documented in the API.

This is the current - very simple - code (taken from here):

PHP:
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

public class Test extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mGLView = new GLSurfaceView(this);
        mGLView.setEGLContextClientVersion(2);
        mGLView.setRenderer(new ClearRenderer());
        setContentView(mGLView);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLView.onResume();
    }

    private GLSurfaceView mGLView;
}

class ClearRenderer implements GLSurfaceView.Renderer {
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        
    }

    public void onDrawFrame(GL10 gl) {
        
    }
}
When I run either this or the demo without the debugger, they crash.

Any ideas why this happens?

Oh and I am currently using the level 9 API, but I tried with both 10 and 11 too to no avail, so I guess that's not the issue.

Thanks for any help :)
 
I finally copied the GLES20 demo that sets the renderer based on a function that checks if ES 2 is supported.

Since I can't find a way to sort of "show" things (I always loved the console that comes with any C/C++ application...), I just commented the check and noticed that apparently ES 2 is simply not supported by the emulator.

A google search on that question turned out to be true, but it is 3 months old.
Is there no way to use ES 2 on the emulator? What's the point of the emulator if you can't do on it what you can do on an actual device?
Since I don't have a device yet (waiting for an Android 3 tablet), I can't actually write anything... (not really happy about writing a lot of code and then later on trying to debug it without ever using it...)
 
Back
Top Bottom