Jump to content
  • Advertisement
Sign in to follow this  
prototypev

OpenGL Question about selection

This topic is 4605 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 currently able to select objects using the opengl selection mode. Currently, objects are selected via a right-mouse-down click. My question here is, assuming that a particular object has already been selected by a right-mouse-down click, what would be the easiest way to determine if the next left-mouse-down click happens to fall inside the existing selected object? (assuming i have a global pointer to the selected object already)

Share this post


Link to post
Share on other sites
Advertisement
A "quick-shot" answer would be:
Either compare the ID returned from the selection buffer with the last selected ID, or insert another local pointer to the last selected object and compare them - which would look like this:


static YourObjectDatatype *pLastObject;
if(pLastObject==YourGlobalObjectPointer)
//Object is the same
else
pLastObject=YourGlobalObjectPointer; //Object not the same

Share this post


Link to post
Share on other sites
Not necessarily.
You could, for instance, pass a parameter to your selection routine which tells what mousebutton was pressed (maybe int iMButton - 1=left button, 2=right button, 3=middle, etc).
Then you could insert a switch(iMButton) within your selection routine and then do, whatever you want to do for each mousebutton.

Another solution (which would be less "clean") is, to simply add another global variable which holds the last pressed mousebutton

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!