Android:GLES20:调用未实现的 OpenGL ES API [英] Android: GLES20: Called unimplemented OpenGL ES API

查看:14
本文介绍了Android:GLES20:调用未实现的 OpenGL ES API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试由 developer.android.com 提供的 GLES20 示例时,我收到调用未实现的 OpenGL ES API"错误.不过,我修改了示例.原因是因为我在 GLSurfaceView.BaseConfigChooser.chooseconfig 中遇到了 IllegalArgumentException,所以我替换了mGLSurfaceView.setEGLContextClientVersion(2);

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

新的 OnCreateMethod:

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 );
}

调用未实现的 OpenGL ES API"错误发生在例如GLES20.glCreateShader;GLES20.glShaderSource.

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

我想,也许是为了检查版本,所以我打电话给gl.glGetString(GLES20.GL_VERSION);public void onSurfaceCreated(GL10 gl, EGLConfig config).glGetString 返回OpenGL ES-CM 1.0".OnSurfaceCreated 是在选择配置并创建上下文后调用的,所以我真的不明白,为什么 glGetString 返回OpenGL ES-CM 1.0".

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

我正在使用 Android 2.2 API,并在 Android 2.2 虚拟设备和 HTC Wildfire 上使用 Android 2.2.1 尝试了该示例.

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.

感谢您的帮助

推荐答案

看到这个帖子 -android中的三角形opengl

正如那里提到的,模拟器不支持 GL2,但正如那篇文章提到的,它在实际设备上对我有用.

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

这篇关于Android:GLES20:调用未实现的 OpenGL ES API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆