para obj instalar developers descargar como cambiar android opengl-es

obj - opengl es 3.1 android download



Android: GLES20: llamada API OpenGL ES no implementada (4)

Recibo un error de "API de OpenGL ES no implementada" al probar el ejemplo de GLES20, proporcionado por developer.android.com. Aunque modifiqué la muestra. La razón fue porque obtuve una IllegalArgumentException en GLSurfaceView.BaseConfigChooser.chooseconfig, por lo que reemplacé mGLSurfaceView.setEGLContextClientVersion( 2 );

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

El error "API de OpenGL ES no implementado" se produce, por ejemplo, en GLES20.glCreateShader; o GLES20.glShaderSource .

Pensé, tal vez para verificar la versión, llamé a gl.glGetString( GLES20.GL_VERSION ); en public void onSurfaceCreated( GL10 gl, EGLConfig config ) . glGetString devolvió "OpenGL ES-CM 1.0". Se llama a OnSurfaceCreated después de elegir la configuración y crear el contexto, así que realmente no entiendo por qué glGetString devuelve "OpenGL ES-CM 1.0".

Estoy usando Android 2.2 API y probé la muestra en un dispositivo virtual Android 2.2 y en un HTC Wildfire, con Android 2.2.1.

Agradezco cualquier ayuda


Debe habilitar OpenGL ES 2.0 en su aplicación de Android.

Primero, en su AndroidManifest.xml, asegúrese de tener lo siguiente:

<uses-feature android:glEsVersion="0x00020000"></uses-feature> <uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8"></uses-sdk>

Segundo, crea una subclase de GLSurfaceView así:

public class CustomView extends GLSurfaceView { final CustomRenderer renderer; CustomView(Context context) { super(context); setEGLContextClientVersion(2); // This is the important line renderer = new CustomRenderer(); setRenderer(renderer); } }

PARA NDK

Asegúrese de elegir el atributo y las listas de atributos de contexto:

const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_NONE }; eglChooseConfig(dpy, attribs, &config, 1, &numConfigs); const EGLint ContextAttribList[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; context = eglCreateContext(GLapp.dpy, config, EGL_NO_CONTEXT, ContextAttribList);


Esto no es un error, sino una declaración. Simplemente le dice que su objetivo no es compatible con OpenGL ES versión 2.0.


Puede ser porque está utilizando la instancia GL10 que estamos obteniendo como parámetro en onSurfaceCreated (), onSurfaceChanged () y onDrawFrame () en su implementación de Renderer. Como tiene la intención de usar OpwnGL ES 2.0, podemos y probablemente no usemos la instancia y usemos una alternativa en su lugar. ¡Hay alternativas! ¡Esta es la razón por la que vemos esos nombres de nombres y códigos no usados ​​o similares en toda la red!


Ver este post - triángulo opengl en android

Como se mencionó allí, los emuladores no son compatibles con GL2, pero como esa publicación menciona, funcionó para mí en un dispositivo real.