sdl accurate coords in windowed mode

Started by
4 comments, last by Jack Sotac 18 years ago
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
Advertisement
See if SDL_GetRelativeMouseState is what you want.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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.
0xa0000000
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;

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
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
0xa0000000

This topic is closed to new replies.

Advertisement