I used this piece of code in LoMeDux. It detects the physical pixel resolution of your monitor. From that you can take a stab at its aspect ratio, and using that you can adapt your screen setup. For instance, lomedux looks good on a 4:3 or 5:4 LCD, but if you run it on a wide screen monitor it will show more of the environment at the sides instead of stretching and distorting. However, lomedux fails a bit in other ways because it always goes into 1024x768 mode and assumes the monitor will do some scaling. It also fails when on my netbook which is 1024x600.
Ideally, detect the physical resolution using the code below, switch to that res, or some whole-numbered scale of that, ie. if 1280x960 is too high, try 640x480, and adjust the aspect ratio of your camera to the pixel aspect ratio of the screen. Still, this won't always work. My desktop screen is 1680x1050, so it will almost always need some pillar-boxing or letter-boxing to get things just right.
DEVMODEA modeInfo;
int modeNum = 0;
DWORD xMax = 0, yMax = 0;
modeInfo.dmSize = sizeof(DEVMODEA);
modeInfo.dmDriverExtra = 0;
while (EnumDisplaySettingsExA(0, modeNum, &modeInfo, 0)) {
++modeNum;
if (modeInfo.dmPelsWidth > xMax) {
xMax = modeInfo.dmPelsWidth;
yMax = modeInfo.dmPelsHeight;
}
}
global_aspect = (float)xMax/yMax;