Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Get monitor refresh rate (vsync)  (Read 1534 times)

0 Members and 1 Guest are viewing this topic.

squares

  • Newbie
  • *
  • Posts: 1
    • View Profile
Get monitor refresh rate (vsync)
« 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);
  }
}
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Get monitor refresh rate (vsync)
« Reply #1 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?
Laurent Gomila - SFML developer