Public Group

# refresh rate numerator

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

## Recommended Posts

Hello.

So Im using EnumAdapters & EnumOutputs to get a list of all possible resolutions and refresh rates; I get the correct resolutions but I dont know how to calculate the right refresh rate number;

im using

 DXGI_MODE_DESC* displayModeList; result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL); displayModeList = new DXGI_MODE_DESC[numModes]; result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList); ....... refresh_rate_temp = ((displayModeList.RefreshRate.Numerator) / (displayModeList.RefreshRate.Denominator)) ; 

The results get almost correct sometimes and correct sometimes. For example on a resolution of 800x600 i get a 85 refresh rate wich I can enable on my monitor, but on a resolution of 1024x768 e get 84 instead of 85 and i cant be enabled automatically on my monitor. What Im dooing wrong that some numbers are inccorent by a unit and some numbers are correct ?

##### Share on other sites
The numbers you see in the monitor control panel are rounded to the nearest integer, while the DXGI rationals are not. So actually the DXGI numbers are more correct. If you want to display the nearest integer, just do (int)((float)numerator / denominator + 0.5).
If you change the resolution using DXGI you specify the refresh rate exactly as returned by GetDisplayModeList, so you can actually set your monitor to 84.9 if that is the number returned.

##### Share on other sites
If I try to display the nearest integer still doesnt work because sometimes I get the correct values and the refresh rate will round to the next unit. For example at the resolution of 800x600 I get the refresh rate 84 and with float + 0,5 I get the correct result. But at the resolution of 1024x768 I get the refresh 85 and with float + 0.5 Ill get 86. The main problem is that the resolution will not change at all if the refresh is not absolutelly correct (84 wont work, 85 works). Also the input for changing the refresh is DWORD.

##### Share on other sites
Why in the world would you use DXGI to get the resolution, and use another API to change it?
You didn't even state what API you try to use. Is it ChangeDisplaySettings?
Use EnumDisplaySettings to enumerate compatible settings for ChangeDisplaySettings. Use DXGI modes when changing the display-mode using DXGI. I would say using ChangeDisplaySettings in a DXGI application is a bad idea.

##### Share on other sites
 DXGI_MODE_DESC* displayModeList; result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, NULL); displayModeList = new DXGI_MODE_DESC[numModes]; result = adapterOutput->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_ENUM_MODES_INTERLACED, &numModes, displayModeList); ....... refresh_rate_temp = ((displayModeList.RefreshRate.Numerator) / (displayModeList.RefreshRate.Denominator)) ; DeviceMode.dmDisplayFrequency = refresh_rate_temp; ChangeDisplaySettings(&DeviceMode,NULL); 

Im using ChangeDisplaySettings to test the resolution before rendering in Dx in the fullscreen mode. In case there's an error or incompatibility with a refresh rate I will get Out of frecvency in the Dx rendering fullscreen mode.

##### Share on other sites
I guess you'd have to use EnumDisplaySettings and manually match the modes. I'm not sure there's even a 1:1 correspondence between them though, but try it.

In any case I don't see any reason to do what you're doing. GetDisplayModes returns supported modes, and SetFullscreenState returns a HRESULT. Whatever "test" you're performing can easily be done with DXGI.

• 16
• 11
• 11
• 9
• 49
• ### Forum Statistics

• Total Topics
631394
• Total Posts
2999749
×