コード例 #1
0
  /**
   * Update the window. If the window is visible clears the dirty flag and calls swapBuffers() and
   * finally polls the input devices if processMessages is true.
   *
   * @param processMessages Poll input devices if true
   */
  public static void update(boolean processMessages) {
    synchronized (GlobalLock.lock) {
      if (!isCreated()) throw new IllegalStateException("Display not created");

      // We paint only when the window is visible or dirty
      if (display_impl.isVisible() || display_impl.isDirty()) {
        try {
          swapBuffers();
        } catch (LWJGLException e) {
          throw new RuntimeException(e);
        }
      }

      window_resized = !isFullscreen() && parent == null && display_impl.wasResized();

      if (window_resized) {
        width = display_impl.getWidth();
        height = display_impl.getHeight();
      }

      if (parent_resized) {
        reshape();
        parent_resized = false;
        window_resized = true;
      }

      if (processMessages) processMessages();
    }
  }
コード例 #2
0
  /**
   * Set the window's location. This is a no-op on fullscreen windows or when getParent() != null.
   * The window is clamped to remain entirely on the screen. If you attempt to position the window
   * such that it would extend off the screen, the window is simply placed as close to the edge as
   * possible. <br>
   * <b>note</b>If no location has been specified (or x == y == -1) the window will be centered
   *
   * @param new_x The new window location on the x axis
   * @param new_y The new window location on the y axis
   */
  public static void setLocation(int new_x, int new_y) {
    synchronized (GlobalLock.lock) {
      // cache position
      x = new_x;
      y = new_y;

      // offset if already created
      if (isCreated() && !isFullscreen()) {
        reshape();
      }
    }
  }