Most of my GUI is in swing but recently I included a javafx chart component in my Ardor3D application.
It works fine in Windows but in Mac OS X I get the exception below. If I remove either Jogl canvas or Javafx component it works fine but if both of them are present at same time I get this exception (should I file a new bug?): java.lang.ClassCastException: javax.media.nativewindow.DefaultGraphicsConfiguration cannot be cast to com.jogamp.nativewindow.awt.AWTGraphicsConfiguration at javax.media.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1096) at javax.media.opengl.awt.GLCanvas.addNotify(GLCanvas.java:529) at java.awt.Container.addNotify(Container.java:2769) at javax.swing.JComponent.addNotify(JComponent.java:4743) at java.awt.Container.addNotify(Container.java:2769) at javax.swing.JComponent.addNotify(JComponent.java:4743) at java.awt.Container.addNotify(Container.java:2769) at javax.swing.JComponent.addNotify(JComponent.java:4743) at java.awt.Container.addNotify(Container.java:2769) at javax.swing.JComponent.addNotify(JComponent.java:4743) at java.awt.Container.addNotify(Container.java:2769) at javax.swing.JComponent.addNotify(JComponent.java:4743) at javax.swing.JRootPane.addNotify(JRootPane.java:756) at java.awt.Container.addNotify(Container.java:2769) at java.awt.Window.addNotify(Window.java:770) at java.awt.Frame.addNotify(Frame.java:487) at java.awt.Window.show(Window.java:1031) at java.awt.Component.show(Component.java:1651) at java.awt.Component.setVisible(Component.java:1603) at java.awt.Window.setVisible(Window.java:1014) at org.concord.energy3d.MainApplication.main(MainApplication.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.sun.javaws.Launcher.executeApplication(Unknown Source) at com.sun.javaws.Launcher.executeMainClass(Unknown Source) at com.sun.javaws.Launcher.doLaunchApp(Unknown Source) at com.sun.javaws.Launcher.run(Unknown Source) at java.lang.Thread.run(Thread.java:722)
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
This post was updated on .
Please try to use JoglNewtAwtCanvas first.
Edit.: JavaFX probably modifies the way AWT works under Mac, the problem doesn't come from JogAmp APIs. I don't know if we can find a solution. Edit.2: You already had this exception some weeks ago, you posted something similar. Are you sure it comes from JavaFX? Edit.3: JoglNewtAwtCanvas (which uses NewtCanvasAWT) is worth a try as your exception occurs in AWT GLCanvas which is used by JoglAwtCanvas. Edit.4: You can write a bug report but please provide a test case. I can fix at least the ClassCastException.
Julien Gouesse | Personal blog | Website
|
Thank you. I will try Newt first. Guess it was about time for me to switch to Newt. I will report a bug if that didn't work.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
This post was updated on .
I replaced JoglAwtCanvas with JoglNewtAwtCanvas in ardor3d example and it worked but in my program it gives the following exception. Any ideas what could be causing it? As far as I can tell my program is very similar than the ardor3d example.
java.lang.RuntimeException: java.lang.NullPointerException at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:65) at jogamp.opengl.GLDrawableHelper.execGLRunnables(GLDrawableHelper.java:419) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:359) at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:655) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:594) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543) at jogamp.opengl.GLDrawableHelper.invoke(GLDrawableHelper.java:516) at jogamp.opengl.GLAutoDrawableBase.invoke(GLAutoDrawableBase.java:381) at com.ardor3d.framework.jogl.JoglNewtAwtCanvas.draw(JoglNewtAwtCanvas.java:79) at com.ardor3d.framework.FrameHandler.updateFrame(FrameHandler.java:90) at org.concord.energy3d.scene.SceneManager.run(SceneManager.java:345) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NullPointerException at com.ardor3d.framework.jogl.JoglCanvasRenderer.makeCurrentContext(JoglCanvasRenderer.java:75) at com.ardor3d.framework.jogl.JoglCanvasRenderer.draw(JoglCanvasRenderer.java:192) at com.ardor3d.framework.jogl.JoglDrawerRunnable.run(JoglDrawerRunnable.java:16) at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:59) ... 12 more Edit: I noticed that I can get the above exception if I remove frame.pack() from the example. Adding frame.pack to my code didn't help though, probably because I have a more complex swing UI. So question is what does frame.pack() has to do with rendering canvas. Here is the exception: Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:65) at jogamp.opengl.GLDrawableHelper.execGLRunnables(GLDrawableHelper.java:419) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:359) at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:655) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:594) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543) at jogamp.opengl.GLDrawableHelper.invoke(GLDrawableHelper.java:516) at jogamp.opengl.GLAutoDrawableBase.invoke(GLAutoDrawableBase.java:381) at com.ardor3d.framework.jogl.JoglNewtAwtCanvas.draw(JoglNewtAwtCanvas.java:79) at com.ardor3d.framework.FrameHandler.updateFrame(FrameHandler.java:90) at com.ardor3d.example.canvas.JoglAwtExample.main(JoglAwtExample.java:132) Caused by: java.lang.NullPointerException at com.ardor3d.framework.jogl.JoglCanvasRenderer.makeCurrentContext(JoglCanvasRenderer.java:75) at com.ardor3d.framework.jogl.JoglCanvasRenderer.draw(JoglCanvasRenderer.java:192) at com.ardor3d.framework.jogl.JoglDrawerRunnable.run(JoglDrawerRunnable.java:16) at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:59)
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
Look at this class, use it in the same way than in JoglAwtCanvas. I will provide a patch Tuesday. Sorry, I do my best. Thank you for testing.
Julien Gouesse | Personal blog | Website
|
I tried to do that but not sure how to translate methods that don't exist in Newt version of Canvas such as:
_joglAwtCanvas.display(); _joglAwtCanvas.getContext(); I commented them out but that gives me exception: java.lang.RuntimeException: java.lang.NullPointerException at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:65) at jogamp.opengl.GLDrawableHelper.execGLRunnables(GLDrawableHelper.java:419) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:359) at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:655) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:594) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543) at jogamp.opengl.GLDrawableHelper.invoke(GLDrawableHelper.java:516) at jogamp.opengl.GLAutoDrawableBase.invoke(GLAutoDrawableBase.java:381) at com.ardor3d.framework.jogl.JoglNewtAwtCanvas.draw(JoglNewtAwtCanvas.java:97) at com.ardor3d.framework.FrameHandler.updateFrame(FrameHandler.java:90) at org.concord.energy3d.scene.SceneManager.run(SceneManager.java:345) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.NullPointerException at com.ardor3d.framework.jogl.JoglCanvasRenderer.makeCurrentContext(JoglCanvasRenderer.java:75) at com.ardor3d.framework.jogl.JoglCanvasRenderer.draw(JoglCanvasRenderer.java:192) at com.ardor3d.framework.jogl.JoglDrawerRunnable.run(JoglDrawerRunnable.java:16) at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:59) ... 12 more
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
The change list is here. Let me know whether it fixes your bug.
Julien Gouesse | Personal blog | Website
|
Administrator
|
In reply to this post by runiter
I will try to reproduce this NullPointerException under Windows in order to check whether it really comes from Ardor3D or from your framework based on it. Do you still use an Intel 3000 HD?
Julien Gouesse | Personal blog | Website
|
To get the null pointer exception with Newt canvas any windows machine will do. Even my laptop with dedicated nvidia graphics throws that exception.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
Can you try to reproduce your bug with JoglNewtAwtExample please? Post the full stacktrace if you get a crash.
Julien Gouesse | Personal blog | Website
|
This post was updated on .
In reply to this post by gouessej
I just tried this and it seemed to have fixed the null exception problem :) My scene is now rendered properly however it appears that the canvas can no longer receive mouse events! How do I fix the problem with the mouse event? Edit: I take it back! It still doesn't work 100%! It seem to work sometimes, especially on the first run when the JVM is slower, but on the subsequent runs it throws same null exception exception!! I'll try the example you referred me to next. Edit 2: The example works but as before, it will not work if I remove the frame.pack() call.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
I will try to reproduce the bug by myself with JoglNewtAwtExample.
Julien Gouesse | Personal blog | Website
|
If there is anything else you need me to do let me know. I'm happy to help.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
Hi
JoglNewtAwtCanvas works very well in JoglNewtAwtExample with frame.pack() and it still works when I replace this call by frame.setSize(800, 600). My fix is completely useless. It already works under Windows even with a crappy Intel GMA chipset. I will revert my fix and don't worry, I don't give up as I will probably fix the remaining ClassCastException that prevents you from using JoglAwtCanvas with JavaFX in the same container soon.
Julien Gouesse | Personal blog | Website
|
gouessej, I emailed you to git url to my project (it's open source) so that you can see how I get the null exception with Newt if you're interested in figuring out why it's doing that.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
How can I modify it to reproduce your ClassCastException too?
Julien Gouesse | Personal blog | Website
|
That problem happens in Mac OS X only.
If you replace the Newt canvas with joglAwtCanavas in SceneManager.java and run it in Mac OS X you should see the ClassCastException. I got that exception when running the webstart version inf Mac OS X. I assume running the stand alone application results in that exception too.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
In reply to this post by gouessej
I noticed that the Newt null exception is thrown before the following invoke in JoglNewtAwtCanvas.init() is called:
getNewtWindow().invoke(true, new GLRunnable() { @Override public boolean run(final GLAutoDrawable glAutoDrawable) { _canvasRenderer.init(_settings, true);// true - do swap in renderer. return true; } }); Judging from the exception it appears that Jogl resize() is called before the above invoke, therefore it results in exception. Shouldn't you avoid the use of context in GLWindow.setSize and wait until it's initialized using the invoke code above? java.lang.RuntimeException: java.lang.NullPointerException at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:65) at jogamp.opengl.GLDrawableHelper.execGLRunnables(GLDrawableHelper.java:419) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:359) at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:655) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:594) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543) at jogamp.opengl.GLAutoDrawableBase.defaultWindowResizedOp(GLAutoDrawableBase.java:128) at com.jogamp.newt.opengl.GLWindow.access$100(GLWindow.java:94) at com.jogamp.newt.opengl.GLWindow$1.windowResized(GLWindow.java:112) at jogamp.newt.WindowImpl.consumeWindowEvent(WindowImpl.java:2374) at jogamp.newt.WindowImpl.sendWindowEvent(WindowImpl.java:2317) at jogamp.newt.WindowImpl.setVisibleActionImpl(WindowImpl.java:758) at jogamp.newt.WindowImpl$SetSizeAction.run(WindowImpl.java:820) at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:206) at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:1577) at jogamp.newt.WindowImpl.setSize(WindowImpl.java:830) at com.jogamp.newt.opengl.GLWindow.setSize(GLWindow.java:399) at jogamp.newt.awt.event.AWTParentWindowAdapter$1.run(AWTParentWindowAdapter.java:103) at com.jogamp.common.util.RunnableTask.run(RunnableTask.java:119) at jogamp.newt.DefaultEDTUtil$EventDispatchThread.run(DefaultEDTUtil.java:313) Caused by: java.lang.NullPointerException at com.ardor3d.framework.jogl.JoglCanvasRenderer.makeCurrentContext(JoglCanvasRenderer.java:75) at com.ardor3d.framework.jogl.JoglCanvasRenderer.draw(JoglCanvasRenderer.java:192) at com.ardor3d.framework.jogl.JoglDrawerRunnable.run(JoglDrawerRunnable.java:16) at jogamp.opengl.GLRunnableTask.run(GLRunnableTask.java:59) ... 20 more
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Administrator
|
The size is correctly set in the constructor of JoglNewtAwtCanvas but I notice that the height is equal to 0 just before setting the visible flag to true. The context is still set to null whereas the drawable should be realized and the context should be available after calling setVisible(true) in init(). I will have to write a tiny test case to reproduce this bug. It never occurs under GNU Linux. Maybe you can try to call getNewtWindow().display() just after setVisible(true) in init().
Julien Gouesse | Personal blog | Website
|
Nope this didn't work either. But I managed to get it to work if I add a Thread.sleep(1000) before calling framehandler.init() in my SceneManager.java: public synchronized void run() { try { Thread.sleep(1000); } catch (final InterruptedException e1) { e1.printStackTrace(); } frameHandler.init(); ... } Obviously this is not a good solution because the 1000ms sleep time may need to be more or less depending on the speed of computer. But it may help figure out the source of the problem.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
|
Free forum by Nabble | Edit this page |