@TheKelsam and @kyotsuyoi,
I have experienced issues with the screen position being offest over the years as well using UWP builds of MonoGame.
The fix TheKelsem laid out is needed in my UWP projects. I solved a bit differently using a timer that delayed about a second before calling ApplyGraphicsSettings. It seemed if I just waited one update cycle it wouldn’t work either. If I didn’t apply this fix it seemed the screen would be stretched incorrectly based on the actual resolution.
I’ve also experience what kyoutsuyoi had difficult with. In this case, to fix I had applied a manual nudge to move the screen into a better position on TV screens when the game is played on XBox. I’m really happy to find this fix as it is much better solution than what I was trying. Thank you for posting your solution!
One last note on this, as I investigated your fix. In a previous release of MonoGame, there used to be 2 UWP templates. The current MonoGame release uses a file called App.xaml.cs to launch Game. In this configuration, I need both the fix kyotsuyoi posted and TheKelsem posted.
In my experience, using the older style UWP template, kyotsuyoi’s fix is not needed, but TheKelsem’s still is. I don’t think anything stops someone from setting up MonoGame to run directly from Program instead of from xaml.app and I am unsure sure why one was chosen over the other in later MonoGame versions than perhaps the differences were insignificant between the two options?
So bottom line, on a current UWP MonoGame template, if someone is expreiencing problems related to resolution, I would recommend trying both a delayed setting ofApplyGraphicsSettings and also setting ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
.
I wonder if it is worth a PR to try to add kyotsuyoi’s fix to the UWP template? This post may be worth reposting over in GitHub discussions as I’m sure others will want this info if they shut down this forum.
The older UWP template would look something like below.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
var factory = new MonoGame.Framework.GameFrameworkViewSource<Game>();
Windows.ApplicationModel.Core.CoreApplication.Run(factory);
}
}
Thanks again for posting, this was very helpful!
-Brett