Hello
I'm designing and Eclipse e4 application and I use SWT GLCanvas (com.jogamp.opengl.swt.GLCanvas) When adding an animator to it, I do have the following exception: Exception in thread "main-Animator" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: javax.media.opengl.GLException: Caught SWTException: Invalid thread access on thread main-Animator at com.jogamp.opengl.util.DefaultAnimatorImpl.display(DefaultAnimatorImpl.java:61) at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:446) at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198) at java.lang.Thread.run(Unknown Source) Caused by: javax.media.opengl.GLException: Caught SWTException: Invalid thread access on thread main-Animator at javax.media.opengl.GLException.newGLException(GLException.java:75) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1317) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1137) at com.jogamp.opengl.swt.GLCanvas$3.run(GLCanvas.java:171) at com.jogamp.opengl.swt.GLCanvas.runInGLThread(GLCanvas.java:959) at com.jogamp.opengl.swt.GLCanvas.display(GLCanvas.java:658) at com.jogamp.opengl.util.DefaultAnimatorImpl.display(DefaultAnimatorImpl.java:54) ... 3 more Caused by: org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:4441) at org.eclipse.swt.SWT.error(SWT.java:4356) at org.eclipse.swt.SWT.error(SWT.java:4327) at org.eclipse.swt.widgets.Widget.error(Widget.java:476) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:367) at org.eclipse.swt.widgets.Control.addMouseListener(Control.java:343) at org.goko.gcode.viewer.camera.PerspectiveCamera.<init>(PerspectiveCamera.java:53) at org.goko.viewer.jogl.service.JoglViewerServiceImpl.initialise(JoglViewerServiceImpl.java:121) at org.goko.viewer.jogl.GokoJoglCanvas.init(GokoJoglCanvas.java:146) at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:638) at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:660) at com.jogamp.opengl.swt.GLCanvas$1.run(GLCanvas.java:143) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1281) ... 8 more I guess this is related to the SWT EDT, right ? Am I missing something ? I managed to update the view by calling the redraw() method from org.eclipse.swt.widgets (from my mouse listener for instance) but this is not the best thing to do I guess. I won't post the source until it's necessary (quite a few class) but basically I'm using the following : public class MyJoglCanvas extends GLCanvas implements GLEventListener{ ... } And I'm attaching the Animator as such : Animator animator = new Animator(); animator.add(myJoglCanvasInstance); animator.start(); Thanks in advance for your help. |
Forgot to mention, I'm using Jogl 2.2.1
|
Administrator
|
In reply to this post by PsyKo
Hi
Don't call any method that requires to be called on the SWT thread inside your implementation of GLEventListener. The constructor of org.goko.gcode.viewer.camera.PerspectiveCamera seems to call org.eclipse.swt.widgets.Control.addMouseListener(). You shouldn't mix the SWT initialization with the OpenGL initialization.
Julien Gouesse | Personal blog | Website
|
Damn, thank you !
That was so obvious, but I was totally focused on something else. Thankks again for the quick answer. |
Administrator
|
You're welcome. As long as you provide enough information, you can expect an answer.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |