How to determine the max. resolution supported by a player's screen.

Started by Manny Calavera, December 07, 2011, 13:33:48

Previous topic - Next topic

Manny Calavera

Hi ppl,

I need to determine the maximal screen resolution supported by a player's screen.
The method Display.getAvailableDisplayModes() lists all available display modes supported by your graphics card, but not all of those display modes are guaranteed to be supported by your screen.

From what I gathered from comments in the Display class, it's recommended to use the available display modes retrieved via Display.getAvailableDisplayModes() in combination with the user's current refresh rate and color depth to ensure some degree of compatibility between the GPU's and screen's supported display modes.

But now when I skip through the available display modes and try to determine the display mode with the highest resolution I always manage to set a resolution which is not supported by my screen and get
a "Out of Range!" message displayed when trying to run my game.

My screens max resolution is:1900x1200 (32bit color depth and 60 Hz refresh rate)
i always ended up with 1920x1440 (32bit color depth and 60 Hz refresh rate) because I expected an exception would be thrown if the desired display mode was rejected.

I tried 2 approaches:


try {
			Display.setDisplayMode(pMode);//expected an exception, but nothing thrown
			Display.setFullscreen(false);
			return false;
		} catch (LWJGLException e) {
			System.out.println("UNSUPPORTED DISPLAY MODE "+pMode.toString()+" WAS FILTERED OUT.");
			return true;
		}


and

try {
			Display.create();// Took as advice from javadoc in Display class "The only certain way to check is to call create() and make sure it works." But again no exception thrown.
			return false;
		} catch (LWJGLException e) {
			System.out.println("UNSUPPORTED DISPLAY MODE "+pMode.toString()+" WAS FILTERED OUT.");
			return true;
		}



So my question is: "How to find out if the screen accepted the given display mode without starting my application and getting an Out of range error message?"
Any help would be appreciated!






kappa

I don't think there is an easy way to determine the max resolution supported by the screen. Its best to assume that the default desktop resolution is the maximum supported resolution.

Manny Calavera

O.K then...
At least I won't reinvent an already existing API feature when I solve my problem.
Cheers, mate.