[SOLVED] Display resolution on Windows 10

I have just started Monogame development, though I have years of experience in XNA , and so far so good.

I have a couple of issues, the main one is that when you run in windowed mode on Windows 10, the window displayed is scaled by the desktop scale setting.

I use a 4K monitor for coding and have to scale the desktop by 1.75 to be able to read anything.

This scaling means I cannot drag the window to my second monitor for debugging because the post scaling resolution is greater than the resolution of the second monitor.

So ā€¦

a) Is it possible to get a Monogame app to ignore the windows scaling?
b) Is it possible to force a Monogame app to start up on a particular monitor

Other than that it is going well. I ported my signed distance field font renderer to Monogame in about 10 minutes.
Ported my scene management system and scene transition system in another 10 minutes.

Really nice to use my old code base again.

Cheers

Stainless

I use a 4K monitor for coding and have to scale the desktop by 1.75 to be able to read anything

You are talking about the windows DPI scaling, right?

Please open the ā€œapp.manifestā€ file in your project root and search for this:

<application xmlns="urn:schemas-microsoft-com:asm.v3">
        <windowsSettings>
          <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
        </windowsSettings>
 </application>

Change the ā€˜dpiAwareā€™ setting to ā€˜falseā€™ and you are good to go.

Is there a more final way to make that change? The only .manifest file I can find is in my gameā€™s output folder where it compiles to. It also doesnā€™t have that section in it, but Iā€™ll try adding it and see if it makes any difference next time Iā€™m using my laptop (which has this same scaling problem).

You can include a .manifest file in your project root (thereā€™s a template for it in VS) and set it as the .manifest file of your project in your project properties. Disabling dpi awareness can cause issues for MonoGame though. It may retrieve incorrect display resolutions from the GraohicsAdapter due to the scaling, which can cause a crash when creating a GraphicsDevice. This is why MG templates since 3.6 include a .manifest file making your project per monitor dpi aware (pm/true setting in the .manifest file).

1 Like

When you create a fresh MonoGame 3.6 project by with one of the original templates, then the ā€œapp.manifestā€ file is automatically a part of your project (root).

When you use an older version of MonoGame or upgraded from an older one, then you can easily add the manifest file by yourself.

Just add a new file to your project, call it ā€œapp.manifestā€ and add the following to it:

<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity version="1.0.0.0" name="Game1"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- A list of the Windows versions that this application has been tested on and is
           is designed to work with. Uncomment the appropriate elements and Windows will 
           automatically selected the most compatible environment. -->

      <!-- Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />

      <!-- Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />

      <!-- Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />

      <!-- Windows 8.1 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />

      <!-- Windows 10 -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

    </application>
  </compatibility>

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
    </windowsSettings>
  </application>

</assembly>

(This is what the original file contains)

After that you need to open the Properties of your project and select the new manifest file:

Edit: Please read the additional infomation provided by @Jjagg

1 Like

Thanks for the explanation! I probably wonā€™t bother disabling it, then. Itā€™s a tough problem though. I was noticing on my laptop that the resolutions that were retrieved from the GraphicsAdapter werenā€™t the computerā€™s resolutions, but the scaled ones, and the game was zoomed in. Itā€™s worth some tinkering later, probably.

Thanks, that sorted it nicely.