Does anybody else get the problem that VSync = 2 doesn’t work in UWP and MonoGame, instead you end up with VSync = 1 no matter what?
The scenario is that I’ve just released “Geometry Warp” on the MS Store and it needs to run at a locked 60FPS, even if the user has a 120Hz+ TV/Monitor. Being an Arcade type game, IsFixedTimeStep = true isn’t ideal as it doesn’t always match 1:1 with the screen refresh so I’d rather sync to every second VBlank.
Maybe I’m doing something silly but I feel that this code should have worked (from a default UWP Game Program):
public class GameTestVSyncTwo : Game
{
GraphicsDeviceManager graphics;
// This will not be applied correctly in UWP, Only interval One.
PresentInterval PresentIntervalRequired = PresentInterval.Two;
public GameTestVSyncTwo()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
this.IsFixedTimeStep = false;
graphics.PreparingDeviceSettings += Graphics_PreparingDeviceSettings;
}
private void Graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
PresentationParameters pp = e.GraphicsDeviceInformation.PresentationParameters;
pp.PresentationInterval = PresentIntervalRequired;
}
protected override void Draw(GameTime gameTime)
{
Color clearColor = GraphicsDevice.PresentationParameters.PresentationInterval == PresentIntervalRequired ?
Color.Blue :
Color.Red;
// Blue = correct but that value has NOT been correctly applied to VSync Interval!
// Instead we have VSync = One.
GraphicsDevice.Clear(clearColor);
base.Draw(gameTime);
}
}
The output I get on a 120Hz Screen, when I would have expected 60FPS:
As an aside I found that
graphics.SynchronizeWithVerticalRetrace = false;
used to crash on MG 3.7 with this error:
// Exception thrown: ‘SharpDX.SharpDXException’ in SharpDX.dll
// Exception thrown: ‘Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException’ in MonoGame.Framework.dll
but works perfectly on MG 3.8.
The VSync issue persists however. I also don’t think it’s a UWP issue per se as Unity can deal with this correctly AND can correctly detect the current screen refresh rate, something I find impossible using MonoGame, there’s just no API for that?
Is this a bug or am I just doing it wrong?