Resolution & Sprite Position

How to fix this:

On a 1600x900 resolution:

Screenshot 2020-09-25 150315

On a 1920x1080 resolution:

Screenshot 2020-09-25 150341

One possibility is to render everything to a Render Target which has a defined resolution (always the same). You would render everything to this Render Target instead the backbuffer (“directly to the screen”). Then the final step is to just take your Render Target and render this to the actual size of your Game window. So everything will be upscaled for you. Does this approach makes sense for you?

Can you give an example code? :slight_smile:

RenderTarget2D gameRT;
...
protected override void LoadContent()
{
    gameRT = new RenderTarget2D(GraphicsDevice, VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
}
...
protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.SetRenderTarget(gameRT);
...
    GraphicsDevice.SetRenderTarget(null);
    _spriteBatch.Begin();
    _spriteBatch.Draw(gameRT, new Rectangle(0, 0, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight), Color.White);
    _spriteBatch.End();
}
1 Like

Check out this article :slight_smile:

http://www.david-amador.com/2010/03/xna-2d-independent-resolution-rendering/

2 Likes