protected override void CreateFrameBuffer()
{
Android.Util.Log.Debug("MonoGame", "MonoGameAndroidGameView.CreateFrameBuffer");
ContextRenderingApi = GLVersion.ES2;
int depth = 0;
int stencil = 0;
switch (_game.graphicsDeviceManager.PreferredDepthStencilFormat)
{
case DepthFormat.Depth16:
depth = 16;
break;
case DepthFormat.Depth24:
depth = 24;
break;
case DepthFormat.Depth24Stencil8:
depth = 24;
stencil = 8;
break;
case DepthFormat.None:
break;
}
List<GraphicsMode> modes = new List<GraphicsMode>();
if (depth > 0)
{
modes.Add(new AndroidGraphicsMode(new ColorFormat(8, 8, 8, 8), depth, stencil, 0, 0, false));
modes.Add(new AndroidGraphicsMode(new ColorFormat(5, 6, 5, 0), depth, stencil, 0, 0, false));
modes.Add(new AndroidGraphicsMode(0, depth, stencil, 0, 0, false));
if (depth > 16)
{
modes.Add(new AndroidGraphicsMode(new ColorFormat(8, 8, 8, 8), 16, 0, 0, 0, false));
modes.Add(new AndroidGraphicsMode(new ColorFormat(5, 6, 5, 0), 16, 0, 0, 0, false));
modes.Add(new AndroidGraphicsMode(0, 16, 0, 0, 0, false));
}
}
else
{
modes.Add(new AndroidGraphicsMode(new ColorFormat(8, 8, 8, 8), 0, 0, 0, 0, false));
modes.Add(new AndroidGraphicsMode(new ColorFormat(5, 6, 5, 0), 0, 0, 0, 0, false));
}
modes.Add(null); // default mode
modes.Add(new AndroidGraphicsMode(0, 0, 0, 0, 0, false)); // low mode
Exception innerException = null;
foreach (GraphicsMode mode in modes)
{
if (mode != null)
Android.Util.Log.Debug("MonoGame", "Creating Color: {0}, Depth: {1}, Stencil: {2}, Accum:{3}", mode.ColorFormat, mode.Depth, mode.Stencil, mode.AccumulatorFormat);
else
Android.Util.Log.Debug("MonoGame", "Creating default mode");
GraphicsMode = mode;
try
{
base.CreateFrameBuffer();
}
catch (Exception e)
{
innerException = e;
continue;
}
Android.Util.Log.Debug("MonoGame", "Created format {0}", GraphicsContext.GraphicsMode);
var status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
Android.Util.Log.Debug("MonoGame", "Framebuffer Status: " + status.ToString());
MakeCurrent();
return;
}
throw new NoSuitableGraphicsDeviceException("Could not create OpenGLES 2.0 frame buffer", innerException);
}