Multi Monitor Info, resolutions, graphics cards

Posted By: Superku

Multi Monitor Info, resolutions, graphics cards - 05/02/19 09:17

I want to share a code snippet with you that I had made some time ago to enumerate all available monitor resolutions (at the current frequency - you can get others as well, easy to change) on all connected monitors.

Screenshot of the test program:


Download: http://www.pogostuck.com/multiMonitorInfo.zip

How to use: Have a look at the test program. You only need to call multiMonitorGetInfo() once.
Open multiMonitorInfo.h and check what info is available.
Posted By: Emre

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 11:27

Thank you Felix! You are generous as always.

There is just one little thing. Not a big deal for me but i want to let you know, because since your game is already on market, maybe you'd like to change it. (though it is not necessary for my opinion.)

Your codes can't detect virtual super resolution, until i select one of them. For example; my monitor support maximum 1920x1080. With super resolution option, it's reach 3840x2160.

When i run the code, i get this (desktop resolution is 1920x1080);


then i set the resolution 2304x1296 and i get all resolution;



So, as long as the resolution is in 1920x1080, pogostuck can't detect higher (virtual) resolutions.
Posted By: Superku

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 11:46

Interesting, I did not know that was a thing (super resolutions).
However, I'm using Windows functions to grab all available resolutions, and what you see is what Windows reports.
Can you pick higher/ super resolutions in other games?
Posted By: Emre

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 11:55

Yes. Tomb Raider series, Resident Evil 7, Dying Light, even Dishonored (very old game) detect and list all resolution. (no need to change desktop resolution )

Edit: i understand it's windows reports but it's also odd that it doesn't list super resolutions, until i change desktop resolution to higher. it doesn't happen in other games. Maybe other developers are using another method to get resolution list. i don't know.
Posted By: Superku

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 12:22

Okay, thank you. Will look that up later or the next couple of days!
Posted By: Emre

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 14:38

You are welcome! And be ready, i think i found the cause of the problem and it's bigger than i thought.

it's about desktop refresh rate. When it is set to the highest freq (60 hz), your code can list all resolutions. But, when it was set to 59, it can't detect all resolutions.

i realized; when i set resolution to 2304x1296, refresh rate automatically change to 60 hz. that is why your code detect all resolutions when desktop resolution is 2304x1296.

Most interesting thing is, when i set it 50hz, i just get two resolution:


image upload


as far as i understand, it's related with this code: "displayMode.RefreshRate == multiMonitorInfo.currentFrequency", but you are the expert.
Posted By: Superku

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 15:28

Oh, good find!
Yeah, I included that line to not have to deal with different frequencies. Did not know that that's resolution dependent.
Posted By: Emre

Re: Multi Monitor Info, resolutions, graphics cards - 05/02/19 18:18

Here is a quick solution;

Code:
if(multiMonitorInfo.numMonitors)
	{
		int count = 0;
		// get screen rects
		multiMonitorInfo.monitorInfo = (MYMONITORINFO*)sys_malloc(sizeof(MYMONITORINFO)*multiMonitorInfo.numMonitors);
		EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&count);
		
		// get display modes
		D3DDISPLAYMODE displayMode;
		int i,j;
		int last_res[2];
		last_res[0]=0;
		last_res[1]=0;
		for(i = 0; i < multiMonitorInfo.numMonitors; i++)
		{
			MYMONITORINFO *pinfo = &(multiMonitorInfo.monitorInfo)[i];
			int maxModes = pd3dKu->GetAdapterModeCount(i,D3DFMT_X8R8G8B8);
			for(j = 0; j < maxModes; j++)
			{
				if(D3D_OK != pd3dKu->EnumAdapterModes(i,D3DFMT_X8R8G8B8,j,&displayMode)) break;
				if(displayMode.Width >= MMminWidth && displayMode.Height >= MMminHeight/* && displayMode.RefreshRate == multiMonitorInfo.currentFrequency*/) 
				{
					if(displayMode.Width==last_res[0]&&displayMode.Height==last_res[1])
					{
						//skip
					}
					else
					{
						pinfo->numModes++;	
						last_res[0]=displayMode.Width;
						last_res[1]=displayMode.Height;
					}
					
				}
				
				
			}
			if(pinfo->numModes)
			{
				last_res[0]=0;
				last_res[1]=0;
				pinfo->displayModes = (DISPLAYMODE*)sys_malloc(sizeof(DISPLAYMODE)*pinfo->numModes);
				int k = 0;
				for(j = 0; j < maxModes; j++)
				{
					if(D3D_OK != pd3dKu->EnumAdapterModes(i,D3DFMT_X8R8G8B8,j,&displayMode)) break;
					if(displayMode.Width >= MMminWidth && displayMode.Height >= MMminHeight /*&& displayMode.RefreshRate == multiMonitorInfo.currentFrequency*/)
					{
						
						if(displayMode.Width==last_res[0]&&displayMode.Height==last_res[1])
						{
							//skip
						}
						else
						{
							DISPLAYMODE* pMode = &(pinfo->displayModes)[k];
							pMode->Width = displayMode.Width;
							pMode->Height = displayMode.Height;
							k++;	
							last_res[0]=displayMode.Width;
							last_res[1]=displayMode.Height;	
						}
						
						
						
					}
				}
			}
			else pinfo->displayModes = NULL;
			MMInfoSortDisplayModes(pinfo,0);
		}
	}

© 2024 lite-C Forums