Login  Register

Re: How to refer GL context in AWT Mouse Event

Posted by n.j. on May 20, 2017; 12:21pm
URL: https://forum.jogamp.org/How-to-refer-GL-context-in-AWT-Mouse-Event-tp4037905p4038003.html

I am sorry, but can I refer the GL Context in SwingUtilities#invokeLater()?

like,

class MouseWorker extends Runnable {
  private MouseEvent mouseEvent;
  private GL2 gl;
  MouseThread(MouseEvent mouseEvent) {
     this.mouseEvent = mouseEvent;
  }
  void setGL2(GL2 gl) {
    this.gl = gl;
  }
  public void run() {
     int x = mouseEvent.getX(), y = mouseEvent.getY();
     NIO nio = getNIO();
     gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, nio.model);
     gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, nio.proj);
     gl.glGetIntegerv(GL2.GL_VIEWPORT, noi.view);
     gl.glReadPixels(x, nio.view.get(3)-y-1, 1, 1, GL2.GL_DEPTH_COMPONENt, GL2.GL_FLOAT, nio.z);
     glu.gluUnProject(x, nio.view.get(3)-y-1, z.get(0), nio.model,nio.proj,nio.view,nio.loc);
     DisplayCompartment selected = getDisplayCompartment(nio.loc.get(0),nio.loc.get(1),nio.loc.get(2));
     if (selected != nulll) {
       setSelected(selected);
       this.MyPanel.repaint();
     }
  }
}
public void mousePressed(MouseEvent e) {
   Runnable r = new MouseWorker(e);
   SwingUtilities.invokeLater(r);
}

You mean like this?
or am i confused?