How do I make a full screen in LWJGL?

孤街浪徒 提交于 2019-12-25 01:35:35

问题


I am making a game in eclipse with LWJGL and I would like to know how to make the screen go full screen by changing some of the following code. Could you help, please?

public static void main(String args[]) {
    AppGameContainer appgc;
    try{
        appgc = new AppGameContainer(new Game(gamename));
        appgc.setDisplayMode(700, 500, false);
        appgc.start();
    }catch(SlickException e){
        e.printStackTrace();
    }

}

回答1:


The JavaDoc says that the 3th param of setDisplayMode indicates the fullscreen flag. Try putting it on true.




回答2:


You can enable fullscreen mode by calling Display.setFullscreen(true);.

Also, be sure to set display mode with resolution supported in fullscreen mode.

Ref: http://www.lwjgl.org/wiki/index.php?title=LWJGL_Basics_5_%28Fullscreen%29


Edit: After I've seen your edit (with snippet), you need to call appgc.setFullscreen(true); (doc).

So it all looks like this:

public static void main(String args[]) {
    AppGameContainer appgc;
    try {
        appgc = new AppGameContainer(new Game(gamename));
        appgc.setDisplayMode(800, 600, false);
        appgc.setFullscreen(true);
        appgc.start();
    }
    catch(SlickException e) {
        e.printStackTrace();
    }

}

OR

public static void main(String args[]) {
    AppGameContainer appgc;
    try {
        appgc = new AppGameContainer(new Game(gamename));
        appgc.setDisplayMode(800, 600, true);
        appgc.start();
    }
    catch(SlickException e) {
        e.printStackTrace();
    }

}



回答3:


You have to search for resolutions wich is available at your display and only at those resolutions are working with fullscreen



来源:https://stackoverflow.com/questions/14787324/how-do-i-make-a-full-screen-in-lwjgl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!