Reply – Re: How to refer GL context in AWT Mouse Event
Your Name
Subject
Message
or Cancel
In Reply To
Re: How to refer GL context in AWT Mouse Event
— by gouessej gouessej
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