Example #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // when rendering sprites, you'll always work within the bounds of the virtual width and height
            // specified when setting up the viewport adapter. The default MonoGame window is 800x480.
            var destinationRectangle = new Rectangle(0, 0, 800, 480);

            _spriteBatch.Begin(transformMatrix: _currentViewportAdapter.GetScaleMatrix());
            _spriteBatch.Draw(_backgroundTexture, destinationRectangle, Color.White);

            _spriteBatch.DrawString(_bitmapFont, $"Press D: {typeof (DefaultViewportAdapter).Name}", new Vector2(5, 5), Color.White);

            _spriteBatch.DrawString(_bitmapFont, $"Press S: {typeof (ScalingViewportAdapter).Name}", new Vector2(5, 5 + _bitmapFont.LineHeight * 1), Color.White);

            _spriteBatch.DrawString(_bitmapFont, $"Press B: {typeof (BoxingViewportAdapter).Name}", new Vector2(5, 5 + _bitmapFont.LineHeight * 2), Color.White);

            _spriteBatch.DrawString(_bitmapFont, $"Current: {_currentViewportAdapter.GetType().Name}", new Vector2(5, 5 + _bitmapFont.LineHeight * 4), Color.Black);

            _spriteBatch.DrawString(_bitmapFont, @"Try resizing the window", new Vector2(5, 5 + _bitmapFont.LineHeight * 6), Color.Black);

            _spriteBatch.DrawString(_bitmapFont, $"Mouse: {_mousePosition}", new Vector2(5, 5 + _bitmapFont.LineHeight * 8), Color.Black);

            _spriteBatch.End();

            base.Draw(gameTime);
        }