org.lwjgl.glfw.GLFW.glfwGetWindowPos()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中org.lwjgl.glfw.GLFW.glfwGetWindowPos()方法的一些代码示例,展示了GLFW.glfwGetWindowPos()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwGetWindowPos()方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwGetWindowPos

GLFW.glfwGetWindowPos介绍

[英]Retrieves the position, in screen coordinates, of the upper-left corner of the client area of the specified window.

Any or all of the position arguments may be NULL. If an error occurs, all non- NULL position arguments will be set to zero.

Notes:

  • This function must only be called from the main thread.
  • Wayland: There is no way for an application to retrieve the global position of its windows, this function will always emit #GLFW_PLATFORM_ERROR.
    [中]检索指定窗口的客户端区域左上角的位置(以屏幕坐标为单位)。
    任何或所有位置参数都可能为空。如果发生错误,所有非空位置参数都将设置为零。
    笔记:
    *只能从主线程调用此函数。
    *Wayland:应用程序无法检索其窗口的全局位置,此函数将始终发出#GLFW_PLATFORM_错误。

代码示例

代码示例来源:origin: libgdx/libgdx

/** @return the window position in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public int getPositionX() {
  GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2);
  return tmpBuffer.get(0);
}

代码示例来源:origin: libgdx/libgdx

/** @return the window position in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public int getPositionY() {
  GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2);
  return tmpBuffer2.get(0);
}

代码示例来源:origin: libgdx/libgdx

/** @return the window position in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public int getPositionY() {
  GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2);
  return tmpBuffer2.get(0);
}

代码示例来源:origin: libgdx/libgdx

/** @return the window position in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public int getPositionX() {
  GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2);
  return tmpBuffer.get(0);
}

代码示例来源:origin: libgdx/libgdx

@Override
public Monitor getMonitor() {
  Monitor[] monitors = getMonitors();
  Monitor result = monitors[0];
  GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  int windowX = tmpBuffer.get(0);
  int windowY = tmpBuffer2.get(0);
  GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  int windowWidth = tmpBuffer.get(0);
  int windowHeight = tmpBuffer2.get(0);
  int overlap;
  int bestOverlap = 0;
  for (Monitor monitor : monitors) {
    DisplayMode mode = getDisplayMode(monitor);
    overlap = Math.max(0,
        Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
            - Math.max(windowX, monitor.virtualX))
        * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
            - Math.max(windowY, monitor.virtualY));
    if (bestOverlap < overlap) {
      bestOverlap = overlap;
      result = monitor;
    }
  }
  return result;
}

代码示例来源:origin: libgdx/libgdx

@Override
public Monitor getMonitor() {
  Monitor[] monitors = getMonitors();
  Monitor result = monitors[0];
  GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  int windowX = tmpBuffer.get(0);
  int windowY = tmpBuffer2.get(0);
  GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  int windowWidth = tmpBuffer.get(0);
  int windowHeight = tmpBuffer2.get(0);
  int overlap;
  int bestOverlap = 0;
  for (Monitor monitor : monitors) {
    DisplayMode mode = getDisplayMode(monitor);
    overlap = Math.max(0,
        Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
            - Math.max(windowX, monitor.virtualX))
        * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
            - Math.max(windowY, monitor.virtualY));
    if (bestOverlap < overlap) {
      bestOverlap = overlap;
      result = monitor;
    }
  }
  return result;
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

/** @return the window position in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public int getPositionY() {
  GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2);
  return tmpBuffer2.get(0);
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

/** @return the window position in logical coordinates. All monitors
 * span a virtual surface together. The coordinates are relative to
 * the first monitor in the virtual surface. **/
public int getPositionX() {
  GLFW.glfwGetWindowPos(windowHandle, tmpBuffer, tmpBuffer2);
  return tmpBuffer.get(0);
}

代码示例来源:origin: nifty-gui/nifty-gui

@Override
public void setMousePosition(final int x, final int y) {
 final IntBuffer xpos = IntBuffer.allocate(1);
 final IntBuffer ypos = IntBuffer.allocate(1);
 glfwGetWindowPos(glfwWindow, xpos, ypos);
 glfwSetCursorPos(glfwWindow, x - xpos.get(0), y - ypos.get(0));
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

@Override
public Monitor getMonitor() {
  Monitor[] monitors = getMonitors();
  Monitor result = monitors[0];
  GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  int windowX = tmpBuffer.get(0);
  int windowY = tmpBuffer2.get(0);
  GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  int windowWidth = tmpBuffer.get(0);
  int windowHeight = tmpBuffer2.get(0);
  int overlap;
  int bestOverlap = 0;
  for (Monitor monitor : monitors) {
    DisplayMode mode = getDisplayMode(monitor);
    overlap = Math.max(0,
        Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
            - Math.max(windowX, monitor.virtualX))
        * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
            - Math.max(windowY, monitor.virtualY));
    if (bestOverlap < overlap) {
      bestOverlap = overlap;
      result = monitor;
    }
  }
  return result;
}

代码示例来源:origin: SpinyOwl/legui

/**
 * Update glfw window.
 */
public void updateGlfwWindow() {
  int[] windowWidth = {0},
    windowHeight = {0};
  int[] frameBufferWidth = {0},
    frameBufferHeight = {0};
  int[] xpos = {0},
    ypos = {0};
  glfwGetWindowSize(glfwWindow, windowWidth, windowHeight);
  glfwGetFramebufferSize(glfwWindow, frameBufferWidth, frameBufferHeight);
  glfwGetWindowPos(glfwWindow, xpos, ypos);
  update(windowWidth[0], windowHeight[0],
      frameBufferWidth[0], frameBufferHeight[0],
      xpos[0], ypos[0],
      glfwGetWindowAttrib(glfwWindow, GLFW_ICONIFIED) == GLFW_TRUE
     );
}

相关文章

GLFW类方法