Login  Register

Re: Multithready between AWT and JOGL

Posted by Sven Gothel on Sep 23, 2011; 7:32pm
URL: https://forum.jogamp.org/Multithready-between-AWT-and-JOGL-tp3356928p3362829.html

On Friday, September 23, 2011 09:22:12 PM millerni456 [via jogamp] wrote:

>
> Here's my new code:
>
>
> //this method is called via mouse click/press
> public void schedulePickSelection()
> {
>     GLRunnable r = new GLRunnable()
>     {
>         public void run(GLAutoDrawable d)
>         {
>             select(d.getGL().getGL2());//this performs a selection in the
> OpenGL Context Thread.
>         }
>     }
> }
http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/graph/demos/ui/SceneUIController.java;hb=HEAD#l208

 212             GLRunnable runnable = new GLRunnable() {
 213                 public boolean run(GLAutoDrawable drawable) {
 214                     UIShape s = getShape(drawable, mouseX, mouseY);
 215                     if(null != s) {
 216                         activeId = getShapes().indexOf(s);
 217                     }
 218                     else {
 219                         activeId = -1;
 220                     }
 221                     return false;
 222                 }
 223             };
 224             cDrawable.invoke(true, runnable);

You must use an old JOGL version, otherwise you couldn't compile it.
See the diff in the GLRunnable run methos signature,
return value 'void' versus 'boolean'.

Also you need to invoke it, best with wait==true (see above).

And if your picking uses false color, return false. (see last post)

>
>
> Although this works fine, my code seems to get stuck  when I move the mouse
> (which triggers this method). It will perform the pick selection, but each
> time it picks, the moving geometry freezes, and sometimes this method will
> not stop calling.

looks 'fishy' .. see above.

maybe you are able to send a little junit test here (see last post)

make sure you use the last JOGL, ie the just released beta 'jogamp-next'

~Sven