Search code examples
fullscreenlwjgl

LWJGL Fullscreen not working


I'm trying to add fullscreen functionality to my program but I couldn't get it to work. I'm trying

Display.setFullscreen(true);

I tried changing its position to above where I create the display or where I set the displaymode, but still not working. Any help about this?


Solution

  • From my experience the DisplayMode needs to support it. You can try this:

            DisplayMode displayMode = null;
            DisplayMode[] modes = Display.getAvailableDisplayModes();
    
             for (int i = 0; i < modes.length; i++)
             {
                 if (modes[i].getWidth() == width
                 && modes[i].getHeight() == height
                 && modes[i].isFullscreenCapable())
                   {
                        displayMode = modes[i];
                   }
             }
    

    After doing this your Display.setFullscreen(true) should work