Hiding mouse cursor with glfw
Asked Answered
R

2

27

I'm working with a game made with glfW and running in Ubuntu. My problem is that hiding the mouse cursor with the line

glfwDisable(GLFW_MOUSE_CURSOR);

causes some machines to simply disregard the mouse input, and thus breaks the game.

Has anyone faced this problem? If so, what was your workaround?

Radius answered 13/12, 2010 at 17:31 Comment(0)
H
19

Since glfw 3.0 the API call has changed, you must use glfwSetInputMode with a pointer of your window.

glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);

For more information see http://www.glfw.org/docs/3.0/moving.html

Hamlin answered 15/5, 2014 at 11:17 Comment(0)
V
19

It sounds like you may want to use GLFW_CURSOR_DISABLED (GLFW 3+).

glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

GLFW_CURSOR_DISABLED hides and locks the cursor so it can't leave your window, just like glfwDisable(GLFW_MOUSE_CURSOR);.

Source: GLFW Input Guide

Virginiavirginie answered 23/10, 2014 at 18:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.