using Microsoft.Xna.Framework; using System; namespace SemiColinGames { public class OpenGLDisplay : IDisplay { private GameWindow window; private GraphicsDeviceManager graphics; public void Initialize(GameWindow window, GraphicsDeviceManager graphics) { this.window = window; this.graphics = graphics; window.Title = "Sneak"; } public void SetFullScreen(bool fullScreen) { if (fullScreen) { // In OpenGL, we misappropriate "fullscreen" to be "the settings good for recording // gameplay GIFs". window.IsBorderless = true; // graphics.PreferredBackBufferWidth = 720; // graphics.PreferredBackBufferHeight = 405; graphics.PreferredBackBufferWidth = graphics.GraphicsDevice.DisplayMode.Width; graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height; } else { window.IsBorderless = false; graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; } Debug.WriteLine("display: {0}x{1}, fullscreen={2}", graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, fullScreen); graphics.ApplyChanges(); } } public static class OpenGLProgram { [STAThread] static void Main() { using (var game = new SneakGame()) { game.Services.AddService(typeof(IDisplay), new OpenGLDisplay()); game.Run(); } } } }