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

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

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

GLFW.glfwSetCursorPosCallback介绍

[英]Sets the cursor position callback of the specified window, which is called when the cursor is moved. The callback is provided with the position, in screen coordinates, relative to the upper-left corner of the client area of the window.

This function must only be called from the main thread.
[中]设置指定窗口的光标位置回调,当光标移动时调用该回调。回调函数提供了相对于窗口客户区左上角的位置(以屏幕坐标表示)。
只能从主线程调用此函数。

代码示例

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

public void initialize() {
  glfwSetCursorPosCallback(context.getWindowHandle(), cursorPosCallback = new GLFWCursorPosCallback() {
    @Override
    public void invoke(long window, double xpos, double ypos) {
      onCursorPos(window, xpos, ypos);
    }
  });
  glfwSetScrollCallback(context.getWindowHandle(), scrollCallback = new GLFWScrollCallback() {
    @Override
    public void invoke(final long window, final double xOffset, final double yOffset) {
      onWheelScroll(window, xOffset, yOffset * WHEEL_SCALE);
    }
  });
  glfwSetMouseButtonCallback(context.getWindowHandle(), mouseButtonCallback = new GLFWMouseButtonCallback() {
    @Override
    public void invoke(final long window, final int button, final int action, final int mods) {
      onMouseButton(window, button, action, mods);
    }
  });
  setCursorVisible(cursorVisible);
  logger.fine("Mouse created.");
  initialized = true;
}

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

public void windowHandleChanged(long windowHandle) {
  resetPollingStates();
  GLFW.glfwSetKeyCallback(window.getWindowHandle(), keyCallback);
  GLFW.glfwSetCharCallback(window.getWindowHandle(), charCallback);
  GLFW.glfwSetScrollCallback(window.getWindowHandle(), scrollCallback);
  GLFW.glfwSetCursorPosCallback(window.getWindowHandle(), cursorPosCallback);
  GLFW.glfwSetMouseButtonCallback(window.getWindowHandle(), mouseButtonCallback);
}

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

public void windowHandleChanged(long windowHandle) {
  resetPollingStates();
  GLFW.glfwSetKeyCallback(window.getWindowHandle(), keyCallback);
  GLFW.glfwSetCharCallback(window.getWindowHandle(), charCallback);
  GLFW.glfwSetScrollCallback(window.getWindowHandle(), scrollCallback);
  GLFW.glfwSetCursorPosCallback(window.getWindowHandle(), cursorPosCallback);
  GLFW.glfwSetMouseButtonCallback(window.getWindowHandle(), mouseButtonCallback);
}

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

glfwSetCursorPosCallback(window, cursorPosCallback = new GLFWCursorPosCallback() {
  @Override
  public void invoke(final long window, final double xpos, final double ypos) {

代码示例来源:origin: org.lwjgl.osgi/org.lwjgl.glfw

/** See {@link GLFW#glfwSetCursorPosCallback SetCursorPosCallback}. */
public GLFWCursorPosCallback set(long window) {
  glfwSetCursorPosCallback(window, this);
  return this;
}

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

public GLFWInput(LWJGLPlatform plat, long window) {
 super(plat);
 this.plat = plat;
 this.window = window;
 glfwSetCharCallback(window, charCallback);
 glfwSetKeyCallback(window, keyCallback);
 glfwSetMouseButtonCallback(window, mouseBtnCallback);
 glfwSetCursorPosCallback(window, cursorPosCallback);
 glfwSetScrollCallback(window, scrollCallback);
}

代码示例来源:origin: jsettlers/settlers-remake

private void registerCallbacks() {
    GLFW.glfwSetKeyCallback(glfw_wnd, key_callback);
    GLFW.glfwSetMouseButtonCallback(glfw_wnd, mouse_callback);
    GLFW.glfwSetScrollCallback(glfw_wnd, scroll_callback);
    GLFW.glfwSetCursorEnterCallback(glfw_wnd, cursorenter_callback);
    GLFW.glfwSetCursorPosCallback(glfw_wnd, cursorpos_callback);
    GLFW.glfwSetWindowSizeCallback(glfw_wnd, size_callback);
  }
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void init(Window window) {
  glfwSetCursorPosCallback(window.getWindowHandle(), (windowHandle, xpos, ypos) -> {
    currentPos.x = xpos;
    currentPos.y = ypos;
  });
  glfwSetCursorEnterCallback(window.getWindowHandle(), (windowHandle, entered) -> {
    inWindow = entered;
  });
  glfwSetMouseButtonCallback(window.getWindowHandle(), (windowHandle, button, action, mode) -> {
    leftButtonPressed = button == GLFW_MOUSE_BUTTON_1 && action == GLFW_PRESS;
    rightButtonPressed = button == GLFW_MOUSE_BUTTON_2 && action == GLFW_PRESS;
  });
}

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

public void windowHandleChanged(long windowHandle) {
  resetPollingStates();
  GLFW.glfwSetKeyCallback(window.getWindowHandle(), keyCallback);
  GLFW.glfwSetCharCallback(window.getWindowHandle(), charCallback);
  GLFW.glfwSetScrollCallback(window.getWindowHandle(), scrollCallback);
  GLFW.glfwSetCursorPosCallback(window.getWindowHandle(), cursorPosCallback);
  GLFW.glfwSetMouseButtonCallback(window.getWindowHandle(), mouseButtonCallback);
}

相关文章

GLFW类方法