MoonTools.ResolutionScaler/README.md

39 lines
854 B
Markdown
Raw Permalink Normal View History

2020-07-17 20:50:24 +00:00
# ResolutionScaler
2020-07-17 20:56:08 +00:00
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.
```cs
2020-07-17 20:56:30 +00:00
ResolutionScaler.Init(
2020-07-17 20:56:08 +00:00
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.
```cs
SpriteBatch.Begin(
SpriteSortMode.Deferred,
null,
null,
null,
null,
null,
2020-07-17 20:56:30 +00:00
ResolutionScaler.TransformMatrix
2020-07-17 20:56:08 +00:00
);
SpriteBatch.Draw(
GameRenderTarget,
Vector2.Zero,
Color.White
);
SpriteBatch.End();
```