sdl accurate coords in windowed mode
I am new to sdl, but I know when I was using opengl, I had to call this command...
ScreenToClient(m_hWnd,&p);
to make my mouse coords in 'p' not have an origin at the top left of the desktop, but at the top left of my window.
I noticed in SDL, that my mouse origin is in the top left of the desktop, so is there a SDL way of converting the coords? And if there isnt, how can I get the handle 'hWnd' to my window, so I can use the above command?
Thanks
Are you polling SDL_GetMouseState() or handling the SDL_MOUSEMOTION event? Both methods give the mouse position relative to the top/left of the SDL window, not the desktop.
This is what im using
and it gives me coords where 0,0 is at the top left of my desktop, not my window
case SDL_MOUSEMOTION:
mouse.pos.x = event->motion.x;
mouse.pos.y = event->motion.y;
and it gives me coords where 0,0 is at the top left of my desktop, not my window
case SDL_MOUSEMOTION:
mouse.pos.x = event->motion.x;
mouse.pos.y = event->motion.y;
I must not have the accurate docs or something, because I cant even find
SDL_GetRelativeMouseState
in the docs im looking at
any link to some good docs?
thanks
SDL_GetRelativeMouseState
in the docs im looking at
any link to some good docs?
thanks
That really weird. Basically SDL uses windows WM_MOUSEMOVE messages to update its internal mouse position. The coordinates it gets from that message are supposed to be relative to the upper-left corner of the client area.
Do you get different coordinates if you use SDL_GetMouseState()?
What method are you using to determine where the mouse origin is?
SDL wiki
Download the docs
Do you get different coordinates if you use SDL_GetMouseState()?
What method are you using to determine where the mouse origin is?
SDL wiki
Download the docs
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement