Ok so updating this thread for future viewers, I’ve had what I think is perhaps the correct answer on Stackoverflow: Unfortunately it is NOT possible to get the screen refresh rate Hz in a UWP game (in a way that is compatible with the Microsoft Store).
(How do I GET the screen refresh Hz in C# UWP? - Stack Overflow)
Another issue arose out of this in that in UWP it is NOT possible to set the PresentationInterval to Two either…that is to say, “This is a fast monitor, lets only draw every second frame and achieve smoothness that way”. It’s just not supported in UWP.
So in UWP I can see only 3 options:
-
Allow a Variable TimeStep. Time all your movement to ElapsedTime between Updates and hope you don’t have any hitches… with varying elapsed times, for a 2D game this is probably a complete non starter with horrible jerky movement but is perhaps OK for 3D games or if potentially running slowly on slow machines.
-
Decide on a framerate (60) and use a FixedTimeStep TargetTime for that (1/60 seconds but in ticks). You can still base your movement on ElapsedTime but since using a FixedTimeStep you don’t actually have to if 60FPS is always going to be achievable. Resign yourself that for high refresh rate monitors, the game may appear jerky since the Update/Draw rate is not going to be 1:1.
I’ve found that this strategy on Windows DirectX, even with a fullscreen exclusive window is beyond awful for 120Hz display (you’re much better off with PresentationInterval.Two if targeting 60FPS) but on Windows UWP it’s not that bad…perhaps because it’s not fullscreen exclusive…but you take a performance hit for that too. -
Bizarrely ask your user what refresh rate their monitor is and set your FixedTimeStep Target to that (1/X but in ticks). Only do this if your game CAN actually run at those high rates on their machine, obviously this may vary depending on their machine.
If I get any more info I’ll try to update this thread. If anyone else has any ideas or input on this I’d love to hear about it.