The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Get mouse position relative to window
Phufhi


Joined: 26 Sep 2016
Posts: 1
I was wondering why SDL2 does not have a function to get the mouse position relative to a given window.
Other functions regarding the mouse like SDL_WarpMouseInWindow allow you to specify a window, while SDL_GetMouseState only works relative to the focus window (this seems inconsistent to me).
Even though I do know how to calculate the relative position using SDL_GetGlobalMouseState, I am curious about any specific reason behind the absence of the function in question.
Furthermore, alternative window/input libraries such as glfw and sfml do have this functionality.
Is the SDL_GetGlobalMouseState solution as efficient as their implementations?
Thanks in advance.