Jump to content
  • Advertisement
Sign in to follow this  
jitu_iiita

How to use glutMotionFunc

This topic is 3086 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 trying to make a LUDO game which involves translating Ludos(disks) from one position to another.I want to do this translation using mouse i.e. by draging a ludo from one position and place it to another.Can I use glutMotionFunc() to do this? If yes then give me discription of this funciton by an example. If no then tell me what to do??? please reply as soon as possible. thanks

Share this post


Link to post
Share on other sites
Advertisement

The trick here is that you need to remember stuff between callbacks; you need to remember what's currently being dragged.

So when you get glutMouseFunc() and it tells you a button is pressed, you look at the XY, find the piece at that position, remember that it's being moved.

When you get glutMouseMotion(), you change the "being dragged" piece's position to be the XY. (and ask for a redraw event, so you can draw stuff in the moved place).

When you get glutMouseFunc() with the button release, you set "currently being dragged" to "none".

You should probably also handle glutMouseEntry() telling you the pointer has left the window, and drop the piece at that point. (so it never leaves visibility).

Be careful about the button release, because it's possible to get that without a corresponding press -- if that happened outside your window.

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!