0
\$\begingroup\$

I am working with Direct3D 11 and I am trying to figure out how to make my game run at 60 fps. Currently I use :

swapChain->Present(1, 0);

To max the fps with Vsync. This only works because my monitor is 60hz though. As I understood it, the first parameter of Present is used to divide the current screen's refresh rate to obtain a certain fps. So I can get 60fps by setting this to 2 on a 120hz monitor or even 4 on future 240hz monitor and so on.

My problem is this : what do I do with 144hz monitors? Is there any way to get 60fps vsync on those monitors?

\$\endgroup\$
2
  • \$\begingroup\$ If you target a 144 and you can't change the screen refresh-rate, I'd suggest you to target a refresh rate different than 60 as you'll see weird stuff on the screen. You should target a refresh rate of a factor of 144. \$\endgroup\$
    – Vaillancourt
    Sep 26, 2017 at 10:08
  • 1
    \$\begingroup\$ Typically you don't angst quite that much about the refresh rate (at least on PC). You render "as fast as possible". You can then use a fixed-time step to ensure that the game simulation logic all runs at a fixed frame-rate like 60 Hz (see StepTimer). \$\endgroup\$ Sep 26, 2017 at 17:02

1 Answer 1

2
\$\begingroup\$

Vsync, like Sleep, is a terrible way of controlling frame rate, because (and also like Sleep) controlling frame rate is not it's primary purpose but a fortuitous side effect of it's primary purpose. Sleep is prone to different clock resolutions and vsync is prone to different refresh rates.

If you break it down, your problem is not that you want to vsync at 60fps; it's that you want to run at a fixed 60Hz timestep instead. So don't use vsync or Sleep for this, Fix Your Timestep instead: https://gafferongames.com/post/fix_your_timestep/

Afterwards, if you wish to reduce CPU usage use Sleep, if you wish to avoid screen tearing use vsync. But unfortunately there is no one solution that reliably does all three on all hardware.

\$\endgroup\$

You must log in to answer this question.

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