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

Author Topic: Add support for custom refresh rates  (Read 11092 times)

0 Members and 1 Guest are viewing this topic.

Tungsten

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add support for custom refresh rates
« 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.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Re: Add support for custom refresh rates
« Reply #1 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 :)
//Zzzarka

Tungsten

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add support for custom refresh rates
« Reply #2 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.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Add support for custom refresh rates
« Reply #3 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 :)
//Zzzarka

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add support for custom refresh rates
« Reply #4 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 ?
Laurent Gomila - SFML developer

Tungsten

  • Newbie
  • *
  • Posts: 4
    • View Profile
Add support for custom refresh rates
« Reply #5 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add support for custom refresh rates
« Reply #6 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.
Laurent Gomila - SFML developer

SephiRok

  • Newbie
  • *
  • Posts: 6
    • View Profile
Add support for custom refresh rates
« Reply #7 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.

blewisjr

  • Newbie
  • *
  • Posts: 23
    • View Profile
Add support for custom refresh rates
« Reply #8 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.

SephiRok

  • Newbie
  • *
  • Posts: 6
    • View Profile
Add support for custom refresh rates
« Reply #9 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.

blewisjr

  • Newbie
  • *
  • Posts: 23
    • View Profile
Add support for custom refresh rates
« Reply #10 on: July 27, 2009, 01:13:21 am »
Opse had it backwards :P

Calmatory

  • Newbie
  • *
  • Posts: 16
    • View Profile
Add support for custom refresh rates
« Reply #11 on: October 05, 2009, 11:59:58 am »
Any further information on "solving" this issue?
The amount of effort we put into something arbitrary we do in our everyday lives is proportional to the amount we gain from it. It's fascinating how this applies to everything in our lives. Your task is to try to enjoy and make the most out of it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Add support for custom refresh rates
« Reply #12 on: October 05, 2009, 12:47:50 pm »
No, sorry.
Laurent Gomila - SFML developer

Antidote

  • Newbie
  • *
  • Posts: 35
    • View Profile
Add support for custom refresh rates
« Reply #13 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.

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Add support for custom refresh rates
« Reply #14 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.

 

anything