SFML community forums
Help => Window => Topic started by: Redee on September 26, 2015, 02:22:28 pm
-
Detection monitor frequency for Windows / MacOS / Linux ?
Using SFML api how ?
Me need to detect screen frequency before generated window, from OS.
-
http://en.sfml-dev.org/forums/index.php?topic=18950.msg136924#msg136924
.... when it finally happens.
Otherwise you need to lookup specific functions for each OS to determine the refresh rate (on your own).
What I am most interested in though, why must you know the refresh rate? To me without a good reason it sounds like it maybe a design flaw that you must know the requested information. To me this seems like the XY problem (http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem).
-
Monitor frequency is not so easy, because the system may have 2-3 displays with different frequency. And an application window may be placed between two displays. So, the parts of app window will be displayed on several displays simultaneously. It will cause an issue if such cases will not be handled in application properly.
Under windows and directx I was used MonitorFromWindow to detect which monitor displays most bigger part of window. And used it to obtain monitor frequency.
-
Like zsbzsb mentioned I am working on multi screen support. It also adds the ability to get the screens refresh rate for every screen like this: sf::Screen::get(id).refreshRate. Currently there is only a windows implementation. But I would be happy if you could test it and see if it works for you. My branch: https://github.com/Foaly/SFML/tree/multi-monitor
-
What I am most interested in though, why must you know the refresh rate? To me without a good reason it sounds like it maybe a design flaw that you must know the requested information.
I used it, because in some cases, foe example - rendered image may contains some effect named "multicolor". It means that color of an object may be changed on every frame. So renderer should be synchronized with physical refresh rate. Otherwise actual color visible to the user may looks like random flicks.
-
If you just need to sync to it but not actually know the actual value, the that sounds like what you need is setVerticalSyncEnabled (http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1Window.php#a59041c4556e0351048f8aff366034f61).
-
On Windows I already have solution.
And its for setVerticalSync also.
For my game logic need to detect monitor freq to measure parts of exact time.
Ok setVertSync good but I cant easily take freq.
We can before game run some measure of screen frame time - and will see how refresh of its monitor.
Maybe its best solution without systems api.
Or we must release separated solutions for each OS.
-
Don't rely on refresh rate for syncing your game logic or animations. Better use timers (sf::Clock). Depending on the user's hardware, there might be nothing such as an actual/current refresh rate at all (e.g. Nvidia's GSync).
-
On Windows I already have solution.
And its for setVerticalSync also.
For my game logic need to detect monitor freq to measure parts of exact time.
Ok setVertSync good but I cant easily take freq.
We can before game run some measure of screen frame time - and will see how refresh of its monitor.
Maybe its best solution without systems api.
Or we must release separated solutions for each OS.
you can enable vblank sync and measure interval between frames. You can do it on app startup, so in that way you can calculate the real frame rate.
-
you can enable vblank sync and measure interval between frames. You can do it on app startup, so in that way you can calculate the real frame rate.
Uhh... no, this is a terribly messed up hack solution to a non issue.
-
you can enable vblank sync and measure interval between frames. You can do it on app startup, so in that way you can calculate the real frame rate.
Uhh... no, this is a terribly messed up hack solution to a non issue.
Actually, sometimes its needed, because the system may report invalid frame rate and the real one may be a little different. In some cases, when refresh rate is used to synchronize output it may cause big issues...
The best way is to use QueryPerformanceCounter on windows platform. I remember that I even read some article about it which describes pros and cons of using TSC vs QueryPerformanceCounter for such purposes.
I'm agree that it's hard solution and is not intended for usual graphics projects. But using such technique is very useful for realtime monitoring of renderer performance.
-
Shouldn't the real fix be to decouple your logic from your refresh rate?
The rate at which you update game logic, physics and what-not ought to be completely decoupled from the rate at which you render frames. If the two interact, then that's where your problem is.
-
Souldn't the real fix be to decouple your logic from your refresh rate?
The rate at which you update game logic, physics and what-not ought to be completely decoupled from the rate at which you render frames. If the two interact, then that's where your problem is.
I talked about the case when realtime effect of switching object color is need to be synchronized with refresh rate. It's not about logic, it's about video effects...
-
So we got one very exotic corner case. Any other examples?
-
So we got one very exotic corner case. Any other examples?
For usual project simple method which returns the value reported by the system ismore than enough :)
-
And we must exacts functions for every OS - not one 4 all...
Yes is more than enough - but no simple to use - and OS dependencies has.
Measuring - yes its very bad idea - need value only from hardware.