5

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?

Mertcan Ekiz
  • 691
  • 1
  • 9
  • 22

2 Answers2

8

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

  • Yes it works this way, thanks. However I don't understand why when I use the exact same width and height creating a new DisplayMode it doesn't work, but when I pass in a DisplayMode from the getAvailableDisplayModes() method it works? – Mertcan Ekiz Sep 10 '12 at 16:36
  • Because width and height is not unique for different display modes. Creating a new display mode actually hands you a default display mode which does not support fullscreen. – Gorky Apr 23 '13 at 19:40
  • I used this method, but I only get 3 compatible modes which have too low resolutions. This causes my fullscreen game to be blurry. Am I doing anything wrong here? – Crazy Redd Aug 09 '16 at 21:16
2

I know this question is quite (5 years) old, but there may still be people looking for a solution to this question.

The simplest way is to do:

Display.setDisplayModeAndFullscreen(Display.getDesktopDisplayMode());

Which will put your display in fullscreen for you. No need for setFullscreen() with this either.