Re: Mouse selection
Posted by
Sven Gothel on
Mar 01, 2012; 12:31pm
URL: https://forum.jogamp.org/Mouse-selection-tp3787468p3790287.html
On 02/29/2012 09:18 PM, Demoscene Passivist [via jogamp] wrote:
>
>
>> if all of them are still valid, or there is a new method that is not listed
> there
>
> Yep they are all still valid, but I would suggest going for "render each
> primitive in an unique color" as its the most performant way todo reliable
> picking. U can simply do it with a FBO and a multiple-rendertarget
> fragment-shader.
<
http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java;h=c6d43480ae61b479d72232586dc0ebefd0030468;hb=HEAD#l133>
Utilizes false color rendering for selection and
glReadPixels(..) from the default buffer 'GL_BACK'.
It injects a GLRunnable into the drawable 'stream', which 'boolean run()'
method returns 'false'. The latter causes the GLAutoDrawable to re-render
the frame with proper colors.
This is hw accelerated and as precise as 'you can see it' :)
Of course 'shooting a ray' maybe also something here
but for sure it would take more CPU time than this little piece of code,
which runs on any device (ES1/ES2/>=GL2).
~Sven
>
> Bug if u have to support very very old hardware then "selection render mode"
> maybe the way to go ... just my 2 cents