1
votes

I am designing a toy Game Engine with OpenGL 4.1, Xcode, and GLFW. I have noticed that if I move the mouse while the scene is loading, the mouse cursor does not disappear, despite the call

glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

The game works fine, but the cursor remains visible.

I tried to put the glfwSetInputMode() call after the scene is loaded, right before entering the game loop, but it didn't help. Also, enabling the cursor and disabling it again does not affect its presence on the screen. How can I fix this issue? Thanks.

2

2 Answers

1
votes

Cursor is not a OpenGL feature, this is underlying OS graphical system feature. GLFW library provides you with cross-platform system API wrapper.

According to the GLWF API:

GLFW_CURSOR_HIDDEN makes the cursor invisible when it is over the client area of the window but does not restrict the cursor from leaving.

When

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

So GLFW_CURSOR_DISABLED is useful in full-screen mode, when GLFW_CURSOR_HIDDEN is useful in windowing mode.

0
votes

I just had this same problem and I managed to find a solution that worked for me. After much poking around I found that as long as I made sure to call glfwPollEvents() at least once before disabling the cursor I'd be good. Hopefully this helps someone.