Author Topic: Enumerating RefreshRates  (Read 1792 times)

Siekmanski

  • Member
  • *****
  • Posts: 1906
Enumerating RefreshRates
« on: December 02, 2018, 11:16:02 PM »
Hi,

I'm working on a 2D sprite routine in full-screen mode
I need the actual monitor RefreshRate to do some calculations.

According to MSDN when enumerating RefreshRates it can return 0 Hz.
The value of 0 Hz indicates an adapter default.
But with 0 Hz I can't use that value for my calculations because it could be 60 or 85 Hz etc.

Now I'm curious if it returns 0 Hz, if it is only the first of all enumerated values?

I have enumerated all refreshrates for a 1024 X 768 full-screen resolution.
So, my question is: If someone of you gets a returned refreshrate of 0Hz, could you then post all "Hz" values?

Thanks.
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 9686
  • Assembler is fun ;-)
    • MasmBasic
Re: Enumerating RefreshRates
« Reply #1 on: December 02, 2018, 11:58:30 PM »
13 modes, 60Hz for both 1024 and 1366px wide. Acer Notebook on Win7-64, lowcost NVidia card.

Biterider

  • Member
  • ***
  • Posts: 376
  • ObjAsm32 + ObjAsm64 = ObjAsm
    • ObjAsm
Re: Enumerating RefreshRates
« Reply #2 on: December 03, 2018, 02:48:42 AM »
Biterider

AW

  • Member
  • *****
  • Posts: 2312
  • Let's Make ASM Great Again!
Re: Enumerating RefreshRates
« Reply #3 on: December 03, 2018, 03:35:40 AM »
I have never seen a refresh rate of 0 or 1 in my whole life but Microsoft says they exist.

Siekmanski

  • Member
  • *****
  • Posts: 1906
Re: Enumerating RefreshRates
« Reply #4 on: December 03, 2018, 05:25:07 AM »
I have also never seen a 0 Hz refreshrate.
Thinking it all over, it could be that if you set 0 Hz as an input value, the adapter automatically sets it to the default refreshrate.
I have just tested this with an input value of 0 and the monitors refreshrate is set to 60 Hz. ( my default refreshrate )

If I'm correct, when enumerating the refreshrate output values, it will never send back 0 Hz refreshrates because 0 can only be an input value?
I hope this is the case, MSDN is not very clear on that subject.
Creative coders use backward thinking techniques as a strategy.

FORTRANS

  • Member
  • *****
  • Posts: 1056
Re: Enumerating RefreshRates
« Reply #5 on: December 03, 2018, 08:36:38 AM »
Hi,

Windows 2000, no response.  No required DLL?

Windows XP

AdapterModeCount: 13
Monitor Aspect Ratio: 1.333
1024x768 60 Hz
Actual 1024x768 60 Hz

Windows 8.1

AdapterModeCount: 10
Monitor Aspect Ratio: 1.779
1024x768 40 Hz
1024x768 60 Hz
Actual 1366x768 60 Hz


HTH,

Steve N.

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Enumerating RefreshRates
« Reply #6 on: December 03, 2018, 11:53:23 AM »
Hi siekmanski, the program fails to run on my system. It seems that fails in the function call to CreateDirect3d9 something... :idea:
Felipe.

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Enumerating RefreshRates
« Reply #7 on: December 03, 2018, 12:25:22 PM »
Siekmanski i think i was wrong the problem is not there. Maybe it's at some point when making a call to a d3d9 function when an error with "a not module found" message error and then seems like occurs an infinite loop. But i can't confirm this because i would have to play for a long time with the debugger...What do you think it is?  :idea:
Felipe.

Siekmanski

  • Member
  • *****
  • Posts: 1906
Re: Enumerating RefreshRates
« Reply #8 on: December 03, 2018, 10:24:38 PM »
Hi Felipe,

Try this version, it will return an error number so I have an indication were to look in the code.
Be sure to unzip the files, it could be that the bitmap images are not correctly loaded when executed from within the zip file.
Creative coders use backward thinking techniques as a strategy.

HSE

  • Member
  • *****
  • Posts: 1104
  • <AMD>< 7-32>
Re: Enumerating RefreshRates
« Reply #9 on: December 03, 2018, 11:54:50 PM »
Hi Siekmanski!

I don't pay to much atention yesterday!  Work perfectly if you open and close, but if program lost focus then there is a problem if you try to activate it.

Siekmanski

  • Member
  • *****
  • Posts: 1906
Re: Enumerating RefreshRates
« Reply #10 on: December 04, 2018, 12:35:18 AM »
Hi HSE,

Yeah I know, I didn't include "restore lost devices" when focus is lost.  :biggrin:
Maybe I'll implement code that prevents using ALT-TAB, I'm not sure yet....
Creative coders use backward thinking techniques as a strategy.

HSE

  • Member
  • *****
  • Posts: 1104
  • <AMD>< 7-32>
Re: Enumerating RefreshRates
« Reply #11 on: December 04, 2018, 12:40:46 AM »
No problem then, just a "feature", :biggrin:

AW

  • Member
  • *****
  • Posts: 2312
  • Let's Make ASM Great Again!
Re: Enumerating RefreshRates
« Reply #12 on: December 04, 2018, 01:11:32 AM »
This is an alternative way of enumeration (I believe Siekmanski is doing it from Dx9):

Code: [Select]
#include <stdio.h>
#include <conio.h>
#include <windows.h>

int main()
{
DWORD iMode = 0;
BOOL bRetVal;

printf("Available Video Modes\n\n");
do
{
DEVMODE dm = { 0 };
bRetVal = EnumDisplaySettings(NULL, iMode, &dm);
iMode++;
if (bRetVal)
{

printf("%d x %d, %d bits %dhtz\n", dm.dmPelsWidth,
dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency);
}
}
while (bRetVal);

_getch();
}

Available Video Modes

640 x 480, 32 bits 59htz
640 x 480, 32 bits 60htz
640 x 480, 32 bits 75htz
720 x 480, 32 bits 60htz
720 x 480, 32 bits 59htz
720 x 576, 32 bits 50htz
800 x 600, 32 bits 60htz
800 x 600, 32 bits 75htz
1024 x 768, 32 bits 60htz
1152 x 864, 32 bits 60htz
1152 x 864, 32 bits 60htz
1152 x 864, 32 bits 60htz
1176 x 664, 32 bits 50htz
1176 x 664, 32 bits 50htz
1176 x 664, 32 bits 50htz
1176 x 664, 32 bits 60htz
1176 x 664, 32 bits 60htz
1176 x 664, 32 bits 60htz
1176 x 664, 32 bits 59htz
1176 x 664, 32 bits 59htz
1176 x 664, 32 bits 59htz
1280 x 720, 32 bits 60htz
1280 x 720, 32 bits 59htz
1280 x 720, 32 bits 50htz
1280 x 768, 32 bits 60htz
1280 x 768, 32 bits 60htz
1280 x 768, 32 bits 60htz
1280 x 800, 32 bits 60htz
1280 x 960, 32 bits 60htz
1280 x 960, 32 bits 60htz
1280 x 960, 32 bits 60htz
1280 x 1024, 32 bits 60htz
1360 x 768, 32 bits 60htz
1360 x 768, 32 bits 60htz
1360 x 768, 32 bits 60htz
1366 x 768, 32 bits 60htz
1366 x 768, 32 bits 60htz
1366 x 768, 32 bits 60htz
1600 x 900, 32 bits 60htz
1600 x 1024, 32 bits 59htz
1600 x 1024, 32 bits 60htz
1600 x 1024, 32 bits 59htz
1600 x 1024, 32 bits 60htz
1600 x 1024, 32 bits 59htz
1600 x 1024, 32 bits 60htz
1680 x 1050, 32 bits 59htz
1680 x 1050, 32 bits 60htz
1768 x 992, 32 bits 25htz
1768 x 992, 32 bits 25htz
1768 x 992, 32 bits 25htz
1768 x 992, 32 bits 30htz
1768 x 992, 32 bits 30htz
1768 x 992, 32 bits 30htz
1768 x 992, 32 bits 29htz
1768 x 992, 32 bits 29htz
1768 x 992, 32 bits 29htz
1920 x 1080, 32 bits 60htz
1920 x 1080, 32 bits 59htz
1920 x 1080, 32 bits 50htz
1920 x 1080, 32 bits 30htz
1920 x 1080, 32 bits 29htz
1920 x 1080, 32 bits 25htz

Interesting that the AdaptarModeCount I got from Siemanski's was 36 and here I have more modes.

Siekmanski

  • Member
  • *****
  • Posts: 1906
Re: Enumerating RefreshRates
« Reply #13 on: December 04, 2018, 01:38:50 AM »
Yes I used DX9 for the enumeration and only for 32 bits resolutions without the alpha channel.
Creative coders use backward thinking techniques as a strategy.

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Enumerating RefreshRates
« Reply #14 on: December 04, 2018, 12:57:39 PM »
I have unzipped correctly both files. This time i see a black color full screen for 1  or 2 seconds and then the program is stopped by windows.  :( I this some indicator of a problem with my graphic video adapter??  :idea:
Felipe.