Coo*_*ill 20 android opengl-es
我在尝试使用developer.android.com提供的GLES20示例时遇到"调用未实现的OpenGL ES API"错误.我修改了样本.原因是因为我在GLSurfaceView.BaseConfigChooser.chooseconfig中得到了IllegalArgumentException,所以我换了
mGLSurfaceView.setEGLContextClientVersion( 2 );
新的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 );
}
Run Code Online (Sandbox Code Playgroud)
"调用未实现的OpenGL ES API"错误发生在例如
GLES20.glCreateShader;
或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".
我正在使用Android 2.2 API并在Android 2.2虚拟设备和HTC Wildfire上使用Android 2.2.1尝试了该示例.
我感谢任何帮助
归档时间: |
|
查看次数: |
39001 次 |
最近记录: |