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

Author Topic: setFrameRateLimit & setVirtualSyncEnabled  (Read 1937 times)

0 Members and 2 Guests are viewing this topic.

MW2TopTenWORLD

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
setFrameRateLimit & setVirtualSyncEnabled
« on: August 26, 2014, 08:21:12 pm »
Hey, I know this is going to be very very very noobish...
but is there a way that I can do like

if(virtualsync() does not work)
{
   setframeratelimit)
}
else
{
virtualsync()
}

please :)

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: setFrameRateLimit & setVirtualSyncEnabled
« Reply #1 on: August 26, 2014, 08:47:24 pm »
What do you mean by "v[ertical]Sync() does not work"? Do you mean that if the graphics card decides to ignore what you tell it to do?
First thing you could do is to make sure your graphics card allows applications to set the vsync.
I don't think there's a way (at least not via SFML) to ask the graphics card if vsync is being using but another thing you could do in that case is to test the framerate to see if it's below a certain amount after trying to activate the vsync. If it's above 1000, for example, it's probably not set, so you can set the framerate limit (after setting vsync to false, of course).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

MW2TopTenWORLD

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: setFrameRateLimit & setVirtualSyncEnabled
« Reply #2 on: August 27, 2014, 12:42:32 am »
From what I know vSync simply syncs the frame rate to the refresh rate of the screen (or something like that) so it's a good frame rate :)
But I am sure not all graphic cards or monitors do not support vSync, so in case it didn't work it would just be set to a default value like 30, 60 ...etc :) Get what I Mean?

Anyways thanks for your suggestion and yeah I dont think there is a way thats why I asked ;(

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: setFrameRateLimit & setVirtualSyncEnabled
« Reply #3 on: August 27, 2014, 01:07:31 am »
Quote
From what I know vSync simply syncs the frame rate to the refresh rate of the screen (or something like that) so it's a good frame rate :)
First part: Yes.  Second part: Maybe?  I believe the primary goal of vsync is to keep the program and monitor in sync, which prevents screen tearing.  Not quite the same thing as having a "good" frame rate, though it does happen to work out that way.

Whether vsync "works" thus depends on timing properties of both the graphics card and the monitor(s), in addition to all the usual stuff like your program and the OS and the user's perception.  I would be shocked if there's a reliable, platform-independent way of judging this that works well enough that none of your users will ever feel the need to flip a vsync setting in the options menu themselves.  As a random example: Chrome uses vsync by default, but I still see screen tearing in streamed online video every day.  I have no idea why this is the case, but I'm sure it's far too complicated for me to understand.

Even if there was a way to detect this, vsync can have downsides (input lag, huge perf drops if the timing is just wrong, etc) which you simply can't measure the impact of, so you'd still want it to be an option users can disable if it doesn't work well for them.  Triple buffering adds another layer of complications and trade-offs.
« Last Edit: August 27, 2014, 01:20:24 am by Ixrec »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: setFrameRateLimit & setVirtualSyncEnabled
« Reply #4 on: August 27, 2014, 01:17:31 am »
Vsync is handed by the graphics card and SFML just informs it that it thinks that it should use it. I'm not aware of a way to find out if the graphics card listened and obeyed though, other than accessing drivers or something. My final suggestion of testing the framerate yourself is a possible way to find out to some degree but some displays can run at a pretty high frequency.

@Ixrec This is a guess but Chrome could be displaying perfectly while the update of the video itself could be tearing. It made sense it my head but seems much sillier now I've written it down.  ???
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: setFrameRateLimit & setVirtualSyncEnabled
« Reply #5 on: August 27, 2014, 01:22:29 am »
@Hapax: Honestly, I can't figure out how to determine whether these videos are being single, double or triple buffered, so I can't even begin to speculate on where the causes of tearing might be.

 

anything