The scaling of Windows 10 may cause window resolution errors.[Solved!]

There’s a resolution problem in Windows 10 when using monogame(both play games and coding).
If you set your “Scaling and layout” to bigger than 100%(such as 125% or 150%) in windows 10, the monogame will render a error resolution.


I put a rectangle in the middle of the screen like this:

ball <- 
            {
                Position = Vector2(float32(this.GraphicsDevice.Viewport.Width / 2 - 4), float32(this.GraphicsDevice.Viewport.Height / 2 - 4))
                Speed = 300.f
                SelfTexture = 
                    let t = new Texture2D(this.GraphicsDevice, 8, 8)
                    (t.Width * t.Height, Color.White) ||> Array.create |> t.SetData
                    t
            }

In the sitiation where the scaling rate is 100%, everything will be fine like this:


(1080P, 100% scaling rate)
if you set you s rate to 125% or 150%, the resolution seems to be set into 720P even there’s no changes at all.

(1080P in code, 125% rate)

(1080P in code, 150% rate)


The problem not only bothers developers, but may bothers Game Player at the same time.
When you use high scaling rate when playing games such as StarDew Valley, there will still have some bugs on graphics.

Ok i’ve solved the problem.
plz setup your RenderTarget2D at the same time.

    override this.Initialize() =
        graphics.PreferredBackBufferWidth <- 1280
        graphics.PreferredBackBufferHeight <- 720
        this.GraphicsDevice.SetRenderTarget (new RenderTarget2D(this.GraphicsDevice, 1920, 1080))
        this.Window.AllowUserResizing <- true
        graphics.ApplyChanges()
        
        base.Initialize()