How to use the correct LWJGL DisplayMode in fullscreen?

564 views Asked by At

I was having issues making my program go fullscreen with:

Display.setFullscreen(true);

...but the following answer helped me: LWJGL Fullscreen not working

This answer suggested that I iterate through all the available DisplayModes and find the compatible ones. Here is the code I currently have:

if (!fullscreen)
    Display.setDisplayMode(new DisplayMode(width, height));
else {
    DisplayMode displayMode = null;
    DisplayMode[] modes = Display.getAvailableDisplayModes();
    ArrayList<String> compatibleModes = new ArrayList<String>();
    for (int i = 0; i < modes.length; i++) {
        System.out.println("Mode "+i+": "+modes[i].toString());
        if (modes[i].getWidth() == width && modes[i].getHeight() == height
                && modes[i].isFullscreenCapable()) {
            displayMode = modes[i];
            compatibleModes.add(modes[i].toString());
        }
    }
    if(compatibleModes.isEmpty()){
        System.out.println("No compatible display modes!");
        System.exit(-1);
    }
    System.out.println("Display Modes :: "+modes.length+" Total :: "+compatibleModes.size()+" Compatible :: "+displayMode.toString()+" Selected");
    for (String string : compatibleModes) {
        System.out.println("Compatible: "+string);
    }
    Display.setDisplayMode(displayMode);
    Display.setFullscreen(true);
}
Display.create(new PixelFormat(), attribs);

My console log shows: (I've omitted some irrelevant modes for clarity)

Mode 0: 1920 x 1080 x 32 @24Hz
Mode 5: 1920 x 1080 x 32 @23Hz
Mode 18: 1280 x 1024 x 32 @60Hz
Mode 19: 1920 x 1080 x 32 @59Hz
Mode 20: 1920 x 1080 x 32 @60Hz
Mode 21: 1920 x 1080 x 32 @50Hz
Mode 23: 1920 x 1200 x 32 @59Hz
Mode 25: 1920 x 1200 x 32 @60Hz
Mode 26: 1768 x 992 x 32 @24Hz
Mode 28: 1920 x 1440 x 32 @59Hz
Mode 29: 2560 x 1440 x 32 @59Hz <-- I have a 1440p monitor, why is this NOT compatible?
Mode 30: 1280 x 800 x 32 @60Hz
Mode 31: 1920 x 1440 x 32 @60Hz
Mode 49: 1600 x 1200 x 32 @59Hz
Mode 50: 1600 x 1200 x 32 @60Hz
Display Modes :: 53 Total :: 3 Compatible :: 1280 x 720 x 32 @60Hz Selected
Compatible: 1280 x 720 x 32 @50Hz
Compatible: 1280 x 720 x 32 @59Hz
Compatible: 1280 x 720 x 32 @60Hz

Full screen games work fine on my computer at 1440p, so why the mode isn't available I am not sure. When I launch the program, the screen is very blurry.

How can I fix this? Thank you in advance.

1

There are 1 answers

0
DestinySpork On BEST ANSWER

Maybe try using

Display.setDisplayModeAndFullscreen(Display.getDesktopDisplayMode());

Even if it doesn't solve the 1440p issue it is still a much neater way of getting a fullscreen displaymode.