(via Xamarin C#) On Android I am unable to create the framebuffer.
I have a subclassed Android.OpenGL.GLSurfaceView, set to GL ES 2, with preserve EGL Context, and my other GL commands are drawing successfully, with no GLErrors:
public class PaintingView : GLSurfaceView, GLSurfaceView.IRenderer
{
public PaintingView( Context context, IAttributeSet attrs ) :
base( context, attrs )
{
SetEGLContextClientVersion( 2 );
// Set the Renderer for drawing on the GLSurfaceView
SetRenderer( this );
PreserveEGLContextOnPause = true;
}
public void OnSurfaceCreated( IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config )
{
...
}
}
OnSurfaceCreated
does get called, and it invokes the following code on the UI thread via myActivity.RunOnUiThread( Action ), as part of creating a buffer of desired size for offscreen rendering:
frameBuffer = -123; // Invalid value, so we can test whether it was set.
GL.GenFramebuffers( 1, out frameBuffer );
Shader.CheckGLError( "Offscreen.Resize 1" ); // My method that checks result of "GL.GetErrorCode()"
if (frameBuffer <= -1) {
... failed to assign an FBO!
}
Problem:
GenFramebuffers
failed to assign an FBO - "frameBuffer" is still set to "-123".
Q: Why might this occur? Is there something I was supposed to do first? Is there a working Xamarin example of using an FBO on Android?
NOTES:
On iOS we successfully used code that created a second EGLContext and pbuffer for offscreen rendering, but after reading that switching between two EGLContexts has poor performance on Android, we are attempting an FBO approach for Android.
The problem seems to be specific to Android, as it involves setting up the FBO.
I've seen several
java
examples of using an FBO on Android, but have been unable to get past this first step, usingXamarin
.