I may finally have an opportunity to give back to the MonoGame community!
I’m trying to get the Android Camera to present on the MonoGame surface for developers to create Augmented Reality experiences.
I can indeed connect the camera to the Surface by modifying MonoGameAndroidGameView.cs in the following manner:
public delegate void OnSurfaceCreatedExternalCallBackFunc(Surface surface);
public static OnSurfaceCreatedExternalCallBackFunc OnSurfaceCreatedExternal;
void ISurfaceHolderCallback.SurfaceCreated(ISurfaceHolder holder)
{
if (OnSurfaceCreatedExternal != null)
OnSurfaceCreatedExternal(holder.Surface);
SurfaceCreated(holder);
Android.Util.Log.Debug("MonoGame", "MonoGameAndroidGameView.SurfaceCreated: surfaceFrame = " + holder.SurfaceFrame.ToString());
_isSurfaceChanged = false;
}
Then, in the basic GameActivity I set that delegate:
var gameView = (View)game.Services.GetService(typeof(View));
SetContentView(gameView);
Microsoft.Xna.Framework.MonoGameAndroidGameView.OnSurfaceCreatedExternal = OnSurfaceCreated;
game.Run();
And when my delegate runs, after the surface has been initialized by MonoGame, I connect the video camera.
Unfortunately this yields a
BufferQueue(161): [SurfaceView] connect: already connected (cur=1, req=4)
Which leads me to believe that only one object can be connected to the SurfaceView.
I’m having trouble finding how to either circumvent or fix this issue (in the case that I should be able to connect more than one), or, the best method to insert another, and have it behind the MonoGame surface and perform efficiently.
Any help is appreciated