Ejemplo n.º 1
0
  public static void setFullScreen(boolean fullScreen) {
    if (Display.fullScreen == fullScreen) return;

    Display.fullScreen = fullScreen;

    if (fullScreen) {
      if (monitor == null) monitor = Monitor.getPrimaryMonitor();

      if (videoMode == null) videoMode = monitor.getVideoMode();

      // Save window size
      oldWidth = width;
      oldHeight = height;

      // Save window position
      oldPosX = posX;
      oldPosY = posY;

      width = videoMode.getWidth();
      height = videoMode.getHeight();
    } else {
      // Restore window size
      width = oldWidth;
      height = oldHeight;

      // Restore window position
      posX = oldPosX;
      posY = oldPosY;

      monitor = null;
      videoMode = null;
    }

    if (displayWindow == null) return;

    // Create new window
    Window fsDisplayWindow =
        createWindow(width, height, displayWindow.getTitle(), monitor, displayWindow);
    displayWindow.destroy();
    displayWindow = fsDisplayWindow;
    displayWindow.makeCurrent();

    setPosition(posX, posY);
    setSize(width, height);

    hide();
    show();

    // Make an update
    update();

    dirty = true;
    resized = true;
  }
Ejemplo n.º 2
0
  public static void setMonitor(Monitor monitor) {
    if (Display.monitor == monitor) return;

    Display.monitor = monitor;
    Display.fullScreen = monitor != null;

    if (displayWindow == null) return;

    videoMode =
        monitor == null ? Monitor.getPrimaryMonitor().getVideoMode() : monitor.getVideoMode();

    // Save window size
    oldWidth = width;
    oldHeight = height;

    // Save window position
    oldPosX = posX;
    oldPosY = posY;

    width = videoMode.getWidth();
    height = videoMode.getHeight();

    // Create new window
    Window fsDisplayWindow =
        createWindow(width, height, displayWindow.getTitle(), monitor, displayWindow);
    displayWindow.destroy();
    displayWindow = fsDisplayWindow;
    displayWindow.makeCurrent();

    setPosition(posX, posY);
    setSize(width, height);

    hide();
    show();

    // Make an update
    update();

    dirty = true;
    resized = true;
  }
Ejemplo n.º 3
0
 public static void setPosition(Vector2 p) {
   setPosition((int) p.x, (int) p.y);
 }
Ejemplo n.º 4
0
  /** Centers the display window on the screen. */
  public static void centerOnScreen() {
    if (monitor != null || fullScreen) return;

    VideoMode videoMode = Monitor.getPrimaryMonitor().getVideoMode();
    setPosition((videoMode.getWidth() - width) / 2, (videoMode.getHeight() - height) / 2);
  }