SFML community forums

Help => Window => Topic started by: squares on March 29, 2013, 06:18:38 pm

Title: Get monitor refresh rate (vsync)
Post by: squares on March 29, 2013, 06:18:38 pm
Is it possible to get the monitor's refresh rate? Also, would it be advisable to check the desired framerate with the refresh rate to use vsync if they are the same, but use setFramerateLimit() if not?
As in:

void initWin()
{
  unsigned short vsyncRate = /* get refresh rate */ 60;
  if ((vsyncRate - this->fps < 5) || (this->fps - vsyncRate < 5)) {
    this->win->setVerticalSyncEnabled(true);
  } else {
    this->win->setVerticalSyncEnabled(false);
    this->win->setFramerateLimit(this->fps);
  }
}
 
Title: Re: Get monitor refresh rate (vsync)
Post by: Laurent on March 29, 2013, 06:59:22 pm
Quote
Is it possible to get the monitor's refresh rate?
No. But if you use a LCD monitor (who doesn't?), it's 60 Hz.

Quote
Also, would it be advisable to check the desired framerate with the refresh rate to use vsync if they are the same, but use setFramerateLimit() if not?
Why would you want a framerate different than the refresh rate of your monitor?