sneak/DesktopGL/DesktopGLProgram.cs

48 lines
1.5 KiB
C#

using Microsoft.Xna.Framework;
using System;
namespace SemiColinGames {
public class DesktopGLDisplay : 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 DesktopGL, 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 = 1280;
graphics.PreferredBackBufferHeight = 720;
}
Debug.WriteLine("display: {0}x{1}, fullscreen={2}",
graphics.PreferredBackBufferWidth,
graphics.PreferredBackBufferHeight,
fullScreen);
graphics.ApplyChanges();
}
}
public static class DesktopGLProgram {
[STAThread]
static void Main() {
using (var game = new SneakGame()) {
game.Services.AddService(typeof(IDisplay), new DesktopGLDisplay());
game.Run();
}
}
}
}