The MASM Forum

Projects => Game Development => Topic started by: Siekmanski on December 02, 2018, 11:16:02 PM

Title: Enumerating RefreshRates
Post by: Siekmanski 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.
Title: Re: Enumerating RefreshRates
Post by: jj2007 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.
Title: Re: Enumerating RefreshRates
Post by: Biterider on December 03, 2018, 02:48:42 AM
Biterider
Title: Re: Enumerating RefreshRates
Post by: aw27 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.
Title: Re: Enumerating RefreshRates
Post by: Siekmanski 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.
Title: Re: Enumerating RefreshRates
Post by: FORTRANS 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.
Title: Re: Enumerating RefreshRates
Post by: felipe 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:
Title: Re: Enumerating RefreshRates
Post by: felipe 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:
Title: Re: Enumerating RefreshRates
Post by: Siekmanski 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.
Title: Re: Enumerating RefreshRates
Post by: HSE 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.
Title: Re: Enumerating RefreshRates
Post by: Siekmanski 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....
Title: Re: Enumerating RefreshRates
Post by: HSE on December 04, 2018, 12:40:46 AM
No problem then, just a "feature", :biggrin:
Title: Re: Enumerating RefreshRates
Post by: aw27 on December 04, 2018, 01:11:32 AM
This is an alternative way of enumeration (I believe Siekmanski is doing it from Dx9):


#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.
Title: Re: Enumerating RefreshRates
Post by: Siekmanski 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.
Title: Re: Enumerating RefreshRates
Post by: felipe 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:
Title: Re: Enumerating RefreshRates
Post by: Siekmanski on December 04, 2018, 01:18:44 PM
No messagebox with an error number?

The program needs d3d9.dll, gdiplus.dll and the SSE2 instruction set.
Title: Re: Enumerating RefreshRates
Post by: felipe on December 04, 2018, 01:30:17 PM
No message. And i have those .dlls and also my machine can execute sse2 instruction set. :idea:
Title: Re: Enumerating RefreshRates
Post by: felipe on December 04, 2018, 01:52:09 PM
The debugger starts to behave buggy after the call to createwindowex  :idea: Buggy here means that after that call i can only stop the debugging process by terminating the debugger itself with the task manager :idea:
Title: Re: Enumerating RefreshRates
Post by: felipe on December 04, 2018, 02:03:53 PM
when the program crashes, windows tells me that the module igdumd32.dll has the problem  :idea:
Title: Re: Enumerating RefreshRates
Post by: Siekmanski on December 04, 2018, 10:16:47 PM
Hi Felipe,

It could be a driver issue,
https://software.intel.com/en-us/forums/developing-games-and-graphics-on-intel/topic/292778
Title: Re: Enumerating RefreshRates
Post by: felipe on December 05, 2018, 04:54:57 AM
seems like that is, thanks.  :icon14:
Title: Re: Enumerating RefreshRates
Post by: Siekmanski on December 05, 2018, 06:53:11 AM
Hi Felipe,

It maybe that 1 of the renderstates I use chokes your graphics card.

Send you a PM.