Hello. I’m trying to transform my texture for different screen resolutions.
I use the following code:
const int DesignWidth = 1920;
const int DesignHeight = 1080;
Matrix scaleMatrix;
protected override void Initialize()
{
float scale_wid = (float)graphics.GraphicsDevice.PresentationParameters.BackBufferWidth / DesignWidth;
float scale_hei = (float)graphics.GraphicsDevice.PresentationParameters.BackBufferHeight / DesignHeight;
scaleMatrix = Matrix.CreateScale(scale_wid, scale_hei, 1.0f);
...
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(transformMatrix: scaleMatrix);
spriteBatch.Draw(static_background, Vector2.Zero, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
The size of the used texture: 1920: 1080 pixels
The result is the following (see image)
Why does the blue bar appear?