sneak/DesktopGL/DesktopGLProgram.cs

53 lines
1.6 KiB
C#
Raw Normal View History

using Microsoft.Xna.Framework;
using System;
using System.IO;
namespace SemiColinGames {
2020-11-20 22:52:40 +00:00
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) {
2020-11-20 22:52:40 +00:00
// 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();
}
}
2020-11-20 22:52:40 +00:00
public static class DesktopGLProgram {
[STAThread]
static void Main() {
string path = System.Reflection.Assembly.GetEntryAssembly().Location;
path = System.IO.Path.GetDirectoryName(path);
Directory.SetCurrentDirectory(path);
using (var game = new SneakGame()) {
2020-11-20 22:52:40 +00:00
game.Services.AddService(typeof(IDisplay), new DesktopGLDisplay());
game.Run();
}
}
}
}