Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for glfw's CursorDisabled #213

Closed
jared-nishikawa opened this issue Jan 6, 2020 · 0 comments · Fixed by #214
Closed

Support for glfw's CursorDisabled #213

jared-nishikawa opened this issue Jan 6, 2020 · 0 comments · Fixed by #214

Comments

@jared-nishikawa
Copy link
Contributor

From https://github.com/beta/glfw/blob/master/glfw.go#L2990:

// - CursorDisabled hides and grabs the cursor, providing virtual and unlimited
// cursor movement. This is useful for implementing for example 3D camera
// controls.

I was experimenting with pixelgl's current best option for 3D camera controls, but I was getting unpredictable results on different operating systems (for instance, on a mac resetting the cursor to the center was causing about 1 second of delay).

I added this in pixelgl/window.go:

func (w *Window) DisableCursor(enabled bool) {
    mainthread.Call(func() {
            w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
    })
}

and disabling the cursor in this way (instead of manually hiding and resetting it) seemed to solve my problems. Poking through the rest of window.go I can tell that this function is not really idiomatic (cf. SetCursorVisible which references a cursorVisible parameter in the Window struct). I'd be happy to make a PR (if indeed this seems like something worth adding), but wanted to talk through how best to fit it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant