pixel icon indicating copy to clipboard operation
pixel copied to clipboard

Native support for glfw cursors

Open Frostman opened this issue 7 years ago • 5 comments

I see that only cursor hiding is currently supported, what do you think about adding support for the standard glfw cursors like hand and crosshair (http://www.glfw.org/docs/latest/group__shapes.html)?

I've already looked a bit on the way how it works and I can try to implement and make pull request if you're interested in a such small feature.

I'd say that it could be done by defining enum of cursor types in pixelgl/window.go and func (w *Window) SetCursorType(type CursorType).

Thanks.

Frostman avatar May 28 '17 07:05 Frostman

Hi, thanks for the initiative!

I've been thinking about it in the past and concluded, that these cursors are mainly a feature for GUI applications that want to integrate well with the system. There are of pretty much zero use in games. (In a game, you just hide the cursor and draw your own sprite at the position of the mouse.)

So, I am not for adding this feature now, but let's keep this issue open and see if anybody misses this feature.

If anyone would like this feature implemented, smack a like!

faiface avatar May 28 '17 09:05 faiface

@faiface yeah, you're right about standard cursors. Another option is to support setting picture for the cursor. I could be wrong, but I think that if we'll pass image to glfw directly, it'll work much faster than if we just render cursor each time by ourselves.

https://github.com/go-gl/glfw/blob/master/v3.2/glfw/input.go

func CreateCursor(img image.Image, xhot, yhot int) *Cursor {

and

func (w *Window) SetCursor(c *Cursor) {

Frostman avatar May 28 '17 19:05 Frostman

My use case for this feature would be switching to "editing" mode for an integrated level editor and seeing the native cursor would be a nice-to-have.

silbinarywolf avatar May 29 '17 03:05 silbinarywolf

+1 for this implementation, this library should become a GUI one as well. Go doesn't really provide a good gui library... why not extend this on to do both! This way the popularity of the package will increase and so the support for it ;)

unreadable avatar May 30 '17 17:05 unreadable

Having custom cursors is important in 2D games. Even if the author does not see benefit of this, it does not mean that users of the library would not enjoy this feature. And the way Pixel hides glfw window field, there is no way to setup custom cursor directly via glfw. So the only way is to fork Pixel and add additional code to the lib.

ysmolski avatar Aug 27 '18 13:08 ysmolski