Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


OpenGL OpenGL selection code...

This topic is 5931 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'm writing a map maker, and getting pretty close to the point of actually finishing the damn thing. However, one thing eludes me: how do I select the objects I've created using the mouse? Now, I've tried to use the selection buffer (glRenderMode(GL_SELECT), gluPickMatrix, etc.), but have so far had no success. I name my objects (with glLoadName) with their array numbers (which are unique), and then use the method in the OpenGL SuperBible to attempt to pick them. But, the wrong object is often selected where two objects overlap. I know the hit records are there (I tried with two overlapping boxes, and got two records back, as expected), but the z values seem like nonsense, even after I've decoded them by dividing by 232-1. I can't use them to do anything other than tell me which object is closest to the viewport. After my code (based on the SuperBible example) failed, I pretty much copied the code from both NeHe's tutorial and the one from GameTutorials.com, but both of them failed too. I am coding in VB, and I think this might be to blame. I've checked my code over and over again, comparing it to all three C examples I have, and nothing is out of place. I think one of the problems might be that the OpenGL data type GLuint is defined as VB data type Long, and the selection buffer requires an unsigned integer. The prototype is glSelectBuffer(size As GLsizei, Buffer As GLuint) I was thinking (but haven't put much serious thought into it yet) that if the selection buffer method doesn't work very well for overlapping objects, I could use the stencil buffer to simulate the selection buffer. I was wondering, though, how something like gmax handles selection of objects. I've never had any problems selecting objects in gmax, or any other OpenGL-based graphics system, including Valve's Hammer editor or q3radiant, which I'm basing my map maker on. Thanks in advance to anyone who can provide a robust selction system...
Movie Quote of the Week:

"I've seen things you people wouldn't believe. Attack ships
on fire off the shoulder of Orion. I watched C-beams glitter
in the dark near the Tannhauser gate. All those moments will
be lost in time, like...tears in rain. Time to die."
- Roy Batty, Blade Runner.
Try http://uk.geocities.com/mentalmantle - DarkVertex Coming Soon!
[edited by - iNsAn1tY on July 25, 2002 3:51:33 PM]

Share this post

Link to post
Share on other sites

  • 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!