# Monitor Refresh Rate

This topic is 4725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I currently have the option for the user of my game to change the refresh rate the monitor runs at (60Hz - 85Hz). To do this, I have several check boxes where the user can choose a refresh rate. However since not all monitors support all rates, I would like to check to make sure that the user's computer can support it. To do so, I wrote the following procedure:
BOOL CheckDisplaySettings(int SizeX, int SizeY, int BitDepth, int Refresh)
{
DEVMODE dmMaxScreenRes;
for(int counter=0; counter<50000; counter++)
{
if(!EnumDisplaySettings(NULL, counter+0, &dmMaxScreenRes))
break;
if(dmMaxScreenRes.dmPelsHeight == SizeY
&& dmMaxScreenRes.dmPelsWidth == SizeX && dmMaxScreenRes.dmBitsPerPel == BitDepth
&& dmMaxScreenRes.dmDisplayFrequency == Refresh)
return TRUE;
}

return FALSE;
}


Basically the procedure should return TRUE if the computer can support a resolution of SizeX by SizeY, bit depth of BitDepth, and a refresh rate of Refresh. The problem however is that it doesn't always trigger a FALSE when a monitor doesn't support a certain refresh rate. I think it might have something to do with the monitor itself (it's an older one), so how could I put a safety feature in here so that the user doesn't do anything to blow up the monitor? Or perhaps I'm using the "EnumDisplaySettings" thing incorrectly? Thank you very much for your time and any suggestions, Walter

##### Share on other sites
Quote:
 Original post by Sam GamgeeThe problem however is that it doesn't always trigger a FALSE when a monitor doesn't support a certain refresh rate. I think it might have something to do with the monitor itself (it's an older one), so how could I put a safety feature in here so that the user doesn't do anything to blow up the monitor? Or perhaps I'm using the "EnumDisplaySettings" thing incorrectly?

Per MSDN notes, you might want to initialize the DEVMODE struct before you make calls involving it:
DEVMODE dmMaxScreenRes; ::ZeroMemory( &dmMaxScreenRes, sizeof(DEVMODE) ); dmMaxScreenRes.dmSize = sizeof(DEVMODE);int i = 0;while( ::EnumDisplaySettings( NULL, i, &dmMaxScreenRes ) ) {	if( i > 0 )		if(	dmMaxScreenRes.dmPelsHeight == SizeY		&&			dmMaxScreenRes.dmPelsWidth == SizeX		&&			dmMaxScreenRes.dmBitsPerPel == BitDepth 	&&			dmMaxScreenRes.dmDisplayFrequency == Refresh )			return true;	++i;}return false;

That said, it'd perhaps be safer to use a similar routine to build list of modes which are actually supported and present this set to the user, instead of predefined list which is later verified ^^;;

##### Share on other sites
Thanks for the reply. Clearing the DEVMODE struct is a good idea, so I added it in, however it still won't trigger a FALSE if needed. However I was looking around and apparantly Windows control panel can't determine what the moniter can do either (I went to Display Settings, etc. and all refresh rates were available to me). So it must just be that the monitor didn't install properly.

If this is the case, does anyone have any sugestions as to what I should do in the options menu? Right now the only thing I can come up with is run through the EnumDisplaySettings and if every single option is available, then limit the user to 60Hz as it's possible that the monitor drivers aren't installed properly. Although someone who had a system that is actually capable of supporting all modes wouldn't be very happy (is this even possible?).

Thanks for any feedback/suggestions.

Quote:
 That said, it'd perhaps be safer to use a similar routine to build list of modes which are actually supported and present this set to the user, instead of predefined list which is later verified

Yes, that's very true, thanks for the suggestion. I'll look into this one as soon as I figure out a solution to the other problem.

Thanks again.

##### Share on other sites
I'd suggest simply providing a passive warning. Some text somewhere around where you select the refresh rate that states that if the user has an older monitor, they should check their documentation if they have it to determine what refresh rates it supports, or simply stick with something like 60 Hz, just to be safe. But really, I doubt it's a really large problem, because I doubt that any monitors made in the last decade would have any serious problems with being set to an unsupported refresh rate. I could be wrong, but I certainly haven't had any problems with that, even on a monitor back from 1992. I think in this situation, you should put the majority of the responsibility on the user, since there isn't much you can do other than provide a simple warning. And I also recommend not making it an intrusive warning, such as a popup box which the user has to hit OK on. That'd get annoying.

##### Share on other sites
Quote:
 Original post by Sam GamgeeIf this is the case, does anyone have any sugestions as to what I should do in the options menu? Right now the only thing I can come up with is run through the EnumDisplaySettings and if every single option is available, then limit the user to 60Hz as it's possible that the monitor drivers aren't installed properly. Although someone who had a system that is actually capable of supporting all modes wouldn't be very happy (is this even possible?).

Thinking more about it, you could perhaps copy Windows' approach -- after the display mode is switched, display a "do you want to keep this mode?" requester, which if unattended will time out and reset settings to previous mode after a few seconds. (was trying to find the actual system function for that but didn't have much luck)

##### Share on other sites
Thanks for these excellent sugestions! I'll probably implement that message idea in addition to the "reset after x seconds" thing. Right now I also have a "safe mode" feature so that if something does go wrong and the user has to either reset or CTRL-ALT-DEL out of the game, it will ask the user to default back to the lowest settings next time it starts. So that in addition to your other suggestions should work out great!

Thanks again,
Walter

• 20
• 10
• 19
• 14
• 20