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

Author Topic: Get Monitor Refresh Rate.  (Read 29065 times)

0 Members and 2 Guests are viewing this topic.

DanielDorn1997

  • Newbie
  • *
  • Posts: 7
    • View Profile
Get Monitor Refresh Rate.
« on: March 17, 2016, 08:15:12 pm »
I feel that SFML should provide a way to get the refresh rate of a monitor, this is needed for anybody interested in making games that rely on a rate limited game loop, the reason for needing a way to get a refresh rate is simply because not all monitors run at 60H any more, some run at 120H and 144H to create a smoother experience, with any game your frame rate should always only be double that of the refresh rate, and without a way to get the refresh rate it sort of breaks things since you cant necessarily make a static rate of 60 anymore, thank you in advanced for taking a look at this (:

korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
Re: Get Monitor Refresh Rate.
« Reply #1 on: March 17, 2016, 08:26:19 pm »
+1!

For example my game looks much better, when framerate limit is set to doubled vsync rate, but now there is no easy way to make this process automated.

DanielDorn1997

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #2 on: March 17, 2016, 09:46:26 pm »
@korczurek k thanks for replying (:, So exactly, your game will look better running a frame rate that is double the refresh rate, that being said it also has an effect on the entire game it's self, so lets say perhaps you are creating a game that has no frame limit while this will run and work correctly you are wasting cycles and reducing performance, and in turn burdening the players hardware, with a frame rate that is statically set the frame rate 120 in the games programming to never be changed and always be the same frame limit you fix the problem of wasting cycles and bad performance but now if someone runs this on a computer monitor running at 144H it will seem less smooth than someone a monitor at 60H, now you could in turn make the frame rate higher to accommodate monitors that run higher than 60 by setting the frame rate and 288, this will also work and look good on all monitors, but once again you are wasting cycles and creating bad performance on a computer using a monitor that runs at 60H, and yes there is no easy way at the moment to get the refresh rate through sfml, the only way you can do this would be to use config.h file in sfml to check the platform and do every thing yourself through os specific interfaces like win32 api, thank you in advanced for any and all replies (:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32110
    • View Profile
    • SFML's website
    • Email
Re: Get Monitor Refresh Rate.
« Reply #3 on: March 17, 2016, 10:08:25 pm »
Any chance that you break these walls of text into sentences and paragraphs, to make them readable? ;)

There's a proposal for a monitor API, which gives access to the monitor(s) refresh rate:
http://en.sfml-dev.org/forums/index.php?topic=18950.0

I think it's safe to assume that such an interface will soon be integrated to SFML.
« Last Edit: March 17, 2016, 10:16:44 pm by Laurent »
Laurent Gomila - SFML developer

DanielDorn1997

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #4 on: March 17, 2016, 10:22:45 pm »
@Laurent sorry for the above post being cluttered together (=,

The first point i was trying to make with the original post was, i think there should be a function in SFML to get the refresh rate of a monitor, the need for getting the refresh rate of the monitor is pretty fundamental to most game loops that rely on fame limiting, that being said i think it should be part of SFML because SFML manages the applications window thus already having to receive information about the monitor, so implementing should not be to difficult.

But to further the point not getting the refresh rate of a monitor directly effects any and all applications using SFML, since your max frame rate should never be higher than double the monitor refresh rate, that being said you could simple just say in the programming the refresh rate is always 60Hz but this will not work because most newer monitors now are running at 120Hz - 144Hz,

Now how exactly does all applications using SFML, this effects not only how smooth the application / game looks, but also effects performance because if your frame limit is higher than double the refresh rate you are not seeing any difference than if it was just double the refresh rate, thus you are wasting cycles, reducing performance, and hindering hardware.

Now you could also say just set the Frame rate double that of 144Hz or in other words 288 fps the highest most monitors refresh rates are but even with this approach there are problems, since running 288 fps on a monitor that only runs 60Hz is wasting cycles and performance.

i hope this is less cluttered, thanks in advanced for looking and replaying to this (=
« Last Edit: March 17, 2016, 10:33:30 pm by DanielDorn1997 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9271
    • View Profile
    • development blog
    • Email
Re: Get Monitor Refresh Rate.
« Reply #5 on: March 18, 2016, 12:26:03 am »
As Laurent said, an API for it is already being discussed, there's no need to further trying to convince us. ;)

In the meantime there are three options you can use:
  • Use VSync and let your GPU driver handle the monitor refresh rate
  • Provide an in-game option for changing the FPS
  • Just use a high FPS rate, if a user doesn't have monitor with a high refresh rate, the GPU will only output as much as the monitor can handle and drop the rest.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

DanielDorn1997

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #6 on: March 18, 2016, 01:44:32 am »
@eXpl0it3r my last reply i posted was just breaking the other reply's aka.( walls of text as Laurent put it  ;) ) into readable groups of text as requested of Laurent which, i saw that Laurent had updated the reply to say an API is already being planned so i left it at that, as for my problem i already fixed it, just did my own version of the implementation.

My temporary version of the implementation was to just use the config.h file provided by sfml to check what OS is being used, after that i just implemented the functions i needed for Mac OSX, Linux, Windows.

But thank you for the reply and possible work around's it was appreciated  :)

Hapax

  • Hero Member
  • *****
  • Posts: 2755
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #7 on: March 18, 2016, 01:52:47 am »
your max frame rate should never be higher than double the monitor refresh rate
If, by frame rate, you mean render frame, I think the obvious choice is to just use vsync.
However, if, by frame rate, you mean logic frame (or tick/cycle), changing this rate based on a monitor's refresh rate means that logic is being executed at a different rate on different monitors (not even different computers!) This can lead to unreliable and inconsistent logic. Consider setting a fixed logic update rate to match the update rate that the application requires and is designed for and separate the rendering to render at, say, the refresh rate (vsync).
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

DanielDorn1997

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #8 on: March 18, 2016, 02:07:44 am »
@Hapax frame rate as in the games fps, and refresh rate of the monitor, having the render frame limit equal to double the refresh rate is ideal for a game to stay smooth, the renders frame limit in no way effects the games logic / physics update since it is all based on delta time not frame limits

An example for instance you have a class called game, game is the main game loop where the render loop, logic / physics loop, and event loop is executed, the frame limit only effects the render loop since in terms of how smooth the game looks, it doesn't really effect the games logic because as any game loop should have every things is based off delta time for updates, you should never base game logic / physics on frame rate updates instead you should implement a timer to get delta time and update based on that.

also as is said to @eXpl0it3r i already made a implementation to work around, but thank you for the reply  :)
« Last Edit: March 18, 2016, 02:18:25 am by DanielDorn1997 »

Hapax

  • Hero Member
  • *****
  • Posts: 2755
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #9 on: March 18, 2016, 02:17:41 am »
What difference does it make if you draw two frames or just one frame per monitor refresh?
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

DanielDorn1997

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #10 on: March 18, 2016, 02:25:33 am »
@Hapax it just makes graphics look smoother, the reason for only going double is because going any higher than double is not noticeable to the human eye, that is the only reason to have a fps double the refresh rate, as for other reasons not to go higher than double just read my other post as they explain :)
« Last Edit: March 18, 2016, 02:28:03 am by DanielDorn1997 »

Hapax

  • Hero Member
  • *****
  • Posts: 2755
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #11 on: March 18, 2016, 03:58:31 am »
Only one of those two frames will be displayed. The first one will be overwritten by the second and then that second one will be displayed; the first one will never be seen.
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: Get Monitor Refresh Rate.
« Reply #12 on: March 18, 2016, 08:08:22 pm »
Daniel, I think you're confusing what you're talking about with a mix of double-buffering (which SFML already does for you) and vsync (which is an option in SFML).

redmaskxux

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Get Monitor Refresh Rate.
« Reply #13 on: April 27, 2019, 09:20:20 pm »
Daniel, I think you're confusing what you're talking about with a mix of double-buffering refresh rate (which SFML already does for you) and vsync (which is an option in SFML).

He is right,he frame limit only effects the render loop since in terms of how smooth the game looks, it doesn't really effect the games logic because as any game loop should have every things is based off delta time for updates.

 

anything