starruler
starruler

Reputation: 302

Grabbing the mouse cursor in GLFW

My question is if GLFW has an easy way of 'grabbing' the mouse cursor. SDL has a grab cursor function that clamps the mouse inside the window area. Does GLFW have an equivalent for SDL_WM_GrabInput?

Upvotes: 3

Views: 11160

Answers (1)

elmindreda
elmindreda

Reputation: 642

If you want the system cursor to be visible and restricted to the window then no, that is not currently possible. However, if you want the system cursor to be grabbed and hidden, for example if you wish to draw your own cursor or implement an free-look camera, then you can use disabled cursor mode. In that case, see glfwSetInputMode and GLFW_CURSOR_DISABLED.

Mouse input will then act as if the cursor is completely unrestricted, but it will in fact be unable to leave the window until you change the mode back or the window loses focus.

Upvotes: 4

Related Questions