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

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

本文整理了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

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

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

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

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

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

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

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

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

  1. @Override
  2. public Monitor getMonitor() {
  3. Monitor[] monitors = getMonitors();
  4. Monitor result = monitors[0];
  5. GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  6. int windowX = tmpBuffer.get(0);
  7. int windowY = tmpBuffer2.get(0);
  8. GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  9. int windowWidth = tmpBuffer.get(0);
  10. int windowHeight = tmpBuffer2.get(0);
  11. int overlap;
  12. int bestOverlap = 0;
  13. for (Monitor monitor : monitors) {
  14. DisplayMode mode = getDisplayMode(monitor);
  15. overlap = Math.max(0,
  16. Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
  17. - Math.max(windowX, monitor.virtualX))
  18. * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
  19. - Math.max(windowY, monitor.virtualY));
  20. if (bestOverlap < overlap) {
  21. bestOverlap = overlap;
  22. result = monitor;
  23. }
  24. }
  25. return result;
  26. }

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

  1. @Override
  2. public Monitor getMonitor() {
  3. Monitor[] monitors = getMonitors();
  4. Monitor result = monitors[0];
  5. GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  6. int windowX = tmpBuffer.get(0);
  7. int windowY = tmpBuffer2.get(0);
  8. GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  9. int windowWidth = tmpBuffer.get(0);
  10. int windowHeight = tmpBuffer2.get(0);
  11. int overlap;
  12. int bestOverlap = 0;
  13. for (Monitor monitor : monitors) {
  14. DisplayMode mode = getDisplayMode(monitor);
  15. overlap = Math.max(0,
  16. Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
  17. - Math.max(windowX, monitor.virtualX))
  18. * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
  19. - Math.max(windowY, monitor.virtualY));
  20. if (bestOverlap < overlap) {
  21. bestOverlap = overlap;
  22. result = monitor;
  23. }
  24. }
  25. return result;
  26. }

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

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

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

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

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

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

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

  1. @Override
  2. public Monitor getMonitor() {
  3. Monitor[] monitors = getMonitors();
  4. Monitor result = monitors[0];
  5. GLFW.glfwGetWindowPos(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  6. int windowX = tmpBuffer.get(0);
  7. int windowY = tmpBuffer2.get(0);
  8. GLFW.glfwGetWindowSize(window.getWindowHandle(), tmpBuffer, tmpBuffer2);
  9. int windowWidth = tmpBuffer.get(0);
  10. int windowHeight = tmpBuffer2.get(0);
  11. int overlap;
  12. int bestOverlap = 0;
  13. for (Monitor monitor : monitors) {
  14. DisplayMode mode = getDisplayMode(monitor);
  15. overlap = Math.max(0,
  16. Math.min(windowX + windowWidth, monitor.virtualX + mode.width)
  17. - Math.max(windowX, monitor.virtualX))
  18. * Math.max(0, Math.min(windowY + windowHeight, monitor.virtualY + mode.height)
  19. - Math.max(windowY, monitor.virtualY));
  20. if (bestOverlap < overlap) {
  21. bestOverlap = overlap;
  22. result = monitor;
  23. }
  24. }
  25. return result;
  26. }

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

  1. /**
  2. * Update glfw window.
  3. */
  4. public void updateGlfwWindow() {
  5. int[] windowWidth = {0},
  6. windowHeight = {0};
  7. int[] frameBufferWidth = {0},
  8. frameBufferHeight = {0};
  9. int[] xpos = {0},
  10. ypos = {0};
  11. glfwGetWindowSize(glfwWindow, windowWidth, windowHeight);
  12. glfwGetFramebufferSize(glfwWindow, frameBufferWidth, frameBufferHeight);
  13. glfwGetWindowPos(glfwWindow, xpos, ypos);
  14. update(windowWidth[0], windowHeight[0],
  15. frameBufferWidth[0], frameBufferHeight[0],
  16. xpos[0], ypos[0],
  17. glfwGetWindowAttrib(glfwWindow, GLFW_ICONIFIED) == GLFW_TRUE
  18. );
  19. }

相关文章

GLFW类方法