Hi,
I'm trying NewtCanvasSWT inside an Eclipse ViewPart. I'm on Mac OS X 10.9.1 I've Jogl 2.1.3 plugin made following Wade's tutorial (+ the addition of Require-Bundle: org.eclipse.swt) I'm still facing the fact that no context can be obtained with the following code public void createPartControl(Composite parent) { GLProfile glprofile = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glprofile); GLWindow glWindow1 = GLWindow.create(caps); composite = new Composite( parent, SWT.NONE ); composite.setLayout( new FillLayout() ); glcanvas = new NewtCanvasSWT( composite, SWT.NO_BACKGROUND, glWindow1 ); GLDrawableFactory gldf = GLDrawableFactory.getFactory( glprofile ); glcontext = gldf.createExternalGLContext(); last line fails with SWTAccessor.<init>: GTK Version: 0.0.0 !ENTRY org.eclipse.e4.ui.workbench 4 0 2013-12-19 18:27:40.048 !MESSAGE !STACK 0 javax.media.opengl.GLException: Error: current Context (CGL) null, no Context (NS) at jogamp.opengl.macosx.cgl.MacOSXExternalCGLContext.create(MacOSXExternalCGLContext.java:91) at jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory.createExternalGLContextImpl(MacOSXCGLDrawableFactory.java:384) at jogamp.opengl.GLDrawableFactoryImpl.createExternalGLContext(GLDrawableFactoryImpl.java:501) at sc.ndt.aml.view.JOGLTestNewt.createPartControl(JOGLTestNewt.java:66) I have no clue on what's going on?! any help will be appreciated cheers stefano |
Administrator
|
I'm glad to see that my suggestion was right.
You need a current CGL context to make that call: https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/cgl_opengl/Reference/reference.html I think this call should be done later, when the canvas is realized.
Julien Gouesse | Personal blog | Website
|
Thank you Julien,
in fact you were right about the required bundle :-) About my code, I don't know exactly how to make that call later. I can add a listener... but on what event? I've also found http://stackoverflow.com/questions/3627507/how-to-make-jogl-2-0-work-with-swt any idea? ste |
Administrator
|
j flemm on Stack Overflow is right. Use a GLEventListener and put your context creation code into init() so that it benefits of the OpenGL current context. I do something similar in Ardor3D even though it is hidden under lots of layers.
Julien Gouesse | Personal blog | Website
|
Julien,
I feel I'm almost there but still some piece is missing. Apparently on stackoverflow they end up with SWT_AWT (?!). J flemm is right I know, but I can't figure how to add the listener to NewtCanvasSWT. I made my ViewPart class implements GLEventListener, but then I have no way to call newtcanvas.addGLEventListener(...) or the like. The only chance left is the generic addListener(int,listener) but this is for SWT and I don't know what arguments it expect (I don't even know if this is ok) Am I missing something?? thank you for the great support. stefano |
Administrator
|
((GLWindow)newtCanvasSwt.getNEWTChild()).addGLEventListener(yourListener);
Julien Gouesse | Personal blog | Website
|
Hi julien,
I added the listener and created some content on the events like the example provided on the following post http://forum.jogamp.org/NewtCanvasSWT-and-SashForm-td4027951.html Now my actual code for the ViewPart is at http://pastebin.com/TDLyKYhz and it works (size seems correct) but the content is always created on top left of the Eclipse windows and it doesn't stick to the ViewPart container as I would expect (but when the view is resized the 3D content is resized too) Also the info message show up in the console Info: GLDrawableHelper.reshape: pre-exisiting GL error 0x501 is this a known problem? thanks for your advice ste |
Administrator
|
Try to pass null instead of glWindow, I assume the GLWindow isn't constrained, it doesn't keep inside the ViewPart. Maybe Petros (JOGL SWT maintainer) can help you.
Julien Gouesse | Personal blog | Website
|
Filed as Bug 956
To recreate create a new eclipse view (plugin) as described <a href="http:// http://www.eclipse.org/articles/viewArticle/ViewArticle2.html">here and put the attachment in the source. Make sure you state the view in plugin.xml: <view name="Newt View" icon="icons/sample.gif" category="TestPlugin" class="testplugin.views.JOGLTestNewt" id="testplugin.views.JOGLTestNewt"> </view> to see the view, you need to go to Window -> Show View -> Other... -> [category as described in plugin.xml] -> [view as described in plugin.xml] In general the problem is another iteration of Bug 672 The solution there was to get the position of the parent. That solution though does not seem to work here, so we need a universal solution. Control.toDisplay(int x, int y); provided by swt directly gives the position of an element on the screen directly, and seems like a reasonable way to determine the position our element is supposed to have, without depending on different calculations of the window first and then the component |
In reply to this post by stefano.cottafavi
|
Administrator
|
On 02/25/2014 01:19 AM, orange-vertex [via jogamp] wrote:
> Pull request for fix is here <https://github.com/sgothel/jogl/pull/77>. > Inclusive source is here <https://github.com/orange-vertex/jogl/tree/bug_969>. > Aggregated issues in bug 969 > <https://jogamp.org/bugzilla/show_bug.cgi?id=969> in case someone can > comment/propose other solutions Thank you! Pls always add git-sha1's of your commits to the bug reports SCM field, as well as describing the change w/ it (the git-sha1) in the comments. I see this last comments was done some time ago, if I miss to read them - pls sent me an email to react! Looks great .. assuming it works ofc, i.e. pls add some 'tests performed on platforms ...' w/ given new unit tests .. Thank you .. great work, will merge and review later. ~Sven signature.asc (894 bytes) Download Attachment |
Free forum by Nabble | Edit this page |