Sign in to follow this  

sdl accurate coords in windowed mode

This topic is 4269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this