Coolkill
Coolkill

Reputation: 221

Android: GLES20: Called unimplemented OpenGL ES API

I am getting a "Called unimplemented OpenGL ES API" error, when trying the GLES20 Sample, provided by developer.android.com. I modified the sample, though. The reason was because I got an IllegalArgumentException in GLSurfaceView.BaseConfigChooser.chooseconfig, so i replaced mGLSurfaceView.setEGLContextClientVersion( 2 );

The new OnCreateMethod:

protected void onCreate( Bundle savedInstanceState )
{
    super.onCreate( savedInstanceState );
    mGLSurfaceView = new GLSurfaceView( this );

    mGLSurfaceView.setEGLConfigChooser( new EGLConfigChooser()
    {
        @Override
        public EGLConfig chooseConfig( EGL10 egl, EGLDisplay display )
        {
            EGLConfig[] configs = new EGLConfig[1];
            int[] num_config = new int[1];

            boolean check = false;

            int[] configSpec = { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };

            check = egl.eglInitialize( display, new int[] { 2, 0 } );

            if ( !check )
                return null;
            check = false;

            check = egl.eglChooseConfig( display, configSpec, configs, 1, num_config );
            if ( !check )
                return null;

            return configs[0];
        }
    } );

    mGLSurfaceView.setEGLContextFactory( new EGLContextFactory()
    {
        @Override
        public void destroyContext( EGL10 egl, EGLDisplay display, EGLContext context )
        {
            egl.eglDestroyContext( display, context );
        }

        @Override
        public EGLContext createContext( EGL10 egl, EGLDisplay display, EGLConfig eglConfig )
        {
            int[] attrib_list = new int[]{EGL10.EGL_VERSION, 2, EGL10.EGL_NONE};

            EGLContext context = egl.eglCreateContext( display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list  );
            return context;
        }
    });

    mGLSurfaceView.setRenderer( new GLES20TriangleRenderer( this ) );

    setContentView( mGLSurfaceView );
}

The "Called unimplemented OpenGL ES API" error occurs for example at GLES20.glCreateShader; or GLES20.glShaderSource.

I thought, maybe to check the version, so I called gl.glGetString( GLES20.GL_VERSION ); in public void onSurfaceCreated( GL10 gl, EGLConfig config ). glGetString returned "OpenGL ES-CM 1.0". OnSurfaceCreated is called after choosing the config and creating the context, so I really do not understand, why glGetString returns "OpenGL ES-CM 1.0".

I am using Android 2.2 API and tried the sample on a Android 2.2 Virtual device and on a HTC Wildfire, with Android 2.2.1.

I appreciate any help

Upvotes: 21

Views: 43652

Answers (3)

stack_ved
stack_ved

Reputation: 721

It may be because you are using the GL10 instance we are getting as a parameter in onSurfaceCreated(), onSurfaceChanged() and onDrawFrame() in your Renderer implementation. Since you intend to use OpenGL ES 2.0, we can and probably not use the instance and use an alternative instead. There are alternatives! This is the reason we see those parameters names and unused or similar in codes across the net!

Upvotes: 0

iDurocher
iDurocher

Reputation: 915

See this post - triangle opengl in android

As mentioned there, the emulators do not support GL2, but as that post mentions, it worked for me on an actual device.

Upvotes: 2

ognian
ognian

Reputation: 11541

This is not an error, but a statement. It simply tells you that your target doesn't support OpenGL ES version 2.0.

Upvotes: 1

Related Questions