setEGLContextClientVersion(2) causes a crash


Last Updated:

  1. wolfscaptain

    wolfscaptain Member

    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:
    1. Thread [<1> main] (Running)    
    2. Thread [<8> Binder Thread #2] (Running)    
    3. Thread [<7> Binder Thread #1] (Running)    
    4. Thread [<9> GLThread 10] (Suspended (exception IllegalArgumentException))    
    5.     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:
    1.  
    2. import javax.microedition.khronos.egl.EGLConfig;
    3. import javax.microedition.khronos.opengles.GL10;
    4.  
    5. import android.app.Activity;
    6. import android.opengl.GLSurfaceView;
    7. import android.os.Bundle;
    8.  
    9. public class Test extends Activity {
    10.     @Override
    11.     protected void onCreate(Bundle savedInstanceState) {
    12.         super.onCreate(savedInstanceState);
    13.         mGLView = new GLSurfaceView(this);
    14.         mGLView.setEGLContextClientVersion(2);
    15.         mGLView.setRenderer(new ClearRenderer());
    16.         setContentView(mGLView);
    17.     }
    18.  
    19.     @Override
    20.     protected void onPause() {
    21.         super.onPause();
    22.         mGLView.onPause();
    23.     }
    24.  
    25.     @Override
    26.     protected void onResume() {
    27.         super.onResume();
    28.         mGLView.onResume();
    29.     }
    30.  
    31.     private GLSurfaceView mGLView;
    32. }
    33.  
    34. class ClearRenderer implements GLSurfaceView.Renderer {
    35.     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    36.        
    37.     }
    38.  
    39.     public void onSurfaceChanged(GL10 gl, int w, int h) {
    40.        
    41.     }
    42.  
    43.     public void onDrawFrame(GL10 gl) {
    44.        
    45.     }
    46. }
    47.  
    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 :)

    Advertisement
  2. wolfscaptain

    wolfscaptain Member

    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...)

Share This Page