How to detect letterboxed video modes (Windows)?
Members - Reputation: 122
Posted 22 February 2012 - 10:31 AM
Edit: Just some notes on what I've figured out so far (still not correcting for letterboxed modes): I'm attempting to find the native resolution (for calculating aspect correction) by enumerating supported modes and picking the one with the widest horizontal resolution and (of all the ones with that maximum width) tallest vertical resolution. That won't necessarily be the mode with the greatest number of pixels, because I noticed some modes are supported that have a greater vertical resolution (but smaller horizontal resolution) than native. I don't know if that's technically correct, but it works on the two machines I have to test on, one with a 16:9 display, and the other with a 16:10 display.
Members - Reputation: 649
Posted 22 February 2012 - 03:53 PM
So let me re-cap: Your switching to a widescreen type mode and your drawings are becoming stretched horizontally?
I'm attempting to find the native resolution
If so, then how do you not know the resolution already when you call glViewport? When setting up your gl window / windows window, you have to know the width and height to create them.
Members - Reputation: 122
Posted 23 February 2012 - 09:30 AM
vmlist = get list of supported graphics modes maxmode = vmlist foreach mode in vmlist if (mode.width > maxmode.width) or (mode.width == maxmode.width and mode.height > maxmode.height) then maxmode = mode end if end foreach nativeAspect = maxmode.width / maxmode.height ... glfwOpenWindow(... REM: sets mode, opens window, inits GL, etc. execute window resize callback function manually to set up projection WINDOW RESIZE CALLBACK (input w and h): dmode = get desktop mode glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if fullscreen then aspect = nativeAspect else aspect = nativeAspect / (dmode.width / dmode.height) * (w / h) end if gluPerspective(90.0, aspect, 0.01, 100.0);
For 11 out of the 13 modes Windows supports on my system (or was it 10 out of 13), this works perfectly. For the remaining two or three modes, Windows (or the driver rather) adds black bars to the top and/or bottom of the screen, instead of stretching the image vertically. If I could somehow detect when this is happening in my code, then I could easily adjust my aspect correction formula when that happens, but I know of no way to detect it.
Also, when I said I was attempting to identify the native resolution, I didn't necessarily mean that I'd switch to that mode, merely that I was getting it's dimensions so I could calculate the native aspect ratio.