Login  Register

Re: How to refer GL context in AWT Mouse Event

Posted by gouessej on May 30, 2017; 11:08am
URL: https://forum.jogamp.org/How-to-refer-GL-context-in-AWT-Mouse-Event-tp4037905p4038018.html

nj wrote
Thank you for you answer.

Then i should wrote like

public void mousePressed(MouseEvent mouseEvent) {
   float[] scale = new float[2];
   /*void*/getCurrentSurfaceScale(scale);
   float x = scale[0] * mouseEvent.getX();
   float y = scale[1] * mouseEvent.getY();
   setMousePressedLocation(x,y);
}
It makes sense. It seems to be correct.

nj wrote
by the way,
can I refer GL context in SwingUtilities#invokeLater()
how can i use it safely ?

Regards,
No you can't use a GL instance in SwingUtilities.invokeLater(). Rather call GLAutoDrawable.invoke(boolean, GLRunnable). You mustn't store any GL instance in non local variables or fields. If you use an invalidated GL instance or if you use it when the OpenGL context isn't current on the current thread, bad things will happen.
Julien Gouesse | Personal blog | Website