SFML community forums

General => Feature requests => Topic started by: Tungsten on November 07, 2008, 02:45:55 pm

Title: Add support for custom refresh rates
Post by: Tungsten on November 07, 2008, 02:45:55 pm
If you are using a CRT-monitor it will default to 60 Hz when using fullscreen mode. Instead of using a refresh rate locker for certain resolutions add a member to the VideoMode class.

VideoMode.hpp
Add an unsigned int DisplayFreq member.
Code: [Select]

    unsigned int Width;        ///< Video mode width, in pixels
    unsigned int Height;       ///< Video mode height, in pixels
    unsigned int BitsPerPixel; ///< Video mode pixel depth, in bits per pixels
    unsigned int DisplayFreq;  ///< Video mode display frequency


Change the constructor to take a DisplayFreq parameter(defaults to 60 if not specified).
Code: [Select]

VideoMode::VideoMode(unsigned int ModeWidth, unsigned int ModeHeight, unsigned int ModeBpp, unsigned int ModeFreq) :
Width       (ModeWidth),
Height      (ModeHeight),
BitsPerPixel(ModeBpp),
DisplayFreq(ModeFreq)


I have implemented it for the win32 platform

VideoModeSupport.cpp

In the GetSupportedVideoModes method add the DisplayFrequency argument to the constructor call.
Code: [Select]

VideoMode Mode(Win32Mode.dmPelsWidth,Win32Mode.dmPelsHeight,
               Win32Mode.dmBitsPerPel,Win32Mode.dmDisplayFrequency);

VideoMode.cpp

Change the overloaded comparison operator to
Code: [Select]

return  (Width        == Other.Width)        &&
        (Height       == Other.Height)       &&
        (BitsPerPixel == Other.BitsPerPixel) &&
        (DisplayFreq  == Other.DisplayFreq);

so it can fail if a too high refresh rate was selected.

WindowImpWin32.cpp

In the SwitchToFullscreen method add
Code: [Select]

DevMode.dmDisplayFrequency = Mode.DisplayFreq;
DevMode.dmFields    = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;

so it can change the frequency when the call to ChangeDisplaySettings is made.
Title: Re: Add support for custom refresh rates
Post by: zarka on November 07, 2008, 09:26:53 pm
Quote from: "Tungsten"
If you are using a CRT-monitor it will default to 60 Hz when using fullscreen mode. Instead of using a refresh rate locker for certain resolutions add a member to the VideoMode class.


A better solution would be to use the refresh rate currently selected by the user.. or you will probably be hated by all the gamers that play your game that have a monitor capable of higher refresh rates. That makes it safer to use to. in case someone has a monitor that does not support 60hz :)
Title: Add support for custom refresh rates
Post by: Tungsten on November 07, 2008, 10:20:14 pm
Uh , i think you misunderstood that statement.

The current svn-version of sfml will default back to 60hz no matter what refresh rate you use in desktop mode. You will always end up with 60 hz in fullscreen mode.

The change adds support for the user to specify the refresh rate used in fullscreen mode nothing else. If the specified refresh rate is not a supported mode it will fail and default back to the "best" mode supported by the card.

If you do not specify a value it will be set to 60. If that is not a supported refresh rate(which is highly unlikely) it will also fail and default back to the "best" mode supported by the card. That functionality is already implemented in sfml by the IsValid() method in the VideoMode class.

Of course you can change the behaviour so if no refresh rate value is specified it will try to pick the current desktop refresh rate but that might also fail if you use a different fullscreen resolution compared to your desktop resolution.
Title: Add support for custom refresh rates
Post by: zarka on November 08, 2008, 11:41:18 am
Quote from: "Tungsten"
Uh , i think you misunderstood that statement.

The current svn-version of sfml will default back to 60hz no matter what refresh rate you use in desktop mode. You will always end up with 60 hz in fullscreen mode.

The change adds support for the user to specify the refresh rate used in fullscreen mode nothing else. If the specified refresh rate is not a supported mode it will fail and default back to the "best" mode supported by the card.

If you do not specify a value it will be set to 60. If that is not a supported refresh rate(which is highly unlikely) it will also fail and default back to the "best" mode supported by the card. That functionality is already implemented in sfml by the IsValid() method in the VideoMode class.

Of course you can change the behaviour so if no refresh rate value is specified it will try to pick the current desktop refresh rate but that might also fail if you use a different fullscreen resolution compared to your desktop resolution.


Aaaah i see :) and now i agree with you :)
Title: Add support for custom refresh rates
Post by: Laurent on November 08, 2008, 09:34:17 pm
This is not the expected behaviour. On Windows, I change only the width, height and bits per pixel. So the frequency is not supposed to change. Did you try on other computers, to make sure this behaviour was consistent ?
Title: Add support for custom refresh rates
Post by: Tungsten on November 09, 2008, 01:33:07 pm
I actually think that is the expected behaviour if you do not specify a value for the dmDisplayFrequency member of the DEVMODE structure.

The ChangeDisplaySettings function will default to what is considered a "compatible" refresh rate for the device if not specified. It's a non-issue for LCD screens because they use a fixed 60 Hz frequency.
Title: Add support for custom refresh rates
Post by: Laurent on November 09, 2008, 07:25:26 pm
Quote
I actually think that is the expected behaviour if you do not specify a value for the dmDisplayFrequency member of the DEVMODE structure

I can't see anything saying this in the MSDN. I just see that there's a parameter where you specify what properties to change, so I assume the others won't be modified.
Title: Add support for custom refresh rates
Post by: SephiRok on July 27, 2009, 12:38:58 am
Quote from: "Laurent"
This is not the expected behaviour. On Windows, I change only the width, height and bits per pixel. So the frequency is not supposed to change. Did you try on other computers, to make sure this behaviour was consistent ?

My friend has the same problem.
Title: Add support for custom refresh rates
Post by: blewisjr on July 27, 2009, 01:07:23 am
I think that might be the default behavior.  Most LCD monitors actually use 60HZ frequency in windowed mode and 75HZ in fullscreen actually tho.
Title: Add support for custom refresh rates
Post by: SephiRok on July 27, 2009, 01:10:50 am
Windowed mode depends on the desktop refresh rate.

When switching to fullscreen you get forced to 60, even if your desktop is 75.
Title: Add support for custom refresh rates
Post by: blewisjr on July 27, 2009, 01:13:21 am
Opse had it backwards :P
Title: Add support for custom refresh rates
Post by: Calmatory on October 05, 2009, 11:59:58 am
Any further information on "solving" this issue?
Title: Add support for custom refresh rates
Post by: Laurent on October 05, 2009, 12:47:50 pm
No, sorry.
Title: Add support for custom refresh rates
Post by: Antidote on November 09, 2009, 07:51:21 am
LCDs DON'T use Hz they use Reponse Time (Measured in milliseconds), and it DOESN'T change when the application is in fullscreen or in windowed, i don't know where you got this information but it's wrong.

SephiRock is correct, windowed mode is dependent on the Desktop settings, and you are forced in to 60Hz when in fullscreen.
Title: Add support for custom refresh rates
Post by: dunce on November 10, 2009, 05:12:34 am
The last post here was more than a month ago. What's the need to dig up this topic just to discuss LCD monitors.
Quote
LCDs DON'T use Hz they use Reponse Time (Measured in milliseconds)

Refresh rate has nothing to do with response time. They are different physical characteristics. LCDs have both. Response time denotes dynamic capability of LCD cells (how fast they can change their state). LCDs DO use Hz (saying your words). For example my old crappy Samsung has three available rates (60, 70, 72 Hz). And I can choose any of them. BTW, a monitor itself, no matter CRT or LCD, knows nothing about windowed or fullscreen mode. These are OS & videodriver that control its behaviour.
Title: Add support for custom refresh rates
Post by: Antidote on November 11, 2009, 07:52:10 pm
dunce, as your name implies your stupid, the response time IS the refresh rate, common companies kept using Hz based refresh rate for LCDs because of people who would become confused, watch an LCD monitor, reduce it's refresh rate to the lowest "supported", then increase it to it's max, what happens? Nothing. Because LCDs are ALWAYS at the response time they are designed to operate at, this is constant and WILL NOT CHANGE, trust me I didn't spend 11 years studying computers and relevant technology just to be lambasted by this.

Refresh rate is used ONLY with CRT's it's the amount the guns fire PER SECOND! Video tape a CRT then video tape an LCD, you'll notice lines going up the CRT, but the LCD is crisp as ever, LCDs don't have electron guns, therefore refresh rate doesn't apply in the sense of CRTs infact LCDs ONLY use Response time. read a tech magazine or an A+ CompTIA or Cisco approved book they will concur with what I have stated, I didn't earn my A+ by sitting around with my thumb up my butt doing nothing.
Title: Add support for custom refresh rates
Post by: Nexus on November 11, 2009, 08:42:27 pm
Quote from: "Antidote"
dunce, as your name implies your stupid, [...] trust me I didn't spend 11 years studying computers and relevant technology just to be lambasted by this.

[...] I didn't earn my A+ by sitting around with my thumb up my butt doing nothing.
Even your great knowledge is no reason to be that rude. Just try to stay objective, no one is in the mood for silly arguments here.
Title: Add support for custom refresh rates
Post by: l0calh05t on November 11, 2009, 09:06:24 pm
despite his name, dunce is right, although using an incorrect terminology. "refresh rate" does technically only apply to CRT monitors, but LCDs also have a specific "update rate" (usually not related to the response time at all, although a 100 Hz update rate would be pointless with a 20ms response time), similar to the vertical refresh rate of old, which is usually fixed to 60 Hz.
Title: Add support for custom refresh rates
Post by: dunce on November 12, 2009, 06:13:03 am
@ Antidote:

I guess no one here has any doubt about your great knowledges. Though I suspect you shirked your lessons from time to time during your study. :D I just wanted to say something close to following:

Quote
Refresh Rate:  The rate at which your video card is sending complete screens from its frame buffer memory to your monitor, and the corresponding rate at which the monitor refreshes the whole image.  60hz = 60 complete refreshes per second.

Quote

Response Time: The amount of time it takes a pixel to change from one specific color to another color in an LCD display.  Typically the figures are worst for certain colors, but if the refresh rate of the LCD monitor is greater than the response time of its pixels' crystals, blurring / ghosting will occur.


You may have a top-notch monitor with an LCD panel that gives you 2.8 msec of response time, but your OS will say to your videocard to send frames to it with the rate 75 Hz if you set it in accordance with the list of available freshrates of your monitor.

May be I could not explain this simple things because of my bad english as it is not my native language. :)

For those who need more info and do not have Antidotes's fundamental 11-years' knowledges and are not dunces like me here is a link to additional info: http://www.tweakguides.com/Graphics_8.html
And of course, wiki is your friend as always.
Title: Add support for custom refresh rates
Post by: Antidote on November 18, 2009, 05:40:12 pm
Three tips: Be open, Be skeptical, Wiki isn't the holy grail of knowledge


EDIT:
I also apologize for my attitude, I was just having a bad day and i have no real excuse. dunce, you are correct in your above post, and despite English not being your native language, you are concise and understandable good job. I also got one of my facts incorrect, Refresh rate is how many times per second the guns fire Across the screen, in an Up, Down Left Right fashion.