Video Mode | How does the PC know the options

How does the PC know the “Video Mode” options?

i think you should be more precise. you mean the resolutions??

The OS knows that by asking the videocard driver
The videocard driver knows that by asking the monitor for resolutions+refresh_rates, and knowing the gpu limits. The monitor doesn’t care about color-depth (8-bit, 16, 24, 32-bit).

You know by asking the OS to enumerate modes, or the gpu to enumerate modes.

Which OS? Can give you more detail with that.

Ilian Dinev’s given you the gist, but on some OSs you can also configure your display manager to ignore the mode list from the monitor and use video mode lists you specify yourself.

And how does this work? (Win32)

under windows you have a struct (PIXELFORMATDESCRIPTOR) which you fill with some values. f.e pfd.iPixelType = PFD_TYPE_RGBA and so on. then with correct functions you request if this resolution, this pixel format and so on are supported. its similar on all OS. easier on consoles where the hardware is basically same (f.e. XBOX) and you know what is supported and what not by reading the specs.


static void SwitchToFullscreen(int width,int height){
	int nMode = 0; int Framerate=60;
	DEVMODE devMode;
	EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &g_oldDevMode );

	while( EnumDisplaySettings( NULL, nMode++, &devMode ) ){
		if( devMode.dmPelsWidth  != width || devMode.dmPelsHeight != height) continue;
		if( devMode.dmBitsPerPel != 32 )continue;
		if( devMode.dmDisplayFrequency != g_oldDevMode.dmDisplayFrequency)continue;
		if( ChangeDisplaySettings( &devMode, CDS_TEST ) == DISP_CHANGE_SUCCESSFUL ){
			InFullScreen=true;
			break;
		}
	}
	if(!InFullScreen){
		MessageBox(hMain,"Monitor doesn't support this resolution","error",0);
		InFullScreen=false;
		return;
	}
	if(ChangeDisplaySettings( &devMode, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL ){
		InFullScreen=false;
		MessageBox(hMain,"Cannot set required monitor mode","error",0);
	}
}

here you can see how to enumerate supported modes