You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't understand the rationale behind glfwGetCursorPos() returning the mouse position in screen coordinates. Why would you want that, if your OpenGL rendering is done in pixels and you set your glViewport() in pixels? Whatever you do with the mouse in OpenGL, you need to know its position in pixels (picking needs to know the pixel at which you clicked, dragging needs to know how many pixels the mouse travelled so that the displacement in pixels is right, etc). Honestly, I don't find a case in which I would prefer to have screen coordinates for the mouse.
Said that, and assuming there's a good reason for it, is there any convenience function for converting from screen coordinates to framebuffer coordinates?
then calculating the scale factors between screen and framebuffer, and applying that to the mouse coordinates, but I feel like this is overkill for such a common task, and I feel like I'm probably undoing a scale conversion that was internally done by GLFW for converting from framebuffer coordinates to screen coordinates...
The text was updated successfully, but these errors were encountered:
Note that only MacOS and Wayland have potentially different window and framebuffer sizes.
GLFW doesn't have an explicit cursor pixel position function, and I'm not sure this would be wise to implement in GLFW as OpenGL / Vulkan etc. have different pixel coordinate origins. The added computational complexity of doing it in your own code is low, and since there are a number of ways of handling UI / cursor interaction it seems that user code is probably the best place to do this.
Yes, I was thinking twice about this yesterday, and came to the same conclusion as you. I'm leaving it open just in case anybody has anything to add, but feel free to close it.
I don't understand the rationale behind
glfwGetCursorPos()
returning the mouse position in screen coordinates. Why would you want that, if your OpenGL rendering is done in pixels and you set yourglViewport()
in pixels? Whatever you do with the mouse in OpenGL, you need to know its position in pixels (picking needs to know the pixel at which you clicked, dragging needs to know how many pixels the mouse travelled so that the displacement in pixels is right, etc). Honestly, I don't find a case in which I would prefer to have screen coordinates for the mouse.Said that, and assuming there's a good reason for it, is there any convenience function for converting from screen coordinates to framebuffer coordinates?
Currently I'm doing it manually by calling
then calculating the scale factors between screen and framebuffer, and applying that to the mouse coordinates, but I feel like this is overkill for such a common task, and I feel like I'm probably undoing a scale conversion that was internally done by GLFW for converting from framebuffer coordinates to screen coordinates...
The text was updated successfully, but these errors were encountered: