3
\$\begingroup\$

I'm using Monogame to create a simple game.

In my Game1 class initializer I set this:

Graphics.PreferredBackBufferWidth = 1280;
Graphics.PreferredBackBufferHeight = 1024;
Graphics.ApplyChanges();

My screen resolution is 2560x1600, so the window should be relatively small on startup. However, it's filling the entire screen and more. Why is that? I'm new to this so I have no idea what other information you might need to help me.

Thanks

EDIT: Okay, it had something to do with me messing with the Configuration Manager. There, I tried adding x64 support (no idea, if that's necessary). I'm not sure what I did there, though. I thought I deleted everything I added. However, after reverting the project to the last commit, the problem is gone. What happened there? Any ideas?

\$\endgroup\$
0

1 Answer 1

0
\$\begingroup\$

On MS Windows

Are you on a high DPI setting and does your application manifest declare DPI-awareness?

Many parts of WinAPI use Device-Independent Pixels, and whether 1280 means pixels or DIPs (on a display with 2x DPI scaling, that's 2560 physical pixels) depends on how your application declares its DPI awareness.

I've encountered some interesting behavior in Monogame with regards to DPI handling, so for best results check both your dpiAware and dpiAwareness settings in the manifest.


Non-Windows

I don't have experience with Monogame on other platforms, so hopefully someone else can answer to that. I believe OSX native APIs also use DIPs, so should show the same effect.

\$\endgroup\$
5
  • \$\begingroup\$ I can check it, thanks. But I don't think, it's related to that (besides, I have an extremely low DPI) .The thing is, it was working perfectly fine until I messed around with the configuration manager. So it's probably something with that \$\endgroup\$ Apr 23, 2018 at 18:25
  • \$\begingroup\$ "By DPI setting" i mean the "UI scaling setting in windows", not the physical dots per inch on your monitor. For example, my current laptop display is 3200x1800 pixels, at 200% dpi scaling, which means its dimensions is 1600x900 DIPs. (imgur.com/a/OUc4Mdk) \$\endgroup\$
    – Jimmy
    Apr 23, 2018 at 18:58
  • \$\begingroup\$ Oh okay. Yeah, it is on 200%. But it still doesn't explain what happened, I think. It worked before, like I said (even with 200% scaling) \$\endgroup\$ Apr 23, 2018 at 19:07
  • 1
    \$\begingroup\$ The default app.config Visual Studio generates for you includes a dpiAware=true setting. If you're using ConfigurationManager in a way that bypasses the default app configuration, dpiAware will be default to false if your own configuration doesn't set it. \$\endgroup\$
    – Jimmy
    Apr 23, 2018 at 19:26
  • \$\begingroup\$ That totally makes sense! Thank you for explaining this. Now it seems likely that this caused it. I will try to confirm it tomorrow and then I will accept this answer. Thanks! \$\endgroup\$ Apr 23, 2018 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .