Jump to content
  • Advertisement
Sign in to follow this  
leggyguy

Interface and getting mouse position

This topic is 5054 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

Hi. I have a neet little 3d app, and everything is fine, but now I find myself doing some 2d interface implementation, and I am not sure what to do. I have concentrated on OpenGL 3d work for a couple years now, with no 2d, so I am very rusty here. I am using Ortho for my interface. It's painted fine. As with all ortho stuff, 0,0 is top left, 10,0 is 10 pixels in, etc. Now I need to get the 2d coords of the mouse, and hopefully get the x and y to corrolate to my ortho icons, so I know if the user is over one of my interface buttons. I expect this is stupidly simple and I have overlooked it. Anyone able to help? Thanks for any and all help.

Share this post


Link to post
Share on other sites
Advertisement
What platform are you using? SDL, Windows + DirectInput, plain Win32 API, Linux (native X server calls), GTK, wxWindows, GTK, GLUT, GLFW, ... (did I miss a major one[wink])?
It' a little different for each API/framework.

Share this post


Link to post
Share on other sites
Hi.

Just using OpenGL and basic window calls.

I tried using GetCursorPos, but that returns the x and y position of the cursor, with no regards for where our window begins and ends. So if the top of my window starts around 200 pixles down the screen, I will get my 100th pixel returned as 300.

I need to get the x and y relative to my window, so if he clicks the top left pixel of my window, it returns 0,0. No matter where my window is.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok, I have found the windows function ScreenToClient, and it is doing the job well.

Now, I think these windows calls are slow, so I shall have to look into using another input system. I used DirectInput a few years ago, I guess I'll go back to it. But I'll get the interface working first.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!