A simple script for managing resolution scaling in FNA.
Go to file
Evan Hemsley 0999b7da78 update README with usage details 2020-07-17 13:56:08 -07:00
LICENSE Initial commit 2020-07-17 20:50:24 +00:00
README.md update README with usage details 2020-07-17 13:56:08 -07:00
ResolutionScaler.cs scaler script 2020-07-17 13:52:05 -07:00

README.md

ResolutionScaler

A simple script for managing resolution scaling in FNA.

Usage

Call ResolutionScaler.Init with your display width and height, and your virtual width and height.

    Resolution.Init(
        GraphicsDevice.PresentationParameters.BackBufferWidth,
        GraphicsDevice.PresentationParameters.BackBufferHeight,
            PLAY_AREA_WIDTH,
            PLAY_AREA_HEIGHT
    );

Then you can pass ResolutionScaler.TransformMatrix to FNA's SpriteBatch to properly transform your game's render target.

    SpriteBatch.Begin(
        SpriteSortMode.Deferred,
        null,
        null,
        null,
        null,
        null,
        Resolution.TransformMatrix
    );

    SpriteBatch.Draw(
        GameRenderTarget,
        Vector2.Zero,
        Color.White
    );

    SpriteBatch.End();