コード例 #1
0
ファイル: Display.java プロジェクト: dreamsxin/SilenceEngine
  private static Window createWindow(
      int width, int height, String title, Monitor monitor, Window share) {
    setHints();

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

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

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

    Window window = new Window(width, height, title, monitor, share);
    window.makeCurrent();
    setCallbacks(window);
    clearHints();

    if (cursorHidden) window.setInputMode(GLFW_CURSOR, GLFW_CURSOR_HIDDEN);

    if (cursorGrabbed) window.setInputMode(GLFW_CURSOR, GLFW_CURSOR_DISABLED);

    if (!fullScreen) window.setPosition(posX, posY);

    if (cursor == null) defaultCursor = cursor = new Cursor(Cursor.Type.ARROW);

    window.setCursor(cursor);

    dirty = true;

    VertexArray.CURRENT = null;
    setVSync(vSync);

    return window;
  }
コード例 #2
0
ファイル: Display.java プロジェクト: dreamsxin/SilenceEngine
  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;
  }
コード例 #3
0
ファイル: Display.java プロジェクト: dreamsxin/SilenceEngine
  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;
  }
コード例 #4
0
ファイル: Display.java プロジェクト: dreamsxin/SilenceEngine
  /** 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);
  }