PDA

View Full Version : Video Mode | How does the PC know the options



Daniel (CGN)
12-12-2008, 07:31 AM
How does the PC know the "Video Mode" options?

_NK47
12-12-2008, 07:33 AM
i think you should be more precise. you mean the resolutions??

Ilian Dinev
12-12-2008, 09:33 AM
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.

Dark Photon
12-13-2008, 06:09 PM
How does the PC know the "Video Mode" options?
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.

Daniel (CGN)
12-16-2008, 02:06 AM
[...]
The videocard driver knows that by asking the monitor for resolutions+refresh_rates, and knowing the gpu limits. [...]

And how does this work? (Win32)

_NK47
12-16-2008, 02:33 AM
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.

Ilian Dinev
12-16-2008, 01:50 PM
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