LWJGL Fullscreen not working

2019-06-23 07:07发布

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?

2条回答
做自己的国王
2楼-- · 2019-06-23 07:30

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

查看更多
Bombasti
3楼-- · 2019-06-23 07:34

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.

查看更多
登录 后发表回答