Search code examples
javamouselwjgl

java lwjgl how to make the mouse invisible


I am making a 3D game and I have just got the ability to allow the mouse to move the camera and then put the mouse back to the centre. But I want don't want the user to see an annoying mouse at the centre of the screen! So what I'm asking is: how do I make the mouse invisible? / how do I make the cursor disappear? I thought that there would be a Mouse.setVisible(false); but doesn't seem to exist. Thanks in advance. Also I want to do it without making a blank image. I'm using LWJGL 2 for java


Solution

  • You can use the Mouse.setGrabbed(true) method to "hide" the cursor and keep it inside your window. Just be aware that you need to call Mouse.create() once during setup, and Mouse.destroy() before exiting the game.