Hello Guest

Proper way to achieve mouselook in LWJGL3

  • 2 Replies
  • 5956 Views
Proper way to achieve mouselook in LWJGL3
« on: November 24, 2015, 21:32:20 »
Hi :)

I wanted to know what the best way to achieve a firstperson styled "mouselook" in lwjgl3 would be.

Originally, I tried using java.awt's MouseInfo class to get information about the mouse position on the screen. I'd then use glfwSetCursorPos to reset the cursor position. However, since you cannot use java.awt on mac I needed to find another way.

I tried using glfwGetCursorPos() and glfwSetCursorPos() to do mouselook (in the whileloop of the game), However, this also does not work on mac, because glfwSetCursorPos() freezes the mouse for 200-300 ms.

[EDIT]
Solved Thanks for Kappa. Here's some documentation on how to do this
« Last Edit: November 25, 2015, 00:02:21 by orange451 »

*

Offline kappa

  • *****
  • 1319
Re: Proper way to achieve mouselook in LWJGL3
« Reply #1 on: November 24, 2015, 22:45:52 »
The best way to implement mouse look is to use the glfwSetInputMode method to set the GLFW_CURSOR mode to the value GLFW_CURSOR_DISABLED.
« Last Edit: November 24, 2015, 22:47:46 by kappa »

Re: Proper way to achieve mouselook in LWJGL3
« Reply #2 on: November 25, 2015, 00:01:25 »
Fantastic, thank you! ^^

If anyone comes across this topic, here's the documentation: Link