当我最大化游戏窗口时,它会切断部分屏幕

时间:2018-11-02 23:06:39

标签: java lwjgl

当我最大化游戏窗口时,它会切断屏幕的一部分,我该如何修复它?最大化屏幕后,如何读取屏幕的分辨率?以及如何添加全屏选项?

    package renderEngine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;

public class DisplayManager {

    private static final int WIDTH = 1280;
    private static final int HEIGHT = 720;
    private static final int FPS_CAP = 120;

    public static void createDisplay(){     
        ContextAttribs attribs = new ContextAttribs(3,2)
        .withForwardCompatible(true)
        .withProfileCore(true);

        try {
            Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
            Display.create(new PixelFormat(), attribs);
            Display.setTitle("First Display");
            Display.setResizable(true);
        } catch (LWJGLException e) {
            e.printStackTrace();
        }

        GL11.glViewport(0,0, WIDTH, HEIGHT);
    }

    public static void updateDisplay(){

        Display.sync(FPS_CAP);
        Display.update();

    }

    public static void closeDisplay(){

        Display.destroy();

    }

    }

0 个答案:

没有答案