Files
LuaCsForBarotraumaEP/Libraries/MonoGame.Framework/Src/MonoGame.Framework/GraphicsDeviceManager.SDL.cs
2019-06-25 16:00:44 +03:00

52 lines
2.2 KiB
C#

// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using Microsoft.Xna.Framework.Graphics;
namespace Microsoft.Xna.Framework
{
public partial class GraphicsDeviceManager
{
partial void PlatformInitialize(PresentationParameters presentationParameters)
{
#if OPENGL
var surfaceFormat = _game.graphicsDeviceManager.PreferredBackBufferFormat.GetColorFormat();
var depthStencilFormat = _game.graphicsDeviceManager.PreferredDepthStencilFormat;
// TODO Need to get this data from the Presentation Parameters
Sdl.GL.SetAttribute(Sdl.GL.Attribute.RedSize, surfaceFormat.R);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.GreenSize, surfaceFormat.G);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.BlueSize, surfaceFormat.B);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.AlphaSize, surfaceFormat.A);
switch (depthStencilFormat)
{
case DepthFormat.None:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 0);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
break;
case DepthFormat.Depth16:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 16);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
break;
case DepthFormat.Depth24:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 24);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
break;
case DepthFormat.Depth24Stencil8:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 24);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 8);
break;
}
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DoubleBuffer, 1);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.ContextMajorVersion, 2);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.ContextMinorVersion, 1);
#endif
((SdlGameWindow)SdlGameWindow.Instance).CreateWindow();
}
}
}