using Foresight.Engine.Renderer; using Microsoft.Xna.Framework; using MonoGame.Extended.ViewportAdapters; namespace Foresight.Engine { public class ResolutionManager { public const int MinimumWidth = 1024; public const int MinimumHeight = 768; private readonly RendererManager _manager; public int TrueWidth { get; private set; } public int TrueHeight { get; private set; } public ViewportAdapter ViewportAdapter { get; } public ResolutionManager(RendererManager manager, int width, int height) { _manager = manager; SetResolution(width, height); ViewportAdapter = new ScalingViewportAdapter(_manager.GraphicsDeviceManager.GraphicsDevice, MinimumWidth, MinimumHeight); } public void SetResolution(int width, int height) { // if (width < MinimumWidth) width = MinimumWidth; // if (height < MinimumHeight) height = MinimumHeight; TrueWidth = width; TrueHeight = height; _manager.GraphicsDeviceManager.PreferredBackBufferWidth = width; _manager.GraphicsDeviceManager.PreferredBackBufferHeight = height; _manager.GraphicsDeviceManager.ApplyChanges(); } } }