Question

hi guys i am in trouble with add picking object in a JOGL project. i know that this could be done with pick buffer.. but i can't find examples anyone?

Was it helpful?

Solution

In general, as you are probably aware, JOGL code translates directly from any other OpenGL examples you might see on the web.

GL_SELECT based picking seems to be very much out of favour these days; deprecated in the spec and poorly implemented by drivers.

Alternatives you can use are:

  • Rendering each object with a unique color (and all lighting / fog etc disabled) so you can determine which object the mouse is over via glReadPixels. (Clearing buffers after the picking stage so that you can then render your normal graphics). This approach is explained by the top rated answer in OpenGL GL_SELECT or manual collision detection? for example.

  • Ray-casting into your geometry (see the selection FAQ link below). This also means that you don't have to have an active gl context in the thread you call the code from, fwiw.

I've used both of these methods in the same application, currently having good results with the latter, but since most of the objects in that application are spheres it is a lot cheaper than it might be with arbitrary models.

http://www.opengl.org/resources/faq/technical/selection.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top