本文整理了Java中org.lwjgl.glfw.GLFW.glfwSetCursor()
方法的一些代码示例,展示了GLFW.glfwSetCursor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwSetCursor()
方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwSetCursor
[英]Sets the cursor image to be used when the cursor is over the client area of the specified window. The set cursor will only be visible when the cursor mode of the window is #GLFW_CURSOR_NORMAL.
On some platforms, the set cursor may not be visible unless the window also has input focus.
This function must only be called from the main thread.
[中]设置光标位于指定窗口的客户端区域上时要使用的光标图像。仅当窗口的{$0$}为#GLFW_cursor_NORMAL时,设置的光标才可见。
在某些平台上,设置光标可能不可见,除非窗口也具有输入焦点。
只能从主线程调用此函数。
代码示例来源:origin: libgdx/libgdx
@Override
public void setCursor(Cursor cursor) {
GLFW.glfwSetCursor(getWindow().getWindowHandle(), ((Lwjgl3Cursor) cursor).glfwCursor);
}
代码示例来源:origin: libgdx/libgdx
@Override
public void setCursor(Cursor cursor) {
GLFW.glfwSetCursor(getWindow().getWindowHandle(), ((Lwjgl3Cursor) cursor).glfwCursor);
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void setNativeCursor(JmeCursor jmeCursor) {
if (jmeCursor != null) {
Long glfwCursor = jmeToGlfwCursorMap.get(jmeCursor);
if (glfwCursor == null) {
glfwCursor = createGlfwCursor(jmeCursor);
jmeToGlfwCursorMap.put(jmeCursor, glfwCursor);
}
glfwSetCursor(context.getWindowHandle(), glfwCursor);
} else {
glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL);
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void update() {
// Manage cursor animation
if (currentCursor != null && currentCursor.length > 1) {
double now = glfwGetTime();
double frameTime = (glfwGetTime() - currentCursorFrameStartTime) * 1000;
if (currentCursorDelays == null || frameTime >= currentCursorDelays.get(currentCursorFrame)) {
currentCursorFrame = ++currentCursorFrame % currentCursor.length;
currentCursorFrameStartTime = now;
glfwSetCursor(context.getWindowHandle(), currentCursor[currentCursorFrame]);
}
}
// Process events
while (!mouseMotionEvents.isEmpty()) {
listener.onMouseMotionEvent(mouseMotionEvents.poll());
}
while (!mouseButtonEvents.isEmpty()) {
listener.onMouseButtonEvent(mouseButtonEvents.poll());
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
@Override
public void setNativeCursor(final JmeCursor jmeCursor) {
if (jmeCursor != null) {
final long[] glfwCursor = jmeToGlfwCursorMap.computeIfAbsent(jmeCursor, GlfwMouseInput::createGlfwCursor);
currentCursorFrame = 0;
currentCursor = glfwCursor;
currentCursorDelays = null;
currentCursorFrameStartTime = glfwGetTime();
if (jmeCursor.getImagesDelay() != null) {
currentCursorDelays = jmeCursor.getImagesDelay();
}
glfwSetCursor(context.getWindowHandle(), glfwCursor[currentCursorFrame]);
} else {
currentCursor = null;
currentCursorDelays = null;
glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL);
}
}
代码示例来源:origin: libgdx/libgdx
static void setSystemCursor(long windowHandle, SystemCursor systemCursor) {
Long glfwCursor = systemCursors.get(systemCursor);
if (glfwCursor == null) {
long handle = 0;
if (systemCursor == SystemCursor.Arrow) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR);
} else if (systemCursor == SystemCursor.Crosshair) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_CROSSHAIR_CURSOR);
} else if (systemCursor == SystemCursor.Hand) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR);
} else if (systemCursor == SystemCursor.HorizontalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.VerticalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.Ibeam) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR);
} else {
throw new GdxRuntimeException("Unknown system cursor " + systemCursor);
}
if (handle == 0) {
return;
}
glfwCursor = handle;
systemCursors.put(systemCursor, glfwCursor);
}
GLFW.glfwSetCursor(windowHandle, glfwCursor);
}
}
代码示例来源:origin: libgdx/libgdx
static void setSystemCursor(long windowHandle, SystemCursor systemCursor) {
Long glfwCursor = systemCursors.get(systemCursor);
if (glfwCursor == null) {
long handle = 0;
if (systemCursor == SystemCursor.Arrow) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR);
} else if (systemCursor == SystemCursor.Crosshair) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_CROSSHAIR_CURSOR);
} else if (systemCursor == SystemCursor.Hand) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR);
} else if (systemCursor == SystemCursor.HorizontalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.VerticalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.Ibeam) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR);
} else {
throw new GdxRuntimeException("Unknown system cursor " + systemCursor);
}
if (handle == 0) {
return;
}
glfwCursor = handle;
systemCursors.put(systemCursor, glfwCursor);
}
GLFW.glfwSetCursor(windowHandle, glfwCursor);
}
}
代码示例来源:origin: nifty-gui/nifty-gui
@Override
public void disable() {
glfwSetCursor(glfwWindow, GLFW_CURSOR_NORMAL);
}
}
代码示例来源:origin: nifty-gui/nifty-gui
@Override
public void enable() {
glfwSetCursor(glfwWindow, cursor);
}
代码示例来源:origin: sriharshachilakapati/SilenceEngine
/**
* <p> This method sets the cursor image to be used when the cursor is over the client area of the specified window.
* The set cursor will only be visible when the cursor mode of the window is {@code GLFW_CURSOR_NORMAL}.</p>
*
* <p> On some platforms, the set cursor may not be visible unless the window also has input focus.</p>
*
* @param cursor The cursor to set, or {@code null} to switch back to the default arrow cursor.
*/
public void setCursor(Cursor cursor)
{
glfwSetCursor(handle, cursor == null ? NULL : cursor.getHandle());
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3
@Override
public void setCursor(Cursor cursor) {
GLFW.glfwSetCursor(getWindow().getWindowHandle(), ((Lwjgl3Cursor) cursor).glfwCursor);
}
代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3
@Override
public void update() {
// Manage cursor animation
if (currentCursor != null && currentCursor.length > 1) {
double now = glfwGetTime();
double frameTime = (glfwGetTime() - currentCursorFrameStartTime) * 1000;
if (currentCursorDelays == null || frameTime >= currentCursorDelays.get(currentCursorFrame)) {
currentCursorFrame = ++currentCursorFrame % currentCursor.length;
currentCursorFrameStartTime = now;
glfwSetCursor(context.getWindowHandle(), currentCursor[currentCursorFrame]);
}
}
// Process events
while (!mouseMotionEvents.isEmpty()) {
listener.onMouseMotionEvent(mouseMotionEvents.poll());
}
while (!mouseButtonEvents.isEmpty()) {
listener.onMouseButtonEvent(mouseButtonEvents.poll());
}
}
代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3
@Override
public void setNativeCursor(JmeCursor jmeCursor) {
if (jmeCursor != null) {
long[] glfwCursor = jmeToGlfwCursorMap.get(jmeCursor);
if (glfwCursor == null) {
glfwCursor = createGlfwCursor(jmeCursor);
jmeToGlfwCursorMap.put(jmeCursor, glfwCursor);
}
currentCursorFrame = 0;
currentCursor = glfwCursor;
currentCursorDelays = null;
currentCursorFrameStartTime = glfwGetTime();
if (jmeCursor.getImagesDelay() != null) {
currentCursorDelays = jmeCursor.getImagesDelay();
}
glfwSetCursor(context.getWindowHandle(), glfwCursor[currentCursorFrame]);
} else {
currentCursor = null;
currentCursorDelays = null;
glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL);
}
}
代码示例来源:origin: Renanse/Ardor3D
@Override
public void setCursor(final MouseCursor cursor) {
if (cursor == MouseCursor.SYSTEM_DEFAULT || cursor == null) {
GLFW.glfwSetCursor(_canvas.getWindowId(), 0);
return;
}
final GLFWImage glfwImage = GLFWImage.create();
glfwImage.set(cursor.getWidth(), cursor.getHeight(), cursor.getImage().getData(0));
final long cptr = GLFW.glfwCreateCursor(glfwImage, cursor.getHotspotX(), cursor.getHotspotY());
GLFW.glfwSetCursor(_canvas.getWindowId(), cptr);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3
static void setSystemCursor(long windowHandle, SystemCursor systemCursor) {
Long glfwCursor = systemCursors.get(systemCursor);
if (glfwCursor == null) {
long handle = 0;
if (systemCursor == SystemCursor.Arrow) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_ARROW_CURSOR);
} else if (systemCursor == SystemCursor.Crosshair) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_CROSSHAIR_CURSOR);
} else if (systemCursor == SystemCursor.Hand) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HAND_CURSOR);
} else if (systemCursor == SystemCursor.HorizontalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_HRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.VerticalResize) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_VRESIZE_CURSOR);
} else if (systemCursor == SystemCursor.Ibeam) {
handle = GLFW.glfwCreateStandardCursor(GLFW.GLFW_IBEAM_CURSOR);
} else {
throw new GdxRuntimeException("Unknown system cursor " + systemCursor);
}
if (handle == 0) {
return;
}
glfwCursor = handle;
systemCursors.put(systemCursor, glfwCursor);
}
GLFW.glfwSetCursor(windowHandle, glfwCursor);
}
}
内容来源于网络,如有侵权,请联系作者删除!