[mono-android] EGLContext.EGL11.EglGetCurrentDisplay() with es 2.0

Jonathan Pryor jonp at xamarin.com
Wed Oct 10 13:56:40 UTC 2012


On Oct 10, 2012, at 1:36 AM, renan jegouzo <renan at aestesis.org> wrote:
> when I try to get the current EGL display, using 
> EGLContext.EGL11.EglGetCurrentDisplay ()
> 
>  I got an exception:
> System.Exception: Unable to convert instance of type 'com/google/android/gles_jni/EGLImpl' to type 'javax.microedition.khronos.egl.EGL11'
> 
> how I can get the current EGL display ?

Your device doesn't support the IEGL11 interface; you should use EGLContext.EGL instead.

The problem is that com.google.android.gles_jni.EGLImpl is returned by EGLContext.getEGL:

	https://github.com/android/platform_frameworks_base/blob/master/opengl/java/javax/microedition/khronos/egl/EGLContext.java

and EGLImpl only implements the EGL10 interface, not the EGL11 interface:

	https://github.com/android/platform_frameworks_base/blob/master/opengl/java/com/google/android/gles_jni/EGLImpl.java

Consequently, the EGLContext.EGL11 helper fails, as the runtime Java type doesn't implement the EGL11 interface.

The workaround is to use the EGL10 interface, which EGLImpl does implement:

	var egl10 = EGLContext.EGL.JavaCast<IEGL10>();
	var display = egl10.EglGetCurrentDisplay();

(The really odd thing is that I remember EGLContext.EGL11 previously working, so it looks like Android has changed things so that only EGL10 is supported...)

 - Jon



More information about the Monodroid mailing list