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

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

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

GLFW.glfwGetCursorPos介绍

[英]Returns the position of the cursor, in screen coordinates, relative to the upper-left corner of the client area of the specified window.

If the cursor is disabled (with #GLFW_CURSOR_DISABLED) then the cursor position is unbounded and limited only by the minimum and maximum values of a double.

The coordinates can be converted to their integer equivalents with the Math#floor function. Casting directly to an integer type works for positive coordinates, but fails for negative ones.

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

This function must only be called from the main thread.
[中]返回光标相对于指定窗口的工作区左上角的位置(以屏幕坐标为单位)。
如果禁用光标(禁用#GLFW_cursor_),则光标位置是无限制的,并且仅受双精度的最小值和最大值限制。
坐标可以通过Math#floor函数转换为其整数等价物。直接强制转换为整数类型对正坐标有效,但对负坐标无效。
任何或所有位置参数都可能为空。如果发生错误,所有非空位置参数都将设置为零。
只能从主线程调用此函数。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private void initCurrentMousePosition(long window) {
  DoubleBuffer x = BufferUtils.createDoubleBuffer(1);
  DoubleBuffer y = BufferUtils.createDoubleBuffer(1);
  glfwGetCursorPos(window, x, y);
  mouseX = (int) Math.round(x.get());
  mouseY = (int) currentHeight - (int) Math.round(y.get());
}

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

private void updateCursorPos() {
 glfwGetCursorPos(glfwWindow, cursorX, cursorY);
}

代码示例来源:origin: WarmfulDevelopment/LWJGL-3-Tutorial

public Vector2f getMousePosition() {
  glfwGetCursorPos(window, x, y);
  
  glfwGetWindowSize(window, winWidth, winHeight);
  
  mousePos.set((float) x[0] - (winWidth[0] / 2.0f), -((float) y[0] - (winHeight[0] / 2.0f)));
  
  return mousePos;
}

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

private Point queryCursorPosition () {
 xpos.rewind(); ypos.rewind();
 glfwGetCursorPos(window, xpos, ypos);
 cpos.set((float)xpos.get(), (float)ypos.get());
 return cpos;
}

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: lwjglgamedev/lwjglbook

nvgFill(vg);
glfwGetCursorPos(window.getWindowHandle(), posx, posy);
int xcenter = 50;
int ycenter = window.getHeight() - 75;

代码示例来源:origin: fynnfluegge/oreon-engine

public boolean onClick()
{
  DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1);
  DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1);
  
  glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos);
  
  Vec2f mousePos = new Vec2f((float) xPos.get(),(float) yPos.get());
  
  if(pos[0].getX() < mousePos.getX() && 
    pos[1].getX() < mousePos.getX() && 
    pos[2].getX() > mousePos.getX() && 
    pos[3].getX() > mousePos.getX() &&
    pos[0].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && 
    pos[3].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && 
    pos[1].getY() > BaseContext.getWindow().getHeight() - mousePos.getY() && 
    pos[2].getY() > BaseContext.getWindow().getHeight() - mousePos.getY()) {
    
    return true;
  }
  else
    return false;
}

代码示例来源:origin: fynnfluegge/oreon-engine

DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1);
DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1);
glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos);
Vec2f screenPos = new Vec2f((float) xPos.get(),(float) yPos.get());

相关文章

GLFW类方法