As the title states, is there a way to get the relative mouse coordinates to the sf::RenderWindow without locking the mouse cursor inside of the window border or monitor edges?

In glfw using a mouse callback function and setting the cursor with a glfw call it grabs the mouse coordinates relative to the glfwwindow but doesn't lock the mouse anywhere, the mouse is free to move on the x-axis as much as the user can drag the mouse.

The sf::RenderWindow function of setMouseCursorGrabbed(boolean, window) is a good function to use but as stated this locks the mouse inside the window.

If there is no way to do this via sfml, then is there a way I can use the glfw callbacks with an sf::RenderWindow?

The goal here is to make a fully rotate-able (360 degree) First Person Camera. I am currently unable to rotate the full 360 degrees, there is about 50 degrees lost when the mouse hits the right or left edge of the sfml renderWindow.


  • \$\begingroup\$ You should add your actual intention as this might change possible solutions. If you just want to get raw movement, just reset the cursor position on mouse movement. \$\endgroup\$ – Mario Dec 1 '17 at 6:26
  • \$\begingroup\$ Are you allowed to use OS API calls? \$\endgroup\$ – Vaillancourt Dec 1 '17 at 11:14
  • \$\begingroup\$ My intention is to have a fully rotate-able FPS Camera on the x and y axis. I have tried setting the mouse position as sfml doesn't allow just moving the cursor position (as far as I'm aware) and that doesn't work toward what I'm trying to accomplish. As for OS API calls, I have no idea how to use those or really what those are so any links to info would be appreciated. \$\endgroup\$ – KaspireFX Dec 2 '17 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.