Set Cursor to platform specific Cursor LWJGL 2.9.2

Started by intrigus, August 29, 2015, 23:03:07

Previous topic - Next topic

intrigus

Is it somehow possible to set a cursor to a platform specific cursor like http://docs.oracle.com/javase/7/docs/api/java/awt/Cursor.html?
So that I can set the cursor to Cursor.WAIT_CURSOR and all platforms show a WAIT_CURSOR (but a platform specific).


Edit:
We use GLFW 3.0 so no support for glfwSetCursor(window, cursor); I confused myself...

Evan407

This is related but it's my understanding this tutorial is for LWJGL 3 and GLFW.
https://github.com/SilverTiger/lwjgl3-tutorial/wiki/Input#cursor-objects
(the "Cursor objects" section)

quew8

So are you using GLFW or LWJGL2? Your post states the former but your title the latter.

intrigus

Sorry for the confusion. (Don't write posts if your are almost sleeping ^^)
I use libgdx. It's lwjgl backend uses lwjgl 2.9.2.
I know that you can use Mouse.setCursor() to set a cursor, but you can only set the cursor to a cursor that you created.
As far as I know, it's not possible to set the Cursor to a predefined cursor like a wait cursor, resize cursor and so on.

Cornix

If you dont have a problem with initializing AWT you might always use AWT to get the native cursor image, extract the image data and create an OpenGL texture from it. (or a bytebuffer or whatever LWJGL2 uses for cursors)

quew8

Don't worry, think we've all been there.

The answer is, not that I know of. I don't think you can retrieve the raw image from an awt Cursor. You might be able to in JavaFX however. You can get system cursors via the static in fields in the javafx.scene.Cursor class then if you can cast them to javafx.scene.ImageCursor (I have no idea whether or not they would be ImageCursors or not) you can retrieve a JavaFX image which can be used. I am sceptical about whether or not this would work however AND it would require loading the whole of JavaFX.

Easier to support a few OSs by having built in images for them, or knowing where to look for the defaults on the various OSs.

EDIT: If @Cornix says otherwise about extracting images from awt Cursors, I'm probably wrong.

Cornix

I dont know if you can, I am only assuming, because why not? AWT certainly has the image data so why not allow us to get it?

quew8


Cornix

Yeah, I looked at the source code, does not seem like there is any way to get the images. Maybe one could dig deeper but I would guess its all platform dependent code.

Kai

Quote from: intrigus on August 29, 2015, 23:03:07
So that I can set the cursor to Cursor.WAIT_CURSOR and all platforms show a WAIT_CURSOR (but a platform specific).
I proposed a pull request on the GLFW repository to support a platform-specific "wait" cursor with a Windows implementation using ICL_WAIT, and an X11 implementation using XC_watch.
People would have to contribute a Cocoa implementation to support this on OS X, too.